Workflow made simple - Part II
By @lex on Dec 12, 2008
...welcome back to Part II of our tour de workflow
Let's reiterate the requirement #2
Retrieve total opportunity revenue for an Account
Sum up the revenue of the current Opportunities for an Account and write the result to an Account field.
This is the prototype workflow. As in part I, Siebel 8.1 was the implementation platform.
Business Object: Account
Process Properties created: CurrentRevenue, LastRecord, RecordCount, TotalRevenue
Get Oppties Step:
Business Component: Opportunity
Search Spec Expression: "[Account Id]='" + [&Object Id] + "'"
Output Args: TotalRevenue = BC Oppty.Primary Revenue Amount
RecordCount = Output Argument NumAffRows
Decision Step Last Record?
yes = Process Property LastRecord = true
no = Default
Go to next Oppty Step
CurrentRevenue = Opportunity.Primary Revenue Amount (1)
TotalRevenue = Expression: [&TotalRevenue] + [&CurrentRevenue] (2)
LastRecord = Output Arg: NoMoreRecords (3)
Note: Numbers in brackets indicate the sequence of the output arguments
Update Account Step
Field Input Arg: Revenue = Process Property TotalRevenue
Note #1: The workflow operates on the Account Business Object with Account BC as the primary BC and Opportunity as a child BC.
Note #2: Despite Note #1 it is still necessary to execute a query to get the Opportunites associated with the Account.
Note #3: The fairly new Siebel Operation NextRecord (along with its siblings PreviousRecord and QueryBiDirectional) has been introduced in Siebel 8.0. It is the first version that allows us to loop through a record set in a workflow without being outwitted by the complexity of looping. The NextRecord operation has an output argument of NoMoreRecords (true or false) which must be used in a decision step to determine whether the loop has to end or not.
Pitfall #1: Adding up the revenue amount requires two process properties. One to get the field value from the BC and the other one to serve as the accumulator. Note the sequence in the NextRecord operation to fill them in the correct order.
Hope you enjoyed this small workflow series. If you want more, drop a comment ;-)