How to request approval with UI action

Hiroki Miyashit
Tera Contributor

Hello exparts!

 

I'd like to set a button on the input form and send an approval request to "Approver Group" by pressing the button.

How can i achieve this ?

Can you please help me with the code .

Thanks.

1 ACCEPTED SOLUTION

Prince Arora
Tera Sage
Tera Sage

@Hiroki Miyashit ,

 

What do you mean by input form, Are you talking about some record of table?

 

BTW here is the code to send the approval to particular group, you need to create a UI action server side and write this code mentioned below:

 

var approval = new GlideRecord('sysapproval_group');
approval.initialize();
approval.assignment_group = //pass the sys_id of group to whom you want to send Approval request
approval.approval = 'requested';
approval.parent = current.sys_id;
approval.insert();
action.setRedirectURL(current);

 

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

View solution in original post

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, can you clarify why you need custom code and cannot use OOB approval functionality?

 

Prince Arora
Tera Sage
Tera Sage

@Hiroki Miyashit ,

 

What do you mean by input form, Are you talking about some record of table?

 

BTW here is the code to send the approval to particular group, you need to create a UI action server side and write this code mentioned below:

 

var approval = new GlideRecord('sysapproval_group');
approval.initialize();
approval.assignment_group = //pass the sys_id of group to whom you want to send Approval request
approval.approval = 'requested';
approval.parent = current.sys_id;
approval.insert();
action.setRedirectURL(current);

 

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

@Prince Arora 
Thank you for answer!

Your advice solved my problem.

Hi @Prince Arora ,

 

thanks for you hint, that help me too! I have only one addiditonal question. Is it possible to change the ui action coding that the agent pick only one approver from the group? E.g. I click on the UI Action Request approval and a seperat window will open with a drop down where I can choose one approver of this group...

 

Thanks a lot for your help,

Nicole