Set a catalog item's variable field into the sc_req_item record

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2012 02:50 PM
Hi All,
This seems pretty simple, but I've been getting a run around in the documentation...
I have a catalog variable set called short description that has one variable, short description.
I want to make this variable become the sc_req_item's short description after it's submitted. I've tried using a current.short_description to pull the record, but I'm getting error messages saying that this shouldn't be done in catalog client scripts. (or any client scripts).
Thanks in advance!
-Adam
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2012 07:01 PM
In the workflow of the item you should be able to add a run script with the following line of code to accomplish this;
current.short_description = current.variable_pool.variable_name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2012 08:31 PM
Hi jacebenson,
The variable value can be paste into fields belong to same table i.e. sc_req_item but I have some similar issue for different field set. We have this Caller variable at the time of submission of Request. Now need to copy this variable value and store it into 'Requested for' field belong to sc_req_item and sc_request, the script you mentioned works for the field of same table but not in my case.
Can you please provide some possible solution for the same.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2012 06:20 AM
If you want to change the requested for before checking out you will not need the script on the workflow.
however you will need an onchange script on the item with the user reference.
function onChange(control, oldValue, newValue, isLoading) {
var cart = new GlideRecord('sc_cart');
cart.addQuery('user', g_user.userID);
cart.query();
if(cart.next()){
cart.requested_for = newValue;
cart.update();
}
}
(this is in demo20 right now on the iphone item, link below)
https://demo20.service-now.com/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=0a380e690a0a0b7b00bb6958776da8ca

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2012 11:07 PM
Sure, that's simple enough.
In the workflow you have the ritm details. So long as your variable is a reference to the sys_user table this should work.
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next()){
req.requested_for = current.variable_pool.user_var;
req.update();
}