- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 07:42 AM
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.
I want to create a new Record Producer based on this details. (New Record Producer as a Name) and others as Variables.
Regards,
Anna.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 01:11 PM
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 */
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 08:08 AM
I am not sure I am following your use case, but have you considered Service Creator:
This is a "self-service" way to create new services in the Service Catalog.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 01:11 PM
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 */
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2017 07:21 AM
It's really more helpful.
I can get the data, but unable to set to the newly created Record Producer variable.
Also can you please tell me how to parse string to object, then iterate object to insert records into table.
Regards,
Anna.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2017 01:39 PM
Hi annasilva
I've created a business rule that runs the following script on insert into "table_a":
(function executeRule(current, previous /*null when async*/) {
var data_from_widget = current.getValue('widget_value');
gs.info("[!] data_from_widget = " + data_from_widget);
var notes = JSON.parse(data_from_widget); //parse string into JSON
//gs.info(notes);
for (var i = 0; i < notes.length; i++){
gs.info('adding record' + i);
gs.info('notes[' + i + '].title=' + notes[i].class_subject);
gs.info('notes[' + i + '].note=' + notes[i].catalog_number);
var newNote = new GlideRecord('table_b');
newNote.initialize();
if(notes[i].class_subject != null)
newNote.class_subject = notes[i].class_subject.toString();
if(notes[i].catalog_number != null)
newNote.catalog_number = notes[i].catalog_number.toString();
newNote.element_id = current.getValue('sys_id');
newNote.insert();
}
})(current, previous);
The idea here being that the sys_id of the current record, is used as the "element_id" of the newly inserted records into "table_b"; of which a relationship between the two tables can be made.
Hope this helps.