0

Been working with Visual Studio 2013 and I am trying to send an email to all the users and users within the groups entered into a UserMulti field (One which allows people and groups).

I have gotten to a stage where I have the ids from the list item but only the id is given which could belong to either a user or group.

I have some activities which lookups the members of the id and loops through them sending an email to them all. the workflow stops however when it reaches an id belonging to a user.

Is there some sort of expression I can use in an if branch to deduce whether a principal id belongs to a user or group?

Thanks

0

Okay so eventually I found a way for performing this check given a principal id and the very limited activities provided in the Visual Studio workflow designer.

Basically you have to set a boolean value to False in Variables to act as a flag for the principal id being a user (I called it isUser).

You then need to create a sequence within a TryCatch which you can find under "Error Handling" that attempts to use the activity LookupSPUser with the input as the principal id.

You then want to save the result to a DynamicValue Variable and use GetDynamicValueProperties to save the property PrincipalType to an int32 Variable.

This value will be 1 if the principal id is a user (as seen here) group should be 8 but you cannot check this PrincipalType property in this scenario to perform the check as if a group principal id is used at the LookupSPUser stage it will fail the TryCatch therefore at the end of the LookupSPUser you need to set your isUser flag to True and then after the TryCatch you need to use an If under "Control Flow" to the isUser boolean variable to allow your workflow to handle a user or group differently given the principal id.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.