Variables not working in notification script

KB15
Giga Guru

I've been trying to figure out what's wrong with this notification script but I'm out of ideas.

The notification is firing from the sc_req_item table. I can get the fullname to appear by itself by removing line 9 and 13 but once I add the lines, I get the error "undefined' for both entries in the notification.

var gr = new GlideRecord("sc_req_item");

gr.addQuery("request", current.sys_id);

gr.query();

var fullName;

var user_id;

while(gr.next()) {

  fullName = gr.variables.ob_fullname;

  user_id = gr.variables.ob_username;

}

template.print(fullName);

template.print(user_id);

1 ACCEPTED SOLUTION

sorry i missed that looks good..



try adding



template.print('ticket number is ' );


template.print(gr.number);



and see if you get the request number on the field..



also are these variables on the REQUEST or on the requested item.. unless you have modified the variables they should be on requested item.. and then you can skip the query and just do



act


template.print(current.variables.ob_fullname);


template.print(current.variables.ob_username);



actually you shouldn't need a script for this at all... if the variables are on the requested item you can use curent.variables in the notification.... if they are on request you can use current.request.varible_name


View solution in original post

6 REPLIES 6

sorry i missed that looks good..



try adding



template.print('ticket number is ' );


template.print(gr.number);



and see if you get the request number on the field..



also are these variables on the REQUEST or on the requested item.. unless you have modified the variables they should be on requested item.. and then you can skip the query and just do



act


template.print(current.variables.ob_fullname);


template.print(current.variables.ob_username);



actually you shouldn't need a script for this at all... if the variables are on the requested item you can use curent.variables in the notification.... if they are on request you can use current.request.varible_name


Talk about using a hammer to kill a fly. Thanks for the suggestion. I think I completely forgot about the current option when it's all on the same table.