- 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-23-2023 07:19 PM
Thank you very much @Ankur Bawiskar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â01-19-2023 06:04 AM
@Ankur Bawiskar Sorry I forgot the script, please help and guidance.
============================================================
Script Include
var getUserJira = Class.create();
getUserJira.prototype = Object.extendsObject(AbstractAjaxProcessor, {
GetUserJiraUppk: function() {
var r = new sn_ws.RESTMessageV2('REST Jira UPPK', 'Default GET');
r.setEndpoint('http://localhost:8080/rest/api/2/user/search?username=.');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var ResponseData = JSON.parse(responseBody);
return response.getBody();
},
type: 'getUserJira'
});
==============================================================
Catalog Client Script
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 uj = answer;
alert(uj);
g_form.clearOptions('customer');
g_form.addOption('customer', uj, uj);
}
}