Script include to query a record and set the value of specific field

Sri56
Tera Contributor

Hi Team,

We need a script include to query 'sysapproval_approver' table and check if approval type is parallel.

For those records, we need to set the field 'parallel approvals intiated' as true from client script by calling above script include.

below screenshot is for your reference:

find_real_file.png

Please help with the code

Thanks,

Sri

 

34 REPLIES 34

And i wanted to know, 

if we give implemented as 'server script' will this work?

Please help!

This is bit urgent business need!

 

Thanks,

Sri

Hello Sri,

Yes this should work if we implement it as server side:

please share your lates script. and yes the below condition needs to be added in query. it was type in my script:

sysApprovalGR.addQuery("sysapproval", parent.getUniqueValue());

Thanks

 

 

Hi Mahendra,

This is my script:

(function () {
    gs.addInfoMessage("To intiate parallel series:::"+parent.getUniqueValue());
    var sysApprovalGR = new GlideRecord("sysapproval_approver");
    sysApprovalGR.addQuery("sysapproval",parent.getUniqueValue());
    sysApprovalGR.addQuery("u_approval_type", "parallel");
    sysApprovalGR.query();
    while (sysApprovalGR.next()) {
        sysApprovalGR.setValue("u_parallel_approvals_initiated", true);
        sysApprovalGR.update();
    }
    gs.addInfoMessage("Parallel Approval Inititated");
})();

But nothing is working after the confirmation!

 

Please help!

 

Thanks,

Sri

Hello Sri,

Could you please confirm share the screenshot of your action assignment that you have created. It should work actually If you change the implemented as to Script Include.

1. Try to add info message inside while() loop and check if the control is going inside the while loop.

2. If the control is not going inside the while() loop that means the user who is trying to update does not have read access on sysapproval_approver table

3. if the control is going inside the while() loop but still the record is not getting updated then it means the user is not have the write access. Also check if there is any ACL that is restrict the admin user from updating u_parallel_approvals_initiated field.

You may need to check the ACL on sysapproval_approver table. I had checked this with admin access and the approval record was getting updated

Thanks

Hi Mahendra,

Please refer below screenshots:

find_real_file.png

And this is where, we need to change,

find_real_file.png

There is no ACL for the fields, which I have created.

Infact, these are the fields which i have created and i have admin access in the instance.

Please help, This is bit urgent!

Thanks,

Sri