- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:33 PM
I have create variable with 2 option and below are the scenario i want to achieve.
Scenario 1
When i choose option 1 variable name (u_option1) default the add to cart and order now button already loaded.
Scenario 2
When i choose option 2 variable name (u_option2) the add to cart and order now button must hide.
I attach the screenshot for your reference and is there scripts or option I can do that.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:48 PM
Hi,
for showing/hiding the add to cart and order now button via script would require DOM manipulation which is not recommended.
if you still require then use this onChange script on that variable
I have shared solution here 2 years ago; enhance it for your requirement
Ensure Isolate Script field is set to False for this client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == 'u_option2'){
// hide
this.document.getElementsByClassName('btn btn-default sc-btn form-control ng-scope')[0].style.display = 'none';
this.document.getElementsByClassName('btn btn-primary btn-block ng-binding ng-scope')[0].style.display = 'none';
}
else{
// show
this.document.getElementsByClassName('btn btn-default sc-btn form-control ng-scope')[0].style.display = '';
this.document.getElementsByClassName('btn btn-primary btn-block ng-binding ng-scope')[0].style.display = '';
}
//Type appropriate comment here, and begin script below
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:44 PM
I have the above option in the maintain item... this is what i would like to achieve based on below scenario.
Scenario 1
When i choose option 1 variable name (u_option1) default the add to cart and order now button already loaded.
Scenario 2
When i choose option 2 variable name (u_option2) the add to cart and order now button must hide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:50 PM
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:52 PM
Please refer below ServiceNow Community Links:-
To Hide "Add to Cart " & "Order Now " Button using client script
Remove OrderNow button
How to hide 'order now' button dynamically in a catalog without using DOM Manipulation
Shakeel Shaik 🙂