How to get variable value of requested item into client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2015 01:46 AM
Hi all,
I'm trying to do the following:
I have a catalog item client script where I want to populate a field of this catalog item form with a value of a variable from a requested item.
Hereunder is my snippet code:
//I set 2 variables to find needed requested item
var company = g_form.getValue('my_company');
var req_item_category_sys_id = '7de5ec5d3ee440f1857b576fe4f10096';
//I use gliderecord to call sc_req_item table and filter with company and category
var join_req = new GlideRecord('sc_req_item');
join_req.addQuery('company', company);
join_req.addQuery('cat_item', req_item_category_sys_id );
join_req.orderByDesc('opened_at');
//join_req.setLimit(1);
join_req.query();
if(join_req.next()) {
//if result found, populate my catalog item field with value of "my_request_item_variable_value"
g_form.setValue('my_catalog_item_field', join_req.variables.my_request_item_variable_value);
}
Doing that, I'm getting "Undefined" in my field on the catalog item.
Any suggestions ?
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2015 02:08 AM
Just paste the code as is. Store the value as g_scratchpad.variablename= value;
Access in any onload script as g_scratchpad.variablename to get the stored value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2015 01:58 AM
Benefits of display rule:
- Form responsiveness is improved.
- Glideajax call is avoided.
- Easier to manipulate data at server side
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2015 02:08 AM
problem is display BRs are not available in the catalog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2015 02:18 AM
That's true mguy !

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2015 02:38 AM
I just totally missed the point in the question that this is a catalog client script
Glideajax is the way to go. Also, I dont think, orderByDesc is available in client side gliderecord