how to get setForceUpdate functionality in scopped app

corbettbrasing1
Mega Guru

How do I recreate this functionality in a scoped app? Not sure why it was removed but I need to trigger other business rules form a ui action without updating the record.

6 REPLIES 6

Jon Barnes
Kilo Sage

You could make it a client UI Action that then calls an AJAX script (using GlideAjax) to do the actual work that you want completed. Would that be a valid workaround?


corbettbrasing1
Mega Guru

too much work, I just added a journal input field that is hidden, added text and updated current.  


Barak Pinchovsk
ServiceNow Employee
ServiceNow Employee

Please try calling gr.update() twice.

couldn't get it to work by removing the first gr.update in the condition, must have them both.

the record will be updated once (only one time for those two calls)

var gr = new GlideRecord(TABLE_NAME);
gr.get(SYS_ID);

if (gr.isValidRecord()) {
	// Call gr.update twice ON PURPOSE.
	// It's a workaround for gr.setForceUpdate(true), that can't be called from scoped apps.
	gr.update();
	gr.update();
}

you can also add something like:

gr.setValue('name', gr.getValue('name')); // set a field from the table to the same value

if it makes it feel less ridiculous... 🙂

@Barak Pinchovsk  This works.  But how?  Why?  (Not a fan of the "Magic")