widget data to record producer

SNOW User8
Giga Guru

Is there any way to retrieve a widget data and create a new Record Producer based on that data.

If someone have a solution please advice me to achieve this.

        find_real_file.png

I want to create a new Record Producer based on this details. (New Record Producer as a Name) and others as Variables.

Regards,

Anna.

1 ACCEPTED SOLUTION

Kristoffer Mon1
Giga Expert

Hi Anna,



It appears you and I have similar requirements.   My widget contains a table, with basic functionality like adding rows and inline editing.



The only way i've discovered to pass the data object is create a hidden catalog variable to store the serialized data object.



Widget client script:



$scope.page.g_form.setValue("hidden_widget_value", angular.toJson(c.data.notes));




Then on catalog client script you could do something like :


function onSubmit() {


        var data_from_widget = g_form.getValue('hidden_widget_value');



        /* parse string to object, then iterate object to insert records into table */


}


View solution in original post

15 REPLIES 15

Hi kristoffermoncada ,



I can get the JSON data from the widget as below,


But unable to get the particular values.


Just tried to get the user entered values as   "json_output.fields.value".


find_real_file.png


Is there any way to get the values alone from the JSON data and add that as a Record Producer variable name and questions?



Regards,


Anna.


Hi annasilva,


Can you copy and paste the actual json string?


var json_output = [{


  "number": 0,


  "fields": [{


      "label": "Field Name",


      "type": "text",


      "value": "Test Name"


  }, {


      "label": "Field Type",


      "type": "text",


      "value": "Test Type"


  }, {


      "label": "Question",


      "type": "text",


      "value": "Test"


  }]


}];






console.log(json_output[0].fields[0].label); //Field Name


console.log(json_output[0].fields[1].label); //Field Type


console.log(json_output[0].fields[2].label); //Question



As for creating the record producer variable....   I would investigate the table "item_option_new".


I have yet to do this, BUT it appears you can add records to this table (with all the necessary fields) and that should create your record producer variables dynamically.



Someone like ctomasi, is more qualified to answer this question.



Hope this helps.


Do we need to include the code in a client script?


How do you implement the add row thing?