Flow Designer is Not Triggering with state change with custom button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have a flow designer which is not triggering
It triggers when I manually change the state in the Table List, it will trigger.
However I have also created a button which basically changes the state to "pending approval"
Which only changes the state but does not trigger the flow.
This is the code, which changes the state, but not triggering the flow.
function onClick(g_form) {
// Validate required fields
if (!g_form.getValue('target_date')) {
g_form.addErrorMessage('Target date is required');
return false;
}
if (!g_form.getValue('reason_and_areas_of_focus')) {
g_form.addErrorMessage('Reason is required');
return false;
}
// Set assignment group BEFORE state change
g_form.setValue('assignment_group', '43a3940a4715b250e12bcea5936d437c');
// Set state FIRST
g_form.setValue('state', 'pending_approval');
// Force save - use save() instead of submit()
g_form.save();
// Show message after save starts
g_form.addInfoMessage('Request submitted for approval!');
}
Kindly assist
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @THDR,
Please test this UI Action on a new record. You've set the Flow trigger to "Run: Once"—have you previously executed this flow for this record?
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
make sure you run Flow as System User
are you sure the record is getting saved using workspace client script and state is getting updated in database?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
