How to trigger workflow for existing records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 02:45 AM
Hi All,
I have a requirement to trigger workflow once in a year (July 1st). The workflow needs to send an approval for all the existing records. I created a scheduled workflow that will run daily but will check the condition if Today's date is July 1st.
If yes is returned then workflow will be executed but the problem is the approval is not triggered for all the records, only for newly created record the workflow is executing.
Something is missing out here. Do let me know how to trigger this workflow for existing records.
Thanks in advance.
Regards,
Manju Shree

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 02:53 AM
Hello,
Please refer to this thread.
Please Mark Correct and Helpful if my answer helps you resolve your issue. Thanks!
Martin Ivanov
Community Rising Star 2022
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 03:03 AM
Hi,
You can use fix script to run this; But you need to be sure for which records it has to run.
The link shared by Martin will help you. It has script shared by me which you can refer and let us know your updates.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 03:20 AM
Thanks for your reply.
The below script from the other thread is working as expected
triggerWorkflow();
function triggerWorkflow(){
try{
var rec = new GlideRecord('table'); // give your table name
rec.addEncodedQuery('YOUR QUERY HERE FOR OLDER RECORDS');
rec.query();
while(rec.next()){
var wf = new Workflow();
wf.startFlow(wf.getWorkflowFromName('give the workflow name'), rec, 'update'); // give workflow name here
}
}
catch(ex){
gs.info('Exception'+ex);
}
}
I do have another question, can we trigger the workflow only from scheduled workflow? I need not want that particular workflow to work when record is inserted.
Regards,
Manju Shree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 03:36 AM
Hi,
then why to create workflow?
why not do the task in some other script?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader