- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-19-2023 03:03 AM
hello everyone, I am just learning ServiceNow, here I am trying to integrate Jira with ServiceNow using the API, but I have a problem in the script include here I am confused (do not understand) how to make the script include can make data from the array that comes from the API into a sting so that it can be called in the catalog client script, please help to explain whether my script call is wrong because the portal has read the data, but the results are still not correct, what should appear in the customer column is only the name, for example, topan. kamil.
thank you for your help, all your explanations will be very helpful for me and I will be very happy and hopefully if there are people who find the same case as me, they can be helped by this question.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-22-2023 08:04 PM
sample script will be like this
function onLoad() {
// var arruj=[];
var ga = new GlideAjax('getUserJira');
ga.addParam('sysparm_name', "GetUserJiraUppk");
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var parsedData = JSON.parse(answer);
var nameArr = [];
for(var i=0;i<parsedData.length;i++)
nameArr.push(parsedData[i].name.toString());
g_form.clearOptions('customer');
for(var j in nameArr)
g_form.addOption('customer', nameArr[j], nameArr[j]);
}
}
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
â01-19-2023 09:00 PM
so from that json which values you want to add to drop down?
you will have to parse the json accordingly
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-20-2023 12:03 AM
@Ankur Bawiskar I want the value of displayName in the JSON to be added to the drop-down.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-20-2023 01:02 AM
are you saying you want these 2 names and want to add to drop down?
name -> kamil and topan.kamil
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-20-2023 05:34 PM
@Ankur Bawiskar Yes, is that possible, can you give an example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-22-2023 08:04 PM
sample script will be like this
function onLoad() {
// var arruj=[];
var ga = new GlideAjax('getUserJira');
ga.addParam('sysparm_name', "GetUserJiraUppk");
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var parsedData = JSON.parse(answer);
var nameArr = [];
for(var i=0;i<parsedData.length;i++)
nameArr.push(parsedData[i].name.toString());
g_form.clearOptions('customer');
for(var j in nameArr)
g_form.addOption('customer', nameArr[j], nameArr[j]);
}
}
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