I am not able to update or create or delete record in Document Tasks

chandan31
Tera Contributor

Hi All,

 

I am not able to update or create or delete record in Document Tasks using 

 

var gr = new GlideRecord('sn_doc_task');
gr.addEncodedQuery('number=DOCT0001005');
gr.addQuery('parent','HRC0231097');
gr.query();
if(gr.next()){
    //gr.short_description = 'Must be  printers that are broken again...';
    gr.setWorkflow(false); //Disable business rules for this query
    gr.deleteRecord();
}
1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@chandan31 

Document task table is in "Document templates" application scope. We don't have option to select this scope in background script. For this scope related error you need to create restricted caller access record.

 

Second way to achieved this is change your scope to "Document templates" and Create fix script. So this fix script will get created in "Document templates" only and then add your code. Then simply click on "Run Fix script".

 

Also in your code, parent is a reference field so use the HR case sys ID instead of HR case number

 

SANDEEP28_0-1689751870987.png

 

var gr = new GlideRecord('sn_doc_task');
gr.addEncodedQuery('number=DOCT0001111);
gr.addQuery('parent','a07f7b8e8a9370cbb354edfdffdfdfdf');
gr.query();
if(gr.next()){
gs.info(gr.number);
gr.setWorkflow(false); //Disable business rules for this query
gr.deleteRecord();

}

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Haven't verified yet, though "parent", isn't that a reference field? You are querying on a number?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi ,

 

I am receiving this error 

 

chandan31_0-1689749263464.png

 

Ah oke scope issue. So did you follow what is mentioned in the logs? Clear error.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

 Just verified, indeed as expected, parent is a reference field. That's you issue 😀

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn