...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.
The workflow itself has the following properties:
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 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.
This article is part of a series on Siebel Workflow. So far the following articles have been posted:
Part I: Update multiple records
Part III: Display error messages
Part IV: Using dot notation
To be continued in January 2009, please post a comment if you want me to cover a specific area.