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

Inbound action Script

amirservice
Mega Explorer

I have an issue in CSM.

I have an inbound action on the Case table. Through this inbound action, I want to perform this on task of a case:

Update the Rejection Details

Update the Tracking Number

Change the State to Canceled

Update Assigned To based on whoever replies via the inbound action on a Case Task

I’ve also created a Business Rule to synchronize task details back to the case. just tell me script to update the details of task from inbound action

2 REPLIES 2

vaishali231
Tera Guru

hey @amirservice 

 

You can achieve this requirement using an Inbound Email Action on the Case table and update the related Case Task using a GlideRecord query inside the script section.

Since the inbound action runs on the Case (current), you need to explicitly query the associated Case Task and update the required fields.

Script:

(function runAction(current, event, email, logger, classifier) {

// Query active Case Task related to this Case
var taskGR = new GlideRecord('sn_customerservice_task'); 
taskGR.addQuery('parent', current.sys_id);
taskGR.addQuery('active', true);
taskGR.query();

if (taskGR.next()) {

// Update Rejection Details
taskGR.u_rejection_details = email.body_text;

// Update Tracking Number (example: from email subject)
taskGR.u_tracking_number = email.subject;

// Change State to Canceled (verify correct state value in your instance)
taskGR.state = 7;

// Update Assigned To based on email sender
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', email.from);
userGR.query();

if (userGR.next()) {
taskGR.assigned_to = userGR.sys_id;
}

taskGR.update();
}

})(current, event, email, logger, classifier);


*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

vaishali231
Tera Guru

hey @amirservice 

 

Hope you are doing well.

Did my previous reply answer your question?

If it was helpful, please mark it as correct ✓ and close the thread 🔒. This will help other readers find the solution more easily.

Regards,
Vaishali Singh