Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

REST Connector - Import Config - Derive value from inner json array of each user

taiyebur1
New Contributor III
New Contributor III

There is a sample json below. I would like to configure the ImportAccntEntJson for the REST connector so that, name and accountId holds the value of player id and customproperty1 will be true, if the player completes any of the training, otherwise, set to false. For the json below, customproperty1 for player 1 should be true and player 2 should be false.

 

{
	"players":[
		{
			"id": 1,
			"training": [
				{
					"trainingId": 1,
					"status": "Completed"
				},
				{
					"trainingId": 2,
					"status": "Not Completed"
				}
			]
		},
		{
			"id": 2,
			"training": [
				{
					"trainingId": 1,
					"status": "Not Completed"
				},
				{
					"trainingId": 2,
					"status": "Not Completed"
				}
			]
		}
	]
}

 

.How to do that? I am not sure how to iterate over the content and do the logical calculations and return true or false. Any help would be greatly appreciated.

 

4 REPLIES 4

rushikeshvartak
All-Star
All-Star

You can use #CONST and iterate through response from api


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

How do I access the "training" array inside const?

Change as per your needs 

def result = call1.response.players.collect { p -> ["name": p.id.toString(), "accountId": p.id.toString(), "customproperty1": p.training.any { it.status == "Completed" } ? "true" : "false"] }; return result


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

After some trial and error, and revision, I have the following json config working.

ImportAccountEntJSON

{
	"accountParams": {
		...
		...
		"listField": "players",
		...
		...
		"colsToPropsMap": {
			"name": "id~#~char",
			"accountID": "id~#~char",
			"customproperty1": "#CONST#${response.training.any{map->map.status=='Completed'}}~#~char"
		}
		...
		...
	}
}