Fetch Catalog Variable from SC Catalog Item Page

sivaranjani3894
Tera Guru

Hi All,

I have a requirement to display a message on right side of Request form if the Catalog Item Variable values meet a condition.

I have created a widget to display message on the right side of "SC Catalog Item" page. I need your help in setting conditions based on the values selected on the Catalog Variable. I tried using below code in Client Controller:

$scope.$watch(function() {
return $scope.page.g_form.getValue('sure').toString();
}, function(value) {
c.data.surevalue = value ? value : "";
});

Getting Error on Console - "TypeError: Cannot read properties of undefined (reading 'getValue')"

Please help with below:
1. getting the value of catalog item variable
2. Display the message widget based on conditions.
 
Thanks,
Siva
1 ACCEPTED SOLUTION

sivaranjani3894
Tera Guru

Resolved now - Below is the steps followed:
1. Create a Widget to capture change in Catalog Item variable and broadcast a variable
2. Create a "Custom" Catalog Item variable and associate the widget created from step 1

3. Create another widget to display necessary text

4. Clone the OOB SC Catalog Item widget to capture the broadcast variable and embed the widget (to display to right side of the page) from step 3 based on broadcast variable value.

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@sivaranjani3894 

where did you place this widget?

it seems your widget is not able to access the g_form object

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

@Ankur Bawiskar Thanks for your response. I have placed the widget in global scope and called in HRM Catalog Item.

@sivaranjani3894 

so it's a custom widget in global scope and added to particular catalog item?

what is HRM catalog item?

have you added that as Custom variable and associated this widget to it?

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

@Ankur Bawiskar I am able to display the widget(text) within the item form when the value selected is "value 2", however the requirement is to display the widget (text) to right side of the page below "Order Now". Please let me know if there is a way to achieve this.

sivaranjani3894_0-1735542995376.png

Thanks,

Siva