The CreatorCon Call for Content is officially open! Get started here.

Need help mapping fields on a UI Page to form(s) - PLEASE ASSIST

Nya Valdez
Kilo Guru

Hello,

I have a requirement to create a UI Action that updates multiple release forms based on entries on a UI page. For some reason, my processing script is not working and the fields do not map. What should happen is that: 1. multiple records are selected in the My Groups Work list view, and then 2. the UI action "Validation Sign-Off" is engaged and the mandatory fields are populated and when the "Complete Sign-Off" button is clicked, the selected records are populated, the UI page closes and you are returned to the list view.  

What is happening is the UI page is populated and when I click "Complete Sign-Off" it blanks out the fields and goes to a screen that only shows the UI page without updating any records selected. Can someone PLEASE tell me what I'm doing wrong? 

The fields that need to be updated are: Validation Complete (validation_complete) and Work Notes (work_notes)

My code is below:

HTML Script:

<?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('current_table') || '';
                                           var sysIDList = RP.getWindowProperties().get('sys_id_list') || '';
                             </g:evaluate>
                             <input type="hidden" name="current_table" value="$[currentTable]" />
                             <input type="hidden" name="current_table" value="$[sysIdList]" />
<table width="400">         
              <tr>
                             <td nowrap="true" valign="top" width="600%" height="100%">
                                           <div class="col-md-8">
                                           <span><b><font style="background-color:lightblue">${gs.getMessage('I confirm the application core functionality has been validated and deemed acceptable for use following this release. By checking this box I am signing off on validation.')}</font></b></span>
                                           </div>
                                          <tr>
                                                        <td>
                                           <div class="mt-10" style="padding-left:15px;">
                                                          <label class="checkbox-label">
                                                                        <label><b>${gs.getMessage('Validation Complete')}:</b></label>
                                  <g2:ui_checkbox id="validation_complete" name="validation_complete" value="false" />
                                           </label>
                             </div>
                             </td>
              </tr>
                             </td>
              </tr>
              <tr>
                             <td>
       <div class="col-md-8" style="padding-left:15px;">
                                 <label><b>${gs.getMessage("Work Notes")}</b></label>
                             <textarea wrap="soft" autocomplete="off" rows="5" id="work_notes_update" data-length="4000" style="; width:150%; overflow:auto; background-color:LightGoldenRodYellow;" name="work_notes_update">${jvar_work_notes}</textarea>
                               </div>
                                </td>
              </tr>
              <tr>
                             <td colspan="2" style="text-align:right; padding-top:10px;">
                                           <button class="btn btn-default" onclick="closeWindow()" style="margin-right:10px;">Cancel</button>
                                           <button class="btn btn-primary" onclick="mass_updates()">Complete Sign Off</button>
                             </td>
              </tr>
                             </table>
                             </g:ui_form>    
</j:jelly>

Client Script:

function mass_updates(){
                             g_form.save();
              GlideDialogWindow.get().destroy();
              }

 function closeWindow() {
              GlideDialogWindow.get().destroy();
}

Processing Script:

updateMutlipleRecords();

function updateMutlipleRecords() {
              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()){
                             choice.validation_complete = validation_complete;
                             choice.work_notes_update = work_notes;
                             choice.update();
              }
              function assign(){
                             var urlOnStack = GlideSession.get().getStack().bottom();
                             response.sendRedirect(urlOnStack);
              }
}
1 ACCEPTED SOLUTION

@Nya Valdez 

Hmm... I guess the worknotes field is wrong...

Replace

choice.work_notes_update = work_note_update;

with

choice.work_notes = work_note_update;

 

As for the redirection, you could simply hardcode the URL:

response.sendRedirect('/incident_list.do');

I think it should work, but I haven't tested it as my PDI has gone offline suddenly!

View solution in original post

17 REPLIES 17

Thank you so much!!!

Replace:

<input type="hidden" name="current_table" value="$[sysIdList]" />

with:

<input type="hidden" name="sys_id_list" value="$[sysIDList]" />

 

 

And change your Processing script to:

updateMutlipleRecords();

function updateMutlipleRecords() {

    gs.addInfoMessage('current_table - ' + current_table);
    gs.addInfoMessage('sys_id_list - ' + sys_id_list);
gs.addInfoMessage('validation_complete - ' + validation_complete);
gs.addInfoMessage('work_notes - ' + work_notes_update);

    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()) {
        choice.validation_complete = validation_complete;
        choice.work_notes_update = work_notes_update;
        choice.update();
    }

    var urlOnStack = GlideSession.get().getStack().bottom();
    response.sendRedirect(urlOnStack);
}

 

(I've added 2 log messages, please verify if the table name and the sysids show up at the top of the screen when the button is clicked)

 

Edit : Updated Processing script

Hello @AnirudhKumar 

Thank you so much for your help and patience with this issue.  

I do see the information messages at the top with the correct sys_ids of the records I am attempting to update but the current table is not the table I want to update and I believe this is why the records are not updating. It is showing me the current table as the rm_task table but the table that needs to be updated is a custom table where the records are actually located: x_namim_edrm_nos_patch_schedule_task

Since my UI Action is on the list view of the rm_task table, it seems I need to call out the actual table I need to have updated - which would be a change to these lines in my HTML script: 

var currentTable = RP.getWindowProperties().get('current_table') || '';

change to:

var currentTable = new GlideRecord('x_namim_edrm_nos_patch_schedule_task') || '';

<input type="hidden" name="current_table" value="$[currentTable]" />

change to:

<input type="hidden" name="current_table" value="$[x_namim_edrm_nos_patch_schedule_task]" />

 

And change this line in my Processing Script: 

var choice = new GlideRecord(current_table);

Is that correct?

find_real_file.png

find_real_file.png 

Yes,

Just replace

var currentTable = RP.getWindowProperties().get('current_table') || '';

with

var currentTable = 'x_namim_edrm_nos_patch_schedule_task';

 

No change required to processing script.. as the existing code would simply pick your required table

Hi @AnirudhKumar 

Do you know how I can bypass the scope policy so that the records are updated? Our release module is a scoped app whereas the list view is in the Global application scope so I'm getting this now: 

find_real_file.png