Update a widget with another widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:49 PM
Dear guys,
I have a quite simple setup:
Widget: A - This is a "Form" displaying a record from a table, several fields, it can be modified
Widget B - A small widget on the right side of the Form page.
Both widget contains recordwatch lines like:
spUtil.recordWatch($scope, $scope.data.table, "sys_id="+$scope.data.sys_id);
$scope.$on('record.updated', function(name, data) {});
What I can achieve:
- Display button on Widget B, if some state is true for widget A.
- Clicked on buttons on Widget B can update the form record for Widget A. (As example change the state, like "Accepted").
My problem: If i change some random field value on Widget A, and click a "Save" button on Widget B, it does not update the record on Widget A.
My server script is extemly easy:
if (action == 'save') {
gr.update();
}
The button I clicked the action is 'save'. "gr" is for sure the form record. I guess something more needed? Where? What? In which widget?
Also I sadly noticed - use case:
I modify some field value on Widget A, I modiy Priority to 2. Then I click "Send to Review" on Widget B. The code:
if (action == 'review') {
gr.sate = 4;
gr.update();
}
In that case the button "Send to Review" updated the Form (Widget A) state to 4, -> OK, but NOT updates the Priority to 2.. It stays as it was.
Can you help me how can I achieve that? Whatever field value I modify on Wifget A, pressing some "update" button on Widget B will update the record.
Thanks a lot!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 01:19 PM
Refer to my article which does something similar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 10:35 PM
Thank you Mike,
Your widget there is basically my Widget "B" which is workinf fine also, but does not cover my situation: ssomebody change a value on field(s) for a record in Widget "A", do not save it, but click the button to Save on Widget "B".
So what I would need, any changes happens on record on widget A client side, could be Saved by clicking a button on Widget B.
I think this is somehow could be realetd to $boracast event.
In my Widget A which is basically OOB snow "Form" I still have lines:
$rootScope.$broadcast(eventName, $scope.data.f._fields);
$rootScope.$broadcast(eventName, $scope.data);
And also on my custom widget B Client controller section I have:
$scope.$on('sp.form.record.updated', function(name, data) {});
But something still missing.
Some more code, Widget B displaying save button HTML:
<button ng-if="data.showSave" type="button" class="btn btn-primary" ng-click="c.uiAction('save')">${Save}</button>
Server side:
if (action == 'save') {
gr.update();
}
I guess some more needed either on server side or client on Widget B, but don't know 😞
Thanks!