Populating a RITM variable based on 'requested_for'

kim-lindgren
Kilo Sage

Hi,

 

We have a requirement to populate a variable on a Requested Item with the user in the 'requested_for' field on the Requested Item record.

 

The problem is, we cannot access the 'requested_for' value using a client script. We have tried a variety of commands: g_form.getValue('requested_for'), g_form.getUniqueValue('requested_for'),

g_form.getReference('request_item.requested_for').

 

getUniqueValue is the only command that returns anything but it is just the sysID of the RITM.

 

The client script is onLoad and the checkbox 'Applies on Requested Item' is ticked.

 

Any help is much appreciated!

 

/Kim

 

 

1 ACCEPTED SOLUTION

I think the main problem here is that catalog client script do not have access fields on the request item table. I'm also positive that client scripts on the request item table do not have access to variables. So I would use a before insert business rule. The conditions could be just a list of Catalog Items it need to run agents and then the code would be as simple as something like below.

current.variables.location = current.requested_for.location; (depending on how you are setup this part may need to be current.request.requested_for.location)

You will need to put your own variable name in there and associated it to the correct field you want from the user table.

View solution in original post

6 REPLIES 6

Thanks!

 

We have continued with a different solution (creating a Requested for variable on the catalog item form) but your explanation makes sense so I will accept it as a solution.

 

Although it does seem odd that the client script doesn't have access to variables on the RITM/TASK level when it has access to them on the form... what is the logic behind this? 🤔

I think it is related to the fact that variables are stored in a different table once the request has been submitted. Client script can only see the data from the table they are associated with.