Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

Add a custom field to Todos HR Case Approval widget

Padraig O_Kane1
Tera Contributor

I have a requirement to introduce a Second Approver field on the HR Case Approval widget that is then passed to the Approval record and updated. I have cloned the out of the box widget and made the following changes (see screenshot 1 where I have introduced the new field, server logic to pull back a list of users and broadcast logic to check for changes to the field - this is needed as the widget relies on an embedded widget where the Approve/Reject buttons are located). The issue I am having is passing the new field value to the embedded widget (see screenshot 2 where I have introduced a listener for field changes). I have also made changes to the script include but whenever I log the secondApprover value it is empty or doesn't appear in the request output). Any help would be great. 

1 ACCEPTED SOLUTION

@Padraig O_Kane1:  Ah, looking closely at your screenshots, a few small variable reference mismatches could be quietly breaking the chain! In your parent client script, c.onRecordChange is trying to broadcast $scope.data.secondApprover, but your <sn-record-picker> actually writes to c.secondApprover (and you'll want to send c.secondApprover.value over). Then, over on the child side, $scope.$on is receiving that payload and setting c.data.secondApprover to the entire event object (obj) instead of obj.secondApprover. Finally, in your child server script , data.secondApprover isn't defined yet on the server, so you'll want to grab input.request.secondApprover directly. If you clean up those three variable assignments, that value should flow right on through to your backend process! You can try the following:

  • Update Parent Client Script: Broadcast c.secondApprover.

  • Update Child Client Script: Set c.data.secondApprover = obj.secondApprover.

  • Update Child Server Script: Use input.request.secondApprover instead of data.secondApprover.

 

View solution in original post

10 REPLIES 10

That’s great to hear, @Padraig O_Kane1 ! Please feel free to mark it as helpful and an accepted solution. Glad I could help. Thanks.