-
Notifications
You must be signed in to change notification settings - Fork 913
Code-Snippets Client Script New Folder 'Time Worked Hide Start' #1928
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
Closed
zstromsodt
wants to merge
2
commits into
ServiceNowDevProgram:main
from
zstromsodt:zstromsodt-pullrequest-startstoptimer
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions
9
Client-Side Components/Client Scripts/Time Worked Hide Start/README.md
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,9 @@ | ||
| # Hide Start/Stop Timer on Record Table | ||
|
|
||
| ## Purpose | ||
| Prevent users from clicking Start/Stop timer and letting it run while they are idle. The goal of this script was to encourage intentional time worked entries. | ||
|
|
||
| ## How to Use | ||
| 1. Create OnLoad client script (timeworkedhidetimer.js) | ||
| 2. Adjust which table you want it on. In this case, it will be Incident table. | ||
|
|
||
7 changes: 7 additions & 0 deletions
7
Client-Side Components/Client Scripts/Time Worked Hide Start/timeworkedhidetimer.js
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,7 @@ | ||
| function onLoad() { | ||
|
|
||
| $j('div[id="element.incident.time_worked"]').children('.form-field-addons').hide(); | ||
|
|
||
| //if you use other tables, just adjust the dot-walking element ie change_request.time_worked | ||
|
|
||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a sentence or two about why this needs to be done with DOM manipulation instead of g_form or other oob methods? Otherwise looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding, this isn't possible using oob methods or g_form according to documentation I found. Happy to use those if there is a solution for it.
https://www.servicenow.com/community/developer-forum/automaticly-stop-time-worked-timer/m-p/1603232
https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/
If DOM manipulation is illegal in the code snippets, I can close the pull request. I misunderstood the purpose of this project if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think you're right that there's not a native method for this. I meant can you add some information in the readme and/or code comments stating that DOM Manipulation must be used for this. Just want to include extra context since DOM manipulation is usually not aligned with best practices.