How to get the variables values of the catalog item using Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2023 10:12 PM
Hi,
I have an advanced on before insert BR on the sc_task table. Im trying to get the variable's value (password) from the catalog item but Im getting undefined in the logs. What am I doing wrong?
BR:
Catalog Item:
Catalog task:
Logs:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2023 10:22 PM - edited 08-06-2023 10:32 PM
Hi @Alon Grod ,
Methods to call catalog item variables is different.
Can you try changing your script reffering this:
var now_GR = new GlideRecord('sc_req_item');
if (now_GR.get('03bc19e11bc90510ee770f2f5b4bcba5')) {
var variables = now_GR.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
gs.log(question.getLabel() + ":" + question.getValue())
}
}
You can also refer to link - Scriptable service catalog variables (servicenow.com)
For your use case:
var now_GR = new GlideRecord('sc_req_item');
now_GR.get('03bc19e11bc90510ee770f2f5b4bcba5');
var temp = now_GR.variables.getElements()[1].getQuestion().getValue();
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2023 10:45 PM
Hi @Alon Grod ,
Were you able to get the desired output?
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2023 11:04 PM
Can you try making the Business rule After-insert and let me know if it works(I haven't tried it)