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

Hi Mahendra,

Above solution is not working.

what should be the new value in above client script.

Moreover, we are defining above client script in sys_declarative action table as imlemented as field as client script.

and i please find the below requirement once again:

So requirement is, when i click on intiate parallel button(on configurable workspace) 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,

Please do help on this.

Thanks,

Sri

Sri56
Tera Contributor

Hi Mahendra,

Can you please help on this?

Thanks,

Sri

Hi Mahendra,

This is partially working.

How do we restrict the script include for current record only?

Please help!

Thanks,

Sri

Hello Sri,

You have created the action assignment Initiate Parallel with Implemented as Client Script. You need to change that to Implemented as Script Include then use the below script in Script field:

(function () {
	var sysApprovalGR = new GlideRecord("sysapproval_approver");
	sysApprovalGR.addQuery("sysapproval_approver", 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");
})();

On condition tab do not specify any condition.

On confirmation tab you can add the confirmation message so that if someone click by mistake it should ask user for confirmation. once user confirm then the Approval will be inititated:

find_real_file.png

You should be able to acheive your requirement.

Please do mark my respsone as helpful/correct, if it answer your question.

Thanks

Hello Sri,

Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.

Thanks