UI Page Processing Script issue

Still Learning
Kilo Sage

Hello Experts, 

I have a UI page that should mass update records selected in a list view when a criteria is met. When the full criteria is not met, the script should show the records that could not be updated with an error and those that were.  What I am struggling with is this:  It seems that my script only works until the point of correctly evaluating the records that should not be updated based on the chosen criteria and then stops without evaluating or updating the records that should be updated. 

I can't find what I've done wrong.  I would appreciate any assistance I can get.  Here is the UI page in it's entirety (also in attached word document in case that's easier)

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="sys_id_list" 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;"> 
	
			<footer class="modal-footer" align="right">	
		<button class="btn btn-default footer-button" onclick="cancel()">${gs.getMessage('Cancel')}</button>
			<button class="btn btn-primary" onclick="mass_updates()" id="update">${gs.getMessage('Complete Sign Off')}</button>
		</footer>
		 </td>
 </tr>
		</table>
		</g:ui_form>	
</j:jelly>

Client Script: 

function cancel() {
    GlideDialogWindow.get().destroy();
    return false;
}
function mass_update() {
    GlideDialogWindow.get().destroy();
    return true;

 

Process Script:

evaluateRecords();
function evaluateRecords() {
    var getRecords = new GlideRecord('x_namim_edrm_nos_patch_schedule_task');
    if (sys_id_list) {
        var check = sys_id_list.split(',');
  //      getRecords.addQuery('sys_id', check);
        getRecords.addEncodedQuery('sys_idIN' + check + '^active=true^type=validation_sign_off^assignment_groupISEMPTY^ORassigned_toISEMPTY^ORvalidation_contact_cell_numberISEMPTY^ORvalidation_typeISEMPTY^type=validation_sign_off^ORvalidation_sign_up');
        getRecords.query();
    }
    while (getRecords.next()) {
        gs.addErrorMessage("Mass Sign Off cannot be completed because the following record(s) have not been signed up:" + "(" + getRecords.number + " ), please update and retry");
        getRecords.setAbortAction('true');
    }
    gs.info('check updates 1');
    if (sys_id_list) {
        var recheck = sys_id_list.split(',');
        getRecords.addQuery('sys_id', recheck);
        getRecords.addEncodedQuery('sysIdIN' + recheck + 'type=validation_sign_off^ORtype=validation_sign_up^assignment_groupISNOTEMPTY^assigned_toISNOTEMPTY^validation_contact_cell_numberISEMPTY^validation_type!=');
        getRecords.query();
        gs.addInfoMessage("Records" + "(" + getRecords.number + ") has been updated.");
        gs.info('check updates 2');
        if (getRecords.next()) {
            getRecords.validation_complete = true;
            getRecords.work_notes = work_notes_update;
			getRecords.type = "validation_complete";
            gs.info('check updates 3');
               // getRecords.setValue("type", 'validation_complete');
                getRecords.setValue("state", 'closed');
            getRecords.update();
        }
	}
	multiUpdate();
}
function multiUpdate() {
    var urlOnStack = GlideSession.get().getStack().bottom();
    response.sendRedirect(urlOnStack);
}

 

 

4 REPLIES 4

Rahul RJ
Giga Sage
Giga Sage

@Still Learning  you need update below code

 getRecords.setAbortAction('true'); to 'true'should be boolen value getRecords.setAbortAction(true);

Please mark the suggestion as helpful, if you find it useful to you or others who want to refer to similar content.

 

Regards,

RJ

Hello @Rahul RJ 

Thank you so much for your reply!! I've updated my script as you've suggested, but unfortunately get the same outcome.  The logs shows me that the script never gets to line: 26 It does not seem to make it to my "if" statement on line 22 and I haven't been able to figure out why.  Any help  you can provide to me to get this to work is greatly appreciated RJ!! 

 

 

 if (getRecords.next()) {
            getRecords.validation_complete = true;
            getRecords.work_notes = work_notes_update;
			getRecords.type = "validation_complete";

 

 

Logs:

 

StillLearning_1-1674051731161.png

 

 

Rahul RJ
Giga Sage
Giga Sage

@Still Learning  Feel free to mark correct If I answered your query.
This will be helpful for future visitors looking for similar questions

 

Regards,

RJ

Hello @Rahul RJ  the problem is that I have the same issue, despite updating my script as you've suggested.  It doesn't appear to make it to line 22 where the "If" statement begins and that's where I need help (figuring out why).  I've included the logs in my earlier reply to you for your reference.  Any suggestions are greatly appreciated.