
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2020 01:48 PM
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.
Workflow condition:
This workflow is triggered when meeting this condition.
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".
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2020 01:58 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2020 01:58 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2020 03:09 PM
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());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2020 03:29 PM
Try it like this
var context = w.startFlow("11e044e41b795410d5d84002dd4bcb66", current, current.operation()
or
var context = w.startFlow("11e044e41b795410d5d84002dd4bcb66", current, rp.operation()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2020 03:38 PM
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.