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

randrews
Tera Guru

1) what table is your notification script running on?


2) can i assum ob_fullname and ob_username are text fields on the catalog item?


1) I believe it's running on the same table but there's no table option for email scripts.


2) They are both string fields that are filled.


sorry i phrased my q badly.. what table is the notification that runs the script running off of ... is it requested items or approvals.. or something else?


It's running on the requested item table per the original post.