To add Dynamic field values to the redirect url of the UI Action button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday - last edited Tuesday
When you click on UI Action button: "Assign Remediation" need to get field values "Sub PTASK type" ,"Cause code" and "Sub Cause code" dynamically to the redirect URL "action.setRedirectURL('problem_task.do?sys_id=-1&sysparm_query=problem_task_type=remediation');"
UI Action:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
did you print what came in query before redirecting?
also are those fields present on form view when you are redirecting to new record?
if yes then it should work fine.
💡 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hi @sureshp89882164 ,
please find the below suggestion for fix the issue -
Suggested Fixes
Ensure Fields Are Populated
- Check if u_close_code and u_root_cause are actually set on the record before the UI Action is triggered.
Make Fields Available to the Script
- If these fields are not on the form, they might not be available in the current object in client-side scripting.
- You can:
- Add them to the form layout.
- Or use a server-side GlideRecord call to fetch their values.
var gr = new GlideRecord('problem_task');
if (gr.get(current.sys_id)) {
var query = 'problem_task_type=remediation';
query += '^u_type_of_task=' + encodeURIComponent(gr.u_type_of_task);
query += '^u_close_code=' + encodeURIComponent(gr.u_close_code);
query += '^u_root_cause=' + encodeURIComponent(gr.u_root_cause);
action.setRedirectURL('problem_task.do?sys_id=-1&sysparm_query=' + query);
}Debug with Logging
- Add gs.info() or console.log() statements to verify what values are being picked up.
please mark it as correct and close the thread if this is helpful.
Thanks,
Rithika.ch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday - last edited Tuesday
HI @sureshp89882164 ,
Can you please explain where you want to display the UI action and where should it redirect? to a new problem_task form? What are the types of your fields "u_close_code" and "u_root_cause"?
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
Tuesday
Currently ui action button: Assign Remediation is available in Investigation task. When you click on button, it need to redirect to Remediation task. Both fields are Choice list "u_close_code" and "u_root_cause"
