Add a custom field to Todos HR Case Approval widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago - last edited 4 hours ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
The probable reason your secondApprover value is coming up empty is perhaps due to an asynchronous timing issue in your embedded widget's client script specifically, you are defining the $scope.$on('data-updated') listener inside your sendUpdateRequest() function right before creating c.data.request. Because $scope.$on sets up an event listener for future broadcasts rather than executing synchronously on the spot, c.data.secondApproverremains undefined when c.server.update() fires. To fix this, move the $scope.$on('data-updated', ...) listener out of sendUpdateRequest to the top level of your embedded widget's client controller so it constantly listens for changes, update your broadcast in the parent widget to pass an object like $rootScope.$broadcast('data-updated', { secondApprover: $scope.data.secondApprover }), and then extract input.request.secondApproveron the server script before handing it off to your Script Include.
Hope this helps.