- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 12:06 PM
I have embedded OOB form widgets in my widget.
HTML :
<div >
<button ng-click="c.onEditForm('widget-form',{'table': c.data.table,'sys_id': -1})" type="button" class="btn btn-success btn-md pull-right pad">Add your item</button>
</div>
Client controller function:
c.onEditForm = function(widgetId, widgetInput) {
spModal.open({
title: 'Add your item',
widget: widgetId,
widgetInput: widgetInput || {}
}).then(function(){
console.log('widget dismissed');
c.server.update();
});
}
This works and let me add new records. But I want two fields dynamically populated with initial values in the empty form displayed.I could not find documentation for what keys goes into 'widgetInput' parameter for spModal.open(). As far as I have seen, it is only 'table','sys_id' and 'view '. Is it possible to give default values for field when the spModal is opened?
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2018 10:10 AM
I could get this working by cloning OOB widget-form . It was a scoped application.What I wanted was to call the form widget inside a spModal in the parent widget and give initial dynamic values for three fields of the form and make the three fields read only. The field values were passed from parent widget to embedded cloned form widget via the 'shared' parameter of spModal.open() as documented here.
c.onEditForm = function(widgetId, widgetInput, initialValues) {
spModal.open({
title: 'Edit your potluck item ',
widget: widgetId, // cloned form widget id
widgetInput: widgetInput || {}, //keys are table , sys_id= '-1', view
shared: initialValues // keys are fields which needed initial values
}).then(function(){
console.log('widget dismissed');
});
}
The 'shared' json object was accessible in the client script of cloned embedded form widget.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 12:13 PM
Hi,
are you looking to give the values to the form you can go through ng-model in the html section of the widget.
Thanks,Naveen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 12:28 PM
The page is complex with three levels of embedding. I want the form widget to be opened inside a modal window by clicking a button with ng-click directive. That will make the page less cluttered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2018 10:10 AM
I could get this working by cloning OOB widget-form . It was a scoped application.What I wanted was to call the form widget inside a spModal in the parent widget and give initial dynamic values for three fields of the form and make the three fields read only. The field values were passed from parent widget to embedded cloned form widget via the 'shared' parameter of spModal.open() as documented here.
c.onEditForm = function(widgetId, widgetInput, initialValues) {
spModal.open({
title: 'Edit your potluck item ',
widget: widgetId, // cloned form widget id
widgetInput: widgetInput || {}, //keys are table , sys_id= '-1', view
shared: initialValues // keys are fields which needed initial values
}).then(function(){
console.log('widget dismissed');
});
}
The 'shared' json object was accessible in the client script of cloned embedded form widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 05:11 AM