-
Notifications
You must be signed in to change notification settings - Fork 908
Form Background via UI Macros #2085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ravichandra1998g
merged 8 commits into
ServiceNowDevProgram:main
from
dvn-lazywinner:SNippets2025
Oct 12, 2025
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6ca7f20
Update cc all group members.js
dvn-lazywinner b879679
Update README.md
dvn-lazywinner fdde06e
Create readme.md
dvn-lazywinner 0edbaf5
Create form_background.xml
dvn-lazywinner 48c1d9a
Update README.md
dvn-lazywinner 0392896
Update cc all group members.js
dvn-lazywinner 65c5afe
Update readme.md
dvn-lazywinner 7ef352c
Merge branch 'main' into SNippets2025
dvn-lazywinner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Client-Side Components/UI Macros/FormBackground/form_background.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <j:jelly trim="false" | ||
| xmlns:j="jelly:core" | ||
| xmlns:g="glide" | ||
| xmlns:j2="null" | ||
| xmlns:g2="null"> | ||
| <style> | ||
| .touch_scroll{ | ||
| background:url("/formbg.png"); | ||
| background-size:cover; | ||
| background-position:center; | ||
| } | ||
| label{ | ||
| font-weight:600; | ||
| font-size:16px; | ||
|
|
||
| } | ||
| .btn-default{ | ||
| background:#fff; | ||
| } | ||
| table,form,.section,.tabs2_section { | ||
| background:transparent !important; | ||
| } | ||
| </style> | ||
| </j:jelly> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # ServiceNow Form Background Macro | ||
|
|
||
| > A lightweight UI Macro to style ServiceNow forms with a custom background and simple element theming (labels, buttons, sections). | ||
| --- | ||
|
|
||
| ## Features | ||
|
|
||
| * Adds a full-cover background image to a form (supports cover, center positioning). | ||
| * Makes table/form/section backgrounds transparent so the background shows through. | ||
| * Easy to customize (image path, label styles, button styles, additional CSS selectors). | ||
|
|
||
| ## Requirements | ||
|
|
||
| * ServiceNow instance with admin access. | ||
| * An image to set as background | ||
|
|
||
| > ⚠️ Note: This macro uses Jelly/CSS that may not work as expected in some Next Experience workspaces or future UI updates. Test in a non-production instance first. | ||
|
|
||
| ## Installation | ||
|
|
||
| 1. **Upload the background image** | ||
|
|
||
| * Navigate to **System UI > Images** and upload your background image (e.g., `formbg.png`). | ||
|
|
||
| 2. **Create the UI Macro** | ||
|
|
||
| * Go to **System UI > UI Macros** and create a new macro (e.g., `ui_form_background`). | ||
| * Copy the example macro content below into the UI Macro. | ||
|
|
||
| 3. **Create a UI Formatter** | ||
|
|
||
| * Go to **System UI > Formatters**. Create a new formatter for the target table (for example, `incident` table). | ||
| * In the *Formatter* field, reference the macro name you created (e.g., `ui_form_background.xml`). | ||
|
|
||
| 4. **Add the Formatter to the Form Layout** | ||
|
|
||
| * Open the form layout for the target table (Form Layout / Form Designer) and place the formatter region on the form. | ||
| * Save and open a record to see the background applied. | ||
|
|
||
| ## Compatibility | ||
|
|
||
| * Tested on ServiceNow classic forms (UI16). May require tweaks for Next Experience, Service Portal, or Workspace. | ||
| * If your instance uses strict Content Security Policy (CSP) or image hosting constraints, host the image in a supported location or adapt the implementation. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| * If no background appears: | ||
|
|
||
| * Confirm the image is uploaded and the filename matches. | ||
| * Ensure the formatter is placed on the form layout and published. | ||
| * Inspect (browser devtools) to confirm CSS selectors are applied. | ||
|
|
||
| ## Result | ||
| <img width="1838" height="922" alt="image" src="https://github.com/user-attachments/assets/14c29e0a-ad88-411e-b7ca-1c82eaeaf324" /> | ||
|
|
||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions, improvements, and pull requests are welcome. Please follow these guidelines: | ||
|
|
||
| * Fork the repo and create feature branches for changes. | ||
| * Keep the macro CSS minimal and well-commented. | ||
| * Include screenshots and a short description for visual changes. | ||
|
|
||
| If you want help adapting this macro to your instance (Next Experience / Workspaces / Service Portal), open an issue or reach out via the repository. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.