Widget - Embedded Modal
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 08:34 AM
Hi - I want to create a 'Custom' variable type on a record producer and include a widget. This is a button widget which onclick will only an other record producer without leaving the current page. Once the 2nd record producer is open user can submit it and be in the same page.
Here is the widget code that is not working. Can someone tell what's the error here?
Widget Details:
ID: embedded-modal-widget
HTML code:
<div>
<button class="btn btn-{{options.color}} m-b" ng-click="openModal()">{{data.buttonMsg}}
<sp-widget widget="data.modalInstance" ng-if="data.modalInstance"></sp-widget>
</button>
</div>
Server Script:
(function() {
data.buttonMsg = gs.getMessage(options.button_text || "Add Record");
})();
Client controller:
api.controller = function(ActionParameterService, $rootScope, $scope, spModal, $http, $window, spUtil, $location, snAnalytics, i18n, $timeout, spAuthModal) {
/* widget controller */
var c = this;
var shared = {};
$scope.openModal = function(ev, table, sysid, query, view) {
if (!sysid)
sysid = -1;
spUtil.get("widget-modal", {
embeddedWidgetId: "sc-cat-item-v2",
embeddedWidgetOptions: {
sys_id: c.options.sysid,
display_cart_on_right: true,
auto_redirect: "false",
disableUIActions: false
}
}).then(function(widget) {
var modalCtrl;
widget.options.afterOpen = function(ctrl) {
modalCtrl = ctrl;
};
//var unregister = $scope.$on('sp.form.record.updated', function () { //if embeddedWidgetId:'widget-modal'
var unregister = $scope.$on("$sp.sc_cat_item.submitted", function() { //if embeddedWidgetId:'sc-cat-item-v2'
modalCtrl.close();
});
widget.options.afterClose = function() {
unregister();
$scope.data.modalInstance = null;
};
$scope.data.modalInstance = widget;
});
}
}
Additional widget settings:
controllerAs: c
Link:
function link(scope, element, attrs, controller) {
}
Data table: Instance [sp_instance]
Variable on Record Producer:
Type: custom
Type Specification - Widget: Database Modal Widget (embedded-modal-widget)
Default value:
{
"widget": "embedded-modal-widget",
"color": "warning",
"button_text": "Add Record",
"sysid": "d313ef4153602210c2f718b0a0490ea7"
}
Here is the button that's not working as expected.
Thank you!
0 REPLIES 0