UI Action to show pop up with values of a table

Alon Grod
Tera Expert

I have the field u_jira_project on the incident table of type Reference to u_jira_project table. I need to create a form button called 'Create Jira'. When the user click on this button, he needs to see a pop up with all the projects from u_jira_project table divded into two columns: u_project_name, u_project key. After the user chose a project, the value of the project that he chose need to be populated inside u_jira_project field on the incident table. How can I achieve that?

3 ACCEPTED SOLUTIONS

@Alon Grod 

 

Their is one more error: make it name,key

 

var $j = jQuery.noConflict();
var ga = new GlideAjax('ShowJiraProject');
ga.addParam('sysparm_name', 'getProjects');
ga.getXML(parseResponse);

function parseResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var str = "<div><table class='table' id='tableData'><tr><th>Name</th><th>Key</th></tr>";
answer = JSON.parse(answer);
for (var i = 0; i < answer.length; i++) {
str = str + '<tr id="tableRow"><td>' + answer[i].name +'</td><td>' + answer[i].key + '</td></tr>';
}
$j('#iframee').append(str);
}

  

View solution in original post

@Alon Grod,

 

There are a lot many tasks in this, will try to help you as I get time daily!

I am also stuck somewhere that has to be completed before this week ends!

 

I hope you understand 🙂

View solution in original post

Mathieu Lepoutr
Mega Guru

Hi

You can achieve this functionality by creating an ui-action on the incident table, which opens a dialog window with a list of projects from the u_jira_project table. Once the user selects a project, a script can set the value of the u_jira_project field on the incident table to the selected project's sys_id.


Please have a look at Exalate integration software. It enables you to synchronize data between the two systems, including incidents and projects, automating the transfer and ensuring they remain in sync. 

View solution in original post

33 REPLIES 33

@Alon Grod ,

 

Have you updated the UI page name too, name of the UI page and in the UI action should be same?

Please follow the exact step, it will not through any error because I have tried this in my PDI 

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

 

my ui page name is create_jira_form and i change it instead of button. Please help me to solve this error @Prince Arora 

@Alon Grod 

 

made the name of the UI page as "button" only, or please share your all scripts step by step ,let me configure it in my PDI 

 

@Prince Arora I change the name of the ui page to button and still getting the prob.


UI Action Script:

var gm = new GlideModal("button", false, 'modal-sm');
gm.setTitle("Jira Projects:");
gm.setWidth(550);
gm.render()

 

UI Page Scripts:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="iframee"></div>
</j:jelly>
var $j = jQuery.noConflict();
var ga = new GlideAjax('ShowJiraProject');
ga.addParam('sysparm_name', 'getProjects');
ga.getXML(parseResponse);

function parseResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var str = "<div><table class='table' id='tableData'><tr><th>Name</th><th>Key</th></tr>";
answer = JSON.parse(answer);
for (var i = 0; i < answer.length; i++) {
str = str + '<tr id="tableRow"><td>' + answer[i].u_jira_name +'</td><td>' + answer[i].u_jira_key + '</td></tr>';
}
$j('#iframee').append(str);
}


Script Include:

 getProjetcs: function() {
var gr = new GlideRecord("u_jira_project");
gr.query();
var arr = [];
while (gr.next()) {
var json = {
"name": gr.u_jira_name+"",
"key": gr.u_jira_key+""
};
arr.push(json);
}
return JSON.stringify(arr);

},


 

@Prince Arora inside u_jira_project i have two fields: u_project_name and u_project_key. Im trying to show all projects without conditions.