Can you update a gliderecord and ignore/override data policies?

howard8
Tera Contributor

Hi,

I would like to update a GlideRecord with a business rule but a data policy is intercepting the update because I am not populating a mandatory field.   The logic of the update is correct through, my question is: Can you update a glide record and ignore/override data policies? I have tried setWorkflow, autoSysFields and setForceUpdate (in the example below) but they don't override a data policy.

//Force an update to all User records without changing field values

var gr = new GlideRecord('sys_user');

gr.query();

while (gr.next()) {

    gr.setWorkflow(false); //Do not run business rules

    gr.autoSysFields(false); //Do not update system fields

    gr.setForceUpdate(true); //Force the update

    gr.update();

}

The instance I am working on had all of it's UI policies converted data policies but they were only designed with what the user can do, in mind. They are now preventing backend scripts from doing their job.   I know I could go and modify each other them as an option, but from a technical stand point, I'd really like to know if they can just be ignored somehow.

Anyone done this before?

1 ACCEPTED SOLUTION

Apologies for updating an old thread, but I recently discovered this is possible. Just add:



gr.setUseEngines(false);



to the query. It's rather cryptically described on the wiki as "Disable or enable the running of any engines (approval rules / assignment rules)", but it also makes the query ignore data policies.



It's probably a bit late for this to be of any use to the original poster, but if nothing else I'll probably need this again in a few months, forget how I did it, google it and end up here again...


View solution in original post

8 REPLIES 8

Anurag Tripathi
Mega Patron
Mega Patron

Hi Howard,



I don't think it is possible


gr.setForceUpdate //has a different meaning, it wont help you to ignore data policies


-Anurag

roy_dreijling
Kilo Contributor


setUseEngines does not(no longer)   disable data policies.



gr.setUseEngines(false)


As setUseEngines is no longer helpful for data policies, Is there an alternative ?

Hi Nithin,

Did you found the alterative for setUseEngines function ?

looking for the alternative

Thanks and regards,

Meenal