Get asset variable value in a ui action on the asset table

Moedeb
Tera Guru

I want to be able to trigger an event that will sent a notification - this I can do, however getting the parm1 value correct so it sends to the correct person, not so much.

 

So on the alm_asset table I have a field that I added called u_responsible_officer (reference field on the sys_user table)

 

What I want to do is the have a UI action - form link (on an alm_asset record) that triggers an event that send the notification to the name/email address of the person in the u_responsible_officer field.

 

I have the script I need to trigger the event successfully, I'm just not sure how to add the email address to the script to dynamically get it from the u_responsible_officer field.

gs.eventQueue("update.due", current, "u_resonsible_officer.email");
action.setRedirectURL(current);
gs.addInfoMessage("Email has been triggered");

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Moedeb 

your syntax is wrong

Ensure Event parm1 contains recipient checkbox is True in your notification

I hope event, notification are on alm_asset table

gs.eventQueue("update.due", current, current.u_resonsible_officer.toString());
action.setRedirectURL(current);
gs.addInfoMessage("Email has been triggered");

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Pooja58
Kilo Sage

Hi @Moedeb ,

 

In the gs.eventQueue don't include the 3rd parameter in quotes and 4th parameter you can send empty string.

It should be as below:

gs.eventQueue("update.due", current, u_resonsible_officer.email,'');
action.setRedirectURL(current);
gs.addInfoMessage("Email has been triggered");

 

Please mark it as helpful/correct if it solves your issue.

 

Best Regards,

Pooja

Also didn't work, it tried to send the notification to the asset name

Ankur Bawiskar
Tera Patron
Tera Patron

@Moedeb 

your syntax is wrong

Ensure Event parm1 contains recipient checkbox is True in your notification

I hope event, notification are on alm_asset table

gs.eventQueue("update.due", current, current.u_resonsible_officer.toString());
action.setRedirectURL(current);
gs.addInfoMessage("Email has been triggered");

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Sorry I had spelt the variable name wrong so there was an error coming up.

 

I have fixed the spelling error now and it is still not working - when I check the event log the parm1 value is blank.

So the correct script I'm currently using is:

 

gs.eventQueue("update.due", current, current.u_responsible_officer.toString());
action.setRedirectURL(current);
gs.addInfoMessage("Email has been triggered");

 

 

I can confirm that the event, ui action and the notification are all on the alm_asset table and the parm1 checkbox is ticked on the notification