How to set a custom attribute in ForgeRock Identity Cloud using Scripted Decision Node?

We know that the custom attributes created in Identity Cloud can be referenced using “fr-idm-custom-attrs”. This is a JSON blob. How can we set this attribute using AM script? Any working example in relation to script can help. I have used idRepository.setAttribute.

https://backstage.forgerock.com/docs/idcloud/latest/am-authentication/scripting-api-node.html#scripting-api-node-id-repo

idRepository.setAttribute(String *userName* , String *attributeName* , Array *attributeValues* )

However, I am not sure what kind of data type has to be embedded in the Array for “fr-idm-custom-attrs”. Repo gets corrupted if we try to do below:

idRepository.setAttribute(sharedState.get("_id") , "fr-idm-custom-attrs",[JSON.stringify(attributeValue)] ). Not sure how we construct the attributeValue after setting up one of the custom_attribute value in JSON blob for “fr-idm-custom-attrs”.

Hi @KaranNayyar1,

The object is a JsonValueorg.forgerock.json.JsonValue.

Then you could use one of the #put method to alter it, or convert to a map with #asMap, update the map, and then set the new value with #setObject.

Regards
Patrick

1 Like