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

Community Alums
Not applicable

There is requirement to send a generic survey reminder notification to the end-user if the last notification/reminder notification sent was 30 days ago and the end-user still has an open survey assigned to him.

The first notification will be sent out when insert record happens on asmt_assessment_instance table.

e.g. asmt_assessment_instance record created date is X. First Notification sent date is also X. Next reminder notification to be sent = X+30 days, only if assigned_to!= empty && state=wip or Ready to take.

I am trying to use the solution provided by Tim Deniston in this post.

However, I am not sure what modifications should I make to it. Could anyone please help?

1 ACCEPTED SOLUTION

amaradiswamy
Kilo Sage

Hi,

There are different ways to accomplish this

1. Create a scheduled job which runs daily at a particular time to check the assessments which are still in in progress state for more than x number of days and then fire an event which will trigger a notification

   - create an event by navigating to system policy --> events --> registry

  - Create a scheduled job and write something like below.

    

var asint = new GlideRecord('asmt_assessment_instance');
asint.addEncodedQuery('stateINready,wip^userISNOTEMPTY');
asint.query();
while(asint.next())
	{
		var gdt = new GlideDateTime(asint.sys_created_on);
        gdt.addDaysLocalTime(30);//add 30 days
		
		var dateaft30 = gdt.getLocalDate();
		dateaft30 = dateaft30.toString();
		var gdt2 = new GlideDateTime();
		var todaydate = gdt2.getLocalDate();
		todaydate = todaydate.toString();
		if(dateaft30 == todaydate)
			{
				gs.eventQueue('event_name_created_above_step',asint,asint.user,'');
			}
		

	}

- notification on assessment instance table and when to run is event is fired and select the event created in above step. in whom to receive, set event.parm1 check box to true.

 

2. you can create a workflow on asmt_assessment_instance table.

 - first activity should a timer activity with duration as 30 days

 - after the above drag and drop "IF" workflow activity and select something like below in conditions.

     state --is one of --workin progress, ready

- for yes transition, drag and drop "Event" workflow activity and select event created for this and in event.parm1 write like return current.user

- for no transition connect to end if you want to send only one reminder notification, if you want to wait for another 30 days and send another reminder email again then you can connect No transition to timer activity 

 

View solution in original post

4 REPLIES 4

amaradiswamy
Kilo Sage

Hi,

There are different ways to accomplish this

1. Create a scheduled job which runs daily at a particular time to check the assessments which are still in in progress state for more than x number of days and then fire an event which will trigger a notification

   - create an event by navigating to system policy --> events --> registry

  - Create a scheduled job and write something like below.

    

var asint = new GlideRecord('asmt_assessment_instance');
asint.addEncodedQuery('stateINready,wip^userISNOTEMPTY');
asint.query();
while(asint.next())
	{
		var gdt = new GlideDateTime(asint.sys_created_on);
        gdt.addDaysLocalTime(30);//add 30 days
		
		var dateaft30 = gdt.getLocalDate();
		dateaft30 = dateaft30.toString();
		var gdt2 = new GlideDateTime();
		var todaydate = gdt2.getLocalDate();
		todaydate = todaydate.toString();
		if(dateaft30 == todaydate)
			{
				gs.eventQueue('event_name_created_above_step',asint,asint.user,'');
			}
		

	}

- notification on assessment instance table and when to run is event is fired and select the event created in above step. in whom to receive, set event.parm1 check box to true.

 

2. you can create a workflow on asmt_assessment_instance table.

 - first activity should a timer activity with duration as 30 days

 - after the above drag and drop "IF" workflow activity and select something like below in conditions.

     state --is one of --workin progress, ready

- for yes transition, drag and drop "Event" workflow activity and select event created for this and in event.parm1 write like return current.user

- for no transition connect to end if you want to send only one reminder notification, if you want to wait for another 30 days and send another reminder email again then you can connect No transition to timer activity 

 

Hello!

I instituted option 1 and works really well, perhaps a little too well. We found that it gets sent even if the Survey is completed or not started.

Do I need alter the beginning of the code in some way?

asint.addEncodedQuery('stateINready,wip^userISNOTEMPTY');

Hello 

is there any way to send the reminder at an interval of three days if the state is WIP or ready to take?

 

You can just amend the script above and change the references from 30 to 3, i.e. 

gdt.addDaysLocalTime(3);//add 3 days