I have a state with an owner and a group ID as a secondary owner, i want to use a VB Script to add a single user to that field.

Here is what I have
If (TransitionID = 361) Then
Dim strEmergencyApprovers, intDeveloper, strSecondaryOwner, strNewComposedvalue
intCurrentUser = Shell.User.GetId()
fldOK = Shell.Item.SetFieldValue("Developer", intCurrentUser)
fldOK = Shell.Item.GetFieldValue("Developer", intDeveloper)
fldOK = Shell.Item.GetFieldValue("Emergency Approvers", strEmergencyApprovers)
fldOK = Shell.Item.GetFieldValue("Secondary Owner", strSecondaryOwner)
strNewComposedValue = "," &strEmergencyApprovers &"," &intDeveloper&","
fldOK = Shell.Item.SetFieldValue("Secondary Owner", strNewComposedValue)
End If
' End of Secondary Owner adding Developer for Emergency during Request Emergency Approval
Responses (2)
  • Accepted Answer

    Friday, July 06 2018, 12:37 PM - #Permalink
    Trying to add values directly to the system Owner or Secondary Owner fields is a bad idea, because every time the item is updated, SBM will overwrite the value you manually set to the field with the value it is supposed to be (from the field that the state uses to define the value).

    Rather, the way I'd suggest doing this is by using a Multi-User/Group field to drive the Secondary Owner for this state. Multi-User/Group fields can store Users, Groups, or both. These values can be copied to the Secondary Owner field by the SBM ownership mechanism.
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, July 08 2018, 12:59 AM - #Permalink
    In addition to Don's suggestion, your code sets the Developer field to the current User's ID, then get's that field (which is now the current User) to append it to the strNewComposedValue string. I think you want to reverse the order of those 2 operations. Then (as per Don) use that to set the field specified in Composer as the Secondary Owner.

    You probably want to ensure that in Composer the "Selection Mode" for your "secondary owners" and "Emergency Approvers" fields are similar. This has to do with multi-user fields that contain a mix of user IDs and Group IDs, where the Group ID is prefixed with a "G".
    The reply is currently minimized Show
Your Reply

Recent Tweets