- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 10:53 PM
Good day
I am needing show an alert message when the user selects the category and subcategory on a catalog item.
Once the user selects the category and subcategory then an alert should appear.
I managed to achieve this : when user selects category show alert, but not able to achieve category and subcategory
Here is my code:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 11:20 PM
This should work for you - you just need to make sure that what you are looking for is the value, not the display value
I've tested this and it works for me
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var Cat = g_form.getValue('u_category');
var SubCat = g_form.getValue('u_sub_category');
if (Cat == 'a' && SubCat == 'x') {
spModal.open({
'title': "Cat and Sub Cat pop upl",
'message': "Are you sure you want to do this?",
'buttons': [{
label: 'Yes',
primary: true,
}, ],
'backdrop': 'static',
'keyboard': false,
});
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 11:20 PM
This should work for you - you just need to make sure that what you are looking for is the value, not the display value
I've tested this and it works for me
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var Cat = g_form.getValue('u_category');
var SubCat = g_form.getValue('u_sub_category');
if (Cat == 'a' && SubCat == 'x') {
spModal.open({
'title': "Cat and Sub Cat pop upl",
'message': "Are you sure you want to do this?",
'buttons': [{
label: 'Yes',
primary: true,
}, ],
'backdrop': 'static',
'keyboard': false,
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2024 01:01 AM
Thanks I have tried this already but did not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2024 01:08 AM
Thanks @Bidduam
I see where I went wrong now. Looked at your screenshot and see you have the field as subcategory. I changed the field on my side now as well from Category to Subcategory and now the code works.
Thanks so much!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2024 04:35 PM - edited 08-15-2024 04:35 PM
@BiancaK glad it worked.
You can also swap out the && if you want it to work if either the category is 'a' or sub category is 'x' with ||