Populate the catalog variable in the form on field change from the SC Catalog Item widget

Roan Galang
Tera Contributor

I have cloned/customised the SC Catalog Item widget and trying to do a simple population of the variable in the catalog item when a certain field changes.

 

$scope.$on("field.change", function(evt, params) {

if (params.field.name == '<variable that triggers the population') {

<set the value of another variable>

}

}

6 REPLIES 6

Roan Galang
Tera Contributor

Yes, we are using an OOTB Save as Draft feature. What we want to achieve is : 

1. In the catalog form, if you select something from a certain field, we want the popup for the Save Draft to show (without manually clicking the Save as Draft)

2. Now, when click the Save in the Draft modal, we want a certain field populated. 

3. We will use the field populated from the widget in a client script to execute some other logic

I'm trying to do this but getting an error

// Access the g_form object
var g_form = $scope.page.g_form;
// Set the value of the variable (replace 'variable_name' and 'value' accordingly)
g_form.setValue('variable name', 'value');

@Roan Galang 

this is heavy customization and I will recommend avoid doing this.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader