Hello,
Anyone help me to pass Routing member to UpdateChangeOrderRoutingMembers method.
Thanks,
Sachin
PrivateSub UpdateMember(coID AsLong)
Dim coSvc AsChangeOrderService = serviceManager.ChangeOrderService
Dim workflow AsWorkflow = coSvc.GetDefaultWorkflow()
Dim routings AsRouting() = coSvc.GetRoutingsByWorkflowId(workflow.Id)
Dim defaultRouting AsRouting = routings.FirstOrDefault(Function(n) n.IsDflt)
If defaultRouting IsNothingThen
ThrowNewException("No default routing")
EndIf
' Not able to find how to set reference to user
Dim Member() AsRoutingUserRoles = ?????
coSvc.UpdateChangeOrderRoutingMembers(coID, defaultRouting.Id, Member, Nothing)
EndSub
Solved! Go to Solution.
Solved by minkd. Go to Solution.
New updated code
now getting error code = 0
PrivateSub UpdateMember(coID AsLong)
Try
Dim coSvc AsChangeOrderService = serviceManager.ChangeOrderService
Dim workflow AsWorkflow = coSvc.GetDefaultWorkflow()
Dim routings AsRouting() = coSvc.GetRoutingsByWorkflowId(workflow.Id)
Dim defaultRouting AsRouting = routings.FirstOrDefault(Function(n) n.IsDflt)
If defaultRouting IsNothingThen
ThrowNewException("No default routing")
EndIf
Dim Member(1) AsRoutingUserRoles
Member(0) =
NewRoutingUserRoles
Member(0).UserId = 28
Dim arrayLong(1) AsLong
arrayLong(0) = 8
Member(0).RoleIdArray = arrayLong
coSvc.UpdateChangeOrderRoutingMembers(coID, defaultRouting.Id, Member,Nothing)
Catch ex AsException
MsgBox("Error: " + ex.Message)
EndTry
EndSub
In order to add users to a Change Order routing, you also need to specify which change order roles that user should have within the routing.
The RoutingUserRoles object (which you pass in arrays of to add / delete those user/roles) contains the userID of the user you want to add. In your case it appears you are working with userID 28, which I assume is a valid user ID.
So what is missing is the array of role IDs that you want to give the user.
The available role definitions can be determined with the GetRoutingRoleDefinitionsByWorkflowId method, which returns an array of RoutingRoleDef objects. Each one of those contains an ID, a localized name, and what kind of changes the signed-in user is allowed to make (add, remove, both, none).
-Dave