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 

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

@Ankur Bawiskar 
Then i should have some flag on the table rtg , correct me if im wrong

@NAIDILE S 

Not required.

You can always compare today's date and the creation date.

If on 14th day it's still in progress, send reminder

If again on 30th day it's in progress, send reminder again.

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

@Ankur Bawiskar 
thanks , ill try this approach 

@NAIDILE S 

I believe I have answered your original and subsequent question.

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