Service Portal spModal: what can the "shared" option be used for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 02:11 PM
What can the "shared" option in spModal be used for and how?
It is shown in below example code
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 02:42 PM
Hello,
shared - a client-side object to share data with the embedded widget client script.
If you send some variable in that shared option you will be able to access it in the widget client controller script that you called in widget parameter
For more explanation and details please refer to below link https://developer.servicenow.com/dev.do#!/reference/api/sandiego/client/SPModal-API
Please mark me answer correct if you find it helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 03:53 PM
HELLO
DID MY RESPONSE HELP IF YES PLEASE MARK MY ANSWER CORRECT AND HELPFUL . THIS WILL HELP OTHERS TOO WITH SAME QUERY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 01:37 AM
Example
Html Template
<div>
<button ng-click="c.onChangeSchedule()">
Open
</button>
<div ng-if="c.selectedValue">
You picked: {{c.selectedValue.text}}
</div>
</div>
Client Script
function ($scope,spModal) {
var c = this;
var shared = {};
c.onChangeSchedule = function(){
spModal.open({
title: 'Select a value',
widget: 'bec1438bdbf276009ed8f81d0f96193e',
widgetInput: { hint: "Soup or Nuts?" },
shared: shared
}).then(function() {
// Shared object was updated
c.selectedValue = shared.selection;
});
}
}