25-09-2014 09:07 AM
Hello All,
I'm trying to disconnect the "Component" link between two business processes using the script mentioned below:
For each oComponent in colComponent
Set oConnectedObject = oBusinessProcess.getCollection("~aLVEBr3hHHQ3[Aggregation Business Behavior]").Add(oComponent)
Set oComponentdis = oBusinessProcess.getCollection("~8l)gvmQ9pKE0[Component]").item(oComponent.GetId)
oComponentdis.Remove
Next
Using this Script code, If there are multiple Component links with a Business Process, only alternate Links are Disconnected but not all. For example, If there are 6 component links for a Business Process. In the first execution, 3 links were disconnected. In the second execution, 2 links were disconnected. And finally in the third execution of this script, the remaining 1 link was disconnected.
Can someone suggest me the correct procedure of disconnecting all the links at a time.
Thanks for your help in advance.
29-09-2014 01:57 PM
Found the solution::
Instead of using For loop, use Do While loop.
Also starting the loop from low to high (i = 1 to 6) do it from high to Low ( i=6 to 1)
Check for the example below:
Set colComponent = oBusinessProcess.getCollection("~8l)gvmQ9pKE0[Component]")
i = colcomponent.count
Do While i > 0
colComponent.Item(1).Remove
i = i-1
Loop
Regards,
Anusha (Colruyt Team)