Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Event Trigger

smithro
Tera Guru

Hi All,

 

Using the contract management module, i'd like to trigger an event 30 days before the end date of the contract to fire a notification.  Which condition operator would work best for this?

 

Thanks in advance.

1 REPLY 1

Runjay Patel
Giga Sage

Hi @smithro ,

 

Best way you can do is writing a scheduled job to check everyday.

 

 

var thirtyDays = new GlideDateTime();
    thirtyDays.addDays(30); // Adds 30 days to the current date

    var contractGR = new GlideRecord('ast_contract'); // Contract table
    contractGR.addQuery('end_date', thirtyDays); // Query contracts with end date 30 days from now
    contractGR.query();
    
    while (contractGR.next()) {
        // Trigger the event when condition is met
        gs.eventQueue('contract.expiry.notification', contractGR, contractGR.sys_id, contractGR.end_date);
    }

 

 

Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.

Regards,

Runjay Patel