- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 11:26 PM
Hi
Can anyone please help with an alternative method for document.getElementById() as DOM manipulation should be avoided in client scripts
Below is the example code
try
{
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
if ((g_form.getValue('u_transition_personal_sim_card_to_corporate_mobile_plan_is_required') == 'yes')) {
alert('Document attachment is mandatory for request submission.');
return false;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 03:14 AM
Hello,
Please use the solution mentioned in the below article:-
https://www.basicoservicenowlearning.in/2020/10/attachment-mandatory.html
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 11:45 PM
Hi,
this is for catalog item or native form?
As per my understanding no other way to replace DOM
What's your requirement?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 03:01 AM
Hi Ankur,
This is for catalog item and requirement to avoid DOM manipulations like document,$,gel
Can you please suggest an alternative method or alternative approach
Thanks,
Anusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 03:05 AM
Hi,
For native?
I don't think. You can try to use onSubmit with Synchronous Ajax
Refer these links for workaround/solution on how to use Synchronous GlideAjax in onSubmit
How To: Async GlideAjax in an onSubmit script
Asynchronous onSubmit Catalog/Client Scripts in ServiceNow
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 04:52 AM
try this script
try{
var attachmentCount = getCurrentAttachmentNumber();
if ((g_form.getValue('u_transition_personal_sim_card_to_corporate_mobile_plan_is_required') == 'yes') && attachmentCount == 0) {
alert('Document attachment is mandatory for request submission.');
return false;
}
}
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