Update variable value using SetValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2017 12:41 AM
Hi,
i'm trying to update requested item variables using script. i tried to do it using the setValue function
Seems like this option work
req.variables.first_name = 'MY NAME';
but this option does not work:
req.setValue('variables.first_name ','MY NAME);
req.update();
Anyone know the reason or how i should use the setValue function for variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2017 12:56 AM
Remove the variables and add a script in catalog client Script. req.setValue('first_name ','MY NAME); PS:Hit like, correct, helpful when you feel happy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2017 12:59 AM
Hi,
The script is not on the client side, but on server side.
I tried to remove the "variables" word like this:
req.setValue('first_name ','MY NAME);
but it's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2017 01:08 AM
If you use the server side then it's easy use the current object.
Ex:
Current.variables.first_name = "MY NAME";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2017 01:26 AM
OK, the only problem is that this is not dynamic, meaning, i'm using a script to update several variables, something like:
function updateVar (number,vaiable_name,value){
var var_name = 'variables.' + vaiable_name;
var req = new GlideRecord('sc_req_item);
req.addQuery('number',number);
req.query();
if (req.next()){
req.setValue(var_name,value);
req.update();
}
}
using directr update does not allow me to do that, or maybe you are familiar with a way to do it?