Set SNC to inactive if past end date

char01
Tera Contributor

How can I automatically set the SNC Access Control to inactive, if past end date 

 

For example. I give a user a SNC access record today 7am and set the end date to tomorrow, I need for it be set to inactive when it reaches the end date. Typically midnight of the end date

1 REPLY 1

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @char01 ,

 

You can achieve this using "gs.eventQueueScheduled" methods are part of the GlideSystem server-side API.

 

1. create a new event. system > Event Registry

2. Create business rule on SNC access cotrol table. and using the gs.eventQueueScheduled schedule the created event.

3. You need to schedule this event on the end date of SNC access cotrol record. So it will run when the end date reaches.

4. Create a script action, select the create event in event field. and write a script to update the SNC Access Control record to active false.

 

Example business rule script:

(function executeRule(current, previous /*null when async*/ ) {

    var endDate = current.end_date;   // please confirm the end_date field on your side as well

gs.eventQueueScheduled('event_name', current, gs.getUserName(), gs.getUserID(), endDate);    

})(current, previous);

 

5.This Business rule will schedule the event to run on exact end date. and then navigate to event > script action.

6. Create new script action for your event and the update to record to active false.

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh