change the short description before 30minutes

marrikruthi
Tera Contributor

Change the short description of a
problem ticket 30 minutes before a time
set in a custom date/time field.
Event - After Business Rule- Script Action

2 REPLIES 2

Deepak Shaerma
Kilo Sage

Hi @marrikruthi 

Just create a Business Rule and a Script Action for this. 

1. Create a After - Insert/ Update business rule on probelm table.
Script= 

var customDateTime = new GlideDateTime(current.custom_date_field); //change custom_date_field to exact name of your custom date field
       
       var executionTime = new GlideDateTime(customDateTime);
       executionTime.addMinutes(-30);
       
       // Schedule the Script Action
       gs.eventQueueScheduled(
           'custom.update.short_description',
           current,
           current.sys_id,
           current.short_description,
           executionTime.getDisplayValue()
       );

Step 2 = Create a Script action
System Policy > Events > Script Actions.
Event Name: custom.update.short_description
Script - 

 (function runAction(current, event, eventParam1, eventParam2, gs) {
       var problemGR = new GlideRecord('problem');
       if (problemGR.get(eventParam1)) { // Load the Problem record using the sys_id
           // Change the short description
           problemGR.short_description = 'New short description set 30 minutes before the custom date/time';
           problemGR.update();
           
           // Log or add any additional logic here if necessary
           gs.info('Short description of problem ticket updated 30 minutes before custom date/time');
       }
   })(current, event, eventParam1, eventParam2, gs);

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards
Deepak Sharma 



marrikruthi
Tera Contributor

@Deepak Shaerma 
Not working can you check it once in your instance