When an object is created in Assets, create a customer in JSM and add him to the object's attributes
Asked by Yossi Avissar:

In asset management, I have an object type "Customer's Contact" with an attribute called "mail." I've attempted to create an automation rule that retrieves this mail, creates a customer in my JSM Portal, and adds the new customer to the new object's attribute (specifically, an attribute called "JSM User").

I'm using REST API requests for both actions. I can successfully create the users and retrieve the account ID. However, when I try to update the attribute, it doesn't work. It seems that these two actions cannot occur within a single automation rule.

I think that because when I split it into two different rules, it works well(I can update the object's attribute correctly using a PUT web request).

so, for now, this is my workaround: the first rule creates the users, and the second rule looks for new objects once an hour and updates their attributes.

first rule : attached in screenshot

![aut1.png](https://community.atlassian.com/t5/image/serverpage/image-id/335534i0391DCA18FA57DE5/image-dimensions/218x232?v=v2 "aut1.png")

second rule: (lookup object looks for all the empty "JSM Customer" attributes.

![2.png](https://community.atlassian.com/t5/image/serverpage/image-id/335536i68C74EDB87395EB1/image-dimensions/253x245?v=v2 "2.png")

then, using GET method ,send web request: orgURL.atlassian.net/rest/api/3/user/search?query={{ObjectsList.mail}}

then, using PUT method, send web request to update the customer in the object's attribute:

[https://api.atlassian.com/jsm/assets/workspace/WorkspaceNumber/v1/object/{{ObjectList.key](https://api.atlassian.com/jsm/assets/workspace/WorkspaceNumber/v1/object/{{Object.key)}} with custom data : { "attributes":\[ { "objectTypeAttributeId":"81", "objectAttributeValues": \[ { "value":"**{{webResponse.body.accountId}}**" } \] }

Does anyone have ideas on how to make this work in a single rule?


Answers:
author: Fernando Eug?nio da Silva
body: [@Yossi Avissar](/t5/user/viewprofilepage/user-id/5538778) , Welcome to the Atlassian Community!

Have you tried using a delay between these actions?

What may be happening is that events within the same rule are executed at very small intervals to ensure that your next action was able to correctly retrieve the information processed by the previous action.

Try adding a Delay action and setting it to something like 1 minute between some key actions in your process. Or if applicable, use re-fetch to ensure that the rule will try to pull data saved in the previous action.

Some of these suggestions should help you keep everything working under the same rule.

If the problem persists, let us know.

KR,

Fernando

comments: author: Yossi Avissar
body: Hey [@Fernando Eug?nio da Silva](/t5/user/viewprofilepage/user-id/4606715)

Thanks a lot for your answer!!

I'm pretty sure that when I wrote this post, this feature didn't exist.

anyway - it works!

To sum-up the solution :

insert this Delay action before the GET web request :

![123delay.png](https://community.atlassian.com/t5/image/serverpage/image-id/341937iA52C9211FC33820C/image-size/large?v=v2&px=999 "123delay.png")

30 seconds should be enough.

and that's it.


Tags: asset-management

cloud

jira-service-management

jira-service-management-cloud