Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Create account JSON issue in REST Connector

Rajesh_IAM
Regular Contributor
Regular Contributor

Hi Everyone,
Issue: Guest/external users are creating in Saviynt through invitation form. Post invitation acceptance,  Guest user's profiles will be creating in saviynt. These guest users have country name. 
For one application, when we are trying creating new account for these guest users, but application API will accept only countrycode(like IN,AU,US..) and it will not accept the country name for country attribute in target.
Is there any way to pass country code in create account JSON based on guest user's country name.?
Ex: If guest user have India as country in Saviynt then we need to push country code "IN" in create account JSON during task execution.

8 REPLIES 8

naveenss
All-Star
All-Star

Hi @Rajesh_IAM 

Yes. This is possible. you can use if/else conditions in your create Account JSON.

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

Rajesh_IAM
Regular Contributor
Regular Contributor

@naveenss  Thank you for your response.
Can you give me sample syntax.? But guest user's profile have country name then how is it possible to generate country code during create account task execution.?

@Rajesh_IAM I'm sharing the sample JSON with if/else for country. Please make modifications to your JSON based on the requirement. 

{
  "accountIdPath": "${(user.customproperty1=='Guest')?'call1.message.invitedUser.id': 'call1.message.id'}",
  "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX",
  "responseColsToPropsMap": {
    "customproperty31": "${(user.customproperty1=='Guest')?'call1.message.inviteRedeemUrl~#~char': ''}",
    "customproperty1": "${(user.customproperty1=='Guest')?'call1.message.invitedUserType~#~char': ''}",
    "displayName": "${(user.customproperty1=='Guest')?'call1.message.invitedUserDisplayName~#~char': 'call1.message.displayName~#~char'}",
    "name": "${(user.customproperty1=='Guest')?'call2.message.userPrincipalName~#~char': 'call1.message.userPrincipalName~#~char'}"
  },
  "call": [
    {
      "name": "call1",
      "connection": "userAuth",
      "url": "${(user.customproperty1=='Guest')?'https://graph.microsoft.com/v1.0/invitations':'https://graph.microsoft.com/v1.0/users'}",
      "httpMethod": "${(user.customproperty1=='Guest')?'POST':'POST'}",
      "httpParams": "${if(user.customproperty1.equals('Guest')){return '{\"invitedUserEmailAddress\":\"' + user.email + '\",\"invitedUserDisplayName\":\"' + user.firstname + '\", \"inviteRedirectUrl\":\"https://portal.azure.com\", \"invitedUserType\": \"Guest\", \"sendInvitationMessage\":\"true\",\"country\":\"'+if(user?.country=='India'){return 'IN'}+'\"}';} else if(user.customproperty1.equals('Work')) {return '{\"accountEnabled\": \"true\", \"displayName\": \"' + user.firstname + '\", \"mailNickname\": \"' + user.firstname + '\", \"passwordProfile\": { \"password\": \"Passw0rd\"}, \"UsageLocation\": \"US\",\"userPrincipalName\": \"' + user.username + '\", \"extension_924eb70c1cb54dc9b9b00ad99df04b38_TimeZone\": \"' + user.customproperty15 + '\",  \"extension_924eb70c1cb54dc9b9b00ad99df04b38_Profile\":\"' + user.customproperty16 + '\"}';}else {return '{\"displayName\": \"' + user.firstname + '\",\"identities\": [{\"signInType\": \"' + user.username + '\",\"issuer\": \"saviyntliveb2c.onmicrosoft.com\",\"issuerAssignedId\": \"' + user.username + '\"},{\"signInType\": \"emailAddress\",\"issuer\": \"saviyntliveb2c.onmicrosoft.com\",\"issuerAssignedId\": \"' + user.email + '\"}],\"passwordProfile\" : {\"password\": \"Saviynt@12345\",\"forceChangePasswordNextSignIn\": false},\"passwordPolicies\":\"DisablePasswordExpiration\", \"extension_924eb70c1cb54dc9b9b00ad99df04b38_TimeZone\": \"' + user.customproperty15 + '\",  \"extension_924eb70c1cb54dc9b9b00ad99df04b38_Profile\":\"' + user.customproperty16 + '\"}';}}",
      "httpHeaders": {
        "Authorization": "${access_token}",
        "Content-Type": "application/json"
      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200,
          201,
          204,
          205
        ]
      },
      "unsuccessResponses": {
        "error.code": [
          "Request_BadRequest",
          "Authentication_MissingOrMalformed",
          "Request_ResourceNotFound",
          "Authorization_RequestDenied",
          "Authentication_Unauthorized",
          "BadRequest"
        ]
      }
    },
    {
      "name": "call2",
      "connection": "userAuth",
      "url": "${(user.customproperty1=='Guest')?'https://graph.microsoft.com/v1.0/users/${response.call1.message.invitedUser.id}': 'https://graph.microsoft.com/v1.0/users'}",
      "httpMethod": "GET",
      "httpParams": "",
      "httpHeaders": {
        "Authorization": "${access_token}"
      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200,
          201,
          204,
          205
        ]
      },
      "unsuccessResponses": {
        "error.code": [
          "Request_BadRequest",
          "Authentication_MissingOrMalformed",
          "Request_ResourceNotFound",
          "Authorization_RequestDenied",
          "Authentication_Unauthorized",
          "BadRequest"
        ]
      }
    }
  ]
}

Let me know if this helps!

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

Rajesh_IAM
Regular Contributor
Regular Contributor

Hi @naveenss  I could see country name (India & IN ) hardcoded in this sample JSON. However user may select any country as per their location, in this case, how come we get exact country code for that country name?

Rajesh_IAM_0-1708690511193.png

 

Let user input the Country using dynamic attribute. Use dynamic attribute in json and implement the logic 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

AmitM
Valued Contributor
Valued Contributor

HI @Rajesh_IAM ,

You can have another attribute that will store country code and you can do this via Sav4Sav connector. Use that attribute in createAccountJson.

You can also write if else conditions in createAccount JSON itself but it will make your JSON complex. 

Thanks,

Amit

If this answers your query, Please ACCEPT SOLUTION and give KUDOS.

Rajesh_IAM
Regular Contributor
Regular Contributor

Hi @AmitM Thank you for your response.
You can have another attribute that will store country code and you can do this via Sav4Sav connector. Use that attribute in createAccountJson  >> Can you tell me how can I store country code via Sav4Sav connector.?

AmitM
Valued Contributor
Valued Contributor

You can have all country codes and name mapping stored in dataset and use that to find the respective code from name