On clicking a approval button on the form approval form, newly created record should open on the approval Form.

Community Alums
Not applicable

I have a form that creates a Business Application , on submitting the form it actually creates a Request item for the approval , as we have a list of approvers in the Requested Item, on selecting a one approver it takes to the approval form , when we click the approve button in the approval form it should redirect to  the newly created business application form.

Kindly help me with this Requirement.

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello Prakash,

As far as I understood your requirement a request is submitted to create a Business application and once the request is submitted, RITM will be created with some approvals on it. When your asked to when some approver opens the approval record to approve the RITM, they click on Approve button on sysapproval_approver table and the RITM is approved. Now once it is approved by clicking on Approve button, the Approve button should redirect to newly created Business Application.

Your business application is created from the Flow that you have created. If that is the case then I believe this is not possible to implement because there is no relationship between the Business Application record and sysapproval_approver table. Also when you click on the Approve button the flow will take say 500ms or 1 second so in this case how the Approve button script will identify if the Business Application is created or not

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

Thanks

View solution in original post

18 REPLIES 18

Community Alums
Not applicable

Hi Ankur,

Yes , the approver is approving using sysapproval_approver button.

Thanks,

Prakash Yadav.

Hi,

then you will have to update the OOB ui action which is at form level

So on click of Approve button it should be redirecting to the business application for which approval is happening?

If yes then do this

if(current.source_table == 'cmdb_ci_business_app'){
	var url = '/cmdb_ci_business_app?sys_id=' + current.document_id;
	current.state='approved';
	current.update();
	action.setRedirectURL(url);
}
else{
	current.state='approved';
	current.update();
	new ApprovalUserFeedback().approved(current);
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Community Alums
Not applicable

Hi Ankur,

Thanks, but after clicking the approve button it did not redirected to the new business application record .

I believe i should change only the url in the above code 

var url= 'domain.servicenow.com/cmdb_ci_business_app?'+ current.document_id;

Still did not work , Kindly help on it.

Thanks,

Prakash.

Hi,

are you sure you are using Form UI action?

Script I shared should work fine.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Community Alums
Not applicable

Hi Ankur,

Yes the user is approving from the sysapproval_approver button.

But, the UI Action is neither setting the approval value nor creating the application

It looks Everything is working out in Workflow , below is how the work flow activities are working out

If new App--->Approval (Activity definition:Approval-user) workflow Activity with condition(activity.result == 'approved' || activity.result=='rejected')--->Mark as Approved (If approved)--->Create an Event(notification to manager)---> Create an App

where would you like me to place the given code Or would you suggest me some other code in this scenario, Please help on it.