Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

UI action Client and server script not running

Snow Tomcal
Tera Expert

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 

 

1 ACCEPTED SOLUTION

Dubz
Mega Sage

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');

View solution in original post

3 REPLIES 3

Dubz
Mega Sage

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');

Thank you!!!

tantony
Mega Guru

Did gsftSubmit() help you with your script above? Does it go as last line?What exactly you added here?