From c79a55ca5936ff858a9e93de8df6ddfad9381099 Mon Sep 17 00:00:00 2001 From: Sumanth Dosapati Date: Thu, 9 Oct 2025 20:56:37 +0530 Subject: [PATCH 1/4] Create README.md --- .../README.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md diff --git a/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md new file mode 100644 index 0000000000..b7da3112e6 --- /dev/null +++ b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md @@ -0,0 +1,21 @@ +## Highlight Mandatory Fields + +**Description** +- This bookmarklet visually highlights all mandatory fields on a ServiceNow form by adding a glowing border or background around them. +- It helps developers, admins, or QA testers quickly see which fields are marked as mandatory. +- It also helps partial visually paired people to find the mandatory fields instead of looking for small * icon for field. +- This works as a toggle. One click highlights the mandatory fields and clicking again removes the highlight. + +**Example :** + +- When activated on a form (e.g. Incident, Request Item): +- Mandatory fields like Short description, Caller, etc get a soft glowing yellow border. +- Click again → glow is removed. + +**How it works:** +- Detects `g_form` context. +- Adds a temporary CSS class (`.mandatory-glow`) to all mandatory fields. +- Click again to remove the highlights. + + + From 2a99c1d812b2ec748a108332a38284fe0b30a2d2 Mon Sep 17 00:00:00 2001 From: Sumanth Dosapati Date: Thu, 9 Oct 2025 21:00:09 +0530 Subject: [PATCH 2/4] Create Highlight mandatory fields on form.js --- .../Highlight mandatory fields on form.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js diff --git a/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js new file mode 100644 index 0000000000..d01483f8c9 --- /dev/null +++ b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js @@ -0,0 +1 @@ +javascript:(function(){try{if(typeof g_form==='undefined'){return;}const styleId='sn-mandatory-highlight-style';const existingStyle=document.getElementById(styleId);if(existingStyle){existingStyle.remove();document.querySelectorAll('.mandatory-glow').forEach(el=>el.classList.remove('mandatory-glow'));return;}const style=document.createElement('style');style.id=styleId;style.innerHTML='.mandatory-glow{outline:3px solid #FFD700 !important;box-shadow:0 0 10px 3px rgba(255,215,0,0.9)!important;border-radius:6px;transition:all 0.2s ease-in-out;}';document.head.appendChild(style);let count=0;const fields=g_form.getEditableFields();fields.forEach(function(fieldName){if(g_form.isMandatory(fieldName)){let fieldElem=g_form.getElement(fieldName);if(!fieldElem)return;let container=fieldElem.closest('.form-group,.question,.input-group,.field');if(!container)container=fieldElem.parentElement;container.classList.add('mandatory-glow');count++;}});if(count===0){alert('No mandatory fields detected.');}else{}}catch(err){console.error('Error running bookmarklet:',err);alert('An error occurred: '+err.message);}})(); From c0190efb5968cf1303928a7008ca0b2309fd51af Mon Sep 17 00:00:00 2001 From: Sumanth Dosapati Date: Thu, 9 Oct 2025 21:01:35 +0530 Subject: [PATCH 3/4] Update README.md --- .../Highlight Mandatory fields on form/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md index b7da3112e6..6efb02ebe4 100644 --- a/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md +++ b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/README.md @@ -17,5 +17,8 @@ - Adds a temporary CSS class (`.mandatory-glow`) to all mandatory fields. - Click again to remove the highlights. +**Sample screenshot** +image + From b340136090f16abee566dee833bd085ebb15dddd Mon Sep 17 00:00:00 2001 From: Sumanth Dosapati Date: Fri, 10 Oct 2025 13:05:37 +0530 Subject: [PATCH 4/4] Update Highlight mandatory fields on form.js Fixed issues in code --- .../Highlight mandatory fields on form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js index d01483f8c9..5d6c622412 100644 --- a/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js +++ b/Specialized Areas/Browser Bookmarklets/Highlight Mandatory fields on form/Highlight mandatory fields on form.js @@ -1 +1 @@ -javascript:(function(){try{if(typeof g_form==='undefined'){return;}const styleId='sn-mandatory-highlight-style';const existingStyle=document.getElementById(styleId);if(existingStyle){existingStyle.remove();document.querySelectorAll('.mandatory-glow').forEach(el=>el.classList.remove('mandatory-glow'));return;}const style=document.createElement('style');style.id=styleId;style.innerHTML='.mandatory-glow{outline:3px solid #FFD700 !important;box-shadow:0 0 10px 3px rgba(255,215,0,0.9)!important;border-radius:6px;transition:all 0.2s ease-in-out;}';document.head.appendChild(style);let count=0;const fields=g_form.getEditableFields();fields.forEach(function(fieldName){if(g_form.isMandatory(fieldName)){let fieldElem=g_form.getElement(fieldName);if(!fieldElem)return;let container=fieldElem.closest('.form-group,.question,.input-group,.field');if(!container)container=fieldElem.parentElement;container.classList.add('mandatory-glow');count++;}});if(count===0){alert('No mandatory fields detected.');}else{}}catch(err){console.error('Error running bookmarklet:',err);alert('An error occurred: '+err.message);}})(); +javascript:(function(){try{let f=window;if(window.frames.length&&window.frames['gsft_main'])f=window.frames['gsft_main'];if(!f||typeof f.g_form==='undefined'){console.log('No ServiceNow form detected.');return;}const g=f.g_form,d=f.document,sid='sn-mandatory-highlight-style',es=d.getElementById(sid);if(es){es.remove();d.querySelectorAll('.mandatory-glow').forEach(e=>e.classList.remove('mandatory-glow'));return;}const st=d.createElement('style');st.id=sid;st.innerHTML='.mandatory-glow{outline:3px solid #FFD700!important;box-shadow:0 0 10px 3px rgba(255,215,0,0.9)!important;border-radius:6px;transition:all 0.2s ease-in-out;}';d.head.appendChild(st);g.getEditableFields().forEach(n=>{if(g.isMandatory(n)){const e=g.getElement(n);if(!e)return;let c=e.closest('.form-group,.question,.input-group,.field');if(!c)c=e.parentElement;c.classList.add('mandatory-glow');}});}catch(e){console.error('Error:',e);}})();