SM6
Giga Guru
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-28-2021 02:20 PM
Hi,
This Modal widget is a similar concept to Add-Row functionality on the catalog item. Instead one can insert a Database record with leaving the current form.
HTML:
<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>
Client Controller:
function($scope, $window, spUtil, glideUserSession, spModal, $rootScope) {
/* 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;
});
}
}
Server Script:
data.buttonMsg = gs.getMessage(options.button_text || "Add Record");
Note: Option Schemas can be added for all the dynamic Options.
Call this dynamically to from a variable:
Create a Macro variable and add the following JSON into the Default value.
{
"widget": "embedded-modal-widget",
"color": "warning",
"button_text": "Add Record",
"sysid": "sys_id of the catalog item/record producer"
}
Hope this is helpful for anyone looking how to use Embedded Modal Widgets. 🙂
Labels:
- 2,028 Views
Comments
Jay Gamblin
Mega Sage
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
12-22-2021
11:22 AM
Might be helpful someday but couldn't get it to work. Maybe I'm missing something.
Thanks