- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:01 AM
If I have a table called my_table with a custom u_ritm_ref field which is a reference to sc_req_item and I have another custom field called u_var_name to hold the name of a variable and another custom field called u_var_value which is hold some string you want to use as a value.
When you insert a record into my_table I want this BR below to find the RITM record and update the variable with a new value.
RITM.variables.points_1 = VARvalue
This works but is I replace the hardcoded "points_1" with VARname it does not work
(function executeRule(current, previous /*null when async*/ ) {
var RITM = current.u_ritm_ref;
var VARname = current.u_var_name;
var VARvalue = current.u_var_value;
RITM.variables.VARname= VARvalue;
//RITM.update();
gs.log('ritm is ' + RITM + ' VARname is ' + VARname + ' VARvalue is ' + VARvalue);
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:38 AM
Allen, the format using [ ] does work.
Thanks
I still get this error in syslog but the functionality I'm looking for works.
I'll figure out why I get this error. Probably how I formed the sys_id.
(function executeRule(current, previous /*null when async*/ ) {
// var RITM = current.u_ritm_ref;
var VARname = current.u_var_name;
var VARvalue = current.u_var_value;
var RITM = new GlideRecord('sc_req_item');
RITM.addQuery('sys_id', current.u_ritm_ref);
RITM.query();
RITM.next();
RITM.variables[VARname] = VARvalue;
RITM.update();
gs.log('ritm is ' + RITM + ' VARname is ' + VARname + ' VARvalue is ' + VARvalue);
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:20 AM
Hello,
Please try using:
RITM.variables[VARname] = VARvalue;
The above is assuming all field names and values are appropriate as well as the BR is appropriately executing, etc.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:34 AM
Thanks Allen.
The BR does fire but the variable does not update.
I see this in syslog
com.glide.script.RhinoEcmaError: Cannot convert null to an object.
<refname> : Line(1) column(0)
==> 1: __ref__.getValue().indexOf(gs.getUserID()) != -1
I'll troubleshoot this a bit and I'll keep trying to use the syntax you provided [ ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:38 AM
Allen, the format using [ ] does work.
Thanks
I still get this error in syslog but the functionality I'm looking for works.
I'll figure out why I get this error. Probably how I formed the sys_id.
(function executeRule(current, previous /*null when async*/ ) {
// var RITM = current.u_ritm_ref;
var VARname = current.u_var_name;
var VARvalue = current.u_var_value;
var RITM = new GlideRecord('sc_req_item');
RITM.addQuery('sys_id', current.u_ritm_ref);
RITM.query();
RITM.next();
RITM.variables[VARname] = VARvalue;
RITM.update();
gs.log('ritm is ' + RITM + ' VARname is ' + VARname + ' VARvalue is ' + VARvalue);
})(current, previous);