Can't get this to work if the field it's looking to is blank. Should just run default rule but it's returning an 'Expected Int64, got NoneType' Error.
def Invoice_Date_Value(args):
invoice = args.Context
order = args.Context.Root
if not invoice:
return
# Get the value for the Custom Fields
AddRevDate = Date(IOrderItem.GetProperty(invoice, 'AddlRevDate_#'))
if IOrderItem.GetProperty(invoice, 'AddlRevDate_#') is not None:
args.Value = AddRevDate
else:
args.RunDefaultRule()
Set Invoice Date
-
- Posts: 1382
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: Set Invoice Date
The part generating the error was passing a None to Date(...). You got the AddRevDate from the custom field and that is what should have been in the if expression. Also, you never need to check if the Context is None - it can never be None.
Code: Select all
def Invoice_Date_Value(args):
# Get the date from the Custom Field
invoice = args.Context
AddRevDate = IOrderItem.GetProperty(invoice, 'AddlRevDate_#')
# If we got a date, use it. Otherwise run Select rules.
if AddRevDate is not None:
args.Value = Date(AddRevDate)
else:
args.RunDefaultRule())
Bob Richards, Senior Software Developer, SoftPro