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

Ankur Bawiskar
Tera Patron
Tera Patron

@NAIDILE S 

so you want to send reminder email after 14th day and 30th day after survey was 1st triggered?

check these links

How to send the reminder notification survey to the users who have not taken the survey.

How to set reminder email post 3 days of survey email triggered?

Send survey reminder if a survey notification went 30 days ago and user has open surveys

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 
Yep thats correct.
thanks for the links , ill go through it 

@NAIDILE S 

Glad to help.

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

Hi @Ankur Bawiskar 
How can i add 2 different triggers in my case ( 14 days and 30 days) , i could not get this part.