Set Invoice Date

Questions about and code samples for custom order rules and validation within Select.
Post Reply
Posts: 83
Joined: Tue Jul 19, 2016 1:48 pm

Set Invoice Date

Post by bdutil » Thu Jun 21, 2018 11:05 am

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:

# Get the value for the Custom Fields
AddRevDate = Date(IOrderItem.GetProperty(invoice, 'AddlRevDate_#'))

if IOrderItem.GetProperty(invoice, 'AddlRevDate_#') is not None:
args.Value = AddRevDate


Posts: 1006
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC

Re: Set Invoice Date

Post by BobRichards » Fri Jun 22, 2018 10:37 am

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)
Bob Richards, Software Developer, SoftPro

Post Reply