Scenario Overview
In this business scenario the end user needed the ability on a yearly basis to generate an Invoice from a Contract. We decided to set this up so that a user could run a workflow called 'Generate Invoice from Contract' that would,
- Use the Contract record to create the Invoice record
- Use the Contract line item records to create the Invoice line items
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- A formula of type 'Process Genie' is created so it can execute as a step within a workflow
- When it reaches the 'Process Genie' step in the workflow it will execute the formula
- The formula first creates the Invoice record from the details on the Contract record
- Next the formula retrieves all the contract line items & creates an invoice line item for each one
North52 Decision Suite Steps
The following set of steps outline how to create this Formula
- Create a new formula of type 'Process Genie'
- Set the Source Entity to 'Contract'
- Copy & paste the formula below into the formula
- Click save & test
Workflow Steps
The following set of steps outline how to create this Formula
- Create a new workflow named 'Generate Invoice From Contract' on the Contract entity
- Set it to run only 'On Demand'
- Add a new step to the workflow to call the North52 Process Genie
- Set the formula shortcode to be the one on the formula you just created, in this case 'lup'
- Publish the workflow
- You are now ready to test
Workflow Configuration
Process Genie Configuration
Formula
SmartFlow(
SetVar('InvoiceId', CreateRecord('invoice',
SetAttribute('name', [contract.title] ),
SetAttributeLookup('pricelevelid', 'pricelevel', FindValue('pricelevel',
'name',
'DefaultList',
'pricelevelid')
),
SetAttributeCustomer('customerid', 'account', [contract.customerid] , '' )
)
),
ForEachRecord(
FindRecords('contractdetail', 'contractid', [contract.contractid] , '*'),
CreateRecord('invoicedetail',
SetAttributeLookup('invoiceid',
'invoice',
GetVar('InvoiceId') ),
SetAttribute('priceperunit', CurrentRecord('rate') ),
SetAttribute('quantity',
CurrentRecord('initialquantity') ),
SetAttributeLookup('productid',
'product',
CurrentRecord('productid') ),
SetAttributeLookup('uomid', 'uom', CurrentRecord('uomid') )
)
) ,
SmartFlowReturn( 'NoOp' )
)