
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 07:49 PM
Hi all
I am not very experienced in the scripting part. Today I get myself into a new challenge.
I need to pass values from a Ticket form to the URL and then use that in a Request Form. I was able to place what I needed in the URL and then call it and use it in the Request form.
The form has a field named: u_ticket_type, one of the values that can be set in that field is sc_request (from a drop down list with other options such as “incident”, “inquiry#, etc…). If you choose sc_request , then you also have to select a Catalog Item from a reference field named: u_catalog_item
What happens is that a UI Action named “Transfer” will open the Catalog Item form to submit a new request. Whatever Catalog item you choose is the one that gets opened to be completed and submit a request.
These are the fields I need to pass from the Ticket to the Request Form:
Customer [u_caller] -> Requested For [u_requested_for]
Business Phone [u_call_back_number] -> Callback # [u_call_back]
Description [description] -> Business reason/need [u_business_reason]
In the “else if” I did this:
else if (ctype == 'sc_request'){
var url = '/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=f709d6cd4fd97a4000402cee0210c7af&sysparm_caller=' + current.u_caller + '&sysparm_callback=' + current.u_call_back_number + '&sysparm_desc=' + current.description;
gs.log(url);
current.u_locked_count = current.u_locked_count + 1;
}
current.update();
action.setRedirectURL(url);
}
It works fine but only works for a particular Catalog Item: “f709d6cd4fd97a4000402cee0210c7af”, whenever the user chooses another Catalog Item, as the sys_id is hardcoded in the URL that is being created, it will always go to the same Catalog Item form.
I want to create a dynamic URL that changes based on the chosen Catalog item.
As the Catalog Item field is a reference field in the Ticket form I thought that I could gather the sys_id using a GlideRecord query but, as I stated at the very beginning of this post, I’m not good at scripting just yet.
This is what I have done so far, and obviously, it doesn’t work.
var catitem = new GlideRecord('sc_cat_item');
catitem.addQuery("sys_id",current.u_catalog_item);
catitem.query();
if (catitem.next());
var gu = new GlideURL('sc_cat_item.do');
var caller = gu.addParam('sysparm_caller', current.u_caller);
var callback = gu.addParam('sysparm_callback', curren.u_call_back_number);
var desc = gu.addParam('syspam_desc', current.description);
var url = gu.addParam('sys_id', current.u_catalog_item);
url = gu.addParam('sysparm_ticket', current.sys_id);
gs.log(url);
action.setRedirectURL(url);
If someone could help me fix or re-do the code, or provide some sample I can probably complete this task.
Thanks a lot in advance for your help.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 08:09 PM
try changing url to below
var url = '/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' +current.u_catalog_item +'&sysparm_caller=' + current.u_caller + '&sysparm_callback=' + current.u_call_back_number + '&sysparm_desc=' + current.description;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 08:09 PM
try changing url to below
var url = '/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' +current.u_catalog_item +'&sysparm_caller=' + current.u_caller + '&sysparm_callback=' + current.u_call_back_number + '&sysparm_desc=' + current.description;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 08:15 PM
Hi Mike,
I can't believe it. It worked! Fixed my issue! Thanks a lot! I'm marking it as the correct answer and helpful.