UI Action not triggering client script on Change Request form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Experts,
I am working on a requirement in ServiceNow to add a UI Action on the Change Request form that triggers a Copilot AI agent (Change Quality Advisor).
Requirement:
Add a button on the Change Request form which generates a prompt using the current change request details and opens a Microsoft Copilot AI agent in a new browser tab. The prompt should be copied to the clipboard so the user can paste it directly into Copilot for review.
Configuration Done:
• Created UI Action on table: change_request
• UI Action type: Form button
• Client checkbox: Enabled
• Onclick: openCopilotAgent();
Script used in UI Action:
function openCopilotAgent() {
var agentUrl = "https://copilot.microsoft.com/";
var number = g_form.getValue('number');
var sysId = g_form.getUniqueValue();
var link = window.location.href;
var prompt =
"You are Change Quality Advisor.\n" +
"Assess this ServiceNow Change Request and return:\n" +
"1) Quality score (0-10)\n" +
"2) Missing information\n" +
"3) Risk rating\n" +
"4) Suggested improvements\n\n" +
"Record:\n" +
"Number: " + number + "\n" +
"sys_id: " + sysId + "\n" +
"Link: " + link;
navigator.clipboard.writeText(prompt);
window.open(agentUrl, "_blank");
}
Issue:
When clicking the UI Action button, nothing happens. The Copilot page is not opening and the script does not appear to execute.
Troubleshooting done:
• Verified Client checkbox is enabled
• Verified Onclick function is configured
• Tested with condition set to true
• Tested in DEV instance
Question:
Is there any additional configuration required for client-side UI Actions to trigger window.open() or clipboard functions in ServiceNow forms?
Any guidance or suggestions would be appreciated.
Please help me here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello @nameisnani ,
Can you please share screenshot . Please ensure isolate script checkbox is unchecked .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @nameisnani ,
Why are your passing sys_id to the prompt, it is very internal .
Somehow in Zurich PDI , window.open() not working ,it might be blocked by modern browser security policies.
When it is replaced by g_navigation.openPopup , it is working .
Try it. On top of it fine tune the code as per your requirement.
function openCopilotAgent() {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday

