Scheduled Background Script – GlideRecordSecure() not updating Incident HTML Description field

NoorulHudaN
Tera Contributor

Hello!

I have a scheduled background script that updates the incident.description HTML field.
Now I've read about ServiceNow scripting governance tool and I have added the admin user and all required users the snc_required_script_writer_permission role.
but still the field doesn't update.
- My script uses GlideRecordSecure() for the update
- Field-level ACL on `incident.description` requires the `sn_incident_write` role - which has also been granted to admin user
Still doesn't work.

If I switch to the standard GlideRecord(), it updates correctly.
How to make my script work without stripping the "Secure"

1 ACCEPTED SOLUTION
17 REPLIES 17

did you check admin override check box?

Tanushree Maiti
Mega Patron

Hi @NoorulHudaN 

 

Add the user to conditional script writer group. It should work after that ( not tested at my end).

 

Refer KB2581331  : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2581331

       also refer: https://www.servicenow.com/community/app-engine-forum/issue-with-html-field-users-can-t-update-value....

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Ankur Bawiskar
Tera Patron

@NoorulHudaN 

see if admin can write to that field and print log

Did you check that field level WRITE ACL has any script which is blocking?

I also used setWorkflow(false) to exclude Query BR from running during your query

var gr = new GlideRecordSecure('incident');
gr.setWorkflow(false); // added to exclude query BR
gr.addQuery('sys_id', 'your_incident_sys_id');  // Replace with your query
gr.query();
if (gr.next()) {
    if (gr.description.canWrite()) {
        gr.description = 'Your HTML update';
        gr.update();
        gs.info('Update successful');
    } else {
        gs.error('No write access to description: ' + gr.getUniqueValue());
    }
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks @Ankur Bawiskar 
I just tried setWorkflow(false) with GlideRecordSecure and It didnt work.
Here's the log:

Running as user: system
canWrite u_description: false
u_description: null



@NoorulHudaN 

since canWrite() is false the update on field is not happening.

Did you use access analyzer and see which ACL is blocking?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader