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>

}

}

5 REPLIES 5

Nehal Dhuri
Mega Sage

is there any specific reason that why you want to populate variable data through widget?
You can use catalog client script to populate variable data.
You can refer to the following posts for more information:
https://www.servicenow.com/community/developer-forum/autopopulate-user-details-onchange-of-user-name...

https://www.servicenow.com/community/developer-articles/auto-populate-a-variable-based-on-a-referenc...

Please hit like and mark my response as correct if that helps

Roan Galang
Tera Contributor

The reason is that we are trying to do something related to the Save as Draft functionality. Once the field changes, we are calling the Save as Draft popup. And when the draft is saved, we want to populate a certain field. And from the client script, we can execute some other logic.

@Roan Galang 

Save as Draft is available as OOTB feature.

You can enable that for your portal and then enable it for your catalog item

Save Catalog Items as draft 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Roan Galang 

what's your actual business requirement here?

what are you doing with that cloned widget?

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