Requested for on RITM is not updated

Blessy2
Tera Contributor

Hi,

 

I have a requirement to update the 'Requested for' (on both REQ and RITM) filed based on what is entered in the 'contact' field in the catalog item during the request submission.

 

For example: ABC is a catalog item and there is a field called 'contact' in the item which is a reference to the 'user' table. During the request submission if I choose 'Abel' in contact field and submit the request, the 'requested for' of the REQ and RITM should be updated to 'Abel' not the logged in user.

 

For this I have written the script in the workflow.

Below is the script:

 

var reqRecord = current.request.getRefRecord();

reqRecord.requested_for = current.variables.request_for;

reqRecord.update();

 

This was working earlier but not sure why it isn't working now. No matter what I select in the 'contact' field the 'requested for' of the REQ and RITM is set to the logged in user.

 

Could this be because of the 'San Diego' version or the patch upgrades? 

Is there any way I can achieve this may be using a business rule?

 

Requesting the suggestions, Thank you in advance.

18 REPLIES 18

Blessy2
Tera Contributor

Sure, here it is

 

Blessy2_0-1669728898192.png

 

 

Blessy2_1-1669728949871.png

 

It should be an after not before.


Raghav
MVP 2023

Blessy2
Tera Contributor

Tried giving after as well, it didn't work.

@Blessy2 did you check the audit logs? there could be a case that it is being set twice.


Raghav
MVP 2023

Blessy2
Tera Contributor

Hi @RaghavSh

I tried the below code in the Business rule (after-insert), and it worked. The 'requested for' of the REQ is now set as the internal contact.

var reqRecord = current.request.getRefRecord();

reqRecord.requested_for = current.variables.request_for;

reqRecord.update();

 

I still wonder why the same code didn't work in the workflow. I'd like to understand if the reason could be due to the patch upgrades.

Is there any other way that we can try to make it work in the workflow?

 

Thank you very much for your responses.