How to provide angular ng-templates when cloning OOB form widget in a scoped app in Kingston?

tantony
Mega Guru

In my scoped app I need to display a form widget with initial two field values populated, on a spModal window.This widget is  embedded in another widget. I thought I could clone the OOB form widget and pass the field values as options and provide that as as widgetInput parameter of spModal. But in the cloned widget, form is not displayed. It says 'Record not found'.I see that in the cloned widget's related link the angular ng-templates are missing. I can copy the original ng-templates from OOB form-widget giviing them  new names and add to related list  for the cloned form widget. But I could not find any reference in client or server script for those angular ng-templates. Where is the angular ng-templates referenced in a OOB form-widget?

 

If anybody has  successfully cloned OOB form widget is a scoped app,  please help.

 

6 REPLIES 6

Shambhu5
Kilo Guru

Hi,

Have you tried creating/defining/using Dependancies in widgets? 

Just create your Widget-Dependancy and add it in your widget. This will also help you provide you your additional feature to widget.

- Vishrut

tantony
Mega Guru

I could achieve the requirement without the ng-templates. The 'Record not found' error was displayed not because the ng-templates were missing.  I found that the error was displayed only when I was using the widget preview of the cloned form widget. The server script gets the input from from parent widget. Hence it had to be previewed on the home page so that widget inputs ( table,sys_id,view) could be passed in from parent widget.

nb: all widgets are clones ...

I need help with the Form widget ... perhaps you can shed some light:

in server script, i need to add additional data (data NOT entered on the screen) ... I need to get that data into the data table somehow so that it gets updated on my incident record.

i have tried, in server script, data.my_field = 'my data i need entered';

this doesn't work.

tantony
Mega Guru

ggg,

When you say the additional data is to be saved to table then I am assuming this is defined as a field in the table. Use the input to get any data that was sent from the client controller, for your case the form.And hence available in the server script as 'input._fields'. My server script definition looks like this

(function($sp, input, data, options, gs) {

.....

.....

.....

 


if (input) {


       var result = {};
       if (input._fields) {
          result = $sp.saveRecord(input.table, input.sys_id, input._fields);// for anew record the sysid will be -1
          //data.sys_id = result.sys_id;  //Populate the 'data' object 
      }


} else {
  //Populate the 'data' object for display
}

 

.......

.......

 

})($sp, input, data, options, gs);

 

You can try adding your additional field to  input._fields as below before saving the record:

input._fields["my_field"] = 'my data i need entered';

I could make my portal work by cloning OOB form widget , but that was a year ago. At that time I could not find any reference on cloning form widget. 

Good luck!