- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 06:31 PM
I have a request to auto populate a reference field on the Task form of a requested item, with user input from a single line text variable on a Catalog Item.
I created a BR on the catalog task table.
When to Run: before Insert, Order: 100, Filter Conditions: request item.item = abc
Advanced:
(function executeRule(current, previous /*null when async*/) {
if(current.variables.action == 'new') //is new ict is selected
{
current.cmdb_ci = current.request_item.variables.name; //user inserts text into the name variable
}
else //if modify existing ict
{
current.cmdb_ci = current.request_item.variables.ict_system_name; //select from look up
}
})(current, previous);
When I go to the task it doesn't auto populate the cmdb_ci field and there is no preview available for this variable:
BUT when I double click on the variable name I get this, so the value which the user input 'debug' is there but just not populating the reference field ?
if I click ok it will populate the value into the field and then I can preview information via the 'i'.
The record is created in the cmdb table and I can see it.
Has anyone experienced this?
I have tried a few ways to do this but none were successful. I feel it should be pretty straight forward and easy but I just can't get it. Any advice?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 06:44 PM
Hi @A Kose ,
You need to pass sys_id to reference fields, you can try like this.
if(current.variables.action == 'new') //is new ict is selected
{
var gr = new GlideRecord("cmdb_ci");
if(gr.get("name", current.request_item.variables.name)){
current.cmdb_ci = gr.getUniqueValue(); //user inserts text into the name varible
}else{
gs.info("Didn't found CI with given name");
}
}
else //if modify existing ict
{
current.cmdb_ci = current.request_item.variables.ict_system_name;//select from lookup
}
})(current, previous);
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 07:12 PM
Hi Wizard,
I will have a look at this, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 05:01 PM - edited 12-20-2023 05:01 PM
Hey__ DC, there is currently a workflow in place for this catalog item so I can't add a flow as this workflow is required to run. So I'm not sure how this will work