- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 04:27 AM
Hi,
In short: I'm trying to update selected list items using a UI Action + UI Page, but the processing script doesn't run properly.
When standing in the list view and having one or more items selected, I want to open a popup that asks the user for a company when a UI Action is clicked. That company should then be added or removed depending on the UI Action (Add Company or Remove Company).
I have the popup showing but when clicking OK, the Processing Script is not being run properly. What am I missing? Shouldn't I have access to the variables from the HTML?
Tried using a <g:ui_form> because it said on the wiki that it should be able to use the processing script, but... the only thing it did was to redirect to a full-size version of the UI Page.
Thanks in advance for any ideas.
BR /Miriam
UI Action "Add Company"
Script
function getCompany() {
var gDialog = new GlideDialogWindow("dialog_get_company");
gDialog.setTitle('Add Company');
gDialog.setWidth("300");
gDialog.render();
}
UI Page "dialog_get_company"
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<g:evaluate>
var currentTable = RP.getWindowProperties().get('table_name') || '';
var sysIdList = RP.getWindowProperties().get('sys_id_list') || '';
</g:evaluate>
<input type="hidden" name="current_table" value="$[currentTable]" />
<input type="hidden" name="sys_id_list" value="$[sysIdList]" />
<table width="100%">
<tr>
<td>
<g:ui_reference name="company_name" table="core_company"/>
</td>
</tr>
<tr id="dialog_buttons">
<td>
<br></br>
<g:dialog_buttons_ok_cancel ok="return checkValue()" ok_id="ok_button" />
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function checkValue(){
var company = gel("company_name");
if(company.value == ""){
return false;
}
GlideDialogWindow.get().destroy();
return true;
}
Processing Script:
addCompany();
function addCompany() {
var choice = new GlideRecord(current_table);
if (sys_id_list) {
var selectedRecords = sys_id_list.split(',');
choice.addQuery('sys_id', selectedRecords);
}
choice.query();
while (choice.next()) {
gs.addInfoMessage(choice.value);
add(choice);
}
refresh();
}
function refresh() {
var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);
}
function add(choice){
// var company = usr.u_org_company.toString();
var list = choice.u_suppliers;
//If the list is empty
if (list == '') {
list = company;
}
//Else - the list is not empty.
//Does it include my company?
else if(list.indexOf(company) < 0) {
list = list + ',' + company;
}
choice.u_suppliers = list;
choice.update();
//action.setRedirectURL(current);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 07:03 AM
Yay!
Found the code to properly send over the correct info from the UI Action:
This should be in the UI Action:
gDialog.setPreference('current_table', g_list.getTableName());
gDialog.setPreference('sys_id_list', g_list.getChecked());
😆

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 04:54 AM
Put gs.log and see whether it goes in processing script of not......mean while i am checking your script too
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 05:23 AM
OK so what I can see, it goes into the Processing Script but fails to do anything because it can't read any variables. i can put a log statement first or the refresh function, and that works fine. but anything using variables from either HTML or Client Script is crashing it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 06:30 AM
I tried hard coding the table name (sys_choice) that was not found as a variable...
This results in a never ending transaction complaining about /ui_page_process.do
and an error message "Invalid 'Table' selected on the Choice record. The 'Remote Application' table is in application 'Scoped App Client', but the current application is 'Global'. The 'Table' field can only select 'Scoped App Client' tables with read and alter access enabled."
But.... some choices now have the company I chose...
Haha!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 07:03 AM
Yay!
Found the code to properly send over the correct info from the UI Action:
This should be in the UI Action:
gDialog.setPreference('current_table', g_list.getTableName());
gDialog.setPreference('sys_id_list', g_list.getChecked());
😆