├── .github └── workflows │ └── hacktrack.yml ├── .gitignore ├── ATF Steps └── Count table records │ ├── README.md │ └── script.js ├── Advanced Conditions ├── Exclude Email Reply Comment Notifications by Group │ ├── README.md │ └── exclude_email_reply_comment_notifications_by_group.js └── Group Approval Check │ ├── README.md │ └── group_approval_check.js ├── Agile Development └── Burndown Chart │ ├── README.md │ ├── requirements.txt │ └── sprint_burndown_chart.py ├── Attachments ├── Attachment to Base64 │ ├── README.md │ └── script.js ├── Attachment to base64 in scope │ ├── README.md │ └── attachmentToBase64Scope.js ├── Base 64 to Attachment │ ├── README.md │ └── base64toattachment.js ├── CSVParser │ ├── README.md │ ├── csvparser.js │ └── script.js ├── Calculate attachment hash code │ ├── README.md │ └── calculateHash.js ├── Convert KnowledgePage to PDF │ ├── Convert_KnowledgePage_to_PDF.js │ └── README.md ├── Create Attachments │ ├── Create attachment via script.js │ └── README.md ├── Delete RITM Attachment │ ├── README.md │ └── deleteattachment.js ├── ExportAttachmentsToMidServer │ ├── README.md │ └── exportattachmentstomid.js ├── ExportRecordsAnyFormat │ ├── README.md │ └── exportRecords.js ├── Send Attachment to MID Server │ ├── README.md │ └── Send Attachment to MID Server.js ├── Show RITM has Attachments │ ├── README.md │ ├── ShowRITMhasAttachment_BR.js │ └── ShowRITMhasAttachment_CS.js └── attachmentToXMLParse │ ├── README.md │ └── code.js ├── Background Scripts ├── Bulk Change of Incident Priority Based on Category │ ├── Bulk Change of Incident Priority Based on Category.js │ └── README.md ├── Add Bookmarks - ITIL Users │ ├── README.md │ └── script.js ├── Add Comments │ ├── README.md │ └── addComment.js ├── Add No Audit Attribute To Multiple Dictionary Entries │ ├── AddNoAuditAttributeToMultipleDictionaryEntries.js │ └── README.md ├── Add Standard Change Model │ ├── README.md │ └── addStandardChgModel.js ├── Adding bookmark to Favorites tab │ ├── Adding bookmark into Favorites tab.js │ └── README.md ├── Approval Reminders │ ├── README.md │ └── approvalReminderToDelegates.js ├── Attach Workflow to Existing Record │ ├── README.md │ └── script.js ├── Bulk Create Records in Multiple Tables │ ├── BulkCreateRecordsMultipleTables.js │ └── README.md ├── Bulk Delete Records in Multiple Tables with Conditions │ ├── BulkDeleteRecordsMultipleTablesWithConditions.js │ └── README.md ├── Bulk Role Assignment Based on Conditions │ ├── README.md │ └── script.js ├── Bulk Update Tables │ ├── BulkUpdateWithConditions.js │ └── README.md ├── Capturing a record in to the current update set │ ├── Capturing a record in to the current update set using background script.js │ └── README.md ├── Change Approver │ ├── BgScript.js │ └── README.md ├── Change Update Set Application Scope │ ├── README.md │ └── changeApplicationScope.js ├── Check String is Valid JSON │ ├── README.md │ └── checkStringisValidJson.js ├── Check for duplicates on multiple criteria │ ├── README.md │ └── check-for-ducplicates.js ├── Clone User Record │ ├── README.md │ └── cloneUserRec.js ├── Clone User with Roles and Groups │ ├── README.md │ └── cloneUser.js ├── Compare Roles Between Two Users │ ├── README.md │ ├── compare-roles-2-users.js │ └── example-output.PNG ├── Convert Date Time │ ├── README.md │ └── convertTimeZone.js ├── Convert Incident Records to JSON │ ├── README.md │ └── convert code.js ├── Convert comma separated values in string to columns │ ├── README.md │ └── script.js ├── Copy table fields from one table to another │ ├── Copy fields from one table to another │ └── README.md ├── Copy table name list header action │ ├── README.md │ ├── addMenuItem.js │ ├── menu.jpg │ └── removeMenuItem.js ├── Currency Conversion │ ├── README.md │ └── currencyConvert.js ├── Currency Formatting │ ├── README.md │ └── currencyFormatting.js ├── Custom Table Usage │ ├── README.md │ └── customTableUsage.js ├── Deactivate groups with no members and inactive manager │ ├── README.md │ └── script.js ├── Decrypt Password Field │ ├── README.md │ └── decryptfield.js ├── Discover Datacenters for Service Accounts │ ├── README.md │ └── script.js ├── Encode and Decode URI │ ├── README.md │ └── encodeURIdecodeURI.js ├── Encrypt & decrypt payload via base64 │ ├── README.md │ └── code.js ├── Extend Code Search Base │ ├── README.md │ └── add_more_tables_to_code_search.js ├── Fetch Active Groups list without members │ ├── README.md │ └── activeGroupsWithoutMembers.js ├── Find Groups Without Members │ ├── Get Groups with no Members.js │ └── README.md ├── Find out Duplicate Records │ ├── Duplicate Records for any table based on field.js │ ├── Duplicate Records.js │ └── README.md ├── Find sys_id named records │ ├── README.md │ └── findSysIdNamedFiles.js ├── Finding groups with inactive managers │ ├── Finding groups with inactive managers.js │ └── README.md ├── Fix reference to Choice │ ├── README.md │ ├── script_v1.js │ └── script_v2.js ├── FlushOutbox │ ├── README.md │ └── script.js ├── Force new value to read only or protected field │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ └── script.js ├── Form Field Count │ ├── Form Field Count.js │ └── README.md ├── Generate JWT Token │ ├── README.md │ └── generateJWTToken.js ├── Generate Random Incident Records │ ├── README.md │ └── generate_random_incident.js ├── Generate statistics about events created today │ ├── README.md │ ├── ScreenShot_0.PNG │ ├── ScreenShot_1.PNG │ └── script.js ├── Get Active MID Servers │ ├── GetActiveMidServer.js │ └── README.md ├── Get All the CI classes │ ├── README.md │ └── getAllCiClasses.js ├── Get Duplicate │ ├── README.md │ └── script.js ├── Get GlideRecord Reference Field │ ├── README.md │ └── get_glide_record_reference_field.js ├── Get Installed Plugins details │ ├── README.md │ └── getInstalledPluginInfo.js ├── Get Instance DB Size │ ├── README.md │ └── getInstDBSize.js ├── Get Instance Info │ ├── README.md │ └── getInstanceInfo.js ├── Get Journal Entry as HTML Without Header │ ├── GetJournalEntryAsHTMLWithoutHeader.js │ └── README.md ├── Get My Groups │ ├── README.md │ └── getMyGroups.js ├── Get The Last Journal Comment Date │ ├── README.md │ └── script.js ├── Get all users where manager is empty │ ├── README.md │ └── script.js ├── Get current logged in user count in all nodes of instance │ ├── README.md │ └── script.js ├── Get list of Update Set types │ ├── README.md │ └── script.js ├── Get the current version of an application │ ├── README.md │ └── currentversionscript.js ├── GetFlowNames │ ├── README.md │ └── getFlowNames.js ├── GetRecordsFromMultipleTables │ ├── README.md │ └── script.js ├── GreenHouse ServiceNow Integration Snippet │ ├── GreenHouse_SN_Snippet.js │ └── README.md ├── Identification and Reconciliation │ ├── README.md │ └── identificationReconciliationOnPayload.js ├── Incident Auto-Categorization Based on Keywords │ ├── Incident Auto-Categorization Based on Keywords.js │ └── README.md ├── Limit String and Add Elipses │ ├── README.md │ └── script.js ├── List Stories and Tasks by User and Date Range │ ├── README.md │ ├── results.png │ └── script.js ├── List fields in table │ ├── README.md │ └── listFieldsInTable.js ├── Logout User │ ├── README.md │ └── logoutUser.js ├── Move Customer Updates │ ├── README.md │ └── moveCustomerUpdates.js ├── Notify User of Password Expiry │ ├── README.md │ └── script.js ├── Parse ISO8601 Date │ ├── README.md │ └── script.js ├── Prevent unnecessary notifications from being sent out │ ├── Prevent_unnecessary_notifications_from_being_sent_out.js │ └── README.md ├── QuickCurrent │ ├── README.md │ └── quickCurrent.js ├── README.md ├── Read Encoded Query │ ├── README.md │ └── readQuery.js ├── Reference field value update from CI relationship connection.js ├── Remove Inactive User │ ├── README.md │ └── Remove Inactive user from active group.js ├── Remove element from list field │ ├── README.md │ └── removeFromList.js ├── Remove roles from inactive user │ ├── README.md │ └── script.js ├── Replace Text │ ├── README.md │ └── script.js ├── Restart RITM Flow │ ├── README.md │ └── restart-ritm-flow.js ├── Retrieve age of Incident │ ├── README.md │ └── ageOfIncidents.js ├── SQL Checker │ ├── README.md │ └── SQLChecker.js ├── Set the status to Retired on Ec2 Instance │ ├── README.md │ └── script.js ├── Set update sets to Complete │ ├── README.md │ └── set_update_sets_to_complete.js ├── Silent update on GlideRecord │ ├── README.md │ └── slientUpdateOnGlideRecord.js ├── Stale Tasks Auto-Close │ ├── README.md │ └── Stale Tasks Auto-Close.js ├── Typed Array Elements │ ├── README.md │ └── typed_array_elements.js ├── Update All Store Apps │ ├── 2023-10-13-08-42-48.png │ ├── 2023-10-13-08-47-01.png │ ├── 2023-10-13-08-55-37.png │ ├── 2023-10-13-09-02-32.png │ ├── 2023-10-13-09-49-57.png │ ├── 2023-10-13-10-19-54.png │ ├── 2023-10-13-10-22-40.png │ ├── 2023-10-13-10-25-04.png │ ├── 2023-10-13-10-26-37.png │ ├── 2023-10-13-10-27-05.png │ ├── 2023-10-13-10-31-04.png │ ├── 2023-10-13-10-31-29.png │ ├── 2023-10-13-10-33-17.png │ ├── 2023-10-13-12-17-09.png │ ├── README.md │ └── update_all_apps.js ├── Updating a record in the sys_user table │ ├── README.md │ └── script.js ├── User Has Role Exactly │ ├── README.md │ └── user_has_role_exactly.js ├── Version Checker │ ├── README.md │ └── VersionUpdateChecker.js ├── add member to groups │ ├── Add the members to List of the Groups using GlideRecord.js │ └── README.md ├── encryptAndDecryptNonPasswordFields │ ├── README.md │ └── encryptAndDecryptNonPasswordFields.js ├── encryptAndDecryptPasswordFields │ ├── Encrypt and Decrypt Non-Password Fields.js │ └── README.md ├── findTableSize │ ├── README.md │ └── findTableSize.js └── inserting a new record into the sys_user table │ ├── README.md │ └── script.js ├── Browser Bookmarklets ├── Copy URL to ServiceNow Journal │ ├── README.md │ └── copy url to servicenow journal.js ├── Create new update set │ ├── README.md │ └── create_update_set.js ├── Create story task │ ├── README.md │ └── create_story_task.js ├── Impersonation │ ├── README.md │ └── impersonation.js ├── Open copied record │ ├── README.md │ └── open copied record bookmarklet.js ├── Quick Notes │ ├── README.md │ └── quick_note.html ├── Quick login to current instance │ ├── Quick login.js │ └── README.md └── ServiceNow Instance Collection │ ├── README.md │ └── bookmarklets.html ├── Browser Utilities └── Custom Search Engines │ └── README.md ├── Business Rules ├── ATF Duplicate Execution Order │ ├── ATF_Duplicate_Execution_order.js │ └── README.md ├── Add HR task for HR case │ ├── Add HR Task for VIP HR Case.js │ └── README.md ├── Add itil role to ootb user query to also see inactive users │ ├── README.md │ └── code.js ├── Add notes on tag addition or removal │ ├── README.md │ ├── update_notes_tag_addition.js │ └── update_notes_tag_removal.js ├── Add woknotes for 75 percent SLA │ ├── README.md │ └── addWorknotesForSLA.js ├── After-BR to generate approvals for catalog tasks │ ├── README.md │ └── approval.js ├── Allow only unique insert │ ├── README.md │ └── script.js ├── Assign specific role to user │ ├── README.md │ ├── ScreenShot1.PNG │ ├── ScreenShot2.PNG │ └── script.js ├── Async REST Call │ ├── README.md │ └── callAsynREST.js ├── Attachment Variable from Activity Stream to Clip Icon │ ├── Attachment Variable Fix.js │ └── README.md ├── Auto Incident Notification and Escalation │ ├── README.md │ └── incident_notification.js ├── Auto add email recipients to the message body when Email Override is on │ ├── IncludeEmailRecipientsInBody.js │ └── README.md ├── Auto approve if previously approved │ ├── Auto_approve approvals.js │ └── README.md ├── AutoAssignment │ ├── Auto Assign Incident.js │ └── README.md ├── AutoCreation of Problem from Incident │ ├── README.md │ └── whenMajorIncidentIsTrueCreateProblem.js ├── Automate Role Assignment for New User │ ├── README.md │ └── autoRoleAssignment.js ├── Automated Incident Categorization Based on Keywords │ ├── Automated Incident Categorization Based on Keywords.js │ └── README.md ├── Automated SLA Monitoring and Escalation │ ├── Automated SLA Monitoring and Escalation.js │ └── README.md ├── Automatic Group Membership Updates via API │ ├── README.md │ └── autoGroupMembershipUpdate.js ├── Backup Critical Table Data │ ├── README.md │ └── backupCriticalTableData.js ├── Block Attachments for specific conditions │ ├── Block Attachments.js │ └── README.md ├── Call JavaScript Probe │ ├── Call JavaScript Probe.js │ └── README.md ├── Capture Implementation Status of Change Request │ ├── Implementation Status of Change Request.js │ └── Readme.js ├── Change Lead Time Calculations │ ├── README.md │ └── change_lead_time_calculations.js ├── Change Risk Assesment mandatory before state change │ ├── README.md │ └── script.js ├── Check domain of record against user session │ ├── README.md │ └── script.js ├── Check for active tickets before inactivating user │ ├── Check for active tickets before inactivating user.js │ └── README.md ├── Close parent RITM when SC Task is Closed │ ├── README.md │ └── closeParentRITMwhenSCTaskisClosed.js ├── Compare two date fields │ ├── README.md │ └── compareTwoDateFields.js ├── Copy Attachment INC to Case │ ├── README.md │ └── copyAttachement.js ├── Copy Attachment on Email │ ├── README.md │ └── copyAttachment.js ├── Copy Comments from RITM to SCTASK Vice versa │ ├── README.md │ └── copyCommentsfromRitmToSctask.js ├── Copy attachments from idea to demand │ ├── README.md │ └── copy attach from idea to demand.js ├── Copy details to Request │ ├── Move Sc_task Assign group and assigne to Request.js │ └── README.md ├── Copy fields from Employee from │ ├── README.md │ └── script.js ├── Copy latest comment from RITM to SCTASK │ ├── CopyComments.js │ └── README.md ├── Copy worknotes from SCTASK to RITM comments │ ├── README.md │ └── sctaskToRitmAdditionalComments.js ├── CopyAttachmentsFromApprovalToChange │ ├── CopyAttachmentsApprovalToChange.js │ └── README.md ├── Count Associated Incidents in Problem │ ├── README.md │ └── script.js ├── Create a copy of incident in another servicenow instance │ ├── README.md │ └── script.js ├── Create catalog task for each row of MRVS │ ├── README.md │ └── script.js ├── Create choice sets if required for new choices │ ├── README.md │ └── script.js ├── Create comment on referenced record │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── DeleteUserRole │ ├── README.md │ └── script.js ├── Display BR to get groupInfo of logged in User │ ├── README.md │ ├── displayBr.js │ └── onLoadClientScript.js ├── Display current user display name on top of form │ ├── README.md │ └── script.js ├── Display warning message when peer reviewer and Requested by are same person │ ├── README.md │ └── Warningmessage_Business rule.jss ├── Due date calculation based on priority │ ├── README.md │ └── code.js ├── Dynamic Business Rule to Update User Roles Based on Department Changes │ ├── Dynamic Business Rule to Update User Roles Based on Department Changes.js │ └── README.md ├── Emergency Change Cannot be closed without AttachedIncident │ ├── README.md │ └── Review to Close Without Incident.js ├── Enforce File Upload Restrictions for HR Document Submission │ ├── Code.js │ └── README.md ├── Enforce Percentage │ ├── README.md │ └── enforce_percentage.js ├── Enforce Single Attachment Rule for HR Core Tasks │ ├── README.md │ └── codingfile.js ├── Enforce Unique Rank │ ├── README.md │ └── UniqueRank.js ├── Enforce a 1-1 relationship │ ├── README.md │ └── enforce_1_1.js ├── Exclude Redundant Email Recipients │ ├── README.md │ └── exclude_redundant_email_recipients.js ├── Fetching reference field value from higher-level parents │ ├── Fetching reference field value from higher-level parents.js │ └── README.md ├── Generate event │ ├── README.md │ ├── ScreenShot_0.PNG │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── If Conflicts are there restrict change resquest to move further │ ├── README.md │ └── ifConflictStopChangeRequestToAssessState.js ├── Make Attachment Mandatory │ ├── MakeAttachmentMandatory.js │ └── README.md ├── Mandatory Attachment │ ├── README.md │ └── threeAttachementsMandatory.js ├── Manipulating system properties values │ ├── README.md │ ├── ScreenShot_0.PNG │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── Mark an Email High Importance initiated from Email Client │ ├── Mark an Email High Importance │ └── README.md ├── Name Change Profile Update │ ├── README.md │ └── script.js ├── Notification │ ├── README.md │ └── Send Notification on New Incident Creation.js ├── Pass server info to client │ ├── README.md │ ├── example.png │ └── passServerInfo.js ├── Preserve enhancement when deleting project │ ├── Preserve enhancement when deleting project.js │ └── README.md ├── Prevent RITM to get closed │ ├── README.md │ └── script.js ├── Prevent adding user to group if manager is inactive │ ├── README.md │ └── Script.js ├── Prevent duplicate update sets │ ├── README.md │ └── preventDuplcateUpdateSets.js ├── Prevent invalid fiscal period in cost plan breakdown │ ├── Prevent invalid fiscal period on cost plan breakdown.js │ └── README.md ├── Previous Approval Check │ ├── README.md │ └── previous_approval_check.js ├── QueryBR-restrict users to see their company records │ ├── README.md │ └── script.js ├── RITM Assignment Sync │ ├── Populate_Assigned _To_on_RITMs_for_Specific_Catalog_Item.js │ └── README.md ├── RITM state change │ ├── README.md │ └── Related_task_state_update.js ├── RITM_to_SCTASK │ ├── README.md │ └── RITM_to_SCTASK.js ├── Randomly distrubite events between custom queues │ ├── DistrubuteEvents.js │ └── README.md ├── ReRank item │ ├── README.md │ └── rerank.js ├── Read Workspace URL │ ├── README.md │ └── ReadWS_URL.js ├── Recursive logic │ ├── README.md │ └── Recursive BR.js ├── Reduce syslog query │ ├── README.md │ ├── business_rule.png │ └── reduce_syslog_query.js ├── Replace KB Author with Manager │ ├── README.md │ └── Replace Script.js ├── Restrict Service Account to Query data │ ├── README.md │ └── restrictedDataQuery.js ├── RoleUpdateOnGroupManagerChange │ ├── README.md │ └── script.js ├── SCTASK_to_RITM │ ├── README.md │ └── SCTASK_to_RITM.js ├── Set program business duration │ ├── PPM_Utils.js │ ├── README.md │ └── set pgm business duration.js ├── Sync CI operational status with child related CIs │ ├── README.md │ └── script.js ├── Transform Data from Attachment │ ├── README.md │ └── data_xform_from_attachment.js ├── Trigger Event when a member is added to a list │ ├── README.md │ └── Trigger an event when user is added to field.js ├── Update Child Incident based on Parent Incident │ ├── README.md │ └── Update_Child_Incident.js ├── Update Locked Out field when Active field changes on User record │ ├── README.md │ └── update_locked_out_field.js ├── Update worknotes of Ptask to parent Problem record │ ├── README.md │ └── script.js ├── UpdateFavouritedKnowledgeArticleWhenItIsUpgradedToNewVersion │ ├── README.md │ └── update_favourited_knowledge_artice.js ├── User Activity Log Tracking │ ├── README.md │ └── userActivityLog.js ├── User Profile Field Validation │ ├── README.md │ └── userProfileValidation.js ├── Validate Email on Import │ ├── README.md │ └── validateEmailOnImport.js ├── Validate JSON Property │ ├── README.md │ └── jsonPropertyValidator.js ├── Warn for changed OOTB artifacts │ ├── README.md │ ├── screenshot.png │ └── warn_for_changed_ootb_artifacts.js ├── duplicateattachments │ ├── AvoidduplicateattachmentsonIncident.js │ └── README.md └── setting future week dates │ ├── README.md │ └── setting future dates.js ├── CMDB ├── CMDB Dynamic Status Update Function │ ├── README.md │ └── updateCMDBOperationalStatus.js ├── CMDB Get CI Relationships │ ├── README.md │ └── getCIRelationships.js ├── CMDB Utility Scripts │ ├── README.md │ ├── detectDuplicateCIs.js │ ├── populateMissingManufacturers.js │ └── unUsedCIs.js ├── CMDB record count │ ├── README.md │ ├── TechTrekwithAJ-CMDBCIcountonclass.js │ ├── TechTrekwithAJ-readme.md │ └── cmdb-record-count.js ├── CSDM Maturity Report │ ├── README.md │ └── csdm-maturity-report.js ├── IRE Errors │ ├── IRE Errors.js │ └── README.md ├── IRE Queridentify │ ├── Identify and query with IRE.js │ └── README.md └── Mandatory Field Analysis │ ├── README.md │ ├── TechTrekwithAJ-CMDBMandatoryfieldanalysis.js │ ├── TechTrekwithAJ-cmdbmandatoryfielddescription_readme.md │ └── mandatory-field-analysis.js ├── CONTRIBUTING.md ├── Catalog Client Script ├── Add Label For Attachment │ ├── README.md │ └── add_label_for_attachment.js ├── Add Rows in MRVS │ ├── README.md │ └── addrows.js ├── Autopopulate Department │ ├── README.md │ └── autopopulateDepartment.js ├── Block Submit │ ├── README.md │ └── block_submit.js ├── Calculate age on based on date of birth │ ├── Calculate age based on dob.js │ ├── README.md │ └── image.png ├── Clear all fields │ ├── README.md │ └── script.js ├── Combine variables into Description │ ├── README.md │ └── script.js ├── Control all RITM variables in one go │ ├── README.md │ └── script.js ├── Currency Validation │ ├── README.md │ └── currency_validation.js ├── CustomAlert │ ├── README.md │ ├── Screenshots │ │ ├── ExampleScreenShotCustomAlertInfo.png │ │ ├── ExampleScreenShotForCustomAlertSuccess.png │ │ ├── ExampleScrenShotForCustomAlertDanger.png │ │ └── README.md │ ├── custom_alert.js │ └── custom_alert_box.js ├── Date Management │ ├── Date Management.js │ └── README.md ├── Dynamically Update Reference Qualifier │ ├── Catalog Item onLoad.js │ ├── README.md │ ├── Script Include.js │ └── Variable Set onLoad.js ├── Get Display Value of MRVS │ ├── README.md │ └── mrvs.js ├── Get MRVS Values from Parent │ ├── README.md │ └── onload.js ├── Hide Attachment icon.js ├── Hide Variables of Catalog Item on Order Guide │ ├── Hide Variables.js │ └── README.md ├── MRVS Email Validation with Mutation Observer │ ├── EmailValidationOnCatalogUI.js │ └── README.md ├── MRVS Interact With Parent Form │ ├── Portal onLoad.js │ ├── README.md │ └── Write to Parent Form.js ├── MRVS Loop Rows │ ├── README.md │ └── loopRows.js ├── MRVS Reference Qualifier from Catalog Item Variable │ ├── Catalog Client Script.js │ ├── README.md │ └── Script Include.js ├── Make OOB Attachment Mandatory │ ├── README.md │ └── onChange.js ├── Mandatory Attachments with 'n' numbers │ ├── README.md │ └── onSubmitClientScript.js ├── Open modal widget in an Onsubmit │ ├── README.md │ └── openmodal.js ├── PAN Validation │ ├── PAN Validation.js │ └── README.md ├── Passport Validation │ ├── README.md │ └── passportvalidity.js ├── Password Validation Script │ ├── README.md │ └── Script.js ├── PopulateDropdown │ ├── README.md │ ├── demo_catalog.png │ └── script.js ├── Prevent duplicate records on MRVS │ ├── README.md │ └── script.js ├── Regex Validation │ ├── README.md │ └── script.js ├── Remove reference icon from portal │ ├── README.md │ └── remove-reference-icon-from-portal-onLoad.js ├── Restrict Number of rows in Multi Row Variable │ ├── README.md │ └── restrict_multi_row.js ├── Rounding Money or Price Field │ ├── README.md │ ├── catalog_client_script.js │ └── catalog_client_script_config.md ├── Set User Field Values on Load │ ├── README.md │ └── script.js ├── Set fields from URL Parameter 2 │ ├── CatalogClientScript.js │ ├── KMXOUtils.js │ ├── README.md │ └── UtilsAjax.js ├── Set fields from URL Parameters │ ├── README.md │ └── script.js ├── Special Characters │ ├── README.md │ └── script.js ├── Strong Username Validation Script │ ├── README.md │ └── Script.js ├── Validate a Credit Card Number │ ├── README.md │ └── Script.js └── onCellEdit Catalog Task State Change Restriction │ ├── README.md │ └── script.js ├── Client Scripts ├── Add Field Decoration │ ├── Add Field Decoration.js │ └── README.md ├── Add Image to Field Based on Company │ ├── AddImageToFieldBasedOnCompany.js │ ├── README.md │ └── SetCompanyScratchPadValue.js ├── Adding Placeholder on Resolution Notes │ ├── README.md │ └── script.js ├── Auto-Populate Short Discription │ ├── README.md │ └── autoPopulateSD.js ├── Auto-populate watch_list based on company │ ├── README.md │ └── script.js ├── Change Label of Field │ ├── Change Label of Field.js │ └── README.md ├── Check all mandatory fields using mandatoryCheck() │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── Client script using getMessage() function without filling Messages field │ ├── README.md │ └── script.js ├── Conditional Form Section based on Role │ ├── README.md │ └── script.js ├── Control Form Behaviour from Reference Lookup │ ├── README.md │ └── script.js ├── Display Section on State │ ├── README.md │ └── script.js ├── Dynamic UI Actions │ ├── README.md │ └── script.js ├── Enable VIP and Senior VIP Checkboxes and read only │ ├── README.md │ └── ScriptToEnableVIP_superVIP users ├── End Date can't be before Start Date │ ├── README.md │ └── code.js ├── Expanding Info Message │ ├── README.md │ └── script.js ├── Field Placeholder │ ├── README.md │ └── fieldplaceholder.js ├── Field Validation │ ├── README.md │ └── specialcharacter.js ├── Get Field Value From List on Client │ ├── README.md │ └── script.js ├── Get URL Parameters │ ├── README.md │ └── script.js ├── Get Value from URL Parameter │ ├── README.md │ └── script.js ├── Hide Work Notes section │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ └── script.js ├── How to adjust the Date format within a client script to align with the User Date format │ ├── README.md │ └── code.js ├── MRVS variables validations │ ├── README.md │ └── script.js ├── Major Incident Proposal │ ├── Client_Script.js │ ├── README.md │ └── Script_Include.js ├── Make Variable Editor Read Only for Catalog Items containing MRVS │ ├── CheckMRVSDetails.js │ ├── MakeVariableSetReadOnly.js │ └── README.md ├── Make all fields read only │ ├── README.md │ └── script.js ├── Make fields read only in specific states │ ├── Make fields read only in specific state.md │ └── code.js ├── On load Switch-Case Testing │ ├── README.md │ └── Switch-Case code snippet.js ├── Only number validation for input │ ├── OnChange.js │ └── README.md ├── Open Record in Agne Workspace Tab │ ├── README.md │ └── openrecawtab.js ├── Populate Jelly Slushbucket with Values │ ├── ClientScript.js │ └── README.md ├── Redact Sensitive Information │ ├── README.md │ └── script.js ├── Remove Option from Choice List │ ├── README.md │ └── Remove Options from Choice List.js ├── Restrict Creation of P1, P2 Incidents │ ├── README.md │ └── Restrict_Creation_Of_P1_P2_Incidents.js ├── Set Severity, state & assigned to │ ├── README.md │ ├── script.js │ └── script_include.js ├── Set Urgency to High onChange of caller field │ ├── README.md │ └── script.js ├── Set field style like font and background │ ├── OnLoad client script.js │ └── README.md ├── Show Message On Both Form and List │ ├── README.md │ └── script.js ├── Show field if x things are checked │ ├── README.md │ └── script.js ├── State changes to On Hold then worknotes should be mandatory │ ├── README.md │ └── worknotes.js ├── Sync Ajax with no getXMLWait │ ├── README.md │ └── script.js ├── Toggle Annotation On Forms With Script │ ├── README.md │ └── script.js ├── Toggle form section visibility │ ├── README.md │ └── toggleFormSection.js ├── Translate Message │ ├── README.md │ └── getMessage.js ├── Update Category from Short Description Keywords │ ├── README.md │ └── script.js ├── Use case of addOption() and removeOption() │ ├── README.md │ └── script.js ├── Validate Email Format │ ├── README.md │ └── ValidateEmailFormat.js ├── Validate Short Description │ ├── README.md │ ├── ShortDescriptionLength.js │ ├── validShortDescription.js │ └── validateSpecialChar.js ├── Validate date is in future without GlideAjax │ ├── OnChange Client Script.js │ └── README.md ├── Verify if e-mail already exists with Ajax call │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── clientScript.js │ └── scriptInclude.js ├── Verify whether a date falls within a hour range │ ├── README.md │ └── verifyWhetherADateFallsWithinAHourRange.js ├── Whitespace Validation │ ├── README.md │ └── whitespaceValidation.js ├── g_form console access in workspace │ ├── README.md │ └── script.js ├── onfocus and onblur │ ├── README.md │ └── script.js ├── state-edit-for-grpmem │ ├── README.md │ └── grpmemstateedit.js └── validate phone number │ ├── README.md │ └── validate phone number.js ├── Dynamic Filters └── getMyDirectReports │ ├── README.md │ ├── example_manager_data.png │ ├── getMyReportsUtil.js │ ├── one_of_my_direct_reports.png │ └── one_of_my_reports.png ├── ECMASCript 2021 ├── README.md ├── arrowfunctions.js ├── class.js ├── const.js ├── defaultparms.js ├── destructuring.js ├── forof.js ├── javascriptmode.png ├── let.js ├── map.js ├── openrecord.png ├── set.js ├── spread.js ├── symbol.js └── templatestringsandliterals.js ├── Fix scripts ├── Add Fields On All List Views │ ├── AddFieldsToLists.js │ └── README.md ├── Add Variable set to multiple catalog items │ ├── README.md │ └── script.js ├── Adjust Variable Order on Catalog Item │ ├── README.md │ └── script.js ├── Anonymise Data │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── ScreenShot_4.PNG │ └── script.js ├── Assign user list to a specific group │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── Authenticate using ScriptedRESTAPI │ ├── README.md │ └── script.js ├── AutoNumberIssueFix │ ├── README.md │ └── autonumberingcode.js ├── Bulk Update Catalog Item Images │ ├── README.md │ └── bulk-cat-item-image-update.js ├── Calculate Business Duration │ ├── README.md │ └── calculate-business-duration.js ├── Cancel Workflow │ ├── Cancel Workflow Context.js │ └── README.md ├── Cancel in progress flow executions using flow name │ ├── README.md │ └── script.js ├── Clean update set │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── ScreenShot_4.PNG │ └── script.js ├── Copy favourite to other users │ ├── README.md │ └── favCopy.js ├── De-Provision Admin user (configurable) │ ├── README.md │ └── deprovisionAdmin.js ├── Delete Change Conflict │ ├── README.md │ └── script.js ├── Delete Duplicate Mobile records │ ├── README.md │ └── script.js ├── Employee document management │ ├── read.md │ └── regenerate_document.js ├── Find Reports Assigned to inactive Groups │ ├── README.md │ └── reportAssignedToInactiveGroups.js ├── Find duplicate records │ ├── Find duplicate records.js │ ├── README.md │ ├── TechTrekwithAJ_DuplicateCIreadme.md │ └── TechTrekwithAJ_FindDuplicateonCMDB_CI.JS ├── Find the reports assigned to Inactive Users │ ├── README.md │ └── reportsassignedtoinactiveusers.js ├── Fiscal period renamer │ ├── README.md │ └── fiscal period renamer.js ├── Fix model names after enabling glide.cmdb_model.display_name.shorten │ ├── README.md │ └── fixModelNames.js ├── Fix teams token │ ├── README.md │ └── script.js ├── Get Catalog Items not used in last few months │ ├── README.md │ └── getUnusedCatItems.js ├── Ignore outbound emails │ ├── README.md │ └── ignoremail.js ├── Install Base PDI Plugins │ ├── README.md │ └── install_plugins.js ├── Install Demo Data │ ├── InstallDemoData.js │ └── README.md ├── Log out active User sessions │ ├── README.md │ └── log_out_active_user_sessions.js ├── Mass Update RITM Variable │ ├── README.md │ └── Update RITM Variable.js ├── Measure code time execution │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── Merge stages or choice │ ├── README.md │ └── script.js ├── Migrate data from one table to another │ ├── README.md │ └── script.js ├── Multiply records from filer breadcrumbs │ ├── Multiply records.js │ └── README.md ├── Post-clone Clear Email Queue │ ├── README.md │ └── script.js ├── Post-clone Email Properties Script │ ├── README.md │ └── script.js ├── Post-clone Set Banner Name │ ├── README.md │ └── script.js ├── Post-clone Set Instance Banner │ ├── README.md │ └── set_instance_banner.js ├── README.md ├── Reject RITM via fix script │ ├── README.md │ └── Reject RITM.js ├── Remove leading and trailing spaces │ ├── README.md │ └── RemoveLeadingTrailingSpaces.js ├── Restart Flow (CatalogItem) │ ├── README.md │ └── restart_flow.js ├── Restore From Audit History │ ├── README.md │ └── restore_from_audit_fix.js ├── Run Subscription Job On Demand │ ├── README.md │ └── code.js ├── SchemaGenerator │ ├── README.md │ ├── cmdb_ci_server_schema.json │ └── schemaGenerator.js ├── Search Results Weight │ ├── README.md │ └── sr_weight.js ├── Swiss German Language Update │ ├── README.md │ └── script.js ├── Sync Data Between Instances │ ├── README.md │ └── SyncData.js ├── Syslog_top10Contributors │ ├── README.md │ └── syslog_script.js ├── Update field with value in sys_audit │ ├── README.md │ └── updateFromAudit.js ├── Updateset checker │ ├── README.md │ └── Updateset_checker.js ├── addBulkUsersToVTB.js ├── deleteMultiple │ ├── README.md │ └── code.js ├── get Groups without Member │ ├── README.md │ └── getGroupsWithoutMember.js └── update variable role │ ├── README.md │ └── updateWriteRolesOfVariables.js ├── Flow Actions ├── Add signature and update fields to a fillable PDF document │ ├── README.md │ └── pdf_signature.js ├── Adhoc Assessment Generator Flow Action │ ├── Assessment.js │ └── README.md ├── Assign Role │ ├── README.md │ └── assignRole.js ├── Calculate Ticket Age │ ├── README.md │ └── script.js ├── Check MID Server Availability │ ├── README.md │ └── check_mid_server_availablility.js ├── Create Student Weekday Pickup Schedule │ ├── README.md │ └── script.js ├── Data Stream │ ├── README.md │ └── pagination-setup.js ├── Extract JSON Key without Flow Transformation │ ├── README.md │ └── remove-html-tags.js ├── Generate unique value based on sequence │ ├── README.md │ └── next-unique-sequence.js ├── Get Days difference │ ├── README.md │ └── getDaysDifference.js ├── Get Property │ ├── README.md │ └── getPropertyFlowAction.js ├── Get choice field value (mitigating known error) │ ├── README.md │ └── script.js ├── GetIPRange │ ├── README.md │ └── getIPRange.js ├── How to refer MID server cluster in integration flow step │ ├── MID Server Cluster.js │ └── README.md ├── Look Up MRVS Rows │ ├── LookUpMrvsRowIndex.js │ └── README.md ├── Look up Support group of CI │ ├── LookUpSupportGroupFromCI.js │ └── README.md ├── Milliseconds to Duration │ ├── README.md │ └── millisecondsToDuration.js ├── Remove HTML Tags from a String in a Flow ├── Runscript activities │ ├── CatalogvariablesSummary.js │ └── README.md ├── Scheduled data import trigger │ ├── README.md │ └── Scheduled data import trigger.js ├── ShuffleArrayMatches │ ├── README.md │ └── Shuffle Array Matches.js ├── Trigger event action │ ├── README.md │ └── trigger event flow action.js ├── Validate MID servers status inside cluster │ ├── MID Server Availibility inside MID Server Cluster.js │ └── README.md └── get Catalog Variables as JSON │ ├── README.md │ └── getCatVarsAsJson.js ├── Formula Builder ├── 1.jpg ├── 2.png ├── Get Age From Birthdate │ ├── README.md │ └── script.js └── README.md ├── GlideAggregate ├── Count incidents based on category │ ├── Count incidents based on category.js │ └── README.md ├── Get Incident Count by Priority │ ├── README.md │ └── get-incident-count-by-priority.js ├── Group Count │ ├── GlideQuery.js │ ├── GlideQuery_readme.md │ ├── README.md │ └── code.js ├── Grouping by three columns │ ├── README.md │ ├── ScreenShot_1.PNG │ └── script.js ├── Improve incident handling │ ├── README.md │ └── script.js ├── Incident Analysis and Resolution Calculation using Glideaggregate │ ├── Incident_analysis_Resolution_Calculation_GlideAggregate.js │ └── README.md ├── List of Child Incident of All Incidents │ ├── README.md │ └── allChildIncidents.js ├── List of Managers in User Table │ ├── ListOfManagers.js │ └── README.md ├── List the incident priority count under each category │ ├── README.md │ └── code.js ├── SLA Count by Assignment Group │ ├── README.md │ └── SLA Count by Assignment Group.js ├── ScheduleJob by ExectionTime_perDay │ ├── README.md │ └── script.js ├── Tiered grouping of an integer column │ ├── README.md │ └── script.js ├── Top 5 Users with Most Incidents │ ├── README.md │ └── top-five-users-with-most-incidents.js ├── Using addHaving │ ├── README.md │ ├── ScreenShot_1.PNG │ └── script.js ├── addTrend │ ├── README.md │ └── addTrend.js ├── getCountAfterDate │ ├── README.md │ └── getCountAfterDate.js └── getTotal of aggregate value │ ├── README.md │ └── getTotal.js ├── GlideAjax ├── AjaxAsyncOnSubmit │ ├── README.md │ ├── ajaxasynconsubmitclient.js │ └── ajaxasynconsubmitserver.js ├── EfficientGlideRecord (Client-side) │ ├── ClientGlideRecordAJAX.js │ ├── EfficientGlideRecord (minified) UI Script.js │ ├── EfficientGlideRecord UI Script.js │ ├── Example usage (client-side code).js │ └── README.md ├── Fetch Multiple Values in GlideAjax without JSON │ ├── ClientScript.js │ ├── README.md │ └── TestScriptInclude.js ├── Get Field Values │ ├── GetFieldValuesAjax.js │ └── README.md ├── Get choices from Decision Table │ ├── GetChoicesFromDT.js │ ├── README.md │ └── addChoicesClient.js ├── GlideAjax Example Template │ ├── README.md │ ├── code.js │ └── example from community.js ├── Return Asset(s) for User │ ├── FindUserAsset.js │ └── README.md ├── ReturnMultipleProperties │ ├── README.md │ └── ReturnMultipleProperties.js ├── Reusable GlideAjax │ ├── README.md │ ├── clientCallableScriptInclude.js │ └── clientSideGlideAjax.js └── Reusable glideajax table query │ ├── README.md │ └── getTableColumnsClientSide.js ├── GlideDate ├── Extract and Convert Date in a Text or String to GlideDate Format.js └── README.md ├── GlideDateTime ├── AddDays │ ├── README.md │ └── addDays.js ├── Check if today is weekend │ ├── Check if today is weekend.js │ └── README.md ├── Convert date format │ ├── README.md │ └── script.js ├── ConvertTicksToGlideDateTime │ ├── ConvertTicksToGlideDateTime.js │ └── README.md ├── Current Date with Fixed Time │ ├── CurrentDateFixedTime.js │ └── README.md ├── Due date generation │ ├── README.md │ └── duedate_generation.js ├── Get Date Difference │ ├── GetDiffernceBtnDates.js │ └── README.md ├── Get Next Monday Date │ ├── GetNextMondayDate.js │ └── README.md ├── Get last day of a month │ ├── README.md │ └── getLastDayOfMonth.js ├── Set time zone and date format to output string dates │ ├── README.md │ └── output_string_dates.js ├── Start, End, and Duration Updates │ ├── README.md │ └── start_end_duration_updates.js └── Use timezone in Scoped App │ ├── README.md │ └── script.js ├── GlideElement ├── Display available choices │ ├── DisplayAvailableChoices.js │ └── README.md └── getDependent │ ├── README.md │ └── glideelement.js ├── GlideFilter └── checkRecord │ ├── README.md │ └── example.js ├── GlideHTTPRequest ├── README.md └── glidehttprequest.js ├── GlideModal ├── Confirm Message │ ├── README.md │ └── glide_confirm.js └── Information Message │ ├── README.md │ ├── glide_info.js │ └── glide_warn.js ├── GlideQuery ├── Basic Wrappers │ ├── README.md │ ├── delete_records.js │ ├── get_records.js │ ├── insert_records.js │ └── update_records.js ├── Field Default │ ├── GlideQueryFieldDefault.js │ └── README.md ├── FlatMap to Nest New Queries │ ├── README.md │ └── getIncidentInfoWithFlatMap.js ├── Get Delegates │ ├── GlideQueryGetDelegates.js │ └── README.md ├── Get User's Roles from User Name │ ├── README.md │ └── getUserRoles.js ├── Nested WHERE orWHERE GlideQueries │ ├── README.md │ └── nestedWhereQueries.js └── Remote Table │ ├── README.md │ └── remotetabldef.js ├── GlideRecord ├── ACL enforcement using GlideRecord │ ├── README.md │ └── glideRecordSecure.js ├── Add n number of users to n number of groups using server scripts │ ├── AddUserstoGroups.js │ └── README.md ├── Choose Window for better performance │ ├── README.md │ └── script.js ├── Count Records By Column │ ├── README.md │ └── script.js ├── Display list of records based on Users Location │ ├── README.md │ └── listOfRecordsBasedOnLocation.js ├── Fetch groups that have no members in them │ ├── README.md │ └── fetchEmptyGroups.js ├── Find Date Overlapping │ ├── README.md │ └── isSimilarDates.js ├── Find No Of Days │ ├── README.md │ └── findNoOfDays.js ├── Get All Groups without Manager │ ├── README.md │ └── getGroupsWithoutManager.js ├── Get Contains role of a role │ ├── Get contains role of a role.js │ └── README.md ├── Get Record Fields in JSON │ ├── README.md │ └── script.js ├── Get Reference Record │ ├── GetRecordRequestedBy_Soumyadeep.js │ ├── README.md │ ├── Readme_Soumyadeep.md │ └── script.js ├── Get Variables from RITM │ ├── README.md │ └── getVariablesJSON.js ├── Get all task records with at least on active child task │ ├── Get all task records with at least on active child task.md │ └── code.js ├── Get all user's group based on username │ ├── README.md │ └── script.js ├── Get all users whose email is empty │ ├── README.md │ └── script.js ├── Get field from GlideRecord │ ├── README.md │ └── getField.js ├── Get link for the Record │ ├── README.md │ └── script.js ├── Get-task-containing-sensitive-data │ ├── README.md │ └── script.js ├── Gets the display value according to the specified language │ ├── README.md │ └── specified_language.js ├── GlideRecord to Object │ ├── README.md │ └── _grToObject.js ├── GlideRecord with Performance Enhancement Condtions │ ├── README.md │ └── script.js ├── LEFT Join │ ├── README.md │ ├── example.js │ └── script.js ├── List of Child Incidents │ ├── README.md │ └── listofchildIncident.js ├── Multi Row Variable Set(MRVS) │ ├── InsertMRVSRecords.js │ └── README.md ├── Populate the type of device on any record │ ├── README.md │ └── typeOfDevice.js ├── Record Activity Collector │ ├── ActivityCollector.js │ └── README.md ├── Set Template │ ├── README.md │ └── setTemplate.js ├── Unique Record │ ├── README.md │ └── uniquerecord.js ├── UpdateMultiple │ ├── README.md │ └── script.js ├── Watch_List_functions │ ├── README.md │ └── removeSpecificUser.js ├── comments on gr.update │ ├── README.md │ └── code.js ├── findDuplicate │ ├── GlideAggregateScript.js │ └── README.md ├── getEncodedQuery │ ├── README.md │ └── code.js └── isValidGlideRecord │ ├── README.md │ └── isValidGlideRecord.js ├── GlideSystem ├── Impersonate │ ├── README.md │ └── impersonate.js ├── Session │ ├── README.md │ └── session.js ├── Table │ ├── README.md │ ├── tableExists.js │ └── truncateTable.js ├── Trigger Event │ ├── README.md │ ├── eventQueue.js │ └── eventQueueScheduled.js ├── User Display Name │ ├── README.md │ └── script.js ├── User │ ├── README.md │ └── userID.js ├── date-time │ ├── README.md │ ├── beginningOfLastMonth.js │ ├── minutesAgoEnd.js │ ├── minutesAgoStart.js │ ├── monthsAgo.js │ ├── monthsAgoEnd.js │ ├── monthsAgoStart.js │ ├── quartersAgo.js │ ├── quartersAgoEnd.js │ ├── quartersAgoStart.js │ ├── setDisplayValueInternalWithAlternates.js │ ├── yearsAgo.js │ └── yesterday.js ├── hasRoleExactly │ ├── README.md │ └── script.js └── workflowFlush │ ├── README.md │ └── workflowFlush.js ├── GlideTableDescriptor └── getFirstTableName() │ ├── GlideTableDescriptor.js │ └── README.md ├── GraphQL ├── Sample INC Details GraphQL Code Snippet │ ├── CMDB Resolver.js │ ├── GetIncident_Details.gql │ ├── Incident Resolver.js │ ├── README.md │ ├── User Resolver.js │ └── resolver mapping.js ├── Sample group query │ ├── README.md │ ├── addUserToGroup.js │ ├── add_user_to_group_broker_properties.json │ ├── add_user_to_group_broker_query.gql │ ├── getGroups.js │ ├── get_groups_broker_query.gql │ ├── resolver_mappings.json │ └── schema.gql └── Sample users query │ ├── README.md │ ├── getUserGroups.js │ ├── getUserObject.js │ ├── getUserRoles.js │ ├── get_user_broker_properties.json │ ├── get_user_broker_query.gql │ ├── resolver_mappings.json │ └── schema.gql ├── ITOM ├── Bulk Location Update │ ├── README.md │ └── script.js ├── Discovery │ ├── README.md │ └── Script to trigger quick discovery from workflow or flow.js └── Generate Discovery Schedule │ ├── README.md │ └── script.js ├── Import Set API └── Attachment Handler │ ├── README.md │ ├── attachmentParser.js │ └── attachmentParserUtil.js ├── Inbound Actions ├── Advanced Scripts │ ├── README.md │ ├── cancel_catalog_item_from_email.js │ ├── create_catalog_item_from_email.js │ └── update_catalog_item_from_email.js ├── Auto Reply Email │ ├── README.md │ └── code.js ├── Automate creation of incidents through inbound actions │ ├── README.md │ └── incidentCreation.js ├── Email Text as Attachment │ ├── README.md │ └── script.js └── Incident Creation from Email with Attachments Handling │ ├── README.md │ └── Script.js ├── Integration ├── AzureAD Integration │ └── Dynamically create reference records │ │ ├── Load_cmn_location.js │ │ └── README.md ├── GraphQL Integration API │ ├── CI Resolver.js │ ├── GraphQL schema.js │ ├── Incident Resolver.js │ ├── README.md │ └── User Resolver.js ├── ITSM │ ├── README.md │ └── liveCItoTAsk.js ├── Import Sets Debug │ ├── README.md │ └── debugImportSet.js ├── Import Sets │ ├── README.md │ └── debug │ │ ├── README.md │ │ └── debugImportSet.js ├── Rest Integration Send Attachment Payload │ ├── README.md │ └── attachment_payload_script.js └── Scripted SOAP Incident Creation │ ├── README.md │ └── Scripted SOAP incident creation.js ├── MIDServer └── API Class Examples │ ├── README.md │ └── scripts.js ├── Mail Scripts ├── Add Checklist │ ├── README.md │ └── script.js ├── Add HTML Table for Requested Item Variables │ ├── README.md │ └── requested_items_detail.js ├── Add Users in Watchlist to CC │ ├── Add Users in Watchlist to CC │ └── README.md ├── Add a link which opens ticket in Service Portal │ ├── README.md │ └── script.js ├── Call Script Include in Notification Mail Script │ ├── README.md │ └── call_script_include.js ├── Call UI Message or System Property in Notification Mail Script │ ├── README.md │ └── call_UIMessage_or_sysProperty.js ├── Configurer Approve Reject Buttons Using Email Scripts │ ├── Email Script.js │ └── README.md ├── Convert DateTime to Date │ ├── README.md │ └── script.js ├── Exclude DateTime details from Comments │ ├── README.md │ └── commentsWithoutDateTime.js ├── HTML Table Creation from ServiceNow Table │ ├── MailScript.js │ └── README.md ├── Open Survey In Portal │ ├── README.md │ └── open_survey.js ├── Print variables to mail │ ├── README.md │ └── printVarsToMail.js ├── PrintRecordDetailsinEmailBody │ ├── README.md │ └── print_record_details_to_body.js ├── RITM Reject Reason │ ├── README.md │ └── reject_reason_new.js └── cc all group members │ ├── README.md │ └── cc all group members.js ├── NOW Experience └── JSX Cheat Sheet │ └── README.md ├── Notifications ├── Conditional Trigger │ ├── Notification_AdvancedCondition.js │ └── README.md └── Notify Users on Specific Date │ ├── NotifyUsers.js │ └── README.md ├── On-Call Calendar ├── README.md └── show_group_on_call_schedule.js ├── Performance Analytics └── Configure Indicators in Batch │ ├── ConfigurePAIndicators.js │ └── README.md ├── Processors └── Dynamic Sitemap │ ├── README.md │ ├── dynamicSitemapProcessor.js │ └── snow-sitemap-results.png ├── README.md ├── RESTMessageV2 ├── API for Automatic Group creation │ ├── Automate Group Creation.js │ └── README.md ├── AzureDevOps │ ├── README.md │ └── azure.js ├── Google-Chat │ ├── README.md │ └── sendgchatmessage.js ├── Integration Between 2 Instance │ ├── IntegrationBetweenTwoInstancesWithReturnoftheCreatedRecordNumber.js │ └── README.md ├── Jira │ ├── README.md │ └── createJiraTask.js ├── Reusable RESTMessageV2 retry pattern │ ├── README.md │ └── ReusableRESTMesaageV2Retry.js ├── Web Scraping REST Message │ ├── README.md │ └── code.js └── youtubeclient │ ├── README.md │ └── youtubeclient.js ├── Record Producer └── Create Records By Import Set │ ├── README.md │ ├── config1.png │ ├── config2.png │ ├── config3.png │ └── createRecordsByImportSet.js ├── Regular Expressions ├── Allow Characters + - ) ( for Phone numbers │ ├── README.md │ └── allowsCharsForPhnNumber.js ├── AllowAnyLanguage │ ├── README.md │ └── allowanylanguage.js ├── Check if number has 10 digits │ ├── README.md │ └── script.js ├── Credit Card Number Validator │ ├── README.md │ └── validateCreditCard.js ├── Email Address Validation │ ├── README.md │ └── isEmail.js ├── Encode spaces for URLs │ ├── README.md │ └── convert.js ├── Ethiopia country code │ ├── README.md │ └── script.js ├── Extracting Product Codes and Prices from a String │ ├── Extracting Product Codes and Prices from a String.js │ └── README.md ├── Find Emoji │ ├── README.md │ └── index.js ├── Format mobile into Australian mobile format │ ├── Format phone in Australian mobile format.js │ └── README.md ├── Hexadecimal color │ ├── README.md │ └── validateHexColor.js ├── IP Address Validation │ ├── README.md │ ├── getIP4OrIPV6address.js │ └── validateIPInput.js ├── ISBN Validator │ ├── README.md │ └── validateISBN.js ├── Indian Mobile Numbers │ ├── README.md │ └── code.js ├── Match URL's from ServiceNow domain │ ├── README.md │ ├── ScreenShot_1.PNG │ └── script.js ├── Negative RegExp for Condition Builder │ ├── NegativeRegExExample.js │ └── README.md ├── PAN Card Validation Script │ ├── README.md │ └── Script.js ├── Password Strength Checker │ ├── README.md │ └── passwordStrength.js ├── Poland country code │ ├── README.md │ ├── ScreenShot_1.PNG │ └── script.js ├── Regular-expression-for-alphanumeric-characters │ ├── AlphanumericCharacters.js │ └── README.md ├── Remove Extra Spaces │ ├── README.md │ └── index.js ├── Remove all HTML Tags │ ├── README.md │ └── Remove all html tags.js ├── Remove newline and carriage return │ ├── README.md │ └── remove cr and nl.js ├── SSN Formatting │ ├── Index.js │ └── README.md ├── UK Country Code │ ├── README.md │ └── script.js └── URL Validation │ ├── README.md │ └── validateURL.js ├── Scheduled Jobs ├── Approval Reminder │ ├── README.md │ ├── change_reminder_scheduled_job.js │ ├── requested_item_approval_reminder_approver.js │ └── requested_item_approval_reminder_requestor.js ├── Auto close changes requests updated 30 days prior │ ├── README.md │ └── script.js ├── Calculate Ticket's Aging │ ├── Calculate Ticket's Aging.js │ └── README.md ├── Condition script to trigger the scheduled job on Quarterly basis │ ├── Condition script to trigger the scheduled job on Quarterly basis.js │ └── README.md ├── Create Scheduled Imports Graphviz file │ ├── README.md │ └── script.js ├── Create send reminders weekly │ ├── README.md │ └── code.js ├── Daily detection of customer updates made in 'Default' update set │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── Deactivate INC in 90 days │ ├── 90daysInactiveScript.js │ └── README.md ├── Deactive and Reactivate Catalog Items │ ├── Deactivate Cat Item Scheduled Job.png │ ├── README.md │ └── schedule-deactivation.js ├── Get All Catalog Tasks without Request items │ ├── catalogTaskWithoutReqItem.js │ └── catalogTaskWithoutReqItem.md ├── Lock out users who have not logged into the system longer than 30 days │ ├── README.md │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ └── script.js ├── Paginated Export │ ├── Paginated Export.md │ └── paginatedExport.js ├── PostUserDisabledActivity │ ├── README.md │ └── script.js ├── Reject approvals created before an year │ ├── README.md │ └── Reject Approvals Created Before an Year.js ├── Remove Inactive and locked out users from All Groups and Roles │ ├── README.md │ └── code.js ├── ScheduleAtSpecificDaysAndTimes │ ├── README.md │ └── schedulejobcondition.js ├── Survey Trigger Scheduled Script │ ├── README.md │ └── survey_trigger_sj.js ├── Unpublish Public Reports │ ├── README.md │ └── UnpublishReports.js └── Update Inactive Application Owner │ ├── README.md │ └── Update Inactive Application Owner.js ├── Script Actions └── Custom Table Helper │ ├── README.md │ └── Script Action.js ├── Script Includes ├── API Model Template for New Application │ ├── AbstractStrategy.js │ ├── AbstractStrategyBase.js │ ├── ApplicationCore.js │ ├── ApplicationCoreBase.js │ ├── Engine.js │ ├── EngineBase.js │ ├── ExampleObject.js │ ├── ExampleObjectBase.js │ ├── ExampleStrategy1.js │ ├── ExampleStrategy1Base.js │ ├── ExampleStrategy2.js │ ├── ExampleStrategy2Base.js │ └── README.md ├── Add and Remove Group Member │ ├── README.md │ └── groupMember.js ├── Approval Rule Builder │ ├── ApprovalRuleBuilder.js │ └── README.md ├── Array prototypes │ ├── ArrayPrototypes.js │ └── README.md ├── ArrayUtil │ ├── README.md │ └── script.js ├── Assign role for a day Util │ ├── AssignRoleToUserForADay.js │ └── README.md ├── Auto Execute Import Set on File Attachment │ ├── CreateImportSetAndRunTransform.js │ ├── CreateSysTrigger.js │ └── README.md ├── Autopopulate caller location in short description │ ├── README.md │ ├── getCallerLocation.js │ └── updateCallerLocationinShortDesc.js ├── BackfillAssignmentGroup │ ├── BackfillAssignmentGroup.js │ └── README.md ├── BenchmarkRunner │ ├── BenchmarkRunner.js │ └── README.md ├── CSV Parser │ ├── CSVParser.js │ └── README.md ├── CacheHelper │ ├── CacheHelper.js │ └── README.md ├── Catalog Item Pricing │ ├── README.md │ └── calculate_catalog_item_price.js ├── CatalogUtils │ ├── CatalogUtils.js │ └── README.md ├── Check User Criteria for Catalog Item │ ├── README.md │ └── checkUserCriteria.js ├── Check User Has Role │ ├── README.md │ └── UserHasRole.js ├── Check Valid Choice │ ├── README.md │ └── script.js ├── Check writer │ ├── CheckWriter.js │ └── README.md ├── Client and Server Callable Script Include │ ├── README.md │ └── script include.js ├── Collect Field Values from Any One Table Record │ └── universalRecordCollector.js ├── Collect Field Values from Any Table │ └── README.md ├── ConnectionCredentialsUtils │ ├── ConnectionCredentialUtils.js │ └── README.md ├── ConversationUtils │ ├── ConversationUtils.js │ └── README.md ├── Convert image into base64 │ ├── Convert image into base63 encoded string.js │ └── README.md ├── Create Multiple RITMS from MRVS │ ├── CreateMultipleRITMSFromMRVS.js │ └── README.md ├── Custom Discovery Schedule With Freeze Periods │ ├── DiscoveryScheduleWithFreezePriod.js │ └── README.md ├── CustomArrayUtils │ ├── CustomArrayUtils.js │ └── README.md ├── CustomDateUtils │ ├── CustomDateUtils.js │ └── README.md ├── CustomObjectUtils │ ├── CustomObjectUtils.js │ └── README.md ├── CustomUserUtils │ ├── CustomUserUtils.js │ └── README.md ├── Data Lookup Table Utils │ ├── DataLookupUtils.js │ └── README.md ├── Delete Multiple Records Async │ ├── DeleteMultipleRecordsAsync.js │ └── README.md ├── Deprecate Field │ ├── README.md │ ├── Result.png │ └── script.js ├── Dynamic Dropdown List │ ├── Client.js │ ├── README.md │ └── UtilScript.js ├── EvtMgmtCustom_PostTransformHandler │ ├── EvtMgmtCustom_PostTransformHandler.js │ └── README.md ├── Excel Attachment Via script │ ├── README.md │ └── excelAttachment.js ├── Excel Parser │ ├── README.md │ └── excelParser.js ├── Extending OOB TableUtils │ ├── EXT_TablesUtils.js │ └── README.md ├── Financial Service Utilities │ ├── FinancialServiceUtilities.js │ └── README.md ├── Find months between two dates │ ├── DateUtil.js │ └── README.md ├── Generate QR Code and attach to RITM │ ├── README.md │ └── script.js ├── Get Approvers of a Ticket │ ├── GetApproversForATicket.js │ └── README.md ├── Get Choice Display Value │ ├── README.md │ └── getChoiceDisplayValue.js ├── Get Current User Information │ ├── README.md │ └── getCurrentUserInformation.js ├── Get Field Label in Specific Language │ ├── README.md │ └── script.js ├── Get Group Members │ ├── README.md │ └── getGroupMembers.js ├── Get Reference Display Value │ ├── README.md │ └── getReferenceDisplayValue.js ├── GetCallerDetails │ ├── Calling Script Include from client.js │ ├── README.md │ └── scriptinclude.js ├── GlideDateTimeUtils │ ├── ClientDateTimeUtils.js │ └── README.md ├── GlideRecord to JSON │ ├── README.md │ └── gr2obj.js ├── GlideRecordHelper │ ├── README.md │ └── script.js ├── HTMLUtils │ ├── README.md │ └── script.js ├── Hybrid Script Include for AJAX or Server Side Parameters │ ├── README.md │ └── ScriptInclude.js ├── Inactive User │ ├── InactiveUserCleanup.js │ └── README.md ├── Install base items with active cases │ ├── README.md │ └── script.js ├── JSONPath │ ├── JSONPath.js │ └── README.md ├── JSONtoYAML │ ├── README.md │ └── code.js ├── KBArticleExpPDF │ ├── ArticlePDFHelper.js │ └── README.md ├── ListFieldUtil │ ├── ListFieldUtil.js │ └── README.md ├── Logger │ ├── Logger.js │ └── README.md ├── ManagerRecursiveUtil │ ├── README.md │ └── RecursiveByManager.js ├── Match URL with a String │ ├── MatchURLByRegex.js │ └── README.md ├── Non Prod Instance Password Reset │ ├── README.md │ └── passwordReset.js ├── NotificationUtil │ ├── NotificationUtil.js │ └── README.md ├── Number Padding │ ├── README.md │ └── numberPadding.js ├── OAuth token helper │ ├── OAuthTokenHelper.js │ └── README.md ├── OrderedRecords │ ├── README.md │ └── orderedRecords.js ├── PII Redactor │ ├── README.md │ └── piiRedaction.js ├── Password Generator with specific length │ ├── PasswordGenerator.js │ └── README.md ├── PerformanceAnalyticsUtils │ ├── PerformanceAnalyticsUtils.js │ └── README.md ├── Project Base Line │ ├── README.md │ └── latestPlannedBaseline.js ├── Public Script Include search │ ├── README.md │ └── script.js ├── PullEmptySerialNumberAssetRecords │ ├── README.md │ └── pull_empty_serial_number_record.js ├── RecordProducerVariableUtils │ ├── README.md │ ├── RecordProducerVariableUtils_v1.0.xml │ └── script.js ├── Records Calculator │ ├── README.md │ └── RecordsCalculator.js ├── Regex utils │ ├── README.md │ └── RegexUtils.js ├── Reparent Table │ ├── README.md │ └── script.js ├── Request Approval Helper │ ├── README.md │ └── RequestApprovalHelper.js ├── RequestNotificationUtil │ ├── README.md │ └── RequestNotificationUtil.js ├── Retrieve Last Comment by Ticket │ ├── README.md │ └── RetrieveLastCommentByTicket.js ├── Return Object │ ├── README.md │ └── ReturnObject.js ├── Role Checker Util │ ├── README.md │ └── checkUserRole.js ├── SCIM Custom Mapping Handler │ ├── README.md │ └── SCIMCustomMappingHandler.js ├── SCIM Payload Generator │ ├── GenerateSCIMPayload.js │ └── README.md ├── SRAPIUtil │ ├── README.md │ └── SRAPIUtil.js ├── Scheduled Recursion │ ├── README.md │ ├── background_script.js │ └── scheduled_recursion.js ├── Single Sign-On (SSO) Direct Login URL Generator │ ├── README.md │ └── UserHelper.js ├── Slack JSON Block Factory │ ├── README.md │ ├── Slacktory.js │ └── sys_script_include_config.md ├── Standard Change Creator │ ├── README.md │ ├── sys_script_include.js │ └── sys_script_include_config.md ├── StarterPack │ ├── AjaxClientScript.js │ ├── AjaxSI.js │ ├── README.md │ ├── classless.js │ ├── constants.js │ ├── reference.js │ └── utilsExample.js ├── Stopwatch │ ├── README.md │ └── Stopwatch.js ├── Store data in User Session │ ├── README.md │ └── storeDataInSession.js ├── StripHTML │ ├── README.md │ └── StripHTML.js ├── SubProdLogger │ ├── README.md │ └── SubProdLogger.js ├── Table List Copy Context Options │ ├── Copy Field Display Value Context Menu.js │ ├── Copy Field Name Context Menu.js │ ├── Copy Field Value Context Menu.js │ ├── README.md │ └── Script Include.js ├── TableUtils Extension │ ├── Enhanced_TableUtils.js │ └── README.md ├── Testing Script Include Using Jasmine │ ├── README.md │ ├── Sample Calculator Script Include.js │ └── Sample Jasmine Script.js ├── TimeZoneUtils │ ├── README.md │ └── TimeZoneUtils.js ├── TinyURLHelper │ ├── README.md │ └── TinyUrlHelper.js ├── Translations Import │ ├── README.md │ └── script.js ├── UnloadXml │ ├── README.md │ └── script.js ├── UserCriteriaUtil │ ├── README.md │ └── UserCriteriaUtil.js ├── UserUtil │ ├── README.md │ ├── UserUtil.js │ └── userMemberOf.png ├── Validate Data Before Insert │ ├── DataValidationUtils.js │ └── README.md ├── VariableHelper │ ├── README.md │ └── variableHelper.js ├── VariableToDescription │ ├── README.md │ └── VariableToDescription.js ├── attachments │ ├── README.md │ └── attachment.js ├── get field values for multiple records from a table │ ├── README.md │ └── script.js ├── getCountFunction │ ├── README.md │ ├── callingSI.js │ └── code.js ├── getGlideRecordObject │ ├── README.md │ └── getGlideRecordObject.js └── regexCheckerScript │ ├── README.md │ └── regexCheckerScript.js ├── Scripted REST Api ├── Approval APIs │ ├── ApprovalRestResource.js │ ├── README.md │ ├── RejectRestResource.js │ └── SRApprovalsAPI.js ├── Approval on Behalf │ ├── README.md │ └── approval_on_behalf.js ├── CMDB API │ ├── CmdbApi.js │ ├── CreateCIs.js │ ├── CreateCiRelationship.js │ ├── DeleteCI.js │ ├── DeleteCiRelationship.js │ ├── README.md │ ├── RetrieveCiGroup.js │ ├── RetrieveCis.js │ ├── Retrieve_CI_Relationships.js │ ├── RetriveCiRelationshipTypes.js │ └── UpdateCi.js ├── CURL Script to create incident via tableAPI │ ├── README.md │ └── script.curl ├── CopyAI Generative AI example │ ├── README.md │ ├── image.png │ └── script.js ├── Difference between two users │ ├── README.md │ ├── output.txt │ └── script.js ├── Get_Choices │ ├── README.md │ ├── script.js │ ├── script.png │ └── scripted_rest_resource.png ├── Promise API Call │ ├── README.md │ └── promiseApiCall.js ├── Retrieve all variables from RITM │ ├── CHVarUtils_ScriptInclude.js │ ├── README.md │ ├── output_example.js │ └── scripted_rest_api.js ├── Tag API │ ├── README.md │ ├── Screenshot 2023-10-11 at 12.51.24 PM.png │ ├── Screenshot 2023-10-11 at 12.51.59 PM.png │ └── insert-tag.js ├── Update the variables or fields in sc_task or RITM │ ├── README.md │ └── Scripted_rest_api.js └── compare roles │ ├── README.md │ ├── output.txt │ └── script.js ├── Server Side ├── CallScriptIncludeWithParameters │ ├── README.md │ └── script.js ├── CheckTableExtension │ ├── README.md │ └── istableextended.js ├── Create Admin Users │ ├── README.md │ └── create_admin_user.js ├── Create Tiny Url with API's │ ├── README.md │ └── tinyUrl.js ├── CreateUpdateCIThroughIRE │ ├── README.md │ └── createupdateciinire.js ├── Custom Relationship │ ├── README.md │ └── script.js ├── DiscoveryDeviceHistory │ ├── devicehistory.js │ └── readme.me ├── ExecuteWorkOnMidServer │ ├── README.md │ └── executeworkonmid.js ├── FetchJSONObject │ ├── README.md │ └── script.js ├── Get all Catalog items associated to variable set │ ├── README.md │ └── script.js ├── Get all variables of catalog item │ ├── README.md │ └── script.js ├── Parse csv file and read each row │ ├── README.md │ └── read csv logic.js ├── Phone Number formating(US Region) │ ├── README.md │ └── script.js ├── Random Password generator │ ├── README.md │ └── script.js ├── Restart Flow on RITM │ ├── README.md │ └── restartFlow.js ├── Restart a workflow via any server side script │ ├── README.md │ └── script.js ├── Trigger Assessments through Script │ ├── README.md │ └── trigger assessment.js ├── Update Sets Scopes Issues Fix Automation │ ├── FixUpdatesScope.js │ ├── PreventCompletiononScopeConflict.js │ ├── README.md │ └── UpdateSetUtilCustom.js ├── Update Variable Choices │ ├── README.md │ └── updateVariableChoices.js ├── User Criteria │ ├── Does User Match Criteria(s).js │ └── README.md ├── Version 4 UUID Generator │ ├── README.md │ └── uuid_generator.js └── getUserGroupMembers │ ├── README.md │ └── script.js ├── Service Portal Widgets ├── Accordion Widget │ ├── Accordion Widget Image.png │ ├── CSS-SCSS.scss │ ├── HTML Template.html │ └── README.md ├── AngularJS Directives and Filters │ ├── README.md │ ├── client_script.js │ ├── css.css │ ├── html.html │ └── server_script.js ├── ApplyCSSDynamically │ ├── README.md │ ├── applycssdynamically.html │ ├── applycssdynamicallyclient.js │ └── applycssdynamicallyserver.js ├── Batman Animation │ ├── Batman Background Image.jpg │ ├── Batman logo.png │ ├── README.md │ ├── client_script.js │ ├── html_template.html │ └── style.css ├── Calendar widget │ ├── README.md │ ├── index.html │ ├── script.js │ └── style.css ├── Card Image Link │ ├── README.md │ ├── doc │ │ ├── card_result.png │ │ └── card_setup.png │ ├── mm_card.html │ ├── mm_card_client_script.js │ ├── mm_card_css.css │ ├── mm_card_server_script.js │ └── mm_card_widget_schema.json ├── Catalog Item Explorer │ ├── README.md │ ├── client_script.js │ ├── css.scss │ ├── options_schema.json │ ├── script.js │ └── template.html ├── Change Notification Preferences │ ├── README.md │ ├── client.js │ ├── css.css │ ├── html.html │ ├── notification_preference.js │ └── server.js ├── Check if user has specific role inside the widget │ ├── ClientScript.js │ └── README.md ├── Clickable SVG Image │ ├── README.md │ ├── client.js │ ├── echarts.js │ ├── flight-seats.svg │ └── html.html ├── Client side pagination │ ├── README.md │ └── script.js ├── Configurable Card Widget │ ├── CSS-SCSS.scss │ ├── Client Script.js │ ├── HTML Template.html │ ├── README.md │ ├── Widget Options.json │ └── image.png ├── Create diagram using GoJS library │ ├── README.md │ ├── body.html │ ├── client.js │ └── style.css ├── Create diagram using Highcharts library │ ├── README.md │ ├── body.html │ └── client.js ├── Custom Greetings in portal homepage │ ├── README.md │ ├── homepage-search-client.js │ └── homepage-search.html ├── Digital Clock │ ├── README.md │ ├── index.html │ ├── script.js │ └── style.css ├── Drag & drop Widget │ ├── README.md │ ├── client.js │ ├── html.html │ ├── remove_icon.png │ └── server.js ├── Drawer Buttons │ ├── README.md │ ├── html_template.html │ └── style.css ├── Dropdown Widget │ ├── README.md │ ├── index.html │ ├── script.js │ └── style.css ├── Export table in portal │ ├── README.md │ ├── export.html │ └── export.js ├── Floater Feedback Widget │ ├── README.md │ ├── demo.JPG │ └── feeback_floater.js ├── Generate QrCode │ ├── Dependencies │ │ └── qrcode.js │ ├── Generated QRCode.png │ ├── README.md │ ├── qrcode.html │ └── qrcode_client.js ├── Guest Login Modal │ ├── README.md │ ├── Service Portal - Guest Login Modal Widget.xml │ ├── client.js │ ├── guest_login_modal_example.png │ ├── ng-template.html │ ├── optionSchema.json │ └── server.js ├── HTML List Table from GlideRecord with JSon │ ├── README.md │ ├── ServerScript.js │ └── html.html ├── ImportXml │ ├── README.md │ └── importXml.js ├── Incident Sound Alerts │ ├── README.md │ └── incident_alerts_widget.js ├── Konami Code Easter Egg │ ├── KonamiCodeEasterEgg.js │ └── README.md ├── Location hierarchy │ ├── README.md │ ├── client controller.js │ ├── css.css │ ├── html.html │ └── server script.js ├── Mouse Effect │ ├── README.md │ ├── index.html │ ├── script.js │ └── style.css ├── Open in Platform │ ├── README.md │ ├── body.html │ └── server.js ├── Paginated Data │ ├── README.md │ ├── paginated-data-server-script.js │ └── paginated-data.html ├── Pagination widget with next and previous button │ ├── CSS.css │ ├── First Page.png │ ├── HTML_Script.html │ ├── Last Page.png │ ├── README.md │ ├── client_controller.js │ └── server_script.js ├── Portal widgets Performance Test │ ├── README.md │ └── code.js ├── Recently Viewed Items │ ├── README.md │ ├── Recently viewed widget.png │ └── recently-viewed-items-widget.js ├── Record process flow │ ├── PortalUtils.js │ ├── PortalUtilsBase.js │ ├── README.md │ ├── body.html │ ├── server.js │ └── style.css ├── RecordPickerForListReference │ ├── README.md │ ├── recordpicker.html │ ├── recordpickerclient.js │ └── recordpickerserver.js ├── Redirect to different portals based on browser │ ├── README.md │ └── redirect_to_different_portals_based_on_browser.js ├── Set Variables By Url │ ├── README.md │ └── client.js ├── Spiderman Animation │ ├── README.md │ ├── client_script.js │ ├── greengoblin.png │ ├── html_template.html │ ├── spid.png │ ├── spider.mp3 │ └── style.css ├── Squid Game Themed Incident-Request-Knowledge │ ├── README.md │ ├── Squid Game Themed Incident-Request-Knowledge Widget Preview.png │ ├── squid_circle_staff.png │ ├── squid_game_irk.css │ ├── squid_game_irk.html │ ├── squid_honeycomb_candy.png │ ├── squid_square_staff.png │ └── squid_triangle_staff.png ├── Squid Game Themed Simple List │ ├── README.md │ ├── Squid Game Themed Simple List - Preview.png │ ├── squid_game_coffin.png │ ├── squid_game_simple_list.css │ └── squid_game_simple_list.html ├── Squid Game Themed User Profile Card │ ├── README.md │ ├── Squid Game Themed User Profile Card - Back - Preview.png │ ├── Squid Game Themed User Profile Card - Front - Preview.png │ ├── squid_game_card.png │ ├── squid_game_user_profile_card.css │ └── squid_game_user_profile_card.html ├── Standard Ticket Header With On Hold Reason │ ├── README.md │ └── ticket_header.png ├── Standard Ticket Page Enhanced Action Widget │ ├── README.md │ ├── enhanced_action_sp_widget.png │ ├── sp_widget_std_action.xml │ └── standard_ticket_config.png ├── Tab Panel Widget │ ├── CSS-SCSS.scss │ ├── HTML Template.html │ ├── Image 1.png │ ├── Options.json │ ├── README.md │ └── image 2.png ├── Upload Files │ ├── README.md │ ├── body.html │ ├── client.js │ ├── server.js │ └── style.css ├── g_form on SP │ ├── README.md │ ├── gform_on_sp.html │ ├── gform_on_sp_client.js │ └── gform_on_sp_server.js └── iFrame │ ├── README.md │ ├── Service Portal - iFrame Widget.xml │ ├── client.js │ ├── optionsSchema.json │ ├── server.js │ ├── style.scss │ └── template.html ├── Service Portal ├── Active Tickets Dashboard │ ├── README.md │ ├── active_tasks_service_script.js │ ├── active_tickets_client_script.js │ ├── active_tickets_dashboard.css │ └── active_tickets_dashboard.html ├── Search Sources │ ├── Approvals.html │ ├── DataFetchScript.js │ └── README.md ├── dark-mode-switcher │ ├── README.md │ ├── avatarDropDown.js │ ├── dark_mode.scss │ ├── demo.gif │ ├── portal_theme.scss │ └── themeSwitcherMenu.js ├── instance-badge │ ├── README.md │ └── header.png ├── sn-avatar │ ├── 2021-10-15-23-18-40.png │ ├── 2021-10-15-23-22-31.png │ ├── 2021-10-15-23-25-15.png │ └── README.md ├── sn-choice-list │ ├── README.md │ ├── screen1.png │ └── screen2.png ├── sn-record-picker │ ├── 2021-10-16-01-08-46.png │ ├── 2021-10-16-01-10-08.png │ ├── 2021-10-16-01-11-40.png │ └── README.md ├── sn-time-ago │ ├── README.md │ └── sp_widget_sn_timeago_demo.xml ├── sn-watchlist │ ├── README.md │ ├── sn-watchlist.gif │ └── snWatchListDirective.js ├── sp-date-picker │ ├── README.md │ └── sp-date-picker.png ├── sp-editable-field │ ├── 2021-10-17-00-17-56.png │ └── README.md ├── sp-modal │ ├── README.md │ └── script.js ├── spGlideAjax │ ├── README.md │ └── spGlideAjaxService.js ├── sparkling │ ├── README.md │ └── sparkling.gif ├── userPreferences │ └── README.md └── validate-data-field │ ├── README.md │ └── script.js ├── Styles ├── Add Background Color to a field │ ├── README.md │ └── style.css ├── Add attachment icon-list view │ ├── README.md │ ├── style.css │ └── value.js ├── Change text color of a field │ ├── README.md │ └── style.css ├── Hide MRVS Buttons │ ├── README.md │ └── styles.html └── ServiceNow Custom Style │ ├── README.md │ └── style.css ├── Transform Map Scripts ├── Choice Field Validator │ ├── README.md │ ├── choiceValidatorUtil.js │ ├── choice_validador1.png │ └── choice_validador2.png ├── Conditional Coalesce │ ├── README.md │ ├── conditional_coalasce.js │ └── conditional_coalesce.png ├── Email Formatter │ ├── README.md │ └── emailFormatterValidator └── Verify headers of a CSV attached file │ ├── README.md │ ├── example.csv │ └── verifyCSVHeaders.js ├── UI Actions ├── Add Show Workflow Related link │ ├── README.md │ └── script.js ├── Add collapsible element in knowledge article │ ├── README.md │ ├── UI_Action.js │ └── add_collapsible.js ├── Call Subflow │ ├── README.md │ └── script.js ├── CallingPopUpBoxInListView │ ├── README.md │ └── calling_pop_up_box_in_list_view.js ├── Cancel Incident │ ├── README.md │ └── script.js ├── Clone incident on Agent Workspace │ ├── README.md │ ├── clone_incident.js │ └── workspace_client_script.js ├── Close child incident │ ├── README.md │ ├── clientScript.js │ └── serverScript.js ├── Convert Request to Incident │ ├── README.md │ ├── UIActionScreenshot.png │ └── script.js ├── Copy Variable Set │ ├── README.md │ └── scripts.js ├── Copy incident details and create a child incident │ ├── README.md │ └── ui_action_script.js ├── Create Incident from Record - Open in both Platform and Workspace │ ├── README.md │ └── script.js ├── Create New blank incident from the incident │ ├── README.md │ └── script.js ├── Create Problem Record from any Table │ ├── CreateProblemRecord.js │ └── README.md ├── Create Problem Task from the Problem │ ├── README.md │ └── script.js ├── Create Update Set on DEV │ ├── README.md │ └── script.js ├── Create incident task and relate to incident │ ├── README.md │ └── script.js ├── Create story │ ├── Create story from other task.js │ └── README.md ├── Display a 2-choice confirmation dialog │ ├── README.md │ └── choice_dialog.js ├── Force to Update Set │ ├── README.md │ └── script.js ├── GlideModalForm - Open New Record and Pass Query │ ├── README.md │ └── code.js ├── GlideModalUiPagePopUp │ ├── README.md │ └── glide_modal_ui_pop_up.js ├── Go to Agent Workspace Home Page │ ├── README.md │ └── ui_action_script.js ├── Mark Records Inactive - List Action │ ├── README.md │ ├── listAction.js │ └── scriptInclude.js ├── Open Email Client using UI Action │ ├── README.md │ └── open_email_client.js ├── Open LIST UI Action │ ├── README.md │ └── UIActionscript.js ├── Open Record in Alternate Instance │ ├── README.md │ ├── RESTMessageV2 │ │ ├── sys_rest_message_config.md │ │ └── sys_rest_message_fn_config.md │ ├── Script Includes │ │ ├── README.md │ │ ├── sys_script_include.js │ │ └── sys_script_include_config.md │ ├── Scripted REST API │ │ ├── sys_ws_definition_config.md │ │ └── sys_ws_operation │ │ │ ├── sys_ws_operation.js │ │ │ └── sys_ws_operation_config.md │ └── UI Action │ │ ├── sys_ui_action.js │ │ └── sys_ui_action_config.md ├── Open Record producer from Form Button In Configurable workspace │ ├── OpenItem.js │ ├── ParseUrl.js │ └── README.md ├── Open a new blank form │ ├── README.md │ └── script.js ├── Open in Service Operations Workspace │ ├── README.md │ └── ui_action_script.js ├── Preview context record during approval │ ├── README.md │ ├── TestScriptInclude.js │ └── UI_Action.js ├── Select Random User From Group │ ├── README.md │ └── script.js ├── Send notification if the incident remains unassigned │ ├── README.md │ └── script.js ├── Send notification to the assigned user │ ├── README.md │ └── script.js ├── Set Incident Priority Critical │ ├── README.md │ └── script.js ├── Show Today Emails Logs │ ├── README.md │ └── script.js ├── Test and Debug Scheduled Scripts │ ├── README.md │ └── script.js ├── Try Catalog item in Portal view │ ├── README.md │ └── TryItInSP.js ├── UI Action to Mark Incident as Escalated │ ├── README.md │ └── Script.js └── View in Portal Page │ ├── README.md │ └── View in Portal Page.js ├── UI Macros ├── Copy To Clipboard │ ├── README.md │ └── copy_field_to_clipboard.xml ├── Purchase Order Approval Summarizer │ ├── README.md │ ├── approval_summarizer_proc_po.png │ └── approval_summarizer_proc_po.xml └── Variable Copy Context Options │ ├── README.md │ └── element context.xml ├── UI Pages ├── CMDB CI Management UI page │ ├── ci_client_script.js │ ├── ci_lifecycle_ui_page.xml │ └── ci_script_include.js ├── Custom Alert using UI Page │ ├── README.md │ ├── client script.js │ ├── custom alert.js │ └── image.png ├── Dynamic program status overview │ ├── Program details dynamic content block.xml │ ├── README.md │ ├── dynamic program status.JPG │ ├── program_list.html │ └── program_list.js ├── EDM DocUnifiedSearch │ ├── EDMSearch.js │ ├── README.md │ ├── client script.js │ └── code.html ├── Export UI pages to word docx │ ├── Export to word.js │ └── README.md ├── Fetch Table(Incident) fields in UI Page │ ├── Fetch incident fields.js │ └── README.md ├── Populate Glide List field │ ├── README.md │ ├── populateGlideListClientScript.js │ └── populateGlideListHTML.js ├── Real time log watcher │ ├── README.md │ ├── TestScriptInclude.js │ └── log_watcher.js └── UI Page Auto Populate Assigned to based on Assignment group │ ├── README.md │ ├── client_script.js │ ├── jelly_script.xml │ └── script_include.js ├── UI Scripts ├── Display number of created records │ ├── README.md │ ├── onLoad.js │ └── ui_script.js ├── Make OOB Attachment Mandatory │ ├── README.md │ └── setAttachmentMandatory.js ├── Observe MRVS Events │ ├── MRVSUtils.js │ └── README.md └── Restrict URL Hack using UI script │ ├── README.md │ └── script.js ├── UX Client Script Include ├── README.md └── Record Operation Utilities │ ├── README.md │ └── script.js ├── UX Client Scripts ├── debug-event │ ├── README.md │ └── debug-event.js └── debug-state │ ├── README.md │ └── debug-state.js └── UX Data Broker Transform ├── FetchSysProperty ├── README.md └── sysPropdataBroker.js ├── create-update-user-preference ├── README.md └── create-update-user-preference.js └── starter-template ├── README.md └── template.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Agile Development/Burndown Chart/requirements.txt: -------------------------------------------------------------------------------- 1 | jpholiday==0.1.10 2 | matplotlib==3.9.2 3 | numpy==2.0.2 4 | pandas==2.2.3 5 | pytz==2024.2 6 | requests==2.32.3 7 | urllib3==1.26.13 8 | -------------------------------------------------------------------------------- /Attachments/Attachment to Base64/README.md: -------------------------------------------------------------------------------- 1 | # Base64 file encoder 2 | 3 | Convert attachment to Base64 -------------------------------------------------------------------------------- /Attachments/Attachment to base64 in scope/README.md: -------------------------------------------------------------------------------- 1 | Encode attachment to base64 for scoped applications. Uses the GlideSysAttachment API. 2 | Place of use: creating a spoke/integration where you need to send an attachment via REST. 3 | -------------------------------------------------------------------------------- /Attachments/CSVParser/README.md: -------------------------------------------------------------------------------- 1 | The script parses through a CSV attachment accessed from the instance and reads each data row by row and column by column. You could also specify the required separator and quote character to escape them. 2 | 3 | Sample Usage: 4 | 5 | parseCSVFile("sys_id=76fc711f2f0b7050809e51172799b685"); 6 | 7 | -------------------------------------------------------------------------------- /Attachments/Create Attachments/README.md: -------------------------------------------------------------------------------- 1 | ## Create an Attachment via script 2 | 3 | You can create a Business Rule (ie: After Insert) to automatically create an Attachment. 4 | 5 | In this example we're creating a text file containing 'some data'. 6 | 7 | The file name is 'fileName.txt' 8 | -------------------------------------------------------------------------------- /Attachments/Delete RITM Attachment/README.md: -------------------------------------------------------------------------------- 1 | The Delete RITM attachment business rule will automatically deletes the attachment on RITM, when the attachment is deleted on SCTASK. 2 | -------------------------------------------------------------------------------- /Attachments/Show RITM has Attachments/README.md: -------------------------------------------------------------------------------- 1 | This feature requires a "Display" Business rule on [sc_task] to pass true/false to the scratchpad and then an "onLoad" Client Script to display a message on the Catalog Task form if the RITM has attachments. 2 | 3 | The result is a message on the Catalog Task form (below the RITM field) indicating when a RITM has attachments. 4 | -------------------------------------------------------------------------------- /Attachments/Show RITM has Attachments/ShowRITMhasAttachment_CS.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | if (g_scratchpad.hasAttachments == true) { 3 | g_form.showFieldMsg('request_item', "Contains attachment(s)",'info'); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Background Scripts/ Bulk Change of Incident Priority Based on Category/README.md: -------------------------------------------------------------------------------- 1 | The code helps to automates the bulk update of incident priorities based on predefined category mappings. 2 | -------------------------------------------------------------------------------- /Background Scripts/Add Bookmarks - ITIL Users/README.md: -------------------------------------------------------------------------------- 1 | Script to be used to add bookmark for ITIL users. This will help add favorites for SLAs for 2 | - My Group Tasks 3 | - SLAs for My Tasks 4 | - Tasks Assigned to Me 5 | - My approvals 6 | to all ITIL users. 7 | Replace the addQuery value to get the favorites applied from the backend to required audience 8 | -------------------------------------------------------------------------------- /Background Scripts/Add Comments/addComment.js: -------------------------------------------------------------------------------- 1 | function addComments(tableName,recSysId, userName, fieldName){ 2 | var rec = new GlideRecord(tableName); 3 | if(rec.get(recSysId)){ 4 | rec[fieldName].setJournalEntry('This is my comment',userName); 5 | rec.update(); 6 | } 7 | } 8 | 9 | addComments(tableName,recSysId,userName,fieldName); 10 | -------------------------------------------------------------------------------- /Background Scripts/Add No Audit Attribute To Multiple Dictionary Entries/README.md: -------------------------------------------------------------------------------- 1 | A background script add the no-audit attribute to multiple dictionary entries. 2 | The no-audit attribute will exclued the specified attributes from the system audit process and will not produc audit track at all. 3 | -------------------------------------------------------------------------------- /Background Scripts/Add Standard Change Model/addStandardChgModel.js: -------------------------------------------------------------------------------- 1 | var sid = 'ADD YOUR CHANGE RECORD SYS_ID HERE'; 2 | 3 | var chg = new GlideRecord('change_request'); 4 | if(chg.get(sid)) { 5 | chg.setValue('chg_model', 'e55d0bfec343101035ae3f52c1d3ae49'); //standard change model 6 | chg.update(); 7 | } 8 | -------------------------------------------------------------------------------- /Background Scripts/Attach Workflow to Existing Record/README.md: -------------------------------------------------------------------------------- 1 | # Attach Workflow to existing records 2 | 3 | This background script can be useful if you run into a situation where the workflow condition did not trigger on an intended record, or an older version of a workflow had a flaw but the record already began fulfillment. 4 | -------------------------------------------------------------------------------- /Background Scripts/Change Approver/BgScript.js: -------------------------------------------------------------------------------- 1 | 2 | var ab=new GlideRecord('sysapproval_approver'); 3 | ab.addQuery('sysapproval',''); 4 | ab.query(); 5 | if(ab.next()) 6 | { 7 | ab.approver.setDisplayValue('')'; 8 | ab.update(); 9 | } 10 | -------------------------------------------------------------------------------- /Background Scripts/Change Approver/README.md: -------------------------------------------------------------------------------- 1 | Use the code to change approver for any record from background script 2 | Replace with sys_id of record for which approval is triggered 3 | Replace with name of user who needs to be set as approver 4 | -------------------------------------------------------------------------------- /Background Scripts/Change Update Set Application Scope/README.md: -------------------------------------------------------------------------------- 1 | # Change update set application scope 2 | In ServiceNow, there are instances where an update set is mistakenly created in the incorrect application scope. To rectify this, I've developed a background script that facilitates the alteration of the update set's application scope to the appropriate one. 3 | -------------------------------------------------------------------------------- /Background Scripts/Check for duplicates on multiple criteria/README.md: -------------------------------------------------------------------------------- 1 | Use this script to check for duplicates (and delete if necessary) in a table based on 2 or more criteria. 2 | For reference: https://www.servicenow.com/community/developer-blog/search-for-duplicates-delete-based-on-2-columns/ba-p/2279274 3 | -------------------------------------------------------------------------------- /Background Scripts/Clone User Record/README.md: -------------------------------------------------------------------------------- 1 | Clone a user to another user after creating a new user from SN and run the below script from Background Script under System Definition app. 2 | The sys id's are needed from both users to run the background script. 3 | -------------------------------------------------------------------------------- /Background Scripts/Clone User with Roles and Groups/README.md: -------------------------------------------------------------------------------- 1 | # Clone User with Roles and Groups 2 | I have created a script in ServiceNow to replicate a user's profile. This script not only duplicates the user's data but also replicates the roles and groups assigned to that user. 3 | -------------------------------------------------------------------------------- /Background Scripts/Compare Roles Between Two Users/example-output.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Compare Roles Between Two Users/example-output.PNG -------------------------------------------------------------------------------- /Background Scripts/Convert Date Time/README.md: -------------------------------------------------------------------------------- 1 | This is the simple code to run independently from AES -> Background Scripts module and convert the datetime from one time zone to other 2 | -------------------------------------------------------------------------------- /Background Scripts/Convert comma separated values in string to columns/script.js: -------------------------------------------------------------------------------- 1 | var Str = "Element1,Element2,Element3,Element4,Element5,Element6"; 2 | result =[]; 3 | var myArray = Str.split(","); 4 | for(var i =0; i<=myArray.length;i++){ 5 | result.push(myArray[i]); 6 | } 7 | var output= "\n" +result.join("\n"); 8 | gs.info(output); 9 | -------------------------------------------------------------------------------- /Background Scripts/Copy table name list header action/menu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Copy table name list header action/menu.jpg -------------------------------------------------------------------------------- /Background Scripts/Currency Conversion/README.md: -------------------------------------------------------------------------------- 1 | # Convert the currency from one country denomination to other 2 | This is for the currency conversion purpose and the js file has the code snippet 3 | -------------------------------------------------------------------------------- /Background Scripts/Currency Conversion/currencyConvert.js: -------------------------------------------------------------------------------- 1 | var conv = new sn_currency.GlideCurrencyConverter('EUR', 'USD'); // call to API by passing Europe and USA 2 | conv.setAmount(100); //currency value 3 | gs.info(conv.convert()); //call the method from the API 4 | -------------------------------------------------------------------------------- /Background Scripts/Deactivate groups with no members and inactive manager/script.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideRecord('sys_user_group'); 2 | gr.addEncodedQuery("active=true^manager.active=false^RLQUERYsys_user_grmember.group,<1,m2m^ENDRLQUERY"); 3 | gr.query(); 4 | gr.active = false; 5 | gr.updateMultiple(); 6 | -------------------------------------------------------------------------------- /Background Scripts/Decrypt Password Field/README.md: -------------------------------------------------------------------------------- 1 | Sometimes we forget the password we are using e.g. the Credentials records for integrations. 2 | With this code, you can go into the "basic_auth_credentials" table and decrypt the field "password" which is of the type password2. 3 | The API GlideEncrypter does only work in the Global scope. 4 | 5 | 6 | -------------------------------------------------------------------------------- /Background Scripts/Encrypt & decrypt payload via base64/README.md: -------------------------------------------------------------------------------- 1 | This code is an example to encrypt or decrypt the payload using base64Encode and decode methods of GlideStringUtil API. 2 | -------------------------------------------------------------------------------- /Background Scripts/Fetch Active Groups list without members/README.md: -------------------------------------------------------------------------------- 1 | Sample code to clean up the Groups with no members. 2 | This code help to get the Active groups list with no members 3 | -------------------------------------------------------------------------------- /Background Scripts/Find out Duplicate Records/Duplicate Records.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideAggregate(incident); 2 | gr.addAggregate('COUNT', number); 3 | gr.groupBy(number); 4 | gr.addHaving('COUNT', '>', 1); 5 | gr.query(); 6 | while (gr.next()) { 7 | gs.print(gr.getValue(number) + ' has ' + gr.getAggregate('COUNT', field) + ' duplicate records '); 8 | } 9 | -------------------------------------------------------------------------------- /Background Scripts/FlushOutbox/README.md: -------------------------------------------------------------------------------- 1 | # Flush Outbox 2 | 3 | Delete or Ignore all email sitting in the outbox. Useful when enabling email in sub-prd and not wanting to get spammed with unsent email 4 | -------------------------------------------------------------------------------- /Background Scripts/Force new value to read only or protected field/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Force new value to read only or protected field/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Background Scripts/Force new value to read only or protected field/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Force new value to read only or protected field/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Background Scripts/Force new value to read only or protected field/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Force new value to read only or protected field/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Background Scripts/Generate JWT Token/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Generate JWT Token 3 | This is used to generate the JWT token from SN background script by using jwtAPI and the corresponding method:generateJWT() 4 | -------------------------------------------------------------------------------- /Background Scripts/Generate Random Incident Records/README.md: -------------------------------------------------------------------------------- 1 | **Generate Random Incident Records** 2 | This script can be used to generate random Incident records for testing purposes. 3 | 4 | **Usage** 5 | Can be used to run on demand in Scheduled Script Execution. 6 | 7 | **Scenario** 8 | Used to generate records in PDI for testing reports and graphs. 9 | -------------------------------------------------------------------------------- /Background Scripts/Generate statistics about events created today/ScreenShot_0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Generate statistics about events created today/ScreenShot_0.PNG -------------------------------------------------------------------------------- /Background Scripts/Generate statistics about events created today/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Generate statistics about events created today/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Background Scripts/Get Active MID Servers/README.md: -------------------------------------------------------------------------------- 1 | # ServiceNow Script: getActiveMidServer 2 | 3 | ## Description 4 | This ServiceNow script defines a function, `getActiveMidServer`, that retrieves the name of an active MID Server that is both up and validated. MID Servers are essential components in the ServiceNow platform for various integration and automation tasks. 5 | -------------------------------------------------------------------------------- /Background Scripts/Get All the CI classes/README.md: -------------------------------------------------------------------------------- 1 | This background script provides the names of all the available Ci classes present in the system 2 | -------------------------------------------------------------------------------- /Background Scripts/Get All the CI classes/getAllCiClasses.js: -------------------------------------------------------------------------------- 1 | // Find all CI Classes 2 | var table = new TableUtils("cmdb_ci"); 3 | var ciTableList = j2js(table.getAllExtensions()); 4 | for (var i = 0; i < ciTableList.length; i++) 5 | gs.print(ciTableList[i]); 6 | -------------------------------------------------------------------------------- /Background Scripts/Get Duplicate/README.md: -------------------------------------------------------------------------------- 1 | Using GlideAggregate function to find out tickets (tasks) with same number. OOB there happens to be a Unique checkbox at dictionary level 2 | and if in case not set to True it might create duplicate numbered tickets. 3 | Script will help find, ticekts if any. 4 | -------------------------------------------------------------------------------- /Background Scripts/Get Duplicate/script.js: -------------------------------------------------------------------------------- 1 | var dpchk = new GlideAggregate('task'); 2 | dpchk.groupBy('number'); 3 | dpchk.addHaving('COUNT', '>', 1); 4 | dpchk.query(); 5 | while(dpchk.next()) 6 | { 7 | gs.print(dpchk.number); 8 | } 9 | -------------------------------------------------------------------------------- /Background Scripts/Get GlideRecord Reference Field/README.md: -------------------------------------------------------------------------------- 1 | # Get GlideRecord to a reference field using getRefRecord() method 2 | 3 | **Use case** : Background script that retrieves the complete record of a reference field -------------------------------------------------------------------------------- /Background Scripts/Get GlideRecord Reference Field/get_glide_record_reference_field.js: -------------------------------------------------------------------------------- 1 | var grApproval = new GlideRecord('sysapproval_approver'); 2 | grApproval.get('007a44badba52200a6a2b31be0b8f525'); 3 | 4 | if(grApproval.sysapproval.getRefRecord().isValidRecord()) { 5 | return grApproval.sysapproval.getRefRecord(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Background Scripts/Get Installed Plugins details/README.md: -------------------------------------------------------------------------------- 1 | Background Script provides the list of installed plugins, version installed and version available for the upgrade in the instance 2 | 3 | Note: We need to set the basic auth credential in order for the script to work on the instance where we are running it. 4 | -------------------------------------------------------------------------------- /Background Scripts/Get Instance DB Size/README.md: -------------------------------------------------------------------------------- 1 | This is to get the size of the DB from the SN instance using SNC. 2 | -------------------------------------------------------------------------------- /Background Scripts/Get Instance DB Size/getInstDBSize.js: -------------------------------------------------------------------------------- 1 | gs.info( 2 | SNC.UsageAnalyticsScriptUtils.getCount( 3 | 'Primary DB size (MB)', 4 | 'Primary DB size of this instance (in MB)' 5 | ) 6 | ); //Run this code in the Background Scripts module to get the size of the DB 7 | -------------------------------------------------------------------------------- /Background Scripts/Get Instance Info/README.md: -------------------------------------------------------------------------------- 1 | These are few scripts to run from Background Script editor to get the instance info. 2 | -------------------------------------------------------------------------------- /Background Scripts/Get Instance Info/getInstanceInfo.js: -------------------------------------------------------------------------------- 1 | var gl= GlideTransaction.get().getRemoteAddr(); 2 | gs.addInfoMessage('IP Address:'+gl); 3 | var gl1=GlideServlet.getSystemID(); 4 | gs.addInfoMessage('Node ID:'+gl1); 5 | var env = gs.getProperty("instance_name"); 6 | gs.info(env); 7 | -------------------------------------------------------------------------------- /Background Scripts/Get Journal Entry as HTML Without Header/GetJournalEntryAsHTMLWithoutHeader.js: -------------------------------------------------------------------------------- 1 | var journalFieldName = 'comments'; 2 | var journalText = current[journalFieldName] 3 | .getJournalEntry(1) 4 | .trim() 5 | .split('\n') 6 | .slice(1) 7 | .join('
\n'); -------------------------------------------------------------------------------- /Background Scripts/Get list of Update Set types/README.md: -------------------------------------------------------------------------------- 1 | This snippet outputs a list of module types included in an update set. 2 | By checking the included module types before committing an update set, you can be sure you aren't including any unintended updates. 3 | -------------------------------------------------------------------------------- /Background Scripts/GetRecordsFromMultipleTables/README.md: -------------------------------------------------------------------------------- 1 | Creating a background script to print the total count of all tables with a specific filter condition 2 | -------------------------------------------------------------------------------- /Background Scripts/Incident Auto-Categorization Based on Keywords/README.md: -------------------------------------------------------------------------------- 1 | # Incident Auto-Categorization Based on Keywords 2 | 3 | This background script auto-categorizes uncategorized incidents based on keywords found in the short_description field, updating the incident with relevant categories (e.g., "Email", "Network"). 4 | -------------------------------------------------------------------------------- /Background Scripts/Limit String and Add Elipses/README.md: -------------------------------------------------------------------------------- 1 | This function can be used to show the string with limited number of characters and add the ellipses to it. This is mostly used on the portal side. -------------------------------------------------------------------------------- /Background Scripts/List Stories and Tasks by User and Date Range/results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/List Stories and Tasks by User and Date Range/results.png -------------------------------------------------------------------------------- /Background Scripts/Logout User/README.md: -------------------------------------------------------------------------------- 1 | # Logout Users 2 | Used to log out all users within the platform. 3 | 4 | ## Usage 5 | Run script in **logoutUser.js** in 'Scripts - Background' 6 | 7 | * **Parameters:** 8 | - **ignoreUser:** Username of a sys_user that is ignored (ex. 'admin') 9 | -------------------------------------------------------------------------------- /Background Scripts/Move Customer Updates/README.md: -------------------------------------------------------------------------------- 1 | # Move Customer Updates 2 | I've developed a script to facilitate the transfer of customer updates between two update sets within the same application scope. The script needs to run at the global scope for execution. 3 | -------------------------------------------------------------------------------- /Background Scripts/Notify User of Password Expiry/README.md: -------------------------------------------------------------------------------- 1 | This script will work to notify the users if their password is going to expire in less than 7 days. 2 | Prerequisite : You will need to create an event first. 3 | -------------------------------------------------------------------------------- /Background Scripts/README.md: -------------------------------------------------------------------------------- 1 | In this piece of code, we are querying a table for some records and then updating a particular reference field's value of those records to the value of the specific parent class to which it has a cmdb_rel_ci relationship. 2 | We are also printing the sys_ids pf the records which would be updated and the ones that would be skipped. 3 | -------------------------------------------------------------------------------- /Background Scripts/Read Encoded Query/readQuery.js: -------------------------------------------------------------------------------- 1 | // This code get the encoded query in readable format. 2 | // Pass the table name and encoded query in the function API whoch you want to read. 3 | 4 | var grQ= new GlideQueryBreadcrumbs().getReadableQuery('table name', 'Pass the encoded query'); 5 | gs.info("Readable Query is "+grQ); 6 | -------------------------------------------------------------------------------- /Background Scripts/Remove Inactive User/README.md: -------------------------------------------------------------------------------- 1 | This code snippet helps to remove the inactive users from active groups. It won't delete the user record from "sys_user" table it will just delete the entry from the "sys_user_grmember" table. 2 | -------------------------------------------------------------------------------- /Background Scripts/Remove roles from inactive user/script.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideRecord('sys_user_has_role'); 2 | gr.addEncodedQuery('user.active=false'); 3 | gr.query(); 4 | gr.deleteMultiple(); -------------------------------------------------------------------------------- /Background Scripts/Replace Text/README.md: -------------------------------------------------------------------------------- 1 | Purpose of the script is to help replace text IT_SAP with IT_ERP for all the Groups in Group table containing IT_SAP as keyword. 2 | It uses replace method which follows format replace(/'ABCD'/g,'PQR') 3 | where ABCD is to be replaced with PQR 4 | -------------------------------------------------------------------------------- /Background Scripts/Replace Text/script.js: -------------------------------------------------------------------------------- 1 | var replacemyname; 2 | var replaceis=new GlideRecord('sys_user_group'); 3 | replaceis.addEncodedQuery('nameLIKEIT_SAP'); 4 | replaceis.query(); 5 | while(replaceis.next()) 6 | { 7 | replaceis.name=replaceis.name.replace(/IT_SAP/g, 'IT_ERP'); // /IT_SAP/g is oldvalue 'IT_ERP' is new value 8 | replaceis.update(); 9 | } 10 | -------------------------------------------------------------------------------- /Background Scripts/Silent update on GlideRecord/README.md: -------------------------------------------------------------------------------- 1 | Add the gr.autoSysFields(false) to prevent system updates when modifying GlideRecord in background script execution. This is to preserve audit containing the last known user modifications from ticket form. 2 | -------------------------------------------------------------------------------- /Background Scripts/Stale Tasks Auto-Close/README.md: -------------------------------------------------------------------------------- 1 | The script identifies tasks that haven’t been updated for a set period, sends reminder notifications to assigned users, and, if still inactive after additional time, automatically closes them. This helps keep task lists current and reduces manual follow-ups. -------------------------------------------------------------------------------- /Background Scripts/Typed Array Elements/typed_array_elements.js: -------------------------------------------------------------------------------- 1 | function arrayElementsToNumber(array) { 2 | return array.map(Number); 3 | } 4 | 5 | function arrayElementsToString(array) { 6 | return array.map(String); 7 | } 8 | 9 | arrayElementsToNumber(['1', '2', '3']) 10 | arrayElementsToString([1, 2, 3]) 11 | -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-08-42-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-08-42-48.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-08-47-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-08-47-01.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-08-55-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-08-55-37.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-09-02-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-09-02-32.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-09-49-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-09-49-57.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-19-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-19-54.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-22-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-22-40.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-25-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-25-04.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-26-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-26-37.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-27-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-27-05.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-31-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-31-04.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-31-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-31-29.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-10-33-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-10-33-17.png -------------------------------------------------------------------------------- /Background Scripts/Update All Store Apps/2023-10-13-12-17-09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Background Scripts/Update All Store Apps/2023-10-13-12-17-09.png -------------------------------------------------------------------------------- /Background Scripts/User Has Role Exactly/user_has_role_exactly.js: -------------------------------------------------------------------------------- 1 | function hasRoleExactly(role) { 2 | var arrayUtil = new ArrayUtil(); 3 | var roles = gs.getSession().getRoles() + ''; 4 | var roleArray = roles.split(","); 5 | var isAuthorized = arrayUtil.contains(roleArray, role); 6 | return isAuthorized; 7 | } -------------------------------------------------------------------------------- /Background Scripts/inserting a new record into the sys_user table/script.js: -------------------------------------------------------------------------------- 1 | var gr=new GlideRecord('sys_user'); 2 | gr.initialize(); 3 | gr.user_name='test.user'; 4 | gr.first_name='test'; 5 | gr.last_name='user'; 6 | gr.email='test.user@servicenow'; 7 | gr.insert(); 8 | -------------------------------------------------------------------------------- /Browser Bookmarklets/Copy URL to ServiceNow Journal/README.md: -------------------------------------------------------------------------------- 1 | ## Copy URL to ServiceNow Journal 2 | A bookmarklet that can be used on any website to copy the website's title and URL to the clipboard as a [code]...[/code] snippet that can be pasted to a Journal field to create a "fancy" clickable link in Comments or Work notes. 3 | -------------------------------------------------------------------------------- /Browser Bookmarklets/Create story task/create_story_task.js: -------------------------------------------------------------------------------- 1 | javascript:var w=window.frames["gsft_main"]!==undefined?window.frames["gsft_main"]:window;var q="parent="+w.g_form.getUniqueValue()+"^type=4"+"^short_description=Test "+w.g_form.getValue("number")+" - "+w.g_form.getValue("short_description")+"^EQ";top.open("rm_scrum_task.do?sys_id=-1&sysparm_query="+q); 2 | -------------------------------------------------------------------------------- /Browser Bookmarklets/Impersonation/impersonation.js: -------------------------------------------------------------------------------- 1 | javascript:let impWin=window.open("/impersonate_dialog.do", "Impersonation", "scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=300,height=300,left=100,top=100");setInterval(()=>{if(!impWin.location.pathname.includes("impersonate")){impWin.close();window.location.reload();};},500); 2 | -------------------------------------------------------------------------------- /Browser Bookmarklets/Open copied record/open copied record bookmarklet.js: -------------------------------------------------------------------------------- 1 | javascript: (c=> c.readText().then( text => window.open("http://" + window.location.hostname + "/nav_to.do?uri=task.do?sysparm_query=number=" + text, "_blank")))(navigator.clipboard); 2 | -------------------------------------------------------------------------------- /Business Rules/Allow only unique insert/README.md: -------------------------------------------------------------------------------- 1 | Before Business rule to check for existing entry in a table , incase one would want to make an insert to be unique based on a certain criteria. 2 | -------------------------------------------------------------------------------- /Business Rules/Assign specific role to user/ScreenShot1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Assign specific role to user/ScreenShot1.PNG -------------------------------------------------------------------------------- /Business Rules/Assign specific role to user/ScreenShot2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Assign specific role to user/ScreenShot2.PNG -------------------------------------------------------------------------------- /Business Rules/AutoAssignment/README.md: -------------------------------------------------------------------------------- 1 | This Business Rule runs before an incident is inserted. 2 | If no user is assigned, it looks up the "IT Support" group and assigns the incident to the group's manager. 3 | This ensures that incidents are promptly directed to the appropriate personnel. 4 | -------------------------------------------------------------------------------- /Business Rules/Block Attachments for specific conditions/Block Attachments.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/) { 2 | gs.addErrorMessage(gs.getMessage("You are not authorized to upload attachments.")); 3 | current.setAbortAction(true); 4 | return false; 5 | 6 | })(current, previous); -------------------------------------------------------------------------------- /Business Rules/Block Attachments for specific conditions/README.md: -------------------------------------------------------------------------------- 1 | This code is used to block attachments for a specific record condition (assignment group, state, etc) -------------------------------------------------------------------------------- /Business Rules/Change Lead Time Calculations/README.md: -------------------------------------------------------------------------------- 1 | Before business rule runs on insert/update - you can set the conditions as you require. Script in change_lead_time_calculations.js 2 | 3 | System property name:change.leadtime.values | type:string | value -> { "High": 5, "Moderate" : 3, "Low" : 1 } 4 | -------------------------------------------------------------------------------- /Business Rules/Compare two date fields/README.md: -------------------------------------------------------------------------------- 1 | This Code will show the number of days difference between 2 date like Start Date and End Date. 2 | -------------------------------------------------------------------------------- /Business Rules/Copy Comments from RITM to SCTASK Vice versa/README.md: -------------------------------------------------------------------------------- 1 | End user recent comments on RITM to be copied as task worknotes to any catalog tasks which is not Closed Complete/Closed Skipped/Cancelled so the assigne aware of recent updates of End users. 2 | 3 | 4 | -------------------------------------------------------------------------------- /Business Rules/Copy attachments from idea to demand/README.md: -------------------------------------------------------------------------------- 1 | Code will copy attachments from idea to demand 2 | 3 | Name: Copy attachments to demand 4 | 5 | Table: Idea 6 | 7 | When: Async 8 | 9 | Filter conditions: demand changes and demand is not empty 10 | 11 | Update: true 12 | 13 | -------------------------------------------------------------------------------- /Business Rules/Copy latest comment from RITM to SCTASK/CopyComments.js: -------------------------------------------------------------------------------- 1 | //Script to update comments on RITM. 2 | 3 | var ritmGr = new GlideRecord('sc_req_item'); 4 | if(ritmGr.get(current.request_item.sys_id))// Use current sys_id of ritm to pull the comments 5 | { 6 | 7 | ritmGr.comments=current.comments.getJournalEntry(1);// This gets the latest comment added. 8 | } 9 | -------------------------------------------------------------------------------- /Business Rules/Copy latest comment from RITM to SCTASK/README.md: -------------------------------------------------------------------------------- 1 | This simple snap code helps to copy latest comment of RITM to SCTASK. 2 | -------------------------------------------------------------------------------- /Business Rules/Copy worknotes from SCTASK to RITM comments/README.md: -------------------------------------------------------------------------------- 1 | Sample code snippet to copy the latest task worknotes comments to additional comments of related RITM record. 2 | So the requester aware of recent updates of tasks. 3 | -------------------------------------------------------------------------------- /Business Rules/Count Associated Incidents in Problem/script.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous) { 2 | 3 | 4 | var gr = new GlideRecord('problem'); 5 | gr.addQuery('sys_id', current.problem_id); 6 | gr.query(); 7 | if(gr.next()) 8 | { 9 | gr.u_associated_incidents += 1; 10 | gr.update(); 11 | 12 | } 13 | 14 | 15 | })(current, previous); 16 | -------------------------------------------------------------------------------- /Business Rules/Create comment on referenced record/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Create comment on referenced record/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Business Rules/Create comment on referenced record/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Create comment on referenced record/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Business Rules/Display BR to get groupInfo of logged in User/displayBr.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/) { 2 | 3 | // Add your code here 4 | g_scratchpad.isMemberOf = gs.getUser().isMemberOf('ServiceNow QA team'); // this will return true if the user is member of 'ServiceNow QA team' and false otherwise. 5 | 6 | })(current, previous); 7 | -------------------------------------------------------------------------------- /Business Rules/Display current user display name on top of form/README.md: -------------------------------------------------------------------------------- 1 | **Use case :** 2 | Display info message with current user display name on top of a form 3 | 4 | **Soulution :** 5 | Write a "Display business rule" on any table using `GlideSystem - getUserDisplayName()` API
6 | Check script.js file for example 7 | -------------------------------------------------------------------------------- /Business Rules/Display current user display name on top of form/script.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/ ) { 2 | 3 | var user = gs.getUserDisplayName(); 4 | gs.addInfoMessage("Welcome " + user); //This adds info message on top of the form 5 | 6 | })(current, previous); 7 | -------------------------------------------------------------------------------- /Business Rules/Display warning message when peer reviewer and Requested by are same person/README.md: -------------------------------------------------------------------------------- 1 | This business rule is used in the Change Management module to display a warning message when requested by and Peer reviewer are the same person. You need to run this business rule "before" you "insert" under the filter conditions. 2 | 3 | 4 | -------------------------------------------------------------------------------- /Business Rules/Enforce Single Attachment Rule for HR Core Tasks/README.md: -------------------------------------------------------------------------------- 1 | This code checks if there is more than one attachment for a specific task in ServiceNow. If there are multiple attachments, 2 | it displays an error message and prevents further processing of the current record to ensure compliance with the rule that 3 | only one attachment is permitted. 4 | -------------------------------------------------------------------------------- /Business Rules/Enforce Unique Rank/README.md: -------------------------------------------------------------------------------- 1 | Before Business rule for keeping a rank field unique. 2 | 3 | Conditions: current.rank.changes() && !current.rank.nil() -------------------------------------------------------------------------------- /Business Rules/Generate event/ScreenShot_0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Generate event/ScreenShot_0.PNG -------------------------------------------------------------------------------- /Business Rules/Generate event/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Generate event/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Business Rules/Generate event/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Generate event/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Business Rules/Make Attachment Mandatory/README.md: -------------------------------------------------------------------------------- 1 | This simple code snippet will help in making attachments mandotary. 2 | Can be used in Before BR/Script Inculde. 3 | -------------------------------------------------------------------------------- /Business Rules/Manipulating system properties values/ScreenShot_0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Manipulating system properties values/ScreenShot_0.PNG -------------------------------------------------------------------------------- /Business Rules/Manipulating system properties values/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Manipulating system properties values/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Business Rules/Manipulating system properties values/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Manipulating system properties values/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Business Rules/Pass server info to client/README.md: -------------------------------------------------------------------------------- 1 | This BR can be used to pass any server information to the client side using the g_scratchpad variable. 2 | 3 | BR Type: Display business rule 4 | 5 | Usage Scenario: We want to apply some logic based 6 | - on some property value stored at the server side. 7 | - on the department/manager associated with the user. 8 | 9 | -------------------------------------------------------------------------------- /Business Rules/Pass server info to client/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Pass server info to client/example.png -------------------------------------------------------------------------------- /Business Rules/Prevent adding user to group if manager is inactive/Script.js: -------------------------------------------------------------------------------- 1 | var user = new GlideRecord('sys_user'); 2 | user.addQuery('sys_id', current.group.manager.sys_id); 3 | user.addQuery('active', 'false'); 4 | user.query(); 5 | if(user.next()) 6 | { 7 | gs.info("Group Manager is inactive"); 8 | current.setAbortAction(true); 9 | } 10 | -------------------------------------------------------------------------------- /Business Rules/Prevent duplicate update sets/README.md: -------------------------------------------------------------------------------- 1 | This Business Rule will help to prevent duplicate names for update set. And this will display error message when there is duplicate name found for update set name. 2 | -------------------------------------------------------------------------------- /Business Rules/Prevent invalid fiscal period in cost plan breakdown/README.md: -------------------------------------------------------------------------------- 1 | Simple business rule that will ensure a cost plan breakdowns fiscal period will remain within the start and end period of the parent cost plan. If a cost plan breakdown is added ousdide of the start/end fiscal periods then rollups do not work correctly. 2 | -------------------------------------------------------------------------------- /Business Rules/RITM state change/README.md: -------------------------------------------------------------------------------- 1 | # Create before insert/update business rule 2 | business rule on sc_req_item table and give condition if state changes to 2 OR cat_item.sc.catalogs is "yourchoice" and run this script. 3 | 4 | This business is to set state on sc_task table when state changes on sc_req_item based on condition. 5 | -------------------------------------------------------------------------------- /Business Rules/RITM_to_SCTASK/README.md: -------------------------------------------------------------------------------- 1 | This business rule script copies the additional comments from RITM to all associated SCTASKs when additional comments are changed on the RITM. 2 | -------------------------------------------------------------------------------- /Business Rules/Randomly distrubite events between custom queues/README.md: -------------------------------------------------------------------------------- 1 | This business rule helps generate multiple events, which are randomly and almost perfetly even distributed by a specified number of custom queues. 2 | -------------------------------------------------------------------------------- /Business Rules/ReRank item/README.md: -------------------------------------------------------------------------------- 1 | Business rule for on after to re-rank a field spaced by 10 in each entry 2 | it updates itself and any larger numbered rank item to keep them all in sync 3 | -------------------------------------------------------------------------------- /Business Rules/Recursive logic/README.md: -------------------------------------------------------------------------------- 1 | Using this Recursive BR, when you select the CMDB CI on incident then it would automatically add all level of affected CIs and when you change the new cmdb_ci then its corresponding affected CIs will get added and old affected CIs will get deleted. 2 | -------------------------------------------------------------------------------- /Business Rules/Reduce syslog query/business_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Reduce syslog query/business_rule.png -------------------------------------------------------------------------------- /Business Rules/Replace KB Author with Manager/README.md: -------------------------------------------------------------------------------- 1 | This business rule help to replace the KB author of knowledge article to Knowledge base manager, if the author of that article leaves the organization. This is a kind of logic which helps to assign the knowledge article to knowledge base manager. 2 | -------------------------------------------------------------------------------- /Business Rules/SCTASK_to_RITM/README.md: -------------------------------------------------------------------------------- 1 | This business rule script copies the additional comments from SCTASK to all associated RITM when additional comments are changed on the SCTASK. 2 | -------------------------------------------------------------------------------- /Business Rules/Set program business duration/README.md: -------------------------------------------------------------------------------- 1 | OOTB the project records exclude weekends and public holidays when calculating the duration, whereas program does not exclude these things. 2 | 3 | This business rule and associated script include address this issue and ensure that the duration field on the program record are calculated in the same way as projects. 4 | -------------------------------------------------------------------------------- /Business Rules/Update Locked Out field when Active field changes on User record/update_locked_out_field.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/) { 2 | 3 | current.locked_out = !current.active; 4 | 5 | })(current, previous); 6 | -------------------------------------------------------------------------------- /Business Rules/Update worknotes of Ptask to parent Problem record/README.md: -------------------------------------------------------------------------------- 1 | If user update work notes of problem task then it should update the same worknotes in parent problem record as well with highlighting problem task number. 2 | this business rule run after updation when worknote changes. 3 | -------------------------------------------------------------------------------- /Business Rules/Warn for changed OOTB artifacts/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Business Rules/Warn for changed OOTB artifacts/screenshot.png -------------------------------------------------------------------------------- /Business Rules/duplicateattachments/README.md: -------------------------------------------------------------------------------- 1 | Type: Business Rule When: OnBefore and On Insert Operation Table:Incident 2 | This BR runs on Insert Operation , IT compares the filename from Sysattachment table and if same attachment with Same file exists on the Incident this BR runs and Abort the Attaching Attachments 3 | -------------------------------------------------------------------------------- /CMDB/CMDB record count/README.md: -------------------------------------------------------------------------------- 1 | # CMDB Record count 2 | 3 | Simple code snippet to count the number of records in each CMDB table 4 | -------------------------------------------------------------------------------- /CMDB/CSDM Maturity Report/README.md: -------------------------------------------------------------------------------- 1 | # CSDM Maturity Report 2 | 3 | This code snippet generates a report that helps with assessing an organization's Common Services Data Model (CSDM) maturity 4 | 5 | It counts the number of records in the tables that are part of the CSDM by category 6 | -------------------------------------------------------------------------------- /CMDB/IRE Errors/README.md: -------------------------------------------------------------------------------- 1 | # IRE Errors 2 | 3 | This code snippet displays a count of IRE errors grouped by category 4 | This background script will help you undertand the most common source of IRE errors 5 | You will need to adjust the record limit in line 30, or change the query time frame in line 27 6 | 7 | -------------------------------------------------------------------------------- /CMDB/Mandatory Field Analysis/README.md: -------------------------------------------------------------------------------- 1 | # Mandatory Field Analysis 2 | 3 | Mandatory fields may cause discovery not to work as expected, especially if the mandatory field is also a custom field. 4 | 5 | This code snippet helps identify mandatory fields and can assist with remediating problematic configuration 6 | -------------------------------------------------------------------------------- /Catalog Client Script/Add Label For Attachment/README.md: -------------------------------------------------------------------------------- 1 | Code Snippet to add a label to the attachment for a Catalog Item on the Portal. -------------------------------------------------------------------------------- /Catalog Client Script/Add Rows in MRVS/README.md: -------------------------------------------------------------------------------- 1 | With this simple script you can through a client script add rows in the MRVS if you like. Ex. you want to prefill a few rows that you get from a GlideAjax call depending on what the user choosed in another variable 2 | -------------------------------------------------------------------------------- /Catalog Client Script/Autopopulate Department/autopopulateDepartment.js: -------------------------------------------------------------------------------- 1 | function onChange(control, oldValue, newValue, isLoading) { 2 | g_form.getReference("requested_for", function (gr) { 3 | g_form.setValue("department", gr.department); 4 | g_form.setValue("email", gr.email); 5 | g_form.setValue("phone", gr.phone); 6 | }); 7 | } 8 | -------------------------------------------------------------------------------- /Catalog Client Script/Block Submit/README.md: -------------------------------------------------------------------------------- 1 | Code Snippet to block submission of catalog item based on answer to other yes/no variable. 2 | 3 | #update 4 | To fix a task from issue #745 5 | Replace JavaScript alert() method to GlideModal() API. 6 | 7 | -------------------------------------------------------------------------------- /Catalog Client Script/Calculate age on based on date of birth/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Catalog Client Script/Calculate age on based on date of birth/image.png -------------------------------------------------------------------------------- /Catalog Client Script/Control all RITM variables in one go/script.js: -------------------------------------------------------------------------------- 1 | function onLoad() 2 | { 3 | 4 | g_form.setVariablesReadOnly(true); //if you want to make all variables read-only 5 | 6 | g_form.setVariablesReadOnly(false); //if you want to make all variables editable 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Catalog Client Script/CustomAlert/Screenshots/ExampleScreenShotCustomAlertInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Catalog Client Script/CustomAlert/Screenshots/ExampleScreenShotCustomAlertInfo.png -------------------------------------------------------------------------------- /Catalog Client Script/CustomAlert/Screenshots/ExampleScreenShotForCustomAlertSuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Catalog Client Script/CustomAlert/Screenshots/ExampleScreenShotForCustomAlertSuccess.png -------------------------------------------------------------------------------- /Catalog Client Script/CustomAlert/Screenshots/ExampleScrenShotForCustomAlertDanger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Catalog Client Script/CustomAlert/Screenshots/ExampleScrenShotForCustomAlertDanger.png -------------------------------------------------------------------------------- /Catalog Client Script/CustomAlert/Screenshots/README.md: -------------------------------------------------------------------------------- 1 | Please see the example Screenshots 2 | -------------------------------------------------------------------------------- /Catalog Client Script/Get Display Value of MRVS/mrvs.js: -------------------------------------------------------------------------------- 1 | 2 | var script = new global.VariableUtil(); 3 | var gr = new GlideRecord("sc_req_item"); 4 | gr.addEncodedQuery("sys_id="); 5 | gr.query(); 6 | if (gr.next()) { 7 | gs.info(script.getDisplayValue('', gr.variables.MRVSName)); //MRVS Display Value 8 | } 9 | -------------------------------------------------------------------------------- /Catalog Client Script/Hide Attachment icon.js: -------------------------------------------------------------------------------- 1 | //Hide attachment icon on catalog item 2 | function onLoad() { 3 | var document = document || top.document; 4 | (jQuery || top.jQuery)("#sc_attachment_button, #catItemTop > div > div.wrapper-md.row.no-margin.ng-scope > label").hide(); 5 | } 6 | -------------------------------------------------------------------------------- /Catalog Client Script/MRVS Loop Rows/README.md: -------------------------------------------------------------------------------- 1 | Use this to loop through a Multi Row Variable Set and create an array of objects with the variables in it. 2 | -------------------------------------------------------------------------------- /Catalog Client Script/Make OOB Attachment Mandatory/onChange.js: -------------------------------------------------------------------------------- 1 | function onChange(control, oldValue, newValue, isLoading) { 2 | if (isLoading || newValue == 'No') { 3 | setAttachmentMandatory(false); 4 | return; 5 | } 6 | 7 | if (newValue == 'Yes') setAttachmentMandatory(true); 8 | } -------------------------------------------------------------------------------- /Catalog Client Script/PopulateDropdown/demo_catalog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Catalog Client Script/PopulateDropdown/demo_catalog.png -------------------------------------------------------------------------------- /Catalog Client Script/Restrict Number of rows in Multi Row Variable/README.md: -------------------------------------------------------------------------------- 1 | ## restrict_multi_row.js 2 | Use this to restrict multi row variable set rows to 1. this value can be changed to any number of rows as requirement. 3 | -------------------------------------------------------------------------------- /Catalog Client Script/Restrict Number of rows in Multi Row Variable/restrict_multi_row.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | var field = g_form.getField("mrvs_variable_set_name"); 3 | if (field != null) { 4 | field.max_rows_size = 1; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Catalog Client Script/Rounding Money or Price Field/catalog_client_script_config.md: -------------------------------------------------------------------------------- 1 | Name: Round [Field] to nearest [Rounding Amount] 2 | UI Type: All 3 | Type: onChange 4 | 5 | Variable name: [VAR NAME] 6 | 7 | Script: see `catalog_client_script.js` for code. -------------------------------------------------------------------------------- /Catalog Client Script/Set User Field Values on Load/script.js: -------------------------------------------------------------------------------- 1 | /* 2 | Set user field value on load using catalog cleint script and make the field readonly 3 | */ 4 | 5 | function onLoad() 6 | { 7 | var user_id = g_user.userID; 8 | g_form.setValue('field_name', user_id); 9 | g_form.setReadOnly('field_name', true); 10 | } 11 | -------------------------------------------------------------------------------- /Client Scripts/Add Field Decoration/Add Field Decoration.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | // Adding Field Decorators 3 | g_form.addDecoration("caller_id", "icon-user-profile", "The Requester"); 4 | } 5 | -------------------------------------------------------------------------------- /Client Scripts/Add Field Decoration/README.md: -------------------------------------------------------------------------------- 1 | # Client Script - Add Field Decoration 2 | 3 | A client script that added field decoration. 4 | 5 | ## Usage 6 | 7 | - Create a new OnLoad script 8 | - Copy this script into it 9 | - Change the field name, icon and the message 10 | -------------------------------------------------------------------------------- /Client Scripts/Add Image to Field Based on Company/SetCompanyScratchPadValue.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/) { 2 | 3 | // Set the Scratchpad value for Company which would be used in the Client Script 4 | g_scratchpad.company = current.request.requested_for.company.getDisplayValue(); 5 | 6 | })(current, previous); 7 | -------------------------------------------------------------------------------- /Client Scripts/Auto-populate watch_list based on company/README.md: -------------------------------------------------------------------------------- 1 | Table: Incident 2 | Type: onChange 3 | field: caller_id 4 | 5 | Sometimes customers have a requirement to add users or distribution lists to all tickets that are raised for their company. This script allows to automatically add a list of users or external email addresses to the watch_list field. -------------------------------------------------------------------------------- /Client Scripts/Change Label of Field/Change Label of Field.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | //Type appropriate comment here, and begin script below 3 | if (g_form.getValue('priority') == '1') { 4 | g_form.setLabelOf('description', 'Please Explain Briefly'); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Client Scripts/Check all mandatory fields using mandatoryCheck()/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Check all mandatory fields using mandatoryCheck()/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Client Scripts/Check all mandatory fields using mandatoryCheck()/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Check all mandatory fields using mandatoryCheck()/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Client Scripts/Enable VIP and Senior VIP Checkboxes and read only/ScriptToEnableVIP_superVIP users: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | //Type appropriate comment here, and begin script below 3 | var myRole= g_user.hasRole("admin"); 4 | if(myRole!=true){ 5 | g_form.setReadOnly("vip",true); 6 | }else{ 7 | g_form.setReadOnly("vip",false); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Client Scripts/Expanding Info Message/README.md: -------------------------------------------------------------------------------- 1 | This is an expanding info message. It can even run a script when an element is clicked. -------------------------------------------------------------------------------- /Client Scripts/Field Placeholder/fieldplaceholder.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | //Type appropriate comment here, and begin script below 3 | var shortDescription = g_form.getControl("short_description"); 4 | shortDescription.placeholder = "Please give the issue details here"; 5 | } 6 | -------------------------------------------------------------------------------- /Client Scripts/Get Value from URL Parameter/README.md: -------------------------------------------------------------------------------- 1 | Script that can be used in Client scripts to get URL parameter value. 2 | 3 | ** Isolate script should be **false** 4 | -------------------------------------------------------------------------------- /Client Scripts/Hide Work Notes section/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Hide Work Notes section/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Client Scripts/Hide Work Notes section/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Hide Work Notes section/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Client Scripts/Hide Work Notes section/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Hide Work Notes section/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Client Scripts/How to adjust the Date format within a client script to align with the User Date format/code.js: -------------------------------------------------------------------------------- 1 | var currentDateObj = new Date(); 2 | var currentDateUsr = formatDate(currentDateObj, g_user_date_format); 3 | -------------------------------------------------------------------------------- /Client Scripts/Make all fields read only/README.md: -------------------------------------------------------------------------------- 1 | Use this script to make all fields readonly via client script. 2 | 3 | **Tested in Global scope 4 | **You can't make mandatory fields as readonly 5 | **Best Practice is to use ACLs 6 | -------------------------------------------------------------------------------- /Client Scripts/Make fields read only in specific states/Make fields read only in specific state.md: -------------------------------------------------------------------------------- 1 | # Make editable fields read only on load in specific state for example state is On Hold. 2 | -------------------------------------------------------------------------------- /Client Scripts/On load Switch-Case Testing/README.md: -------------------------------------------------------------------------------- 1 | This is code snippet of switch case, and it will easily help to understand the usage of switch case and how we can implement it into the environment as per our requirements. 2 | -------------------------------------------------------------------------------- /Client Scripts/Open Record in Agne Workspace Tab/README.md: -------------------------------------------------------------------------------- 1 | This code helps to open a record in readonly mode irrespective of ACLS, UI Policies via client script in a Agent workspace tab. 2 | 3 | Here we are opening a story that is stored in the parent field on the incident record in the agent workspace. 4 | -------------------------------------------------------------------------------- /Client Scripts/Open Record in Agne Workspace Tab/openrecawtab.js: -------------------------------------------------------------------------------- 1 | // Opens a Story attached to a Incident record in the parent field in the readonly mode. 2 | function onLoad(g_form) { 3 | g_aw.openRecord('rm_story', g_form.getValue('parent'), {readOnlyForm: true}); 4 | } 5 | -------------------------------------------------------------------------------- /Client Scripts/Populate Jelly Slushbucket with Values/README.md: -------------------------------------------------------------------------------- 1 | This code is used to populate the Jelly tag within a UI Page. 2 | 3 | In the UI Page, must ensure that this tag is located in the HTML section. 4 | 5 | Then in the client script, include the code provided in the example. 6 | -------------------------------------------------------------------------------- /Client Scripts/Remove Option from Choice List/Remove Options from Choice List.js: -------------------------------------------------------------------------------- 1 | function onChange(control, oldValue, newValue, isLoading, isTemplate) { 2 | if (isLoading || newValue == '') { 3 | return; 4 | } 5 | if (newValue == 'inquiry') { //Onchange of Category 6 | g_form.removeOption('impact', '1'); 7 | g_form.removeOption('urgency', '1'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Client Scripts/Set Urgency to High onChange of caller field/README.md: -------------------------------------------------------------------------------- 1 | This is a client script that change urgency to high automatically when changing caller field with the caller name whose vip is true 2 | -------------------------------------------------------------------------------- /Client Scripts/Show field if x things are checked/README.md: -------------------------------------------------------------------------------- 1 | Use this script to show a field after `n` checkboxes are checked and not before. 2 | 3 | **Tested in Global scope 4 | **You can't make mandatory fields as readonly 5 | **Best Practice is to use UI Policies 6 | **Sometimes you have a lot of check marks and that logic gets narly 7 | -------------------------------------------------------------------------------- /Client Scripts/Toggle Annotation On Forms With Script/script.js: -------------------------------------------------------------------------------- 1 | // Show form annotations 2 | SN.formAnnotations.show(); 3 | 4 | // Hide form annotations 5 | SN.formAnnotations.hide(); 6 | 7 | // Toggle form annotations 8 | SN.formAnnotations.toggle(); 9 | -------------------------------------------------------------------------------- /Client Scripts/Translate Message/README.md: -------------------------------------------------------------------------------- 1 | # Translate your messages in client script using getMessage method 2 | 3 | *[getMessage() code snippet](getMessage.js) 4 | 5 | *[Translate message in client script doc](https://docs.servicenow.com/bundle/rome-platform-administration/page/administer/localization/task/t_TranslateAClientScriptMessage.html) 6 | -------------------------------------------------------------------------------- /Client Scripts/Update Category from Short Description Keywords/README.md: -------------------------------------------------------------------------------- 1 | ## Client Script that looks for category keywords in the Short Description updates the category field 2 | 3 | * Name: Set Category From Desc Keyword 4 | * Table: Incident 5 | * Type: onChange 6 | * Field Name: Short Description 7 | -------------------------------------------------------------------------------- /Client Scripts/Use case of addOption() and removeOption()/README.md: -------------------------------------------------------------------------------- 1 | # onChange client script for table 'change_request' where field is 'priority' 2 | if priority is critical, impact can be high and medium i.e, low will be removed from choice list using removeOption() 3 | and for other priority ,impact can be high, medium and low i.e, low option will be added, using addOption() 4 | -------------------------------------------------------------------------------- /Client Scripts/Validate Email Format/README.md: -------------------------------------------------------------------------------- 1 | onSubmit Function: This client script validates the email format when the form is submitted. 2 | Regular Expression: It uses a regex pattern to check if the entered email matches a standard email format. 3 | Error Message: If the email is invalid, an error message is displayed, and form submission is prevented. 4 | -------------------------------------------------------------------------------- /Client Scripts/Validate Short Description/README.md: -------------------------------------------------------------------------------- 1 | This Client Script validates the "Short Description" field before the form is submitted. 2 | If the description is more than 100 characters, it displays an alert and prevents submission. 3 | This helps maintain data quality by ensuring adequate information is provided. 4 | -------------------------------------------------------------------------------- /Client Scripts/Verify if e-mail already exists with Ajax call/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Verify if e-mail already exists with Ajax call/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Client Scripts/Verify if e-mail already exists with Ajax call/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Verify if e-mail already exists with Ajax call/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Client Scripts/Verify if e-mail already exists with Ajax call/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Client Scripts/Verify if e-mail already exists with Ajax call/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Client Scripts/Verify whether a date falls within a hour range/README.md: -------------------------------------------------------------------------------- 1 | A code snippet that verifies whether a date falls within a specific hour range. 2 | -------------------------------------------------------------------------------- /Client Scripts/Whitespace Validation/README.md: -------------------------------------------------------------------------------- 1 | This Client Script will validate whether the field contains any whitespace. 2 | -------------------------------------------------------------------------------- /Client Scripts/onfocus and onblur/script.js: -------------------------------------------------------------------------------- 1 | g_form.getElement("Field Name").onfocus = focus; 2 | g_form.getElement("Field Name").onblur = blur; 3 | } 4 | 5 | //function definition 6 | 7 | function focus() { 8 | g_form.showFieldMsg("Field Name", "Message you want to display"); 9 | } 10 | 11 | function blur() { 12 | g_form.hideFieldMsg("Field Name"); 13 | } 14 | -------------------------------------------------------------------------------- /Client Scripts/state-edit-for-grpmem/README.md: -------------------------------------------------------------------------------- 1 | This code will make state field editable only for group members, with the help of scratchpad variable that returns true or false from display business rule. 2 | 3 | -------------------------------------------------------------------------------- /Dynamic Filters/getMyDirectReports/example_manager_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Dynamic Filters/getMyDirectReports/example_manager_data.png -------------------------------------------------------------------------------- /Dynamic Filters/getMyDirectReports/one_of_my_direct_reports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Dynamic Filters/getMyDirectReports/one_of_my_direct_reports.png -------------------------------------------------------------------------------- /Dynamic Filters/getMyDirectReports/one_of_my_reports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Dynamic Filters/getMyDirectReports/one_of_my_reports.png -------------------------------------------------------------------------------- /ECMASCript 2021/destructuring.js: -------------------------------------------------------------------------------- 1 | // Okay, so destructuring is a LOT more than this but here is just an example. 2 | 3 | const x = [1, 2, 3, 4, 5]; 4 | const [y, z] = x; 5 | // y: 1 6 | // z: 2 7 | 8 | const obj = { a: 1, b: 2 }; 9 | const { a, b } = obj; 10 | // is equivalent to: 11 | // const a = obj.a; 12 | // const b = obj.b; -------------------------------------------------------------------------------- /ECMASCript 2021/javascriptmode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/ECMASCript 2021/javascriptmode.png -------------------------------------------------------------------------------- /ECMASCript 2021/openrecord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/ECMASCript 2021/openrecord.png -------------------------------------------------------------------------------- /Fix scripts/Add Fields On All List Views/README.md: -------------------------------------------------------------------------------- 1 | # Add Fields On All List Views 2 | 3 | This will add Updated On, Updated By, Created on, and Created by to every list view for the current user. You can add or remove fields to fieldsToAdd if you want others added as well 4 | -------------------------------------------------------------------------------- /Fix scripts/Add Variable set to multiple catalog items/README.md: -------------------------------------------------------------------------------- 1 | ### Add variable set to multiple catalog items through script 2 | 3 | Use this fix script to associate new variable set to few/all catalog items through script. 4 | Use sys_ids of all catalog items and Variable set in the script. 5 | -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Anonymise Data/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Anonymise Data/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Anonymise Data/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Anonymise Data/ScreenShot_4.PNG -------------------------------------------------------------------------------- /Fix scripts/Assign user list to a specific group/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Assign user list to a specific group/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Assign user list to a specific group/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Assign user list to a specific group/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Authenticate using ScriptedRESTAPI/README.md: -------------------------------------------------------------------------------- 1 | This fix script is created to make a post call using scripted REST API when header type is 'application/x-www-form-urlencoded' to get the token and authenticate 2 | -------------------------------------------------------------------------------- /Fix scripts/AutoNumberIssueFix/README.md: -------------------------------------------------------------------------------- 1 | # The Script is for correcting auto number issues 2 | # This Script should be run in global scope using scripts background 3 | # Ensure you update the required tableName per your requirement 4 | -------------------------------------------------------------------------------- /Fix scripts/Cancel Workflow/README.md: -------------------------------------------------------------------------------- 1 | Script to Cancel the workflow context attached to a record 2 | -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Clean update set/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Clean update set/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Clean update set/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Clean update set/ScreenShot_4.PNG -------------------------------------------------------------------------------- /Fix scripts/Delete Change Conflict/README.md: -------------------------------------------------------------------------------- 1 | Use this script to delete change Conflicts and set conflict status as 'No Conflict' using fix script. 2 | -------------------------------------------------------------------------------- /Fix scripts/Find Reports Assigned to inactive Groups/README.md: -------------------------------------------------------------------------------- 1 | This Fix script will get you the reports assigned to inactive groups so that you can do the cleanup of reports 2 | Required role: itil_admin 3 | 4 | -------------------------------------------------------------------------------- /Fix scripts/Find duplicate records/README.md: -------------------------------------------------------------------------------- 1 | # Find duplicate records 2 | 3 | Run the script to find duplicate records in a table. It is using GlideAggregate to find duplicate records. Replace the TABLE_TO_FIND_DUPLICATE_IN and FIELD_TO_GROUP_BY constants with your table and field and it will spit the records. 4 | -------------------------------------------------------------------------------- /Fix scripts/Find the reports assigned to Inactive Users/README.md: -------------------------------------------------------------------------------- 1 | This Fix script will get you the reports assigned to inactive Users so that you can do the cleanup of reports 2 | Required role: itil_admin 3 | -------------------------------------------------------------------------------- /Fix scripts/Fix teams token/README.md: -------------------------------------------------------------------------------- 1 | This script helps to fix the MS teams integration token for a specific user. Once the script has been executed, the user can try to reinitiate the teams from the task to retrieve a new token. -------------------------------------------------------------------------------- /Fix scripts/Get Catalog Items not used in last few months/README.md: -------------------------------------------------------------------------------- 1 | Use this fix script to get the list of Catalog items that are not used in few months. 2 | 3 | This information is used by stackholders to identify unused cat items and the can start deactivating it. 4 | -------------------------------------------------------------------------------- /Fix scripts/Ignore outbound emails/README.md: -------------------------------------------------------------------------------- 1 | Used to ignore all emails in the system so they are not sent on outbox activation. 2 | Run this script prior to enabling email sending to ensure no testing emails are sent upon email activation 3 | -------------------------------------------------------------------------------- /Fix scripts/Ignore outbound emails/ignoremail.js: -------------------------------------------------------------------------------- 1 | var emailGR = new GlideRecord('sys_email'); 2 | 3 | emailGR.addQuery('type','send-ready'); 4 | emailGR.query(); 5 | 6 | while (emailGR.next()) { 7 | emailGR.type = 'send-ignored'; 8 | emailGR.update(); 9 | } 10 | -------------------------------------------------------------------------------- /Fix scripts/Install Base PDI Plugins/README.md: -------------------------------------------------------------------------------- 1 | # Install Base PDI Plugins 2 | 3 | Fix Script to speed up installation of multiple plugins on a fresh PDI (even with demo data). 4 | 5 | Options: (modify script as needed) 6 | - plugins (array) includes names of the plugins to install 7 | - include_demo_data (true/false) whether to install demo data or not (default=false) 8 | -------------------------------------------------------------------------------- /Fix scripts/Install Demo Data/README.md: -------------------------------------------------------------------------------- 1 | Add demo data to a list of installed plugins. I use this to add demo data for the OOTB ATF tests to work in sub-prod instances. It is expected that the corresponding ATF Test plugins are installed on the production instance already, and we are only adding the demo data. -------------------------------------------------------------------------------- /Fix scripts/Mass Update RITM Variable/README.md: -------------------------------------------------------------------------------- 1 | Use this Fix Script to update a variable value on one or more RITM records 2 | -------------------------------------------------------------------------------- /Fix scripts/Measure code time execution/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Measure code time execution/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Measure code time execution/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Fix scripts/Measure code time execution/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Run Subscription Job On Demand/code.js: -------------------------------------------------------------------------------- 1 | var summarizer = new SNC.SubscriptionSummarizer(); 2 | summarizer.runSummary(); 3 | -------------------------------------------------------------------------------- /Fix scripts/SchemaGenerator/README.md: -------------------------------------------------------------------------------- 1 | The mentioned script provides a schema for any table in ServiceNow. -------------------------------------------------------------------------------- /Fix scripts/get Groups without Member/README.md: -------------------------------------------------------------------------------- 1 | Use this fix script to get the list of groups having no members or group without active members in it. 2 | 3 | Such gruups can be deactivated if not required. 4 | -------------------------------------------------------------------------------- /Flow Actions/Assign Role/README.md: -------------------------------------------------------------------------------- 1 | # Assign Role 2 | A custom flow action which will help us to assign the a role to a user. 3 | -------------------------------------------------------------------------------- /Flow Actions/Calculate Ticket Age/script.js: -------------------------------------------------------------------------------- 1 | (function execute(inputs, outputs) { 2 | var start_date = new GlideDateTime(inputs.start_date); //created date 3 | var end_date = new GlideDateTime(inputs.end_date); //updated 4 | outputs.ticket_age = GlideDateTime.subtract(start_date,end_date).getDisplayValue(); 5 | })(inputs, outputs); 6 | -------------------------------------------------------------------------------- /Flow Actions/Check MID Server Availability/README.md: -------------------------------------------------------------------------------- 1 | ## Action Script to check mid server availability 2 | 3 | ### Use this script in a new flow action to check if a mid server is up/available or not. This can be used to for orchestration projects or similar. 4 | ### Note: The script returns availability as true/false back as the action output to the flow. 5 | -------------------------------------------------------------------------------- /Flow Actions/Get Days difference/README.md: -------------------------------------------------------------------------------- 1 | # Get Days Difference 2 | Frequently, in our flow, there's a need to calculate the difference in days between two dates. To address this, I've developed a specialized flow action that facilitates this calculation. 3 | -------------------------------------------------------------------------------- /Flow Actions/Get Property/README.md: -------------------------------------------------------------------------------- 1 | Flow Action to return the value of a sys_properties 2 | 3 | Action requires: 4 | - One string input for sys_properties name 5 | - Script Step (provided in getPropertyFlowAction.js) 6 | - One string output for returned value -------------------------------------------------------------------------------- /Flow Actions/Get Property/getPropertyFlowAction.js: -------------------------------------------------------------------------------- 1 | (function execute(inputs, outputs) { 2 | outputs.value = gs.getProperty(inputs.property); 3 | })(inputs, outputs); -------------------------------------------------------------------------------- /Flow Actions/Milliseconds to Duration/millisecondsToDuration.js: -------------------------------------------------------------------------------- 1 | (function execute(inputs, outputs) { 2 | 3 | var gdt0 = new GlideDateTime("1970-01-01 00:00:00"); //Epoch DateTime 4 | var gdt1 = inputs.milliseconds; 5 | gdt0.add(gdt1); // Adds the milliseconds to the epoch date/time 6 | 7 | outputs.time = gdt0.toString(); 8 | 9 | })(inputs, outputs); 10 | -------------------------------------------------------------------------------- /Flow Actions/Remove HTML Tags from a String in a Flow: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Flow Actions/Runscript activities/README.md: -------------------------------------------------------------------------------- 1 | This code help to set the RITM description as the summary of catalog item variables. 2 | we can reuse the code on catalog workflows in runscript activity and flow designers 3 | -------------------------------------------------------------------------------- /Flow Actions/ShuffleArrayMatches/README.md: -------------------------------------------------------------------------------- 1 | # Shuffle Array Matches 2 | Flow Action: inputs of a List of SysID's and it creates a Shuffled Arrays, Matches of 2 sysIDs 3 | 4 | -------------------------------------------------------------------------------- /Flow Actions/Trigger event action/trigger event flow action.js: -------------------------------------------------------------------------------- 1 | (function execute(inputs, outputs) { 2 | 3 | gs.eventQueue(inputs.event_name, inputs.event_record, inputs.parm1, inputs.parm2); 4 | 5 | })(inputs, outputs); 6 | -------------------------------------------------------------------------------- /Flow Actions/get Catalog Variables as JSON/README.md: -------------------------------------------------------------------------------- 1 | Get catalog variables from a given RITM 2 | -------------------------------------------------------------------------------- /Formula Builder/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Formula Builder/1.jpg -------------------------------------------------------------------------------- /Formula Builder/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Formula Builder/2.png -------------------------------------------------------------------------------- /Formula Builder/Get Age From Birthdate/script.js: -------------------------------------------------------------------------------- 1 | IF(OR(MONTH(birthdate) < MONTH(TODAY()), AND(MONTH(birthdate) = MONTH(TODAY()), DAY(birthdate) < DAY(TODAY()))), SUBTRACT(YEAR(TODAY()), YEAR(birthdate)), SUBTRACT(SUBTRACT(YEAR(TODAY()), 1) ,YEAR(birthdate))) 2 | -------------------------------------------------------------------------------- /GlideAggregate/Count incidents based on category/README.md: -------------------------------------------------------------------------------- 1 | Go to background and execute the script then you will get the total count of incidents based on category. 2 | 3 | It will easily help to segregate the data based on categories/priority/ etc anything. 4 | -------------------------------------------------------------------------------- /GlideAggregate/Get Incident Count by Priority/README.md: -------------------------------------------------------------------------------- 1 | Many of times, you are being asked to report the total count of incidents grouped by Incident priority. This code will be helpful to get that information. The code could be further enhanced or modified to get more detailed requirements like getting the latest incident being raised within the respective priority. 2 | -------------------------------------------------------------------------------- /GlideAggregate/Group Count/GlideQuery.js: -------------------------------------------------------------------------------- 1 | function getGroupCountGQ(table, groupBy, min) { 2 | var gqCount = new GlideQuery(table) 3 | .aggregate('count', groupBy) 4 | .whereNotNull(groupBy) 5 | .groupBy(groupBy) 6 | .having('count', groupBy, '>=', min) 7 | .select() 8 | .toArray(10); 9 | return gqCount; 10 | } -------------------------------------------------------------------------------- /GlideAggregate/Grouping by three columns/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/GlideAggregate/Grouping by three columns/ScreenShot_1.PNG -------------------------------------------------------------------------------- /GlideAggregate/Incident Analysis and Resolution Calculation using Glideaggregate/README.md: -------------------------------------------------------------------------------- 1 | These scripts explain the usage of Glideaggregate. This script helps to group the incidents by their assigned user, counts the number of incidents assigned to each user, and calculates the average time it takes to close these incidents. 2 | -------------------------------------------------------------------------------- /GlideAggregate/List of Child Incident of All Incidents/README.md: -------------------------------------------------------------------------------- 1 | This code will show all the Incidents who are Parent Incidents based on filter condition query with how many Child Incidents they have. 2 | -------------------------------------------------------------------------------- /GlideAggregate/List of Managers in User Table/README.md: -------------------------------------------------------------------------------- 1 | This code will display the list of Users who are at Managers level and someone's manager. 2 | -------------------------------------------------------------------------------- /GlideAggregate/SLA Count by Assignment Group/README.md: -------------------------------------------------------------------------------- 1 | # SLA Count by Assignment Group 2 | 3 | This script retrieves active SLAs (task_sla table) grouped by assignment groups in ServiceNow. It counts the number of active SLAs per group and logs the result, displaying the group name and corresponding SLA count. 4 | -------------------------------------------------------------------------------- /GlideAggregate/Tiered grouping of an integer column/README.md: -------------------------------------------------------------------------------- 1 | # Tiered grouping of an integer column 2 | 3 | If you have a column with points (as an integer), this script breaks them down by percentile tiers. 4 | -------------------------------------------------------------------------------- /GlideAggregate/Using addHaving/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/GlideAggregate/Using addHaving/ScreenShot_1.PNG -------------------------------------------------------------------------------- /GlideAggregate/addTrend/README.md: -------------------------------------------------------------------------------- 1 | ### GlideAggregate - addTrend() 2 | 3 | #### To show number of closed incidents by Assignment group monthly. 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /GlideAggregate/getTotal of aggregate value/README.md: -------------------------------------------------------------------------------- 1 | ### GlideAggregate - getTotal() 2 | 3 | #### Script to get total of aggregate value 4 | 5 | Example 6 | To show total number of closed P1 incidents which was illustrated in a trend (count of incident every month). 7 | -------------------------------------------------------------------------------- /GlideAjax/EfficientGlideRecord (Client-side)/README.md: -------------------------------------------------------------------------------- 1 | # EfficientGlideRecord 2 | See related article for full usage instructions and API documentation: 3 | https://go.snc.guru/egr -------------------------------------------------------------------------------- /GlideAjax/Fetch Multiple Values in GlideAjax without JSON/README.md: -------------------------------------------------------------------------------- 1 | This code snippet allows to receive multiple response from server side to client side using GlideAjax without using the complex JSON format. You can set multiple attributes in server side, and use the same attribute at the client side to receive responses. 2 | -------------------------------------------------------------------------------- /GlideDateTime/AddDays/README.md: -------------------------------------------------------------------------------- 1 | A code snippet to set a default value on a date variable to a date relative (+/- days from today) 2 | 3 | Example Syntax: 4 | 5 | javascript:var gdt = new GlideDateTime(); gdt.addDays(-1);gdt.getDate(); 6 | -------------------------------------------------------------------------------- /GlideDateTime/AddDays/addDays.js: -------------------------------------------------------------------------------- 1 | //prefix with javascript: in default value field 2 | //Add or Subtract a relative amount of days from today 3 | javascript:var gdt = new GlideDateTime(); gdt.addDays(-1);gdt.getDate(); 4 | -------------------------------------------------------------------------------- /GlideDateTime/Check if today is weekend/Check if today is weekend.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideDateTime(); 2 | var day = gr.getDayOfWeekLocalTime(); 3 | if(day == 7 || day == 6) 4 | { 5 | gs.print("Today is Weekend"); 6 | } 7 | else 8 | { 9 | gs.print("Today is working day"); 10 | } 11 | -------------------------------------------------------------------------------- /GlideDateTime/Check if today is weekend/README.md: -------------------------------------------------------------------------------- 1 | Use this script to know whether today is weekend or weekday. 2 | 3 | It helps to restrict the schedule job/ any other activity during weekends. 4 | -------------------------------------------------------------------------------- /GlideDateTime/Convert date format/README.md: -------------------------------------------------------------------------------- 1 | # Convert date format 2 | 3 | **Use-case / Requirement :** 4 | Convert date from one format to another format 5 | For example from dd-mm-yyyy to yyyy-mm-dd or yyyy/mm/dd etc 6 | 7 | **Solution :** 8 | Use GlideDate object and getByFormat method for conversion. 9 | Check the script.js file to find the code 10 | -------------------------------------------------------------------------------- /GlideDateTime/Current Date with Fixed Time/CurrentDateFixedTime.js: -------------------------------------------------------------------------------- 1 | var gd = new GlideDate(); 2 | var gdt = new GlideDateTime(); 3 | gdt.setValue(gd + " 18:00:00"); 4 | gs.info(gdt); 5 | -------------------------------------------------------------------------------- /GlideDateTime/Current Date with Fixed Time/README.md: -------------------------------------------------------------------------------- 1 | This script helps to set fixed time to Present Date.. 2 | -------------------------------------------------------------------------------- /GlideDateTime/Due date generation/README.md: -------------------------------------------------------------------------------- 1 | For the workflows created using flow designer, the due date for sctasks is not populated automatically. 2 | This code populates the due date of sctask automatically when RITMs are created through flow designers. 3 | -------------------------------------------------------------------------------- /GlideDateTime/Get last day of a month/README.md: -------------------------------------------------------------------------------- 1 | Code snippets to get the last day of a month from a date field or an GDT object. 2 | -------------------------------------------------------------------------------- /GlideElement/Display available choices/DisplayAvailableChoices.js: -------------------------------------------------------------------------------- 1 | var grInc = new GlideRecord('incident'); 2 | grInc.get('number', 'INC0006924'); 3 | var acceptedValues = j2js(grInc.contact_type.getChoices()); 4 | gs.debug('The accepted values for field contact_type are: ' + acceptedValues.join(', ')); -------------------------------------------------------------------------------- /GlideElement/Display available choices/README.md: -------------------------------------------------------------------------------- 1 | A code snippet to show how to obtain the list of accepted values for a given choice field. 2 | It also uses `j2js()` to convert the output array from Java to Javascript. -------------------------------------------------------------------------------- /GlideFilter/checkRecord/README.md: -------------------------------------------------------------------------------- 1 | Ever wondered how business rule works in the background. This example depicts the common scenario where we want to analyse certain records against a certain condition. This is one of the OOB class provided by servicenow. 2 | -------------------------------------------------------------------------------- /GlideFilter/checkRecord/example.js: -------------------------------------------------------------------------------- 1 | var cond='short_description=certificate: Fingerprint: - Certificate Expired'; 2 | var emalert = new GlideRecord('em_alert'); 3 | emalert.query(); 4 | 5 | var bool = true; 6 | 7 | while(emalert.next()) 8 | { 9 | bool = GlideFilter.checkRecord(emalert, cond); 10 | gs.info("Source "+ emalert.source + " is " + bool); 11 | } 12 | -------------------------------------------------------------------------------- /GlideHTTPRequest/README.md: -------------------------------------------------------------------------------- 1 | GlideHTTPRequest API is used to work on Glide HTTP Request and Response. 2 | 3 | API Documentation Link for "PARIS" release : https://developer.servicenow.com/dev.do#!/reference/api/paris/server_legacy/GlideHTTPRequestAPI 4 | 5 | Please update the variable details in the script to check it. 6 | -------------------------------------------------------------------------------- /GlideQuery/Field Default/GlideQueryFieldDefault.js: -------------------------------------------------------------------------------- 1 | javascript:var gq = new global.GlideQuery('sys_user').get(gs.getUserID(), [ 'phone']);gq._value.phone; 2 | -------------------------------------------------------------------------------- /GlideQuery/Field Default/README.md: -------------------------------------------------------------------------------- 1 | # Use GlideQuery to get a default value for a field 2 | 3 | Use GlideQuery to get a field value when specifying a default in the dictionary record 4 | 5 | Substitute the field name for the value you want (i.e., phone, first_name etc). 6 | -------------------------------------------------------------------------------- /GlideQuery/Get User's Roles from User Name/README.md: -------------------------------------------------------------------------------- 1 | # Get User's Roles from User Name 2 | 3 | GlideQuery's can greatly simplify extracting information from queries, especially when dot walking. 4 | 5 | This code has been updated to simplify the function to return an array of roles for the given user. Shows the use of GlideQuery and .reduce() in place of .toArray(). 6 | -------------------------------------------------------------------------------- /GlideQuery/Remote Table/README.md: -------------------------------------------------------------------------------- 1 | This script is used to combine 2 internal tables:sc_req_item and sc_item_produced_record from a Report Table Definition => Script tab. 2 | We can create a report on the created remote table (Pie chart). 3 | -------------------------------------------------------------------------------- /GlideRecord/ACL enforcement using GlideRecord/glideRecordSecure.js: -------------------------------------------------------------------------------- 1 | var grSecure = new GlideRecordSecure(''); 2 | grSecure.addEncodedQuery(''); 3 | grSecure.query(); 4 | while(grSecure.next()) 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /GlideRecord/Add n number of users to n number of groups using server scripts/README.md: -------------------------------------------------------------------------------- 1 | This server-side script will add any number of Users to any number of groups. It is required to be used in Server-Side scripts. 2 | -------------------------------------------------------------------------------- /GlideRecord/Choose Window for better performance/script.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideRecord('incident'); 2 | gr.chooseWindow(0, 10); // Fetch the first 10 records 3 | gr.query(); 4 | while (gr.next()) { 5 | gs.info(gr.number); 6 | } 7 | -------------------------------------------------------------------------------- /GlideRecord/Count Records By Column/README.md: -------------------------------------------------------------------------------- 1 | # Count records in a table by column 2 | Script to count records in a table, grouped by a certain column and output as CSV for further data analysis. 3 | Can be useful where further data analysis is needed for example during data or domain migration projects. 4 | -------------------------------------------------------------------------------- /GlideRecord/Display list of records based on Users Location/README.md: -------------------------------------------------------------------------------- 1 | Get the list of records based on the User's Location while getting the list of records 2 | -------------------------------------------------------------------------------- /GlideRecord/Fetch groups that have no members in them/README.md: -------------------------------------------------------------------------------- 1 | This is script is useful in listing out the groups that do not have any members. You can use it before setting any group record/s as inactive. 2 | -------------------------------------------------------------------------------- /GlideRecord/Find Date Overlapping/README.md: -------------------------------------------------------------------------------- 1 | Logic to check if new dates are falling between already created record's dates. 2 | -------------------------------------------------------------------------------- /GlideRecord/Find No Of Days/README.md: -------------------------------------------------------------------------------- 1 | This code will let you find the date difference between the provided dates: Helps in calculating No of days, payment processing , etc. 2 | -------------------------------------------------------------------------------- /GlideRecord/Get All Groups without Manager/README.md: -------------------------------------------------------------------------------- 1 | The GlideRecord query is used to get the groups names having manager field Empty. 2 | -------------------------------------------------------------------------------- /GlideRecord/Get Contains role of a role/Get contains role of a role.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideRecord('sys_user_role_contains'); 2 | gr.addQuery('role.name', ''); //replace with the name of a role to which you need to get all the conatins role 3 | gr.query(); 4 | while(gr.next()){ 5 | gs.info(gr.contains.name.toString()); 6 | } 7 | -------------------------------------------------------------------------------- /GlideRecord/Get Contains role of a role/README.md: -------------------------------------------------------------------------------- 1 | The script in GlideRecord > Get Contains role of a role >Get contains role of a role.js file will get all the roles contains in a role. 2 | 3 | The ' needs to be replaced with the name of a role to which you need to get all the contains role 4 | -------------------------------------------------------------------------------- /GlideRecord/Get Reference Record/README.md: -------------------------------------------------------------------------------- 1 | # Get Reference Record 2 | 3 | If you need a GlideRecord object for a reference item, then getRefRecord() is the method to use. You must call isValidRecord() after getting the reference record as getRefRecord() does not throw errors for empty values. isValidRecord() will be true if your reference record was found. 4 | -------------------------------------------------------------------------------- /GlideRecord/Get Reference Record/Readme_Soumyadeep.md: -------------------------------------------------------------------------------- 1 | This script will glide for a particular record whose sys id has been provided 2 | It will fetch the record and then use getRefRecord() to fetch the requested by user details. 3 | If the user is a valid record, then it will fetch the user_name and email. 4 | -------------------------------------------------------------------------------- /GlideRecord/Get Reference Record/script.js: -------------------------------------------------------------------------------- 1 | function getAssignmentGroup(grIncident) { 2 | var grGroup = grIncident.assignment_group.getRefRecord(); 3 | if (grGroup.isValidRecord()) { 4 | gs.print(grGroup.getValue("name")); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /GlideRecord/Get all task records with at least on active child task/Get all task records with at least on active child task.md: -------------------------------------------------------------------------------- 1 | # Glide record to get all the task records which have at least one active child task -------------------------------------------------------------------------------- /GlideRecord/Get all user's group based on username/README.md: -------------------------------------------------------------------------------- 1 | Get all user's group based on username 2 | 3 | Just add replace the **userid** with the correct username in script 4 | -------------------------------------------------------------------------------- /GlideRecord/Get link for the Record/README.md: -------------------------------------------------------------------------------- 1 | getLink() generates a direct URL to the record, useful for embedding links to records in notifications or logging them. 2 | Summary: Generate a URL link to the record. -------------------------------------------------------------------------------- /GlideRecord/Get link for the Record/script.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideRecord('incident'); 2 | if (gr.get('sys_id_of_record')) { 3 | gs.info('Incident link: ' + gr.getLink()); 4 | } 5 | -------------------------------------------------------------------------------- /GlideRecord/GlideRecord with Performance Enhancement Condtions/README.md: -------------------------------------------------------------------------------- 1 | A sample GlideRecord code with conditions to enhance performance. 2 | -------------------------------------------------------------------------------- /GlideRecord/List of Child Incidents/README.md: -------------------------------------------------------------------------------- 1 | This code will help to show list of Incidents whih are child of a particular incident. 2 | -------------------------------------------------------------------------------- /GlideRecord/Multi Row Variable Set(MRVS)/README.md: -------------------------------------------------------------------------------- 1 | This piece of code will let you insert MRVS Records without quering the Question Answers out of the box table! 2 | -------------------------------------------------------------------------------- /GlideRecord/Populate the type of device on any record/README.md: -------------------------------------------------------------------------------- 1 | This script will return and populate the type of device from which incident or issue is raised. 2 | -------------------------------------------------------------------------------- /GlideRecord/Set Template/README.md: -------------------------------------------------------------------------------- 1 | This function is useful in applying template on tables when creating new record using scripts. 2 | -------------------------------------------------------------------------------- /GlideRecord/UpdateMultiple/README.md: -------------------------------------------------------------------------------- 1 | Update Multiple is such a useful tool. It has a few restrictions so make sure you are able to use it for your use case (not Journals) 2 | 3 | -------------------------------------------------------------------------------- /GlideRecord/Watch_List_functions/README.md: -------------------------------------------------------------------------------- 1 | This code snippet is to help you remove a specific element/sys_id from a List or an array using javascript. This code can be run via any server side scripting. 2 | For eg: 3 | 1. Background scripting 4 | 2. Fix script 5 | 3. BR 6 | 4. ScriptInclude etc. 7 | -------------------------------------------------------------------------------- /GlideRecord/comments on gr.update/README.md: -------------------------------------------------------------------------------- 1 | Comments on gr.update via an optional parameter of why or from where it is being update. 2 | 3 | Reference of documentation link: https://developer.servicenow.com/dev.do#!/reference/api/utah/server/no-namespace/c_GlideRecordScopedAPI#r_ScopedGlideRecordUpdate_String?navFilter=update 4 | -------------------------------------------------------------------------------- /GlideRecord/comments on gr.update/code.js: -------------------------------------------------------------------------------- 1 | var now_GR = new GlideRecord('incident'); 2 | now_GR.get('99ebb4156fa831005be8883e6b3ee4b9'); 3 | now_GR.setValue('short_description', 'Update the short description'); 4 | now_GR.update("updated from BR" ); // This comment gets added to the activity log of incident for audit purposes. 5 | -------------------------------------------------------------------------------- /GlideRecord/findDuplicate/README.md: -------------------------------------------------------------------------------- 1 | This sripts is used to find Duplicate Records in the 'asset' table you can change table as per your wish. 2 | Duplicates are counted on 'asset_tag'. 3 | If count is greater than 2 than we add it to array. 4 | -------------------------------------------------------------------------------- /GlideRecord/getEncodedQuery/code.js: -------------------------------------------------------------------------------- 1 | gr.query(); 2 | var outPutQuery = gr.getEncodedQuery(); //this gives query applied above as encoded query 3 | if(!gr.next()){ //check if record exist or not 4 | //create record 5 | gr.initialize(); 6 | gr.applyEncodedQuery(outPutQuery); //set field values as “outPutQuery” encoded query 7 | gr.insert(); 8 | } 9 | -------------------------------------------------------------------------------- /GlideSystem/Impersonate/README.md: -------------------------------------------------------------------------------- 1 | GlideSystem (referred as "gs") provides a way to find information about the current session. 2 | Using the getSession() method of the scoped GlideSystem API. 3 | 4 | This gives the example on how to impersonate a user using the impersonate method in the code. 5 | -------------------------------------------------------------------------------- /GlideSystem/Session/session.js: -------------------------------------------------------------------------------- 1 | //Get user session object. 2 | var session = gs.getSession(); 3 | 4 | //Set value for custom key 5 | session.putClientData("custom_key","custom_value"); 6 | 7 | //Print the value for the key supplied 8 | gs.print(session.getClientData("custom_key")); 9 | -------------------------------------------------------------------------------- /GlideSystem/Table/tableExists.js: -------------------------------------------------------------------------------- 1 | var table = gs.tableExists('cmdb_ci'); //Name of the table 2 | gs.info(table); //Will return a boolean 3 | 4 | //Output Example: 5 | //*** Script: true 6 | -------------------------------------------------------------------------------- /GlideSystem/Table/truncateTable.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/GlideSystem/Table/truncateTable.js -------------------------------------------------------------------------------- /GlideSystem/User/README.md: -------------------------------------------------------------------------------- 1 | # GlideSystem User Methods 2 | 3 | ### userID 4 | * Description: Returns the sys_id of the user associated with this session. 5 | * [userID Code Snippet](userID.js) 6 | * [userID API Doc](https://developer.servicenow.com/dev.do#!/reference/api/rome/server_legacy/c_GlideSystemAPI#r_GS-userID) -------------------------------------------------------------------------------- /GlideSystem/User/userID.js: -------------------------------------------------------------------------------- 1 | var id = gs.userID(); //Returns the sys_id of the user associated with this session 2 | gs.info(id); 3 | 4 | //Example Output: 98b9c2ee1b356664a496154de4febcb 5 | -------------------------------------------------------------------------------- /GlideSystem/date-time/monthsAgo.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var monthsAgo = gs.monthsAgo(5); //Returns a date and time for a certain number of months (in brackets) ago. 4 | gs.info('5 Months Ago: ' + monthsAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 14:47:23 8 | //*** Script: 5 Months Ago: 2021-05-04 18:47:23 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/quartersAgo.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var quartersAgo = gs.quartersAgo(2); //Returns a date and time for a certain number of quarters ago 4 | gs.info('2 Quarters Ago: ' + quartersAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 15:41:32 8 | //*** Script: 2 Quarters Ago: 2021-04-04 15:41:32 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/yearsAgo.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var yearsAgo = gs.yearsAgo(1); //Gets a date and time for a certain number of years ago. 4 | gs.info('1 Year Ago: ' + yearsAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-05 08:54:28 8 | //*** Script: 1 Year Ago: 2020-10-05 12:54:28 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/yesterday.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var yesterdayDateTime = gs.yesterday(); //Returns yesterday's time (24 hours ago). 4 | gs.info('24 Hours Ago: ' + yesterdayDateTime); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-05 08:59:50 8 | //*** Script: 24 Hours Ago: 2021-10-04 08:59:50 9 | -------------------------------------------------------------------------------- /GlideSystem/hasRoleExactly/README.md: -------------------------------------------------------------------------------- 1 | # Server-side version of the hasRoleExactly 2 | 3 | Determines whether the current user has the specified role. 4 | 5 | This feature only exists on the client-side but can be useful on the server-side also. 6 | -------------------------------------------------------------------------------- /GlideSystem/hasRoleExactly/script.js: -------------------------------------------------------------------------------- 1 | function hasRoleExactly(role) { 2 | // Java String to JavaScript String 3 | var roles = gs.getSession().getRoles() + ''; 4 | var roleArr = roles.split(','); 5 | return roleArr.indexOf(role) !== -1; 6 | } 7 | -------------------------------------------------------------------------------- /GlideTableDescriptor/getFirstTableName()/GlideTableDescriptor.js: -------------------------------------------------------------------------------- 1 | var td = GlideTableDescriptor.get(dictionaryGR.getValue("name")); 2 | var ed = td.getElementDescriptor(dictionaryGR.getValue("element")); 3 | gs.print(ed.getFirstTableName()); //using “getFirstTableName()” to find out where it was descended from. 4 | 5 | 6 | -------------------------------------------------------------------------------- /GraphQL/Sample INC Details GraphQL Code Snippet/CMDB Resolver.js: -------------------------------------------------------------------------------- 1 | (function process(/*ResolverEnvironment*/ env) { 2 | 3 | var user= env.getSource(); 4 | var CI = new GlideRecord("cmdb_ci"); 5 | CI.addQuery("sys_id",CI); 6 | CI.query(); 7 | return CI; 8 | 9 | 10 | })(env); 11 | -------------------------------------------------------------------------------- /GraphQL/Sample INC Details GraphQL Code Snippet/Incident Resolver.js: -------------------------------------------------------------------------------- 1 | (function process(/*ResolverEnvironment*/ env) { 2 | 3 | var sys_id=env.getArguments().sys_id; 4 | var INC = new GlideRecord("incident"); 5 | INC.addQuery("sys_id",sys_id); 6 | INC.query(); 7 | return INC; 8 | 9 | 10 | })(env); 11 | -------------------------------------------------------------------------------- /GraphQL/Sample INC Details GraphQL Code Snippet/User Resolver.js: -------------------------------------------------------------------------------- 1 | (function process(/*ResolverEnvironment*/ env) { 2 | 3 | var user= env.getSource(); 4 | var User = new GlideRecord("sys_user"); 5 | User.addQuery("sys_id",user); 6 | User.query(); 7 | return User; 8 | 9 | 10 | })(env); 11 | -------------------------------------------------------------------------------- /GraphQL/Sample INC Details GraphQL Code Snippet/resolver mapping.js: -------------------------------------------------------------------------------- 1 | { 2 | "incident:cmdb_ci": "CMDB Resolver", 3 | "incident:caller_id": "User Resolver", 4 | "Query:EntersysID":"Incident Resolver" 5 | } 6 | -------------------------------------------------------------------------------- /GraphQL/Sample group query/add_user_to_group_broker_query.gql: -------------------------------------------------------------------------------- 1 | mutation ($userID: ID!, $groupID: ID!) { 2 | app_namespace { 3 | schema_namespace { 4 | addUserToGroup(userID: $userID, groupID: $groupID) { 5 | userName 6 | groupName 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /GraphQL/Sample group query/get_groups_broker_query.gql: -------------------------------------------------------------------------------- 1 | query { 2 | app_namespace { 3 | schema_namespace { 4 | getGroups { 5 | id 6 | name 7 | manager 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /GraphQL/Sample group query/resolver_mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Query:getGroups": "getGroups", 3 | "Mutation:addUserToGroup": "addUserToGroup" 4 | } -------------------------------------------------------------------------------- /GraphQL/Sample users query/get_user_broker_properties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "id", 4 | "label": "User Sys Id", 5 | "description": "User's Sys ID", 6 | "readOnly": false, 7 | "fieldType": "string", 8 | "mandatory": true, 9 | "defaultValue": "" 10 | } 11 | ] -------------------------------------------------------------------------------- /GraphQL/Sample users query/resolver_mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "User:groups": "getUserGroups", 3 | "Query:getUser": "getUserObject", 4 | "User:roles": "getUserRoles" 5 | } -------------------------------------------------------------------------------- /ITOM/Bulk Location Update/README.md: -------------------------------------------------------------------------------- 1 | This script will get all the CI classes mentioned in the property "nonDiscovery.location.update" in a comma-separated and fetch all the sub-classes of the mentioned classes and update the location data based on subnet information stored in 'cmdb_ci_ip_network_subnet' table and make updates in bulk on location basis. -------------------------------------------------------------------------------- /Inbound Actions/Automate creation of incidents through inbound actions/README.md: -------------------------------------------------------------------------------- 1 | This is a simple code to automate creation of incidents for the alerts receiving to ServiceNow instance. This code has functionality of adding receipients (excluding service-now instance emails) of email to watchlist of incident. 2 | -------------------------------------------------------------------------------- /Integration/Import Sets/README.md: -------------------------------------------------------------------------------- 1 | # Import Sets 2 | 3 | Here you can put scripts related to data imports and transforms -------------------------------------------------------------------------------- /Integration/Scripted SOAP Incident Creation/README.md: -------------------------------------------------------------------------------- 1 | I have created a scripted SOAP service for creation of incident with the help of third party tools, with all mandatory validations. My API will check the validations while creating the incidents from third party tool and it won't allow to submit the record untill all validations will pass. 2 | -------------------------------------------------------------------------------- /MIDServer/API Class Examples/README.md: -------------------------------------------------------------------------------- 1 | # MIDServer class samples 2 | 3 | * Description: Usage samples for the MIDServer API class. 4 | * [MIDServer Code Snippet](scripts.js) 5 | * [MIDServer API Doc](https://developer.servicenow.com/dev.do#!/reference/api/rome/server_legacy/c_MIDServerAPI) -------------------------------------------------------------------------------- /Mail Scripts/Add Checklist/README.md: -------------------------------------------------------------------------------- 1 | # Add Checklist 2 | 3 | If a checklist exists for the task, add it to the email notification. 4 | -------------------------------------------------------------------------------- /Mail Scripts/Add HTML Table for Requested Item Variables/README.md: -------------------------------------------------------------------------------- 1 | Use this snippet to create an HTML file of requested item variables. Will exclude variables that are not needed (empty/undefined) 2 | -------------------------------------------------------------------------------- /Mail Scripts/Add Users in Watchlist to CC/README.md: -------------------------------------------------------------------------------- 1 | This script allow users in the watchlist to be added to the CC in the Email. This script will work for a table extended from Task table. You can make changes to the field 'watch_list' to match to any other user list field to be added to CC 2 | -------------------------------------------------------------------------------- /Mail Scripts/Add a link which opens ticket in Service Portal/README.md: -------------------------------------------------------------------------------- 1 | Use this script to add a link in email notification which opens the ticket in Service Portal 2 | -------------------------------------------------------------------------------- /Mail Scripts/Add a link which opens ticket in Service Portal/script.js: -------------------------------------------------------------------------------- 1 | var url = 'Ticket Link'; //Replace sp with your portal. 2 | template.print(url); 3 | -------------------------------------------------------------------------------- /Mail Scripts/Call Script Include in Notification Mail Script/README.md: -------------------------------------------------------------------------------- 1 | Here is the syntax to call your Script Include from a Global or Scoped application into Notification Mail script. 2 | 3 | -------------------------------------------------------------------------------- /Mail Scripts/Call UI Message or System Property in Notification Mail Script/README.md: -------------------------------------------------------------------------------- 1 | Here is the syntax to call your UI Message or System property into Notification Mail script. 2 | 3 | -------------------------------------------------------------------------------- /Mail Scripts/Exclude DateTime details from Comments/commentsWithoutDateTime.js: -------------------------------------------------------------------------------- 1 | (function runMailScript(current, template, email, email_action, event) { 2 | 3 | current.comments.getJournalEntry(1).match(/\n.*/gm).join('').replace(/^\s*\n/gm, ""); //getting the comments without the username,date/time 4 | 5 | })(current, template, email, email_action, event); 6 | -------------------------------------------------------------------------------- /Mail Scripts/HTML Table Creation from ServiceNow Table/README.md: -------------------------------------------------------------------------------- 1 | This mail script uses a GlideRecord object to get values from a ServiceNow table and then format that information into an HTML table in a notification. 2 | 3 | Replace "example_table" with your desired table. 4 | 5 | Change the style tags to fit your desired results, like background-color, etc. 6 | -------------------------------------------------------------------------------- /Mail Scripts/Open Survey In Portal/README.md: -------------------------------------------------------------------------------- 1 | 1)create a notification on "Assessment Instance" table
2 | 2)when record is created and state is ready to take trigger notification to assigned to
3 | 3)use this mail script to get the url to survey in the email that takes them to the portal
4 | -------------------------------------------------------------------------------- /Mail Scripts/Open Survey In Portal/open_survey.js: -------------------------------------------------------------------------------- 1 | 2 | var survey = 'Click Here to take Survey '; 3 | template.print(survey); 4 | -------------------------------------------------------------------------------- /Mail Scripts/Print variables to mail/README.md: -------------------------------------------------------------------------------- 1 | Script block to be used within a Notification Email Script or as a standalone one. 2 | It prints all variables + answers of a catalog produced record to the email body, along with the short description of the task on top (please check script). 3 | -------------------------------------------------------------------------------- /Notifications/Notify Users on Specific Date/README.md: -------------------------------------------------------------------------------- 1 | This configuration will send an email on the specified date. 2 | 3 | This will use a date field to trigger email notifications. 4 | 5 | Business Rule will run on Insert/Update to trigger the event. As soon as the event is triggered, the notification will be in the queue to be triggered on the specified date field. 6 | -------------------------------------------------------------------------------- /Processors/Dynamic Sitemap/snow-sitemap-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Processors/Dynamic Sitemap/snow-sitemap-results.png -------------------------------------------------------------------------------- /RESTMessageV2/AzureDevOps/README.md: -------------------------------------------------------------------------------- 1 | This rest message is used to create an issue in azure devops from servicenow using basic authentication 2 | -------------------------------------------------------------------------------- /RESTMessageV2/Google-Chat/README.md: -------------------------------------------------------------------------------- 1 | How we can use RESTMessageV2 to send notification in Google chat using Google chat webhook. 2 | 3 | Reference link is given in the code on how we can get the Google chat webhook URL. 4 | -------------------------------------------------------------------------------- /RESTMessageV2/Jira/README.md: -------------------------------------------------------------------------------- 1 | # JIRA Task Creation via ServiceNow Script 2 | 3 | This script demonstrates how to create a JIRA task using the JIRA REST API from ServiceNow. 4 | 5 | ## Requirements 6 | 7 | - Valid JIRA instance URL. 8 | - JIRA API token. -------------------------------------------------------------------------------- /RESTMessageV2/Web Scraping REST Message/README.md: -------------------------------------------------------------------------------- 1 | # Web Scraper REST Message 2 | 3 | This snippet shows how you would use RESTMessageV2 to scrape HTML from a website using a GET HTTP request. -------------------------------------------------------------------------------- /RESTMessageV2/youtubeclient/README.md: -------------------------------------------------------------------------------- 1 | Example of how you can utilize the older style rest message v2 to interact with youtube data client. 2 | Has been replaced with the newer youtube spoke, but is fun to have around and reference how it used to be done. 3 | -------------------------------------------------------------------------------- /Record Producer/Create Records By Import Set/config1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Record Producer/Create Records By Import Set/config1.png -------------------------------------------------------------------------------- /Record Producer/Create Records By Import Set/config2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Record Producer/Create Records By Import Set/config2.png -------------------------------------------------------------------------------- /Record Producer/Create Records By Import Set/config3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Record Producer/Create Records By Import Set/config3.png -------------------------------------------------------------------------------- /Regular Expressions/Allow Characters + - ) ( for Phone numbers/README.md: -------------------------------------------------------------------------------- 1 | ### Allows Characters +, -, (, ) for entering Phone Numbers 2 | 3 | Allows characters useful for adding phone numbers in various formats like (+1) - 123 - 456 - 789, +1-978-654-362, (123) (567) (897) etc. 4 | One can add more functionality to it, by controlling the number of digits added etc. 5 | -------------------------------------------------------------------------------- /Regular Expressions/AllowAnyLanguage/README.md: -------------------------------------------------------------------------------- 1 | Allow Any Language Character Remove Special Characters, Can be used to verify valid names. Sorry Elon Musk's First born. 2 | -------------------------------------------------------------------------------- /Regular Expressions/AllowAnyLanguage/allowanylanguage.js: -------------------------------------------------------------------------------- 1 | module.exports.trimNonCharacters = (str) => str.replace(/[^\p{L}\d()\s]+/ug, ''); 2 | -------------------------------------------------------------------------------- /Regular Expressions/Check if number has 10 digits/README.md: -------------------------------------------------------------------------------- 1 | Script is used to check if the number has 10 digts( you can update the digit count in the code based on the need. 2 | -------------------------------------------------------------------------------- /Regular Expressions/Check if number has 10 digits/script.js: -------------------------------------------------------------------------------- 1 | var reg = '/^\d{10}$/'; // Update the number based on the need 2 | 3 | var k = '123456789144'; // example 4 | 5 | if (/^\d{10}$/.test(k)){ // This will check if it has 10 digits 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Regular Expressions/Email Address Validation/isEmail.js: -------------------------------------------------------------------------------- 1 | const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; 2 | 3 | const email = "example@email.com"; 4 | 5 | if (emailRegex.test(email)) { 6 | console.log("Valid email address"); 7 | } else { 8 | console.log("Invalid email address"); 9 | } 10 | -------------------------------------------------------------------------------- /Regular Expressions/Encode spaces for URLs/README.md: -------------------------------------------------------------------------------- 1 | convert spaces to %20 for creating dynamic urls 2 | -------------------------------------------------------------------------------- /Regular Expressions/Encode spaces for URLs/convert.js: -------------------------------------------------------------------------------- 1 | var name = 'hafsa asif'; 2 | gs.info(encodeURIComponent(name.trim())); 3 | -------------------------------------------------------------------------------- /Regular Expressions/Find Emoji/README.md: -------------------------------------------------------------------------------- 1 | # Detect emoji in string 2 | 3 | Use this script to detect if string contains emoji -------------------------------------------------------------------------------- /Regular Expressions/Find Emoji/index.js: -------------------------------------------------------------------------------- 1 | const withEmojis = /\p{Extended_Pictographic}/ug 2 | 3 | const familyEmoji = '👨‍👩‍👧' 4 | console.log(withEmojis.test(familyEmoji)) 5 | //true 6 | 7 | const familyString = 'family' 8 | console.log(withEmojis.test(familyString)) 9 | //false -------------------------------------------------------------------------------- /Regular Expressions/Format mobile into Australian mobile format/README.md: -------------------------------------------------------------------------------- 1 | # Format phone into Australian mobile Format 2 | 3 | Use this script to format a phone number from +61433394881 style to 0433 394 881 style. -------------------------------------------------------------------------------- /Regular Expressions/Hexadecimal color/README.md: -------------------------------------------------------------------------------- 1 | ## This code snippet helps validating the hexadecimal color codes ## 2 | 3 | Based on the regular expression, the following formats are allowed: 4 | * #ABC 5 | * #AB1 6 | * #123 7 | * #ABCDEF 8 | * #ABC123 9 | * #123456 10 | -------------------------------------------------------------------------------- /Regular Expressions/IP Address Validation/getIP4OrIPV6address.js: -------------------------------------------------------------------------------- 1 | extractIPAddresses: function(text) { 2 | var ipRegex = /\b((\d{1,3}\.){3}\d{1,3})\b|\b([a-fA-F0-9:]+:+[a-fA-F0-9:]+)\b/g; 3 | var matches = text.match(ipRegex); 4 | return matches; 5 | }, 6 | -------------------------------------------------------------------------------- /Regular Expressions/IP Address Validation/validateIPInput.js: -------------------------------------------------------------------------------- 1 | (\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3} 2 | -------------------------------------------------------------------------------- /Regular Expressions/Indian Mobile Numbers/code.js: -------------------------------------------------------------------------------- 1 | var regex = /^(?:(?:\+|0{0,2})91(\s*[\ -]\s*)?|[0]?)?[789]\d{9}|(\d[ -]?){10}\d$/; 2 | var fieldValue = '919876543210'; // Replace with your field name 3 | if (fieldValue && fieldValue.match(regex)) { 4 | gs.info('Mobile number is valid.'); 5 | } else { 6 | gs.info('Invalid mobile number format.'); 7 | } 8 | -------------------------------------------------------------------------------- /Regular Expressions/Match URL's from ServiceNow domain/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Regular Expressions/Match URL's from ServiceNow domain/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Regular Expressions/Poland country code/README.md: -------------------------------------------------------------------------------- 1 | **Regular Expressions** 2 | 3 | Regular Expressions, which allows checking for Poland nine-digit Country code. Poland format starts with +48 and is followed by nine digits. 4 | 5 | **Example effect of execution** 6 | 7 | ![Execution](ScreenShot_1.PNG) 8 | -------------------------------------------------------------------------------- /Regular Expressions/Poland country code/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Regular Expressions/Poland country code/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Regular Expressions/Remove Extra Spaces/README.md: -------------------------------------------------------------------------------- 1 | Accepts a string and removes unnecessary spaces! -------------------------------------------------------------------------------- /Regular Expressions/Remove Extra Spaces/index.js: -------------------------------------------------------------------------------- 1 | const input = " hello w ! my name is kartike singh "; 2 | 3 | const fixed = input.replace(/^\s+|\s+$|\s+[!\.,\;]+/g, c => c.trim()).replace(/\s\s+/g, " "); 4 | 5 | console.log(`"${fixed}"`) -------------------------------------------------------------------------------- /Regular Expressions/Remove all HTML Tags/README.md: -------------------------------------------------------------------------------- 1 | Will accept a html and remove all the html tags and give a string from it. 2 | -------------------------------------------------------------------------------- /Regular Expressions/Remove all HTML Tags/Remove all html tags.js: -------------------------------------------------------------------------------- 1 | var html = '
Hello World
'; // insert your html content 2 | var outputString = html.replace(/<\/?[^>]+(>|$)/g, ""); // output will a string without the HTML tags 3 | -------------------------------------------------------------------------------- /Regular Expressions/Remove newline and carriage return/README.md: -------------------------------------------------------------------------------- 1 | Will accept a string and remove all newline (\n) and carriage return (\r) characters 2 | -------------------------------------------------------------------------------- /Regular Expressions/Remove newline and carriage return/remove cr and nl.js: -------------------------------------------------------------------------------- 1 | var inputString = ""; // insert your input string here 2 | var outputString = inputString.replace(/[\r\n]/g, ''); // the processed string is returned in the outputString variable 3 | -------------------------------------------------------------------------------- /Scheduled Jobs/Auto close changes requests updated 30 days prior/README.md: -------------------------------------------------------------------------------- 1 | This script can be used to auto close records if they have not been updated from past 30 days. For eg. I have taken change requests. This script can be written in a schedule job 2 | to run it daily at 23:59:59 time to check if there is any such records present act accordingly. 3 | -------------------------------------------------------------------------------- /Scheduled Jobs/Daily detection of customer updates made in 'Default' update set/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scheduled Jobs/Daily detection of customer updates made in 'Default' update set/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Scheduled Jobs/Daily detection of customer updates made in 'Default' update set/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scheduled Jobs/Daily detection of customer updates made in 'Default' update set/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Scheduled Jobs/Deactive and Reactivate Catalog Items/Deactivate Cat Item Scheduled Job.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scheduled Jobs/Deactive and Reactivate Catalog Items/Deactivate Cat Item Scheduled Job.png -------------------------------------------------------------------------------- /Scheduled Jobs/Get All Catalog Tasks without Request items/catalogTaskWithoutReqItem.js: -------------------------------------------------------------------------------- 1 | function catalogTaskWithoutReqItem(){ 2 | var gliderecordToCatalogTask = new GlideRecord('sc_task'); 3 | gliderecordToCatalogTask.encodedQuery('request_itemISEMPTY'); 4 | gliderecordToCatalogTask.query(); 5 | } 6 | // catalogTaskWithoutReqItem(); -------------------------------------------------------------------------------- /Scheduled Jobs/Get All Catalog Tasks without Request items/catalogTaskWithoutReqItem.md: -------------------------------------------------------------------------------- 1 | # Fetch all Catalog tasks which do not have any Request items associated. 2 | 3 | Get all the Catalog tasks which do not have any Request items, so that the requester can be notified and action can be taken. -------------------------------------------------------------------------------- /Scheduled Jobs/Lock out users who have not logged into the system longer than 30 days/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scheduled Jobs/Lock out users who have not logged into the system longer than 30 days/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Scheduled Jobs/Lock out users who have not logged into the system longer than 30 days/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scheduled Jobs/Lock out users who have not logged into the system longer than 30 days/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Scheduled Jobs/PostUserDisabledActivity/README.md: -------------------------------------------------------------------------------- 1 | Get today's deactivated users records script Scheduled Jobs 2 | -------------------------------------------------------------------------------- /Scheduled Jobs/Reject approvals created before an year/Reject Approvals Created Before an Year.js: -------------------------------------------------------------------------------- 1 | var grAppr = new GlideRecord("sysapproval_approver"); 2 | grAppr.addEncodedQuery("sys_created_on Method: getChoiceDisplayValue(question, value) 6 | 7 | - @param {String} question: Name of the question that needs to be queried 8 | - @param {String} value: Value of that question -------------------------------------------------------------------------------- /Script Includes/Get Group Members/README.md: -------------------------------------------------------------------------------- 1 | # Get Group Members by Id 2 | 3 | A Script utils containing utility functions, to get the group members sys ids -------------------------------------------------------------------------------- /Script Includes/Get Reference Display Value/README.md: -------------------------------------------------------------------------------- 1 | # Get Reference Choice Display Value 2 | 3 | This scripts gets the display value of the selected reference value. 4 | 5 | > Method: getChoiceDisplayValue(question, value) 6 | 7 | - @param {String} table: name of the referenced table. 8 | - @param {String} value: Value of that reference field -------------------------------------------------------------------------------- /Script Includes/GetCallerDetails/README.md: -------------------------------------------------------------------------------- 1 | This script include will help to get the details of caller Id_name like (email, first_name, last_name user_name etc.) mentioned in incident form with the help of on change client script by iniating a Ajax call. 2 | -------------------------------------------------------------------------------- /Script Includes/Install base items with active cases/README.md: -------------------------------------------------------------------------------- 1 | # Install base items with active cases 2 | 3 | This script will run **RLQUERY** on the `sn_install_base_item` table and get active cases by the help of `RLQUERYsn_install_base_m2m_affected_install_base` table. 4 | -------------------------------------------------------------------------------- /Script Includes/Install base items with active cases/script.js: -------------------------------------------------------------------------------- 1 | var ibGr = new GlideRecord("sn_install_base_item"); 2 | ibGr.addEncodedQuery("RLQUERYsn_install_base_m2m_affected_install_base.install_base,>0,case.active=true^ENDRLQUERY"); 3 | ibGr.query(); 4 | 5 | while (ibGr.next()) { 6 | // Do something 7 | } 8 | -------------------------------------------------------------------------------- /Script Includes/Match URL with a String/README.md: -------------------------------------------------------------------------------- 1 | # Match URL with a String using Regex 2 | 3 | This script gets the url using the referer method and matches the substring in the url. -------------------------------------------------------------------------------- /Script Includes/Number Padding/README.md: -------------------------------------------------------------------------------- 1 | Lets you pad your single digit number for better formating 2 | -------------------------------------------------------------------------------- /Script Includes/Number Padding/numberPadding.js: -------------------------------------------------------------------------------- 1 | module.exports.numberPadding = function (value) { 2 | return String(value).padStart(2, '0'); 3 | } 4 | -------------------------------------------------------------------------------- /Script Includes/OrderedRecords/README.md: -------------------------------------------------------------------------------- 1 | # ArtifactRank 2 | Script Include that helps with getting the next spaced out ordering 3 | 4 | ## Example Script 5 | ```javascript 6 | var nextRank = new ArtifactRank.getNextRank(); 7 | ``` 8 | -------------------------------------------------------------------------------- /Script Includes/Project Base Line/README.md: -------------------------------------------------------------------------------- 1 | // Sample code to pull the latest planned baseline tasks list of each project. It will fetch the list and push it an array. 2 | -------------------------------------------------------------------------------- /Script Includes/Public Script Include search/README.md: -------------------------------------------------------------------------------- 1 | # Find public Script Includes 2 | 3 | The snippet helps to find public Script Includes (can be executed by a non-logged-in user) and check their security later manually. 4 | 5 | Such Script Include can be called from a public page (e.g. login.do page) in the browser console. -------------------------------------------------------------------------------- /Script Includes/Request Approval Helper/README.md: -------------------------------------------------------------------------------- 1 | # Checks all RTIMs approval status for a request returns True if all RTIMs are approved or rejected 2 | 3 | # Example: 4 | 5 | ```javascript 6 | var result = new RequestApprovalHelper().areAllRTIMsApprovedOrRejected("sys_id_of_the_request"); 7 | ``` -------------------------------------------------------------------------------- /Script Includes/Return Object/README.md: -------------------------------------------------------------------------------- 1 | ## ReturnRecord Script Include 2 | - The script include is client callable 3 | - The returnRecordObject function allows for users to return a record values within the objects properties. 4 | - In call back function, in client script, parse the object that is return, then dot walk to access its propery values. -------------------------------------------------------------------------------- /Script Includes/SRAPIUtil/README.md: -------------------------------------------------------------------------------- 1 | #SRAPIUtil 2 | 3 | Utility class for common methods when implementing SRAPIs. Also includes examples of SNDocs and Revealing Module script include pattern with true private methods 4 | -------------------------------------------------------------------------------- /Script Includes/Slack JSON Block Factory/README.md: -------------------------------------------------------------------------------- 1 | This Script Includes provides simple factories (Slacktory) to create Slack JSON blocks, that can be sent in payloads. 2 | Documentation for syntax is inline in the code. 3 | 4 | The factories will always return the created or modified block [Object]. -------------------------------------------------------------------------------- /Script Includes/Slack JSON Block Factory/sys_script_include_config.md: -------------------------------------------------------------------------------- 1 | Name: Slacktory 2 | Client callable: false -------------------------------------------------------------------------------- /Script Includes/Standard Change Creator/README.md: -------------------------------------------------------------------------------- 1 | This Script Includes provides a way to create a Standard Change, that will be auto-populated with certain fields. 2 | 3 | Usage and list of required variables, as well as documentation and commets are inline in the code. -------------------------------------------------------------------------------- /Script Includes/Standard Change Creator/sys_script_include_config.md: -------------------------------------------------------------------------------- 1 | Name: RepeatingStandardChange 2 | Client callable: false -------------------------------------------------------------------------------- /Script Includes/Translations Import/README.md: -------------------------------------------------------------------------------- 1 | # Translations import 2 | 3 | `runImportNow` is designed to load language files for the specified application scope name. 4 | -------------------------------------------------------------------------------- /Script Includes/UnloadXml/README.md: -------------------------------------------------------------------------------- 1 | # Unload XML 2 | With this script include you can export a GlideRecord Query to XML which can be imported via the "Import XML" functionality. 3 | 4 | ```javascript 5 | var exportedXmlStr = UnloadXml("incident", "active=true"); 6 | ``` -------------------------------------------------------------------------------- /Script Includes/UserUtil/userMemberOf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Script Includes/UserUtil/userMemberOf.png -------------------------------------------------------------------------------- /Script Includes/VariableToDescription/README.md: -------------------------------------------------------------------------------- 1 | This script include can be used to get all of the variables from a RITM as text. It is client callable, so it can be used from any client script as well as Server Side script like a business rule. -------------------------------------------------------------------------------- /Script Includes/attachments/README.md: -------------------------------------------------------------------------------- 1 | Little utility for attachment types 2 | 3 | ## Example Script 4 | var att = new Attachment(current); 5 | if(att.hasImage()) 6 | var attID = att.getImageID(); -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/CreateCIs.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).createCi(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/CreateCiRelationship.js: -------------------------------------------------------------------------------- 1 | 2 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 3 | 4 | // implement resource here 5 | return new CmdbApi(request, response).createCiRelationship(); 6 | 7 | })(request, response); 8 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/DeleteCI.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).deleteCi(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/DeleteCiRelationship.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).deleteCiRelationship(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/RetrieveCis.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).getCis(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/Retrieve_CI_Relationships.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).getRelationships(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/RetriveCiRelationshipTypes.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).getCiRelationshipTypes(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CMDB API/UpdateCi.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | // implement resource here 4 | return new CmdbApi(request, response).updateCi(); 5 | 6 | })(request, response); 7 | -------------------------------------------------------------------------------- /Scripted REST Api/CopyAI Generative AI example/README.md: -------------------------------------------------------------------------------- 1 | - Make sure you have a key stored in a system property named `openai.key` 2 | - Quick script to do a `gpt-3.5-turbo` chatgpt call 3 | - If you set `show_tokens` to true then it will also show the estimated cost of the prompt+response 4 | 5 | Example usage: 6 | ![Alt text](image.png) -------------------------------------------------------------------------------- /Scripted REST Api/CopyAI Generative AI example/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scripted REST Api/CopyAI Generative AI example/image.png -------------------------------------------------------------------------------- /Scripted REST Api/Difference between two users/README.md: -------------------------------------------------------------------------------- 1 | This is a scripted rest api that finds the differences between two user field and the value for the fields that are different between two users will print that in result. 2 | 3 | Query parameters:- 4 | user1Email abc@example.com 5 | user2Email xyz@example.com 6 | -------------------------------------------------------------------------------- /Scripted REST Api/Get_Choices/script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scripted REST Api/Get_Choices/script.png -------------------------------------------------------------------------------- /Scripted REST Api/Get_Choices/scripted_rest_resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scripted REST Api/Get_Choices/scripted_rest_resource.png -------------------------------------------------------------------------------- /Scripted REST Api/Promise API Call/README.md: -------------------------------------------------------------------------------- 1 | Allows you to make async/await promise API Calls using Request 2 | -------------------------------------------------------------------------------- /Scripted REST Api/Tag API/Screenshot 2023-10-11 at 12.51.24 PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scripted REST Api/Tag API/Screenshot 2023-10-11 at 12.51.24 PM.png -------------------------------------------------------------------------------- /Scripted REST Api/Tag API/Screenshot 2023-10-11 at 12.51.59 PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Scripted REST Api/Tag API/Screenshot 2023-10-11 at 12.51.59 PM.png -------------------------------------------------------------------------------- /Scripted REST Api/compare roles/README.md: -------------------------------------------------------------------------------- 1 | This is a scripted rest api and print the difference between two fields 2 | 3 | Query parameters: 4 | role1: role 5 | 6 | role2:role 7 | -------------------------------------------------------------------------------- /Server Side/FetchJSONObject/README.md: -------------------------------------------------------------------------------- 1 | The `fetchJSONObject` function is designed to retrieve a JSON object containing specified field values from a GlideRecord instance in ServiceNow. 2 | It allows for optional input of field names to fetch; if no fields are specified, all fields will be retrieved. 3 | -------------------------------------------------------------------------------- /Server Side/Get all Catalog items associated to variable set/README.md: -------------------------------------------------------------------------------- 1 | Use this script to get List of Catalog Items associated to the Variable set. 2 | -------------------------------------------------------------------------------- /Server Side/Phone Number formating(US Region)/README.md: -------------------------------------------------------------------------------- 1 | Use this script to format Phone Number in standard format 3-3-4 example if phone is 1234567891 then output will be 123-456-7891 2 | -------------------------------------------------------------------------------- /Server Side/Random Password generator/README.md: -------------------------------------------------------------------------------- 1 | This script is used to generate a random password, you can update the length parameter to adjust the length of password. 2 | -------------------------------------------------------------------------------- /Server Side/Restart Flow on RITM/README.md: -------------------------------------------------------------------------------- 1 | Restart a flow designer flow on a Requested Item. I use this in a UI Action, but it could also be modified and used in a background script if needed. 2 | -------------------------------------------------------------------------------- /Server Side/Restart a workflow via any server side script/README.md: -------------------------------------------------------------------------------- 1 | Use this to attach a new workflow to your old records. 2 | -------------------------------------------------------------------------------- /Server Side/Update Sets Scopes Issues Fix Automation/FixUpdatesScope.js: -------------------------------------------------------------------------------- 1 | var util = new global.UpdateSetUtilCustom(); 2 | var message = util.fixScopeBatch(current); 3 | gs.addInfoMessage(message); 4 | action.setRedirectURL(current); 5 | -------------------------------------------------------------------------------- /Server Side/User Criteria/README.md: -------------------------------------------------------------------------------- 1 | Use this script to determine if a user passes an array of user criterias 2 | 3 | 4 | userID - String of a sys_user sys_id 5 | 6 | userCriteria - Array of user_criteria sys_ids to check again 7 | -------------------------------------------------------------------------------- /Server Side/getUserGroupMembers/README.md: -------------------------------------------------------------------------------- 1 | Script to get members of groups which our users also belongs to. 2 | 3 | example: added Abel to 2 HR groups and then printing the names of members who belong to those groups. 4 | 5 | ![image](https://user-images.githubusercontent.com/46869542/193464977-53b613db-650b-452c-ac72-fbee5196605f.png) 6 | -------------------------------------------------------------------------------- /Service Portal Widgets/Accordion Widget/Accordion Widget Image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Accordion Widget/Accordion Widget Image.png -------------------------------------------------------------------------------- /Service Portal Widgets/Accordion Widget/README.md: -------------------------------------------------------------------------------- 1 | # Accordion Widget 2 | 3 | ![alt text](https://raw.githubusercontent.com/debendu-das/code-snippets/service-portal-widget-accordion/Service%20Portal%20Widgets/Accordion%20Widget/Accordion%20Widget%20Image.png) 4 | -------------------------------------------------------------------------------- /Service Portal Widgets/AngularJS Directives and Filters/css.css: -------------------------------------------------------------------------------- 1 | h4 { 2 | font-weight: bolder; 3 | margin-top: 30px; 4 | color: green; 5 | } 6 | 7 | .mydata { 8 | font-weight: bolder; 9 | color: blue; 10 | } 11 | -------------------------------------------------------------------------------- /Service Portal Widgets/AngularJS Directives and Filters/server_script.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | /* populate the 'data' object */ 3 | /* e.g., data.table = $sp.getValue('table'); */ 4 | 5 | //Variables from Server Script 6 | data.record = [1,2,3,4,5,6]; 7 | data.record1 = ["abc","xyz","Abc","Xyz","ABC","XYZ"]; 8 | 9 | })(); 10 | -------------------------------------------------------------------------------- /Service Portal Widgets/ApplyCSSDynamically/README.md: -------------------------------------------------------------------------------- 1 | The widget demonstrates how CSS can be dynamically applied on the HTML attributes via client controller. Inorder to demonstrate, a color picker dropdown has been placed in the HTML. Upon selecting a color option, the corresponding CSS is applied on an HTML text to color it with the same. 2 | -------------------------------------------------------------------------------- /Service Portal Widgets/Batman Animation/Batman Background Image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Batman Animation/Batman Background Image.jpg -------------------------------------------------------------------------------- /Service Portal Widgets/Batman Animation/Batman logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Batman Animation/Batman logo.png -------------------------------------------------------------------------------- /Service Portal Widgets/Batman Animation/client_script.js: -------------------------------------------------------------------------------- 1 | api.controller=function($scope) { 2 | /* widget controller */ 3 | var c = this; 4 | setTimeout(function(){ $scope.togglelightray = true; }, 2000); 5 | }; 6 | -------------------------------------------------------------------------------- /Service Portal Widgets/Card Image Link/README.md: -------------------------------------------------------------------------------- 1 | # Card Image Link Widget 2 | 3 | Provides an easy to use and nice looking card widget to add to Service Portal pages 4 | 5 | # Set up 6 | ![Image of Card set up](./doc/card_setup.png) 7 | 8 | # End Result 9 | ![Image of Card result](./doc/card_result.png) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Service Portal Widgets/Card Image Link/doc/card_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Card Image Link/doc/card_result.png -------------------------------------------------------------------------------- /Service Portal Widgets/Card Image Link/doc/card_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Card Image Link/doc/card_setup.png -------------------------------------------------------------------------------- /Service Portal Widgets/Card Image Link/mm_card_client_script.js: -------------------------------------------------------------------------------- 1 | api.controller=function() { 2 | /* widget controller */ 3 | var c = this; 4 | }; -------------------------------------------------------------------------------- /Service Portal Widgets/Change Notification Preferences/README.md: -------------------------------------------------------------------------------- 1 | ## Notification Preference by Category widget 2 | 3 | Portal Widget that shows user notification preferences for a certain category (changed within the options). User can switch his notification on or off. The notification description gets displayed under the notification name. -------------------------------------------------------------------------------- /Service Portal Widgets/Change Notification Preferences/css.css: -------------------------------------------------------------------------------- 1 | 2 | .list-group-item { 3 | border: none; 4 | 5 | .btn-link { 6 | padding-left: 0; 7 | padding-right: 0; 8 | } 9 | } 10 | .input-switch{ 11 | display: inline-block; 12 | float: right; -------------------------------------------------------------------------------- /Service Portal Widgets/Change Notification Preferences/server.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | data.category = options.categoryid || 'b69d02137f232200ee2e108c3ffa9142'; // sys id of the category 3 | })(); 4 | -------------------------------------------------------------------------------- /Service Portal Widgets/Check if user has specific role inside the widget/README.md: -------------------------------------------------------------------------------- 1 | # Check if user has a role within the widget code 2 | 3 | Use this code to check inside widget client code to see if user has a role or not. Can be used in scenarios where you want to hide to show part of the widget UI. 4 | 5 | 6 | -------------------------------------------------------------------------------- /Service Portal Widgets/Clickable SVG Image/html.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
-------------------------------------------------------------------------------- /Service Portal Widgets/Client side pagination/README.md: -------------------------------------------------------------------------------- 1 | This code can be used to add client side pagination to the widget. 2 | if there are a lot of records on a customized widget and you prefer using client side pagination instead of server side pagination, use this method me -------------------------------------------------------------------------------- /Service Portal Widgets/Configurable Card Widget/Client Script.js: -------------------------------------------------------------------------------- 1 | api.controller=function() { 2 | /* widget controller */ 3 | var c = this; 4 | c.image = c.options.background_image; 5 | c.image = "url('" + c.image + "')"; 6 | }; 7 | -------------------------------------------------------------------------------- /Service Portal Widgets/Configurable Card Widget/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Configurable Card Widget/image.png -------------------------------------------------------------------------------- /Service Portal Widgets/Create diagram using GoJS library/body.html: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /Service Portal Widgets/Create diagram using GoJS library/style.css: -------------------------------------------------------------------------------- 1 | #infobox { 2 | width: 256px; 3 | background: #757575; 4 | color: #FFF; 5 | padding: 20px; 6 | } 7 | 8 | #myDiagramDiv * { 9 | outline: none; 10 | -webkit-tap-highlight-color: rgba(255, 255, 255, 0); /* mobile webkit */ 11 | } -------------------------------------------------------------------------------- /Service Portal Widgets/Digital Clock/index.html: -------------------------------------------------------------------------------- 1 |
2 | {{ currentTime }} 3 |
4 | -------------------------------------------------------------------------------- /Service Portal Widgets/Drag & drop Widget/remove_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Drag & drop Widget/remove_icon.png -------------------------------------------------------------------------------- /Service Portal Widgets/Drawer Buttons/html_template.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | Policies 4 | Divisions 5 | Contact 6 |
7 | -------------------------------------------------------------------------------- /Service Portal Widgets/Export table in portal/README.md: -------------------------------------------------------------------------------- 1 | This widget can be used to download/export a table based on the given query and list view from a button click on the widget -------------------------------------------------------------------------------- /Service Portal Widgets/Export table in portal/export.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Service Portal Widgets/Floater Feedback Widget/demo.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Floater Feedback Widget/demo.JPG -------------------------------------------------------------------------------- /Service Portal Widgets/Generate QrCode/Dependencies/qrcode.js: -------------------------------------------------------------------------------- 1 | //install the code from this repository https://github.com/davidshimjs/qrcodejs/blob/master/qrcode.min.js -------------------------------------------------------------------------------- /Service Portal Widgets/Generate QrCode/Generated QRCode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Generate QrCode/Generated QRCode.png -------------------------------------------------------------------------------- /Service Portal Widgets/Generate QrCode/qrcode.html: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /Service Portal Widgets/Generate QrCode/qrcode_client.js: -------------------------------------------------------------------------------- 1 | api.controller=function() { 2 | /* widget controller */ 3 | var c = this; 4 | var contentToRender = "Ryan"; 5 | var qrCodeInstance = new QRCode(document.getElementById("qrcode"), contentToRender); 6 | }; -------------------------------------------------------------------------------- /Service Portal Widgets/Guest Login Modal/guest_login_modal_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Guest Login Modal/guest_login_modal_example.png -------------------------------------------------------------------------------- /Service Portal Widgets/Guest Login Modal/server.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | /* populate the 'data' object */ 3 | /* e.g., data.table = $sp.getValue('table'); */ 4 | 5 | data.authenticated = gs.isLoggedIn(); 6 | 7 | })(); -------------------------------------------------------------------------------- /Service Portal Widgets/HTML List Table from GlideRecord with JSon/README.md: -------------------------------------------------------------------------------- 1 | A simple code snippet to get data using GlideRecord in server script and Display in HTML Table using JSON. 2 | 3 | In order to use the widget, follow the below steps: Create a new widget and copy the html and server script in the widget. 4 | -------------------------------------------------------------------------------- /Service Portal Widgets/ImportXml/README.md: -------------------------------------------------------------------------------- 1 | This widget can be used to import XML files into Servicenow instance. 2 | This is done via portal into an existing table -------------------------------------------------------------------------------- /Service Portal Widgets/Konami Code Easter Egg/README.md: -------------------------------------------------------------------------------- 1 | # Konami Code Easter Egg 2 | 3 | Put this code in the client controller of a widget to listen for the Konami Code. By default it just opens a modal notifying the user that the konami code as activated. Modify to do whatever fun things you want. 4 | -------------------------------------------------------------------------------- /Service Portal Widgets/Location hierarchy/README.md: -------------------------------------------------------------------------------- 1 | This widget allows you to hierarchically choose a location for the catalog item variable. 2 | 3 | With small additional setup you can adjust it to your own structure. You also need a variable (preferably multi line text) to save the output of this widget. 4 | -------------------------------------------------------------------------------- /Service Portal Widgets/Mouse Effect/index.html: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /Service Portal Widgets/Open in Platform/body.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | {{::options.button_text}} 4 | 5 |
6 | -------------------------------------------------------------------------------- /Service Portal Widgets/Open in Platform/server.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | data.table = input.table || $sp.getParameter("table"); 3 | data.sys_id = input.sys_id || $sp.getParameter("sys_id"); 4 | 5 | data.url = "/nav_to.do?uri="+data.table+".do?sys_id="+data.sys_id; 6 | 7 | data.role = false; 8 | if (gs.hasRole("itil")){ 9 | data.role = true; 10 | } 11 | })(); 12 | -------------------------------------------------------------------------------- /Service Portal Widgets/Pagination widget with next and previous button/First Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Pagination widget with next and previous button/First Page.png -------------------------------------------------------------------------------- /Service Portal Widgets/Pagination widget with next and previous button/Last Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Pagination widget with next and previous button/Last Page.png -------------------------------------------------------------------------------- /Service Portal Widgets/Recently Viewed Items/Recently viewed widget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Recently Viewed Items/Recently viewed widget.png -------------------------------------------------------------------------------- /Service Portal Widgets/Record process flow/PortalUtils.js: -------------------------------------------------------------------------------- 1 | var PortalUtils = Class.create(); 2 | PortalUtils.prototype = Object.extendsObject(PortalUtilsBase, { 3 | initialize: function() { 4 | }, 5 | type: 'PortalUtils' 6 | }); -------------------------------------------------------------------------------- /Service Portal Widgets/RecordPickerForListReference/README.md: -------------------------------------------------------------------------------- 1 | The widget is an example record picker that can be used as reference or list field. The field is referring to user table and upon change, the new values are passed to the server side for processing any business logic. 2 | -------------------------------------------------------------------------------- /Service Portal Widgets/Spiderman Animation/client_script.js: -------------------------------------------------------------------------------- 1 | api.controller=function() { 2 | /* widget controller */ 3 | var c = this; 4 | var sound=new Audio('spider.mp3'); 5 | sound.play(); 6 | setTimeout( function() { 7 | var ele = document.querySelector('.spidey') 8 | ele.style.animationPlayState = 'paused' 9 | }, 8500); 10 | }; -------------------------------------------------------------------------------- /Service Portal Widgets/Spiderman Animation/greengoblin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Spiderman Animation/greengoblin.png -------------------------------------------------------------------------------- /Service Portal Widgets/Spiderman Animation/html_template.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |
6 |
-------------------------------------------------------------------------------- /Service Portal Widgets/Spiderman Animation/spid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Spiderman Animation/spid.png -------------------------------------------------------------------------------- /Service Portal Widgets/Spiderman Animation/spider.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Spiderman Animation/spider.mp3 -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/Squid Game Themed Incident-Request-Knowledge Widget Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/Squid Game Themed Incident-Request-Knowledge Widget Preview.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_circle_staff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_circle_staff.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_honeycomb_candy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_honeycomb_candy.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_square_staff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_square_staff.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_triangle_staff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Incident-Request-Knowledge/squid_triangle_staff.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Simple List/Squid Game Themed Simple List - Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Simple List/Squid Game Themed Simple List - Preview.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed Simple List/squid_game_coffin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed Simple List/squid_game_coffin.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed User Profile Card/Squid Game Themed User Profile Card - Back - Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed User Profile Card/Squid Game Themed User Profile Card - Back - Preview.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed User Profile Card/Squid Game Themed User Profile Card - Front - Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed User Profile Card/Squid Game Themed User Profile Card - Front - Preview.png -------------------------------------------------------------------------------- /Service Portal Widgets/Squid Game Themed User Profile Card/squid_game_card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Squid Game Themed User Profile Card/squid_game_card.png -------------------------------------------------------------------------------- /Service Portal Widgets/Standard Ticket Header With On Hold Reason/ticket_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Standard Ticket Header With On Hold Reason/ticket_header.png -------------------------------------------------------------------------------- /Service Portal Widgets/Standard Ticket Page Enhanced Action Widget/enhanced_action_sp_widget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Standard Ticket Page Enhanced Action Widget/enhanced_action_sp_widget.png -------------------------------------------------------------------------------- /Service Portal Widgets/Standard Ticket Page Enhanced Action Widget/standard_ticket_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Standard Ticket Page Enhanced Action Widget/standard_ticket_config.png -------------------------------------------------------------------------------- /Service Portal Widgets/Tab Panel Widget/CSS-SCSS.scss: -------------------------------------------------------------------------------- 1 | .tab-content{ 2 | background-color: #f0f0f0; 3 | padding: 10px; 4 | } 5 | -------------------------------------------------------------------------------- /Service Portal Widgets/Tab Panel Widget/Image 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Tab Panel Widget/Image 1.png -------------------------------------------------------------------------------- /Service Portal Widgets/Tab Panel Widget/image 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal Widgets/Tab Panel Widget/image 2.png -------------------------------------------------------------------------------- /Service Portal Widgets/Upload Files/README.md: -------------------------------------------------------------------------------- 1 | # Service Portal Widget - "Add attachments" form 2 | 3 | This widget is using the 'Attachment API - POST /now/attachment/file' to upload multiple files on form submit. 4 | 5 | The result will appear in the console or check directly the record. -------------------------------------------------------------------------------- /Service Portal Widgets/Upload Files/server.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | data.response = ''; 3 | if(input.record){ 4 | var gr = new GlideRecord(input.table); 5 | gr.addQuery('number',input.record); 6 | gr.query(); 7 | if(gr.next()){ 8 | data.rec_sysid = gr.sys_id.toString(); 9 | data.response = 'success'; 10 | } 11 | } 12 | 13 | })(); -------------------------------------------------------------------------------- /Service Portal Widgets/Upload Files/style.css: -------------------------------------------------------------------------------- 1 | #removeicon:hover{ 2 | cursor:pointer; 3 | cursor:hand; 4 | } -------------------------------------------------------------------------------- /Service Portal Widgets/g_form on SP/gform_on_sp_server.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | data.table = $sp.getParameter("table"); 3 | data.sys_id = $sp.getParameter("sys_id"); 4 | data.view = $sp.getParameter("view"); 5 | 6 | data.f = $sp.getForm(data.table, data.sys_id, data.query, data.view, false); 7 | })(); -------------------------------------------------------------------------------- /Service Portal Widgets/iFrame/server.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | options.size = options.size || "large"; 3 | })(); -------------------------------------------------------------------------------- /Service Portal/dark-mode-switcher/avatarDropDown.js: -------------------------------------------------------------------------------- 1 | function avatarDropDown($compile){ 2 | return { 3 | restrict: 'C', 4 | link: function(scope, element) { 5 | var $themeSwitcher = angular.element(''); 6 | element.before($themeSwitcher); 7 | $compile($themeSwitcher)(scope); 8 | } 9 | }; 10 | } -------------------------------------------------------------------------------- /Service Portal/dark-mode-switcher/dark_mode.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/dark-mode-switcher/dark_mode.scss -------------------------------------------------------------------------------- /Service Portal/dark-mode-switcher/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/dark-mode-switcher/demo.gif -------------------------------------------------------------------------------- /Service Portal/instance-badge/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/instance-badge/header.png -------------------------------------------------------------------------------- /Service Portal/sn-avatar/2021-10-15-23-18-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-avatar/2021-10-15-23-18-40.png -------------------------------------------------------------------------------- /Service Portal/sn-avatar/2021-10-15-23-22-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-avatar/2021-10-15-23-22-31.png -------------------------------------------------------------------------------- /Service Portal/sn-avatar/2021-10-15-23-25-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-avatar/2021-10-15-23-25-15.png -------------------------------------------------------------------------------- /Service Portal/sn-choice-list/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-choice-list/screen1.png -------------------------------------------------------------------------------- /Service Portal/sn-choice-list/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-choice-list/screen2.png -------------------------------------------------------------------------------- /Service Portal/sn-record-picker/2021-10-16-01-08-46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-record-picker/2021-10-16-01-08-46.png -------------------------------------------------------------------------------- /Service Portal/sn-record-picker/2021-10-16-01-10-08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-record-picker/2021-10-16-01-10-08.png -------------------------------------------------------------------------------- /Service Portal/sn-record-picker/2021-10-16-01-11-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-record-picker/2021-10-16-01-11-40.png -------------------------------------------------------------------------------- /Service Portal/sn-watchlist/sn-watchlist.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sn-watchlist/sn-watchlist.gif -------------------------------------------------------------------------------- /Service Portal/sp-date-picker/sp-date-picker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sp-date-picker/sp-date-picker.png -------------------------------------------------------------------------------- /Service Portal/sp-editable-field/2021-10-17-00-17-56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sp-editable-field/2021-10-17-00-17-56.png -------------------------------------------------------------------------------- /Service Portal/sp-modal/README.md: -------------------------------------------------------------------------------- 1 | This script is used to generate a popup on the Service Portal page, you can update the html based on your need. 2 | 3 | If a callback is needed, use the .then() part of the spModal and add any functions/statements to it as required. 4 | -------------------------------------------------------------------------------- /Service Portal/sparkling/sparkling.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Service Portal/sparkling/sparkling.gif -------------------------------------------------------------------------------- /Styles/Add Background Color to a field/README.md: -------------------------------------------------------------------------------- 1 | Open a record. Right click on any field label and select configure style. 2 | A list will open with all the styles applied on that field. 3 | Click on New button to create your custom style. 4 | Enter the code of style.css in Style field of style and done. 5 | You can use this code on any field in any table. 6 | -------------------------------------------------------------------------------- /Styles/Add Background Color to a field/style.css: -------------------------------------------------------------------------------- 1 | background-color:blue; 2 | font-size:12px; 3 | color:white; 4 | -------------------------------------------------------------------------------- /Styles/Add attachment icon-list view/value.js: -------------------------------------------------------------------------------- 1 | // Write this in Value field of your style to check if there is any attachment present to that record. 2 | javascript:current.hasAttachments() 3 | -------------------------------------------------------------------------------- /Styles/Change text color of a field/style.css: -------------------------------------------------------------------------------- 1 | background-color:white; 2 | font-size:16px; 3 | text-align: center; 4 | color:#000066; 5 | -------------------------------------------------------------------------------- /Styles/Hide MRVS Buttons/README.md: -------------------------------------------------------------------------------- 1 | # Stylesheet for hiding MRVS buttons 2 | 3 | This stylesheet can be used to hide buttons within a multi-row variable set on both the platform and portal. 4 | 5 | To use, create a Rich Text Label and paste the code into that. 6 | -------------------------------------------------------------------------------- /Transform Map Scripts/Choice Field Validator/choice_validador1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Transform Map Scripts/Choice Field Validator/choice_validador1.png -------------------------------------------------------------------------------- /Transform Map Scripts/Choice Field Validator/choice_validador2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Transform Map Scripts/Choice Field Validator/choice_validador2.png -------------------------------------------------------------------------------- /Transform Map Scripts/Conditional Coalesce/conditional_coalesce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/Transform Map Scripts/Conditional Coalesce/conditional_coalesce.png -------------------------------------------------------------------------------- /Transform Map Scripts/Email Formatter/README.md: -------------------------------------------------------------------------------- 1 | The purpose of this script is to validate email addresses during a data import in ServiceNow. It ensures that the email addresses conform to a standard format (i.e., are valid email addresses), converts them to lowercase, trims any extra spaces, and logs invalid email addresses for review or further action. 2 | -------------------------------------------------------------------------------- /Transform Map Scripts/Verify headers of a CSV attached file/example.csv: -------------------------------------------------------------------------------- 1 | First Name,Last Name,Middle Name,Age,City 2 | Robert,Nancy,Jr.,53,Boston 3 | -------------------------------------------------------------------------------- /UI Actions/Cancel Incident/README.md: -------------------------------------------------------------------------------- 1 | This is a ui action run on incident table which is client callable, run on condition current.state == '1' which means when state is new.It cancel the incident through the form. 2 | -------------------------------------------------------------------------------- /UI Actions/Clone incident on Agent Workspace/workspace_client_script.js: -------------------------------------------------------------------------------- 1 | function onClick() { 2 | getMessage("Are you sure you want to Clone this Incident?", function (msg) { 3 | g_modal.confirm(getMessage("Confirmation"), msg, function (confirmed) { 4 | if (confirmed) { 5 | g_form.submit('clone_incident'); 6 | } 7 | }); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /UI Actions/Close child incident/serverScript.js: -------------------------------------------------------------------------------- 1 | var gr = new GlideRecord('incident'); 2 | gr.addQuery('parent_incident',current.sys_id); //querying over particular parent incident 3 | gr.query(); 4 | while(gr.next()){ 5 | gr.state = '7'; //updating the state of the child incident to closed 6 | gr.update(); 7 | } 8 | -------------------------------------------------------------------------------- /UI Actions/Convert Request to Incident/UIActionScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/UI Actions/Convert Request to Incident/UIActionScreenshot.png -------------------------------------------------------------------------------- /UI Actions/Create New blank incident from the incident/script.js: -------------------------------------------------------------------------------- 1 | //UI Action - Create New blank incident from the incident. 2 | 3 | var newFormURL = new GlideURL('incident.do'); 4 | newFormURL.addParam('sys_id', '-1'); // Open a new blank form 5 | action.setRedirectURL(newFormURL.toString()); 6 | -------------------------------------------------------------------------------- /UI Actions/Create Problem Record from any Table/README.md: -------------------------------------------------------------------------------- 1 | This UI action helps in creating a problem record from an incident or even from a change table, and we can modify this code by changing the table name we can use it for any sort of table to create a problem record. 2 | -------------------------------------------------------------------------------- /UI Actions/Create story/README.md: -------------------------------------------------------------------------------- 1 | Code Snippet for UI Action to create an Agile Story from another task. For example Incident -> Story, Task -> Story, Requested Item -> Story 2 | -------------------------------------------------------------------------------- /UI Actions/Go to Agent Workspace Home Page/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /UI Actions/Go to Agent Workspace Home Page/ui_action_script.js: -------------------------------------------------------------------------------- 1 | function onClick() { 2 | top.window.location ='now/workspace/agent/home'; 3 | } -------------------------------------------------------------------------------- /UI Actions/Open Email Client using UI Action/open_email_client.js: -------------------------------------------------------------------------------- 1 | // This is a Client UI action. In the onClick field, call the function openEmailClient() and use below script in the script section. 2 | function openEmailClient(){ 3 | emailClientOpenPop(''); 4 | } 5 | -------------------------------------------------------------------------------- /UI Actions/Open LIST UI Action/README.md: -------------------------------------------------------------------------------- 1 | This UI Action opens the LIST view for the current table in another tab. 2 | UI action will run on Onclick openinLIST() 3 | -------------------------------------------------------------------------------- /UI Actions/Open LIST UI Action/UIActionscript.js: -------------------------------------------------------------------------------- 1 | function openinLIST() { 2 | var taskTable = g_form.getTableName(); 3 | 4 | // Construct the hardcoded LIST URL 5 | var listURL = '/' + taskTable + '_list.do?sysparm_clear_stack=true'; 6 | 7 | // Open in new window 8 | var w = getTopWindow(); 9 | w.window.open(listURL, '_blank'); 10 | } 11 | -------------------------------------------------------------------------------- /UI Actions/Open Record in Alternate Instance/RESTMessageV2/sys_rest_message_config.md: -------------------------------------------------------------------------------- 1 | Name: Cross-Instance Record Checking 2 | Endpoint: [An Instance Url]/api/[api subpath, i.e., riot]/recordapi/record_exists 3 | 4 | See `sys_rest_message_fn_config.md` for HTTP Method setup. -------------------------------------------------------------------------------- /UI Actions/Open Record in Alternate Instance/RESTMessageV2/sys_rest_message_fn_config.md: -------------------------------------------------------------------------------- 1 | Name: [Target Instance] Record Exists 2 | HTTP Method: PATCH 3 | Endpoint: [Target Instance Url]/api/[api subpath]/.../record_exists 4 | 5 | HTTP Request Parameters: 6 | 7 | { 8 | "table": "${table}", 9 | "sysId": "${sysId}" 10 | } -------------------------------------------------------------------------------- /UI Actions/Open Record in Alternate Instance/Script Includes/README.md: -------------------------------------------------------------------------------- 1 | 2 | !! The switch statement in CrossInstanceHelper.js will need to be reconfigured to match instance names, and RESTMessage naming. -------------------------------------------------------------------------------- /UI Actions/Open Record in Alternate Instance/Script Includes/sys_script_include_config.md: -------------------------------------------------------------------------------- 1 | Name: CrossInstanceHelper 2 | Client callable: false 3 | 4 | Script: See `sys_script_include.js` for code. -------------------------------------------------------------------------------- /UI Actions/Open Record in Alternate Instance/Scripted REST API/sys_ws_definition_config.md: -------------------------------------------------------------------------------- 1 | General: 2 | 3 | Name: RecordAPI 4 | API ID: recordapi 5 | 6 | Content Negotiation: 7 | 8 | Supported request formats: application/json,application/xml,text/xml 9 | Supported response formats: application/json,application/xml,text/xml -------------------------------------------------------------------------------- /UI Actions/Open a new blank form/script.js: -------------------------------------------------------------------------------- 1 | //Create New blank incident form 2 | //Server side Script 3 | 4 | var newFormURL = new GlideURL('incident.do'); 5 | newFormURL.addParam('sys_id', '-1'); // Open a new blank form 6 | action.setRedirectURL(newFormURL.toString()); 7 | -------------------------------------------------------------------------------- /UI Actions/Open in Service Operations Workspace/README.md: -------------------------------------------------------------------------------- 1 | # Open in Service Operation Workspace 2 | 3 | Create UI Action with: 4 | 5 | Table: `Task` 6 | 7 | Onclick: `openInServiceOperationWorkspace()` 8 | 9 | Will open any task record in SOW 10 | -------------------------------------------------------------------------------- /UI Actions/Preview context record during approval/README.md: -------------------------------------------------------------------------------- 1 | While approving any request it was very hard until now to preview the record for which the approval was required. This UI action created on sysapproval_approver table will enable previewing the record before approval so that the approver can make an easy informed decision. 2 | -------------------------------------------------------------------------------- /UI Actions/Select Random User From Group/README.md: -------------------------------------------------------------------------------- 1 | # Random User Assignment 2 | 3 | This function allows you to select a random user from a specified group. Use case could be on all task-like records that need to be worked on by someone and you want to select the person randomly. 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /UI Actions/Test and Debug Scheduled Scripts/script.js: -------------------------------------------------------------------------------- 1 | try{ 2 | 3 | var evaluator = new GlideScopedEvaluator(); 4 | evaluator.evaluateScript(current, 'script'); 5 | action.setRedirectURL(current); 6 | 7 | } 8 | catch(e){ 9 | gs.addInfoMessage(e); 10 | } 11 | -------------------------------------------------------------------------------- /UI Actions/View in Portal Page/View in Portal Page.js: -------------------------------------------------------------------------------- 1 | function goToPortal(){ 2 | var url = '?='; 3 | g_navigation.openPopup(url); 4 | return false; 5 | } 6 | -------------------------------------------------------------------------------- /UI Macros/Purchase Order Approval Summarizer/approval_summarizer_proc_po.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/UI Macros/Purchase Order Approval Summarizer/approval_summarizer_proc_po.png -------------------------------------------------------------------------------- /UI Pages/Custom Alert using UI Page/README.md: -------------------------------------------------------------------------------- 1 | This script helps you to create custom popup easily and attached the screenshot for the reference, have a look. 2 | -------------------------------------------------------------------------------- /UI Pages/Custom Alert using UI Page/client script.js: -------------------------------------------------------------------------------- 1 | function onChange(control, oldValue, newValue, isLoading, isTemplate) { 2 | if (isLoading || newValue === '') { 3 | return; 4 | } 5 | 6 | 7 | var gm = new GlideModal("glide_confirm2", false, 600); 8 | gm.setWidth(600); 9 | gm.setTitle('Confirmation'); 10 | gm.render(); 11 | } 12 | -------------------------------------------------------------------------------- /UI Pages/Custom Alert using UI Page/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/UI Pages/Custom Alert using UI Page/image.png -------------------------------------------------------------------------------- /UI Pages/Dynamic program status overview/dynamic program status.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceNowDevProgram/code-snippets/902172263d5c4a4eae7f3f3a8ed008be60d37d67/UI Pages/Dynamic program status overview/dynamic program status.JPG -------------------------------------------------------------------------------- /UI Scripts/Display number of created records/onLoad.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | if(g_form.isNewRecord()) 3 | { 4 | var obj = new SampleUIScript(); // Initialize the class in UI Script 5 | // Call the function in UI Script 6 | obj.callFromClientScript("incident"); //you can give your required table name 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /UX Client Scripts/debug-event/debug-event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {params} params 3 | * @param {api} params.api 4 | * @param {any} params.event 5 | * @param {any} params.imports 6 | * @param {ApiHelpers} params.helpers 7 | */ 8 | function handler({ api, event, helpers, imports }) { 9 | console.log(`DEBUG Event ${event.elementId} ${event.name}`, event); 10 | } 11 | -------------------------------------------------------------------------------- /UX Client Scripts/debug-state/debug-state.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {params} params 3 | * @param {api} params.api 4 | * @param {any} params.event 5 | * @param {any} params.imports 6 | * @param {ApiHelpers} params.helpers 7 | */ 8 | function handler({ api, event, helpers, imports }) { 9 | console.log(`DEBUG State:`, { ...api.state }); 10 | } 11 | --------------------------------------------------------------------------------