How to remove User -> Organization relation through script in Event hooks?

Hi team,

I have struck with the situation where the user accounts get created through Form like structure which created through Journey.
So, After collecting organization name to which the user has to belong, I have created event hooks to create relationship with organization based on below suggestion.
How to assign organization to user identities added through bulk import in Identity Cloud - Integrations - ForgeRock Community
The problem I am facing is I also have update form to update existing user and I created option to modify organization to which they belong. With current execution whenever the change happens the event hooks will create another relation with new organization, but previous organization still exist.
I got suggestion to do “remove” operation, but it is working for “/parent” object, but for “/memberofOrg/-” it is not working. Below is sample code I used to removal operation which is not working…
var orgID = object.orgID
var patchedUser = openidm.patch(“managed/alpha_user/” + object.username, null, [{

I need suggestion where I can make changes to remove all previous relations made. Thank you in advance!

The REST call is not correct. Please have a look a this knowledge page: Knowledge - ForgeRock BackStage


  • field should be /memberOfOrg
  • In the value, you also need to pass in the _refProperties, _refResourceCollection and _refResourceId

Another way of achieving this usecase is to first retrieve the object payload, manipulate the JSON at the client side to remove the old relationship, and add the new one, then perform a patch replace with the new JSON.