Modify Requested_for field by script

Sylvain12
Tera Contributor

Hello;

 

For a business need, I need to modify the field "Requested for" of RITMs by script.

 

I did the following test in a background script:

var grRITM = new GlideRecord('sc_req_item');
grRITM.get('<sys_id of the RITM>');
grRITM.setValue('requested_for','<sys_id of the user>');
grRITM.update();

- On my PDI, it works fine, the field is being updated;

- On my business instance, field is not updated.
Although there is a comment added mentioning it was updated:

Sylvain12_1-1686145888154.png

 

Note: If I modify the value of the field manually, it works. (meaning after saving, the new value is displayed).

I suppose this is due to a rule in my business instance, I looked for "requested_for" in Business Rules but I did not find one that would prevent to update this field.

 

I wanted to ask where I could look / what should I be searching for, to find out what is causing me this issue ? 

 

Thank you very much in advance for your support !

 

Kr,

Sylvain

 

 

 

1 ACCEPTED SOLUTION

Yeah that is what i am saying it is the field coming from sc_request and not a field directly on ritm table

 

var grRITM = new GlideRecord('sc_request');
grRITM.get('sys_id_of_request'); // you can get this from request field of ritm
grRITM.requested_for='sys_id of the user';
grRITM.update();

 

OR 

 

Bring the requested for field of RITM on the form.

 

Please mark my answer as correct based on Impact.

View solution in original post

6 REPLIES 6

Saurav11
Kilo Patron
Kilo Patron

If it is logging in the activity formatter as field chnages then the field value should have been updated.

 

Any ways please use the below code once and check:-

 

var grRITM = new GlideRecord('sc_req_item');
grRITM.get('<sys_id of the RITM>');
grRITM.requested_for='sys_id of the user';
grRITM.update();

 

Also just check once if the requested for you are looking at on the RITM form is requested for from the RITM tabke or is it dotwalked from request and you are looking at that value.

 

Please mark my answer as correct based on Impact.

Hello Saurav,

 

Thanks for your reply.

 

I tried your code and it does not work either.

 

The "requested for" field is indeed the standard field of the RITM and not a variable of the catalog item:

Sylvain12_0-1686211459799.png

 

Other information : If I update the "description" field by script with same code as above, it works.

 

Hello,

 

Please right click on the requested for field. Then click on show requestd for as below:-

 

Saurav11_1-1686211840890.png

 

Then let me know what you see in the below:-

 

Saurav11_0-1686211797460.png

 

Hi Saurav,

 

Please find below:

Sylvain12_0-1686214371989.png