Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Cheng2
ServiceNow Employee
ServiceNow Employee

Hi there,
I think you can use "CustomEvent" as an "event publisher & subscriber" in widget controller & record producer catalog client script, something like:
1. Fire an event In widget controller:

 

 

CustomEvent.fireAll('hs-event', c.data.eventGenerated);

 

 

2. Listen the event in catalog client script (onLoad type script normally):

 

 

CustomEvent.on('my-event', function(newValue) {
        g_form.setValue('description', newValue);
});

 

 


The events listening or firing can be dual-direction if needed.

 

Cheers,

Cheng