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 Claudia Cruz,



Please refer this ticket, then you will get some idea,



Add Dynamic single line text variable in Service Portal



And I just write the code in the Record Producer script.



regards,


Anna.


Hello Kris,

I also have the same requirement i am not trying to create record producer, I am trying to write in one of the record producer variable. But i am having the record producer also in the service portal. So from the Sc catalog item widget i am trying to write on hidden record producer variable and i am trying to get that value from the hidden variable. 

 

But i am not able to achieve it. Instead i am getting an error that cannot find set value from undefined.

 

Could you please provide any solution or suggestions regarding this ?

 

Any suggestions or solution will be helpful.

 

 

Thanks,

Ruthra.v

Hi ruthrav,

 

Were you able to find the answer? If not, could you post the "Client Script" for your widget?

Community Alums
Not applicable

Anna,



If I understand correctly, you're trying to build an interface that will allow users to create Record Producers from the portal? Why not just give them Catalog roles so they can create the catalog item inside the tool?



thanks,



Andrew Cadaret


Cheng2
ServiceNow Employee
ServiceNow Employee

Hi there, 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);
});