- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2025 12:07 AM
Hello,
I have a script include and a UI action Script
(function fetchAndPopulateProjects() {
var ga = new GlideAjax('JiraProjectFetcher');
ga.addParam('sysparm_name', 'getJiraProjects');
ga.getXMLAnswer(function(response) {
var projects = JSON.parse(response);
if (projects.length === 0) {
alert('No Jira projects returned.');
return;
}
g_form.clearOptions('u_project_name');
g_form.addOption('u_project_name', '', '-- Select a project --');
for (var i = 0; i < projects.length; i++) {
g_form.addOption('u_project_name', projects[i].value, projects[i].label);
}
alert("Jira project options loaded.");
});
})();
The issue is when i click in the button the button is not clicked / unclickable.
I need to test the script that it is fetching value from the script include and populating in the field
Thanks, and Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:44 AM
share your UI action configuration screenshot
since you are using Client Side UI action make sure this
1) client checkbox - true
2) Onclick function - fetchAndPopulateProjects()
3) Script field as this
function fetchAndPopulateProjects() {
var ga = new GlideAjax('JiraProjectFetcher');
ga.addParam('sysparm_name', 'getJiraProjects');
ga.getXMLAnswer(function(response) {
var projects = JSON.parse(response);
if (projects.length === 0) {
alert('No Jira projects returned.');
return;
}
g_form.clearOptions('u_project_name');
g_form.addOption('u_project_name', '', '-- Select a project --');
for (var i = 0; i < projects.length; i++) {
g_form.addOption('u_project_name', projects[i].value, projects[i].label);
}
alert("Jira project options loaded.");
});
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:30 AM
In your UI Action, make sure the Client checkbox is checked and enter fetchAndPopulateProjects() in the onClick field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:44 AM
share your UI action configuration screenshot
since you are using Client Side UI action make sure this
1) client checkbox - true
2) Onclick function - fetchAndPopulateProjects()
3) Script field as this
function fetchAndPopulateProjects() {
var ga = new GlideAjax('JiraProjectFetcher');
ga.addParam('sysparm_name', 'getJiraProjects');
ga.getXMLAnswer(function(response) {
var projects = JSON.parse(response);
if (projects.length === 0) {
alert('No Jira projects returned.');
return;
}
g_form.clearOptions('u_project_name');
g_form.addOption('u_project_name', '', '-- Select a project --');
for (var i = 0; i < projects.length; i++) {
g_form.addOption('u_project_name', projects[i].value, projects[i].label);
}
alert("Jira project options loaded.");
});
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 09:58 PM
Thank you so much it always work
@Ankur Bawiskar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:49 AM
Hi @SuyashJ41731830 ,Based on what you've described, the issue is likely related to how the client script is structured and triggered. Since you're calling fetchAndPopulateProjects() immediately inside the UI Action script, and UI Actions don't directly allow async actions like getXMLAnswer() to finish properly when inline JavaScript is executed, the button can behave weirdly (including appearing unclickable or doing nothing).
Wrap the GlideAjax logic inside a named function and call it through the onclick field of the UI action instead of embedding the whole script inline.
try with this code -script include
var JiraProjectFetcher = Class.create();
JiraProjectFetcher.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getJiraProjects: function() {
var projects = [
{ name: 'Project A', id: 'P-001', u_id: 'UID-001' },
{ name: 'Project B', id: 'P-002', u_id: 'UID-002' },
{ name: 'Project C', id: 'P-003', u_id: 'UID-003' }
];
var result = [];
for (var i = 0; i < projects.length; i++) {
result.push({
label: projects[i].name,
value: projects[i].id
});
}
return JSON.stringify(result);
}
});
client script
function fetchAndPopulateProjects() {
var ga = new GlideAjax('JiraProjectFetcher');
ga.addParam('sysparm_name', 'getJiraProjects');
ga.getXMLAnswer(function(response) {
var projects = JSON.parse(response);
if (projects.length === 0) {
alert('No Jira projects returned.');
return;
}
g_form.clearOptions('u_project_name');
g_form.addOption('u_project_name', '', '-- Select a project --');
for (var i = 0; i < projects.length; i++) {
g_form.addOption('u_project_name', projects[i].value, projects[i].label);
}
alert("Jira project options loaded.");
});
}