I have an SDK Script activity that is designed to change an account password if a certain set of requirements are met (in this case the requirement is the Workflow Initiator and the User Account that needs a password change have to be members of the same Group) . The SDK script works as expected in my VAR kit Avante environment but when I port the workflow to a client's Rio system the SDK script fails. Here is the code;
Protected Overrides Sub Execute() 'Get the username and new password from the template fields... Dim userName As String = Me.GetTokenValue("RetrieveFieldValues_UserName") Dim newPassword As String = Me.GetTokenValue("RetrieveFieldValues_New Password") 'Instantiate return status and message... Dim success As Boolean = False Dim returnMessage As String = "" 'Wrap in a Try/Catch to catch any errors... Try 'Get workflow initiator name and account, and user account... Dim initiatorName As String = Me.WorkflowApi.Initiator.ToString Dim initiatorAccount As AccountInfo = Account.GetInfo(initiatorName, Me.RASession) Dim userAccount As AccountInfo = Account.GetInfo(userName, Me.RASession) 'Make sure we are working with a valid user account... If userAccount IsNot Nothing Then 'Get the user info and groups for both accounts... Dim initiatorInfo As UserInfo = DirectCast(initiatorAccount, UserInfo) Dim initiatorGroups() As String = initiatorInfo.Groups Dim userInfo As UserInfo = DirectCast(userAccount, UserInfo) Dim userGroups() As String = userInfo.Groups Dim found As Boolean = False 'Step through the initiator and user groups to find a match... For Each initiatorGroupName As String In initiatorGroups For Each userGroupName As String In userGroups If userGroupName = initiatorGroupName Then found = True Exit For End If Next If found Then Exit For Next 'A match was found so change the password and set success flags... If found Then userInfo.Password = newPassword userInfo.Save success = True returnMessage = "Password changed for User " & userName Me.WorkflowApi.TrackInformation(returnMessage) Else 'No match found so set success and message flags... success = False returnMessage = "Initiator " & initiatorName & " and User " & userName & " did not have any groups in common. Password not changed." Me.WorkflowApi.TrackWarning(returnMessage) End If End If Catch ex As Exception 'If we threw an error then record it... If ex.Message.Contains("9012") Then returnMessage = ex.Message & " User " & userName Else returnMessage = ex.Message End If Me.WorkflowApi.TrackError(returnMessage) success = False End Try 'These are the two return tokens from the script. Use these in conditional logic 'to change workflow flow and possibly trigger email? Me.SetTokenValue("Success", success) Me.SetTokenValue("ReturnMessage", returnMessage) End Sub
The script apparently fails on this line in Rio and throws a 9012 error (Account not found);
Dim userAccount As AccountInfo = Account.GetInfo(userName, Me.RASession)
In the Avante environment the Account.GetInfo method correctly returns an instance of the AccountInfo. In the Rio environment the Account.GetInfo method fails to find the account name. In both systems the account I am looking to retrieve is configured similarly (Not a named user, same rights and privileges, same group memberships)
Any feedback is appreciated...