Ui Action button is not working in UI native
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Team,
I have one Reject button created in UI action, this button is working in workspace but same button is not working in native View.. It is throwing undefined onclick.. Shared the screenshot below. Please help me out..
Thanks,
Manju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @manju12 ,
The error openCommentForControl is not defined clearly indicates that the function used in your UI Action onclick is not available in Native UI, even though it works in Workspace.
Root Cause
The function is likely defined in Workspace (UI Builder / Client Script)
Native UI does not load those scripts
Hence, onclick fails with undefined function
Step-by-Step Solution
Step 1: Check UI Action Configuration
Go to System Definition → UI Actions
Open your Reject button
Verify:
Client = true
Onclick:
openCommentForControl();Step 2: Create Client Script for Native UI
Go to System Definition → Client Scripts
Click New
Configure:
Table: same as your UI Action table
Type: onLoad
Step 3: Define the Function
Add this script:
var comment = prompt("Enter rejection comments:");
if (comment) {
g_form.setValue('comments', comment);
}
}
This makes the function available in Native UI
Step 4: Test the Button
Open the record in Native UI
Click Reject
It should now:
Prompt for comment
Populate the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hello @manju12 ,
ensure right client-side function scope.
because most times it’s due to missing client-side function scope also the workspace loads modules differently than UI16.
Also ensure Client = true and scripted in this way :
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @manju12,
This issue is happening because the function openCustomControl() is not available in the Native UI.
In Workspace, things work a bit differently; scripts can come from UI Builder or other sources, so even if the function isn’t in the UI Action itself, it may still work. But in the Native view, it strictly looks for that function inside the UI Action (or a loaded UI Script).
So when you click the button in Native UI, it tries to run openCustomControl() and fails, giving the “not defined” error.
To fix this, just make sure:
The UI Action is marked as Client = true
The same function (openCustomControl) is properly defined in the Script section of the UI Action, or available via a global UI Script
In short, I guess the function exists for Workspace but not for Native UI; that's why it breaks there.
Refer to these documents; this may help you:
https://www.servicenow.com/docs/r/application-development/ui-builder/using-ui-builder.html
If you find my answer useful, please mark it as helpful and correct. 😊
Regards,
Soham Tipnis
ServiceNow Developer || Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10
