- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 10:56 PM
I have written below code from community to hide submit button but it is giving issue when updating the case created. Is this code correct?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 11:11 PM - edited 12-29-2024 11:15 PM
Code is fine. But to ensure DOM manipulation works ensure Isolate Script = False for your ui policy.
If this field is not on form then from list make it false
Didn't get what's the issue you are facing?
Are you sure your catalog UI policy is satisfying the condition?
why not use onChange catalog client script instead of Catalog UI policy?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 11:11 PM - edited 12-29-2024 11:15 PM
Code is fine. But to ensure DOM manipulation works ensure Isolate Script = False for your ui policy.
If this field is not on form then from list make it false
Didn't get what's the issue you are facing?
Are you sure your catalog UI policy is satisfying the condition?
why not use onChange catalog client script instead of Catalog UI policy?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 11:13 PM
Hi @Hafsa1
Try this below code
if (typeof window !== 'undefined' && window.location) {
if (window.location.pathname.includes('/portal')) {
// For portal
var buttons = document.getElementsByClassName("btn btn-primary btn-block ng-binding ng-scope");
if (buttons.length > 0) {
buttons[0].style.display = 'none'; // Hides the first button with the specified class
}
} else {
// For native
var submitButton = document.getElementById("submit_button");
if (submitButton) {
submitButton.style.display = 'none'; // Hides the button with the specific ID
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2024 11:13 PM
Hi @Hafsa1
Ideally it is not recommended to have DOM manipulation this would be not a good solution from long term perspective.
It would be helpfull if you could elaborate your requirement