We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

notification

sriramsin
Tera Contributor

Hi Guys 
I have created a record producer for my custom table, for that i have created a notification with a button like accept , if the any user of the assignment group clicks accept , it change assigned to field with the logged in user. 
For that i have tried with email script + UI action , But I don't know why it won't work . 

Help me learn about it .

Thanks in advance 
Sri .

 

8 REPLIES 8

@sriramsin 

share what you created and what's not working.

what debugging did you do?

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

yashkamde
Kilo Sage

Hello @sriramsin ,

This can be done using Scripted Rest API + Button URI (in email) because UI Action will not be triggered from the Email..

 

First of all In Email add Button :

<a href="${URI_REF}api/x_assignment_api/accept?sys_id=${sys_id}" > Accept </a>


Scripted Rest API : 

(function process(request, response) {
    var recordId = request.queryParams.sys_id;
    var tableName = "<table_name>";

    var gr = new GlideRecord(tableName);
    if (gr.get(recordId)) {
        gr.assigned_to = gs.getUserID();
        gr.update();

        response.setStatus(200);
        response.setBody({
            message: "Record accepted",
        });
    } else {
        response.setStatus(404);
        response.setBody({error: "Record not found"});
    }
})(request, response);

 

 

If my response helped mark as helpful and accept the solution.

 

Aditya_hublikar
Mega Sage

Hello @sriramsin ,

 

Earlier I work on same kind of scenario in which by  email notification button i need to update ritm record .

 

You just need to create one scripted rest api through which you can able to update that record .

You need to pass sys_id of that record with its corresponding table name for scripted rest api parameter.

 

You can refer this  : https://www.servicenow.com/community/now-assist-for-creator-forum/email-notification-on-click-of-but...

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya

Hello @sriramsin ,

 

I hope you are doing well. Does my response helps you ?

 

If my response helps you then mark it as helpful and accept as solution.

Regards,
Aditya