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

Muhammad Khan
Mega Sage
Mega Sage

You can utilize the below code snippet in your script include.

var grApproval = new GlideRecord('sysapproval_approver');

grApproval.addQuery('<backend_name_of_field_approval_type>', '<backend_value_of_parallel_choice>');
grApproval.query();

while(grApproval.next()){
	grApproval.setValue('<backend_name_of_field_parallel_approvals_initiated', true);
	grApproval.update();
}

Not sure when you want this to happen.

Hi Muhammed,

please share the client script code as well.

Thanks,

Sri

It does not seem a good approach to use this in client scripts. It would be better if you could explain your requirement in detail then maybe we can find a better solution.

Hi Muhammed,

This has written on scoped application-'CSM workspace' not on agent workspace.

I have defined the button on 'sys_declarative_action_assignment'table.

Where i have options to implement as server script/client script etc..

I need to query all current records which is of type parallel then only for those records i need to set the field intiated as true when i click the button.

Below screenshot for your reference:

So requirement is, when i click on intiate parallel button, I need to query a records which is of approval type as parallel and for those records, i need to set the value of parallel approvals intiated value to true.

find_real_file.png

As above, when agent clicks on intiate parallel button,

it should query current record with parallel approval type and highlighted value should be turned from false to true.

Please help,

Thanks,

Sri