- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2015 06:58 AM
We currently use an order guide that our users use to order computer hardware requests and on the form they choose if it's for a cost centre or project. The Cost Centre and Project fields are reference field variables to their respective tables.
Our hardware provisioner's prefer to work these requests at the Request level (REQ) instead of the catalog task and they'd like to see more information on the Request form. I'm trying to set the short_description field to 'Computer Equipment Request for [Cost Centre or Project] name' depending on what they chose on the form but in the Service Catalog Request workflow it doesn't seem like it sees the variables and gives an undefined for it (e.g. 'Computer Equipment Request for undefined'). The code below is what I'm using to try to set the short_description. Does anyone know why this is happening? Also, is it possible to show these fields on the Request form layout?
current.short_description = "Computer Equipment Request" + " for " + current.variables.project.u_project_number;
current.short_description = "Computer Equipment Request" + " for " + current.variables.cost_centre.u_name;
Thanks,
Aryanos
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2015 06:45 AM
Hi Aryanos,
You can't dot-walk that way when setting a field value, you'll have to use a gliderecord:
var req = new GlideRecord('sc_request');
if (req.get(current.request)) {
if(current.variables.project_choice == 'Project'){
req.short_description = "Computer Equipment for " + current.variables.project.u_project_number;
}
else{
req.short_description = "Computer Equipment for " + current.variables.cost_centre.u_name;
}
req.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 07:17 AM
Helllo,
I am facing the same issue and i really do not know what to do here, I am not script fan, still need to learn.
I need to Complete Request Short Description with Catalog Item name when it is just 1 item. When we have few items it is ok to have just " 3 Items" or something similar and when we use Order Guide like for New Hire, it would be ok to have at least words New Hire on Short description.
I am not able to do it. I know I have to run AFTER Insert business rule but... my rules are stupid.
Could you help me, please?
Sniega
Tried this:
(function
executeRule(current, previous /*null when async*/) {
var
req = new GlideRecord('sc_request');
req.get(current.request);
req.short_desription
= current.cat_item.getDisplayValue();
req.update();
})(current,
previous);
Tried this also:
(function
executeRule(current, previous /*null when async*/) {
var ritm = new
GlideRecord("sc_req_item");
ritm.addQuery("request",
gr.getUniqueValue());
ritm.query();
if
(ritm.getRowCount() == 0) something like
continue;
if
(ritm.getRowCount() > 1)
record.display_field
= gs.getMessage("{0} requested items", ritm.getRowCount());
else {
ritm.next();
record.display_field
= ritm.cat_item.getDisplayValue() ||
ritm.getDisplayValue("short_description");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2017 05:28 PM
Im trying the same thing but my issue is when I use the service portal. I have a new hire order guide. Its called New hire request. When the user hits submit and the request is created I want the order guide name to be in the short description. All my items have all the info they need and I've also created a variable formate on the request table so getting any variable info on the request record is not a issue. I just need to populate the short description field. This way we can work the ticket at the request level also

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 02:29 PM
(editing my post)
There are a few things you need to look at, the REQ does not have a cat_item for example.
If your REQs are 1-to-1 on the RITMs you might be able to pull that off, but otherwise you will have to script.
var reqitem = new GlideRecord('sc_req_item');
reqitem.addQuery('request', current.sys_id);
reqitem.query();
var x = reqitem.getRowCount();
if(x>1){
current.short_description = x + " catalog items";
}else{
reqitem.next();
current.short_description = reqitem.short_description;
}
current.update();
I have not tried that, but it should work