Set current.variables from RITM form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 01:16 AM
Hello guys!
I want to use RITM "stage", "assignment_group" and "assigned_to" for catalog policies to show some variables during the fulfillment process. I used this solution in my last job but now I am trying to set it up again and I am not able to set current values.
I have three variables on my Item as you can see, callled "stage_read_only", "fulfillment_group" and "assigned_to" and BR which takes current values from RITM. It takes actual values and I am able to print it to the log but not set to the variables. Dont know where the fault is.
I´ve also tried to rename variable "assigned_to" to "fulfiller" but no change.
Thank you!
(function executeRule(current, previous /*null when async*/) {
var stage = current.stage.getDisplayValue();
current.variables.stage_read_only = stage;
gs.log('Stage is: ' + stage);
var afg = current.assignment_group.getDisplayValue();
current.variables.fulfillment_group = afg;
gs.log('Assignment group is: ' + afg);
var assignedto = current.assigned_to.getDisplayValue();
current.variables.assigned_to = assignedto;
gs.log('Assigned to is: ' + assignedto);
})(current, previous);
edit: I forgot to say that BR is after Insert / update.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 01:21 AM
Hey,
Instead of current.variables.assigned_to try using current.variables[field_name]
Below article highlights that:
Display or Modify ritm variables from script
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 01:29 AM
Hi Aman!
Im not sure if I got it right but when I try
var stage = current.stage.getDisplayValue();
current.variables[stage_read_only] = stage;
then I have this error in the log:
com.glide.script.RhinoEcmaError: "stage_read_only" is not defined.
sys_script.80b3c2ce970c1d10b8a1fef3a253af38.script : Line(4) column(0)
1: (function executeRule(current, previous /*null when async*/) {
2:
3: var stage = current.stage.getDisplayValue();
==> 4: current.variables[stage_read_only] = stage;
5: gs.log('Stage is: ' + stage);
6:
7: var afg = current.assignment_group.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 02:01 AM
LOL, my bad, just need to add "current.update();" and it works. So final code is:
(function executeRule(current, previous /*null when async*/) {
var stage = current.stage.getDisplayValue();
current.variables.stage_read_only = stage;
var afg = current.assignment_group.getDisplayValue();
current.variables.fulfillment_group = afg;
var assignedto = current.assigned_to.getDisplayValue();
current.variables.assigned_to = assignedto;
current.update();
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 02:19 AM
Please mark response as helpful/correct so the thread can be closed
Aman Kumar