How do get the field (when user update the state as pending) updated by name in notification

raj99918
Tera Contributor

Hi 

 

I have requirement like whoever changing the field called state(field is on sc_req_item table) as pending then notification should trigger with that state field upated by name in the body of the notification(on sc_req_item). How can I get this one

1 ACCEPTED SOLUTION

@raj99918 

you will have to use email script for that. I hope you know how to do that or can search in docs for the same

1) create email script -> get_user

2) then include that in email body of your notification like this and print the content

${mail_script:get_user}

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
    var gr = new GlideRecord("sys_user");
    gr.addQuery("user_name", current.sys_updated_by);
    gr.query();
    if (gr.next()) {
        template.print("State pending Updated By : " + gr.getDisplayValue());
    }

})(current, template, email, email_action, event);

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

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron

@raj99918 

you can use flow designer for this

Run as : User who initiates the session

Trigger: State Changes to Pending

Use Send Email Action and send the email to the user who triggered the flow

It's a simple one

What did you start with and what didn't work?

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

Hi @Ankur Bawiskar Thanks for the reply 

 

Already I have created the notification when state changes to pending(From sc task state to RITM state its changing to pending) it will trigger the notification but I want to pull the user name who is changing that state to pending on that particular sc task ?

 

In the body of the email I want to get the below value:

 

State pending Updated By : {User name who updated the state to pending}

@raj99918 

you can directly handle this using flow and no notification required

Flow will be on RITM table

please share what flow did you configure?

Hi @Ankur Bawiskar Thanks for the reply.

We are not using any flows for this one just sending an email when state changes to pending so :

 

In the body of the email I want to get the below value:

 

State pending Updated By : {User name who updated the state to pending}