Siebel – Looping multiple records – Update records
by Nitin JainHi,
We often come across a requirement where we need to loop through multiple records satisfying a certain search spec on a particular BC.
Let’s assume a simple search spec, for eg. to update the Status of all Sales Orders to Submitted which have their Account as “Nitin Test Account”.
One easy way to do it through Siebel scripts is maybe a pseudocode as follows:
var bo_Order = TheApplication().GetBusObject ( “Order Entry (Sales)” );
var bc_Order = bo_Order.GetBusComp ( “Order Entry – Orders” );
with (bc_Order)
{
ClearToQuery();
SetViewMode(AllView);
ActivateField ( “Status” );
SetSearchSpec ( “Account”, “Nitin Test Account” );
ExecuteQuery ( ForwardOnly );
var IsRecord = FirstRecord();
while (IsRecord)
{
SetFieldValue ( “Status”, “Submitted” );
IsRecord = NextRecord();
}
}
return (CancelOperation);
Or, a more elegant approach which I personally prefer for the above solution, use a workflow. Use the step Siebel Operation.
The Siebel Operation, Update operation, will automatically update all the records satisfying that particular Search Spec fed in as Input.
One line solution to nearly 10-15 lines of script!
Related posts:
- Siebel – Looping multiple records – Query and Process In my last post, I discussed as to how we...
- Siebel – Looping Multiple Records – III Looping through multiple records is a requirement we come across...
- Siebel – EAI Siebel Adapter – Looping Multiple Records This is a follow-up post on the post, Siebel –...
- Siebel – SIA BC Utility Service – Loop multiple records This is a vanilla business service which provides an extensive...
- EAI Siebel Adapter BS – Upsert Multiple Child Records EAI Siebel Adapter finds its usage in almost all integration...
- Siebel – Popup Update Only Hi all, I was working with Siebel Multi Valued Links...
- Siebel – Merge Records – Checklist I call this Part III, and concluding part of a...
Thank you
but it updates allways even when a new record is created.
And
my query where we need to write the script and in which event
Hi Vishnu
How will it update for a new record? I ran an ExecuteQuery().
This script would most probably be written in a custom Business Service.
[...] In my last post, I discussed as to how we can query and update multiple records in Siebel Database. You can find it in the link below: Siebel – Looping multiple records – Update. [...]
By the way your script is wrong …
Hi,
Thanks for the updates. I just updated the TheApplication() to bo_Order. Anything else that you can see amiss here?
This was just intended as a pseudocode / sample script and has not been run practically. Please do point out in case you feel it can be improved.
As “Account” in only use in a query you don’t need to Activate it.
ExecuteQuery would be fine with a ForwardOnly .
Hi Bob,
I agree. I have made ur suggested changes to the sample script above. Even if we activate account before query, it would work without issues. In any case, following the best coding practices, I have removed it. Cheers..
Hi,
I was using wokflow to update multiple records uing Siebel Operation Step.But to my surprise, it threw error “Error updating business component at step ‘Siebel Operation 1′.(SBL-BPR-00187)
–
This error is returned when the workflow/task is executing the Siebel Operation business service.(SBL-BPR-00100)
–
No Primary Row found in ‘Channel Partner’ for Siebel Operation.(SBL-BPR-00101)”
I also tried using Query Step and then update.Then also, it threw error.
I am not sure if it works on Primary BC.
I think it works if we first query on Primary BC and then update the records of child BC.