- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 03:36 AM
Hi all,
I've checked numerous articles but cannot find a solution that would suit me.
What I am trying to do is to create a UI action that would give me a pop-up window for user selection and then take the value for use in server side in order to determine which view should be used and this is what I came up with until now but I cannot get the value in the server script at any way:
UI ACTION:
var companyName;
var dialog;
function openWindow(){
dialog = new GlideDialogWindow("test_pop");
dialog.render();
}
function getCompany(company){
g_list.setGroupBy(company);
dialog.destroy();
g_list.action("SOME ACTION ID", "sysverb_new");
}
if (typeof window == 'undefined') {
run();
}
function run(){
gs.addInfoMessage(current.company);
if (gs.hasRole('itil,sn_incident_write')) {
var view = "";
if(companyName === "SOME COMPANY ID"){
view = "SOME VIEW NAME";
} else {
view = "SOME VIEW NAME";
}
var test = 'incident.do?sysparm_view=ofsted&sysparm_view_forced=true';//sysparm_view= would be a variable
action.setRedirectURL(test);
}
}
UI PAGE XML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<body>
Company Name: <g:ui_reference name="company" id="company" table="core_company" completer="AJAXTableCompleter" query="active=true"/>
<g:dialog_buttons_ok_cancel ok="validateComments()"/>
</body>
</html>
</j:jelly>
UI PAGE CLIENT SCRIPT
function getCompanyValue() {
//Gets called if the 'OK' dialog button is clicked
//Make sure dialog comments are not empty
var name = gel("company").value;
name = trim(name);
if (name == "") {
//If comments are empty stop submission
alert("Please provide company to proceed.");
return false;
} else {
//If comments are not empty do this...
getCompany(name);
}
}
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 05:31 AM
Its better to write your server code in UI page processing script. Instead of UI action.
gs.addInfoMessage(company);
if (gs.hasRole('itil,sn_incident_write')) {
var view = "";
if(company === "SOME COMPANY ID"){
view = "SOME VIEW NAME";
} else {
view = "SOME VIEW NAME";
}
var test = 'incident.do?sysparm_view_forced=true&sysparm_view='+view+"&sys_id"+sys_id;//sysparm_view= would be a variable
response.setRedirectURL(test);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 05:31 AM
Its better to write your server code in UI page processing script. Instead of UI action.
gs.addInfoMessage(company);
if (gs.hasRole('itil,sn_incident_write')) {
var view = "";
if(company === "SOME COMPANY ID"){
view = "SOME VIEW NAME";
} else {
view = "SOME VIEW NAME";
}
var test = 'incident.do?sysparm_view_forced=true&sysparm_view='+view+"&sys_id"+sys_id;//sysparm_view= would be a variable
response.setRedirectURL(test);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 06:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 06:36 AM
I used response.sendRedirect instead and it worked. thank you!