How can i trigger notification for 14th day and 30th day from the time of survey creation

NAIDILE S
Tera Contributor

Hi,
I have a survey which last for 42 days and in that i want to trigger notification twice i.e. 14 day and 30th day.
how can i achieve this ?

i tried with event is fired and SJ its not working.

"Script-

function attestationReminder1() {
    var grAttestReminder = new GlideRecord("asmt_assessment_instance");
 gs.info("NAIDILS Processing grAttestReminder" + grAttestReminder);
    // Proper encoded query:
    // - state IN ready,wip
    // - sys_updated_on less than 14 days ago (RELATIVELT@dayofweek@ago@14 means within last 14 days)
    // - sn_grc_item.attestation equals attestationSysId
    var encodedQuery = 'stateINready,wip^sys_updated_onRELATIVELT@dayofweek@ago@14^sn_grc_item.attestation=' + attestationSysId;

    grAttestReminder.addEncodedQuery(encodedQuery);
    grAttestReminder.query();

    while (grAttestReminder.next()) {
        gs.info("NAIDILS Processing assessment instance: " + grAttestReminder.number);

        // Send event, passing the record as parameter
        gs.eventQueue('sn_grc.attest.sendreminder', grAttestReminder, grAttestReminder.sn_grc_item.owner, '');

        gs.info('NAIDILS Owner: ' + grAttestReminder.sn_grc_item.owner);
        gs.info('NAIDILS Assessment Instance Number: ' + grAttestReminder.number);
    }
}

attestationReminder1()

thanks,
Naidile 

 

1 ACCEPTED SOLUTION

@NAIDILE S 

This is how you can do the logic

1) run scheduled job daily and check which surveys are yet to be completed, don't give past days encoded query

2) iterate those records 1 by 1

3) compare today's date and the survey creation date

a) if it' 14 days difference then send email with some content

b) if it' 30 days difference then send email with some other content

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

19 REPLIES 19

@NAIDILE S 

what script did you use?

you can tweak it and check difference between today and created date of survey is 14 or 30 then send email

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 
I used scheduled Script for 14 days and 30 days separate with different email notification for 2 and it run daily. 

I also tried to flow designer.

NAIDILES_0-1752989844990.png

Here, its i have added wait for condition , so that first it will check for 14days and in 2nd wait for 30 days.

Is this approach correct or anywhere im goin wrong. i want to check this on daily basis as well. 
Kindly correct me .

thanks 

 

Its triggering for both notification even when i consider created past 14days ,
Idly it should trigger for 14 days alone.
Even with 30 days its happening the same.

@NAIDILE S 

Please use scheduled job as using flow will lead to performance issue as flow will wait for those many days and if lot of surveys are there there will be more flow context waiting for those many days taking up system resources.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 
okay okay got it, thanks
Now if at all i need to use 2 different days to trigger , how can i do it.
Its triggering for both notification even when i consider created past 14days ,
Idly it should trigger for 14 days alone.
Even with 30 days its happening the same.

Currently how its behaving is  its triggering for both 14th and 30th day together in SJ