Need to send a notification 15 days before end date.

Community Alums
Not applicable

Resource Plan:

My requirement is to notify project managers on 15th day before end date that the resource plan will expire.

I created a workflow and that works nice with the Timer & Event activity.

find_real_file.png

Workflow condition:

This workflow is triggered when meeting this condition.

find_real_file.png

When new Resource Plan is created, the custom field "Trigger Expiry Notification" is checked and then the workflow is triggered. This logic works on all new Resource Plans. But, on existing Resource Plans, when I manually check the custom field "Trigger Expiry Notification", it triggers workflow only on some Resource Plans while missing many.

What is the best way to trigger workflow on existing Resource Plans? or handle this existing Resource Plans in different way? I want to send the notification 15th day before the "End date".

 

1 ACCEPTED SOLUTION

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to run fix script to start workflow on existing resource plans.

Run below fix script to start workflow on existing records

Instead of current object, you can query requested item object and then run this script

 

var w = new Workflow();


var context = w.startFlow(<sys_id of the workflow goes here>, current, current.operation());

 

Regards,

Sachin

View solution in original post

6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to run fix script to start workflow on existing resource plans.

Run below fix script to start workflow on existing records

Instead of current object, you can query requested item object and then run this script

 

var w = new Workflow();


var context = w.startFlow(<sys_id of the workflow goes here>, current, current.operation());

 

Regards,

Sachin

Community Alums
Not applicable

I tried this, and got an error

Unable to find workflow version for 11e044e41b795410d5d84002dd4bcb66 (user=b4e2fc9737638e40473ca9c2b3990e67)

 

var rp = new GlideRecord("resource_plan");
rp.addQuery("task.sys_class_name", "pm_project");
rp.addEncodedQuery("state=3^ORstate=2^ORstate=11");
rp.addQuery("sys_created_on", "<", gs.dateGenerate('2020-06-30','00:00:00'));
rp.query();
while(rp.next()){
    count++;
	gs.print(rp.number);
	var w = new Workflow();
	var context = w.startFlow("11e044e41b795410d5d84002dd4bcb66", rp, rp.operation());
}

Try it like this

var context = w.startFlow("11e044e41b795410d5d84002dd4bcb66", current, current.operation()

or 

var context = w.startFlow("11e044e41b795410d5d84002dd4bcb66", current, rp.operation()

 

Community Alums
Not applicable

It worked. I had to take the sys_id from wf_workflow table.

var rp = new GlideRecord("resource_plan");
rp.addQuery("task.sys_class_name", "pm_project");
rp.addEncodedQuery("state=3^ORstate=2^ORstate=11");
rp.addQuery("sys_created_on", "<", gs.dateGenerate('2020-06-30','00:00:00'));
rp.query();
while(rp.next()){
    	var w = new Workflow();
	var context = w.startFlow("5e8706e8db29541079e4dd0968961904", rp, rp.operation());
}

Thank you so much.