- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 11:20 PM
Hi, i'm trying to run a UI action that takes the variables from a requested item and opens a new request.
I am using both client and server script, but the server script isn't running.
typeof window is not returning "undefined" and if I try to run my script without it it doesn't work also.
my script:
function onClick() {
var item = g_form.getParameter("sysparm_id");
g_navigation.open("URL/sp?id=sc_cat_item&sys_id="+item+"&sysparm_clone=true', "_blank");
if (typeof window == "undefined")
get_variables();
function get_variables(){
var variables = new GlideRecord('sc_item_option_mtom');
variables.addQuery('request_item', current.sys_id);
variables.query();
var variable_list = [];
while (variables.next()){
var dict = variables.sc_item_option.item_option_new;
var v = variables.request_item.variables[dict.name];
var o = {
'name' = dict.name;
'question' = dict.question_text;
'value' = v;}
if (o.value != ""){
variables_list.push(o);
}
}
gs.getSession.putClientData('variable_values', variable_list);
}
Can anyone help?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 12:10 AM
You need to have the line below in place to get the client side code calling the server side code in the UI action:
gsftSubmit(null, g_form.getFormElement(), 'action_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 12:10 AM
You need to have the line below in place to get the client side code calling the server side code in the UI action:
gsftSubmit(null, g_form.getFormElement(), 'action_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 12:24 AM
Thank you!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 07:03 AM
Did gsftSubmit() help you with your script above? Does it go as last line?What exactly you added here?