├── .github └── workflows │ └── hacktrack.yml ├── Advanced Conditions ├── Exclude Email Reply Comment Notifications by Group │ ├── exclude_email_reply_comment_notifications_by_group.js │ └── readme.md └── Group Approval Check │ ├── group_approval_check.js │ └── readme.md ├── Attachments ├── Attachment to Base64 │ ├── readme.md │ └── script.js ├── Attachment to base64 in scope │ ├── attachmentToBase64Scope.js │ └── readme.md ├── Base 64 to Attachment │ ├── base64toattachment.js │ └── readme.md ├── CSVParser │ ├── csvparser.js │ └── readme.md ├── Calculate attachment hash code │ ├── calculateHash.js │ └── readme.md ├── Convert KnowledgePage to PDF │ ├── Convert_KnowledgePage_to_PDF.js │ └── readme.md ├── Delete RITM Attachment │ ├── deleteattachment.js │ └── readme.md ├── ExportAttachmentsToMidServer │ ├── exportattachmentstomid.js │ └── readme.md ├── ExportRecordsAnyFormat │ ├── exportRecords.js │ └── readme.md ├── Show RITM has Attachments │ ├── ShowRITMhasAttachment_BR.js │ ├── ShowRITMhasAttachment_CS.js │ └── readme.md └── attachmentToXMLParse │ ├── Readme.md │ └── code.js ├── Background Scripts ├── Add Standard Change Model │ ├── addStandardChgModel.js │ └── readme.md ├── Approval Reminders │ ├── approvalReminderToDelegates.js │ └── readme.md ├── Attach Workflow to Existing Record │ ├── readme.md │ └── script.js ├── Change Approver │ ├── BgScript.js │ └── Readme.md ├── Change Update Set Application Scope │ ├── changeApplicationScope.js │ └── readme.md ├── 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 │ ├── cloneUser.js │ └── readme.md ├── Compare Roles Between Two Users │ ├── README.md │ ├── compare-roles-2-users.js │ └── example-output.PNG ├── Convert Date Time │ ├── Readme.md │ └── convertTimeZone.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 │ ├── addMenuItem.js │ ├── menu.jpg │ ├── readme.md │ └── removeMenuItem.js ├── Currency Conversion │ ├── Readme.md │ └── currencyConvert.js ├── Currency Formatting │ ├── README.md │ └── currencyFormatting.js ├── Custom Table Usage │ ├── customTableUsage.js │ └── readme.md ├── Deactivate groups with no members and inactive manager │ ├── readme.md │ └── script.js ├── Decrypt Password Field │ ├── decryptfield.js │ └── readme.md ├── Discover Datacenters for Service Accounts │ ├── readme.md │ └── script.js ├── Extend Code Search Base. │ ├── add_more_tables_to_code_search.js │ └── readme.md ├── Fetch Active Groups list without members │ ├── Readme.md │ └── activeGroupsWithoutMembers.js ├── Find out Duplicate Records │ ├── Duplicate Records.js │ └── readme.md ├── Find sys_id named records │ ├── findSysIdNamedFiles.js │ └── readme.md ├── FlushOutbox │ ├── readme.md │ └── script.js ├── Force new value to read only or protected field │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── readme.md │ └── script.js ├── Generate JWT Token │ ├── Readme.md │ └── generateJWTToken.js ├── Generate Random Incident Records │ ├── generate_random_incident.js │ └── readme.md ├── Generate statistics about events created today │ ├── ScreenShot_0.PNG │ ├── ScreenShot_1.PNG │ ├── readme.md │ └── script.js ├── Get Active MID Servers │ ├── GetActiveMidServer.js │ └── readme.md ├── Get GlideRecord Reference Field │ ├── get_glide_record_reference_field.js │ └── readme.md ├── 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 │ ├── getMyGroups.js │ └── readme.md ├── Get The Last Journal Comment Date │ ├── README.md │ └── script.js ├── Get current logged in user count in all nodes of instance │ ├── readme.md │ └── script.js ├── 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 │ ├── listFieldsInTable.js │ └── readme.md ├── Logout User │ ├── logoutUser.js │ └── readme.md ├── Move Customer Updates │ ├── moveCustomerUpdates.js │ └── readme.md ├── Parse ISO8601 Date │ ├── README.md │ └── script.js ├── QuickCurrent │ ├── quickCurrent.js │ └── readme.md ├── Remove element from list field │ ├── readme.md │ └── removeFromList.js ├── Set the status to Retired on Ec2 Instance │ ├── readme.md │ └── script.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 └── User Has Role Exactly │ ├── readme.md │ └── user_has_role_exactly.js ├── Browser Bookmarklets ├── Copy URL to ServiceNow Journal │ ├── copy url to servicenow journal.js │ └── readme.md ├── Open copied record │ ├── open copied record bookmarklet.js │ └── readme.md ├── Quick Notes │ ├── quick_note.html │ └── readme.md ├── Quick login to current instance │ ├── Quick login.js │ └── readme.md └── ServiceNow Instance Collection │ ├── bookmarklets.html │ └── readme.md ├── Browser Utilities └── Custom Search Engines │ └── README.md ├── Business Rules ├── ATF Duplicate Execution Order │ ├── ATF_Duplicate_Execution_order.js │ └── readme.md ├── Add itil role to ootb user query to also see inactive users │ ├── code.js │ └── readme.md ├── After-BR to generate approvals for catalog tasks │ ├── approval.js │ └── readme.md ├── Allow only unique insert │ ├── readme.md │ └── script.js ├── Assign specific role to user │ ├── ScreenShot1.PNG │ ├── ScreenShot2.PNG │ ├── readme.md │ └── script.js ├── Async REST Call │ ├── Readme.md │ └── callAsynREST.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 ├── Block Attachments for specific conditions │ ├── Block Attachments.js │ └── readme.md ├── Change Lead Time Calculations │ ├── change_lead_time_calculations.js │ └── readme.md ├── Check domain of record against user session │ ├── readme.md │ └── script.js ├── Copy Attachment INC to Case │ ├── Readme.md │ └── copyAttachement.js ├── Copy Comments from RITM to SCTASK Vice versa │ ├── Readme.md │ └── copyCommentsfromRitmToSctask.js ├── Copy attachments from idea to demand │ ├── copy attach from idea to demand.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 ├── 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 │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── script.js ├── DeleteUserRole │ ├── readme.md │ └── script.js ├── Display BR to get groupInfo of logged in User │ ├── displayBr.js │ ├── onLoadClientScript.js │ └── readme.md ├── 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 │ ├── Warningmessage_Business rule.jss │ └── readme.md ├── Due date calculation based on priority │ ├── code.js │ └── readme.md ├── Enforce Percentage │ ├── enforce_percentage.js │ └── readme.md ├── Enforce Unique Rank │ ├── UniqueRank.js │ └── readme.md ├── Enforce a 1-1 relationship │ ├── enforce_1_1.js │ └── readme.md ├── Exclude Redundant Email Recipients │ ├── exclude_redundant_email_recipients.js │ └── readme.md ├── Generate event │ ├── ScreenShot_0.PNG │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── script.js ├── Make Attachment Mandatory │ ├── MakeAttachmentMandatory.js │ └── readme.md ├── Mandatory Attachment │ ├── Readme.md │ └── threeAttachementsMandatory.js ├── Manipulating system properties values │ ├── ScreenShot_0.PNG │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── 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 ├── Pass server info to client │ ├── example.png │ ├── passServerInfo.js │ └── readme.md ├── 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 │ ├── Script.js │ └── readme.md ├── Prevent invalid fiscal period in cost plan breakdown │ ├── Prevent invalid fiscal period on cost plan breakdown.js │ └── readme.md ├── Previous Approval Check │ ├── previous_approval_check.js │ └── readme.md ├── QueryBR-restrict users to see their company records │ ├── readme.md │ └── script.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 │ ├── ReadWS_URL.js │ └── readme.md ├── Recursive logic │ ├── Recursive BR.js │ └── readme.md ├── Replace KB Author with Manager │ ├── Readme.md │ └── Replace Script.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 ├── Update Child Incident based on Parent Incident │ ├── README.md │ └── Update_Child_Incident.js ├── Warn for changed OOTB artifacts │ ├── readme.md │ ├── screenshot.png │ └── warn_for_changed_ootb_artifacts.js └── setting future week dates │ ├── readme.md │ └── setting future dates.js ├── CMDB ├── CMDB record count │ ├── 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 │ └── mandatory-field-analysis.js ├── CONTRIBUTING.md ├── Catalog Client Script ├── Add Label For Attachment │ ├── README.MD │ └── add_label_for_attachment.js ├── Add Rows in MRVS │ ├── addrows.js │ └── readme.md ├── Autopopulate Department │ ├── autopopulateDepartment.js │ └── readme.md ├── Block Submit │ ├── README.MD │ └── block_submit.js ├── Calculate age on based on date of birth │ ├── Calculate age based on dob.js │ ├── image.png │ └── readme.md ├── 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 │ ├── currency_validation.js │ └── readme.md ├── Date Management │ ├── Date Management.js │ └── readme.md ├── Get MRVS Values from Parent │ ├── onload.js │ └── readme.md ├── MRVS Interact With Parent Form │ ├── Write to Parent Form.js │ └── readme.md ├── MRVS Loop Rows │ ├── loopRows.js │ └── readme.md ├── Make OOB Attachment Mandatory │ ├── onChange.js │ └── readme.md ├── Mandatory Attachments with 'n' numbers │ ├── onSubmitClientScript.js │ └── readme.md ├── Open modal widget in an Onsubmit │ ├── openmodal.js │ └── readme.md ├── PopulateDropdown │ ├── demo_catalog.png │ ├── readme.md │ └── 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 │ ├── catalog_client_script.js │ ├── catalog_client_script_config.md │ └── readme.md ├── Set User Field Values on Load │ ├── readme.md │ └── script.js ├── Set fields from URL Parameters │ ├── readme.md │ └── script.js └── Special Characters │ ├── readme.md │ └── script.js ├── Client Scripts ├── Add Field Decoration │ ├── Add Field Decoration.js │ └── readme.md ├── Add Image to Field Based on Company │ ├── AddImageToFieldBasedOnCompany.js │ ├── SetCompanyScratchPadValue.js │ └── readme.md ├── Auto-Populate Short Discription │ ├── autoPopulateSD.js │ └── readme.md ├── Auto-populate watch_list based on company │ ├── readme.md │ └── script.js ├── Check all mandatory fields using mandatoryCheck() │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── script.js ├── Client script using getMessage() function without filling Messages field │ ├── readme.md │ └── script.js ├── Control Form Behaviour from Reference Lookup │ ├── 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 │ ├── code.js │ └── readme.md ├── Expanding Info Message │ ├── readme.md │ └── script.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 │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── readme.md │ └── script.js ├── How to adjust the Date format within a client script to align with the User Date format │ ├── code.js │ └── readme.md ├── MRVS variables validations │ ├── readme.md │ └── script.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 ├── Populate Jelly Slushbucket with Values │ ├── ClientScript.js │ └── readme.md ├── 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 ├── 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 │ ├── getMessage.js │ └── readme.md ├── Update Category from Short Description Keywords │ ├── readme.md │ └── script.js ├── Validate date is in future without GlideAjax │ ├── OnChange Client Script.js │ └── readme.md ├── Verify if e-mail already exists with Ajax call │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── clientScript.js │ ├── readme.md │ └── scriptInclude.js ├── Verify whether a date falls within a hour range │ ├── README.MD │ └── verifyWhetherADateFallsWithinAHourRange.js ├── g_form console access in workspace │ ├── readme.md │ └── script.js └── onfocus and onblur │ ├── readme.md │ └── script.js ├── Dynamic Filters └── getMyDirectReports │ ├── example_manager_data.png │ ├── getMyReportsUtil.js │ ├── one_of_my_direct_reports.png │ ├── one_of_my_reports.png │ └── readme.md ├── ECMASCript 2021 ├── arrowfunctions.js ├── class.js ├── const.js ├── defaultparms.js ├── destructuring.js ├── forof.js ├── javascriptmode.png ├── let.js ├── map.js ├── openrecord.png ├── readme.md ├── 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 │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── ScreenShot_4.PNG │ ├── readme.md │ └── script.js ├── Assign user list to a specific group │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── script.js ├── Cancel Workflow │ ├── Cancel Workflow Context.js │ └── readme.md ├── Clean update set │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── ScreenShot_3.PNG │ ├── ScreenShot_4.PNG │ ├── readme.md │ └── script.js ├── Copy favourite to other users │ ├── favCopy.js │ └── readme.md ├── De-Provision Admin user (configurable) │ ├── deprovisionAdmin.js │ └── readme.md ├── Delete Change Conflict │ ├── readme.md │ └── script.js ├── Delete Duplicate Mobile records │ ├── readme.md │ └── script.js ├── Find duplicate records │ ├── Find duplicate records.js │ └── readme.md ├── Fiscal period renamer │ ├── fiscal period renamer.js │ └── readme.md ├── Fix model names after enabling glide.cmdb_model.display_name.shorten │ ├── fixModelNames.js │ └── readme.md ├── 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 ├── Measure code time execution │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── 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 ├── Restart Flow (CatalogItem) │ ├── readme.md │ └── restart_flow.js ├── Run Subscription Job On Demand │ ├── code.js │ └── readme.md ├── Search Results Weight │ ├── readme.md │ └── sr_weight.js ├── Swiss German Language Update │ ├── readme.md │ └── script.js ├── Update field with value in sys_audit │ ├── readme.md │ └── updateFromAudit.js └── deleteMultiple │ ├── code.js │ └── readme.md ├── Flow Actions ├── Assign Role │ ├── assignRole.js │ └── readme.md ├── Calculate Ticket Age │ ├── readme.md │ └── script.js ├── Check MID Server Availability │ ├── check_mid_server_availablility.js │ └── readme.md ├── Create Student Weekday Pickup Schedule │ ├── readme.md │ └── script.js ├── Generate unique value based on sequence │ ├── next-unique-sequence.js │ └── readme.md ├── Get Days difference │ ├── getDaysDifference.js │ └── readme.md ├── Get Property │ ├── getPropertyFlowAction.js │ └── readme.md ├── Get choice field value (mitigating known error) │ ├── readme.md │ └── script.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 ├── Runscript activities │ ├── CatalogvariablesSummary.js │ └── readme.md ├── Scheduled data import trigger │ ├── Scheduled data import trigger.js │ └── readme.md ├── 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 │ ├── getCatVarsAsJson.js │ └── readme.md ├── 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 ├── Group Count │ ├── GlideQuery.js │ ├── GlideQuery_readme.md │ ├── code.js │ └── readme.md ├── Grouping by three columns │ ├── ScreenShot_1.PNG │ ├── readme.md │ └── script.js ├── Tiered grouping of an integer column │ ├── readme.md │ └── script.js ├── Using addHaving │ ├── ScreenShot_1.PNG │ ├── readme.md │ └── script.js ├── addTrend │ ├── README.md │ └── addTrend.js ├── getCountAfterDate │ ├── getCountAfterDate.js │ └── readme.md └── getTotal of aggregate value │ ├── README.MD │ └── getTotal.js ├── GlideAjax ├── AjaxAsyncOnSubmit │ ├── ajaxasynconsubmitclient.js │ ├── ajaxasynconsubmitserver.js │ └── readme.md ├── 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 ├── GlideAjax Example Template │ ├── code.js │ ├── example from community.js │ └── readme.md ├── Return Asset(s) for User │ ├── FindUserAsset.js │ └── readme.md ├── ReturnMultipleProperties │ ├── ReturnMultipleProperties.js │ └── readme.md ├── Reusable GlideAjax │ ├── clientCallableScriptInclude.js │ ├── clientSideGlideAjax.js │ └── readme.md └── Reusable glideajax table query │ ├── README.md │ └── getTableColumnsClientSide.js ├── 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 ├── Current Date with Fixed Time │ ├── CurrentDateFixedTime.js │ └── readme.md ├── Due date generation │ ├── duedate_generation.js │ └── readme.md ├── 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 │ ├── output_string_dates.js │ └── readme.md ├── 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 │ ├── glideelement.js │ └── readme.md ├── GlideFilter └── checkRecord │ ├── example.js │ └── readme.md ├── GlideHTTPRequest ├── glidehttprequest.js └── readme.md ├── GlideModal ├── Confirm Message │ ├── glide_confirm.js │ └── readme.md └── Information Message │ ├── glide_info.js │ ├── glide_warn.js │ └── readme.md ├── GlideQuery ├── Basic Wrappers │ ├── delete_records.js │ ├── get_records.js │ ├── insert_records.js │ ├── readme.md │ └── update_records.js ├── Field Default │ ├── GlideQueryFieldDefault.js │ └── readme.md ├── FlatMap to Nest New Queries │ ├── getIncidentInfoWithFlatMap.js │ └── readme.md ├── Get Delegates │ ├── GlideQueryGetDelegates.js │ └── readme.md ├── Get User's Roles from User Name │ ├── getUserRoles.js │ └── readme.md ├── Nested WHERE orWHERE GlideQueries │ ├── nestedWhereQueries.js │ └── readme.md └── Remote Table │ ├── Readme.md │ └── remotetabldef.js ├── GlideRecord ├── ACL enforcement using GlideRecord │ ├── README.md │ └── glideRecordSecure.js ├── Count Records By Column │ ├── README.md │ └── script.js ├── Fetch groups that have no members in them │ ├── fetchEmptyGroups.js │ └── readme.md ├── Find Date Overlapping │ ├── isSimilarDates.js │ └── readme.md ├── Find No Of Days │ ├── findNoOfDays.js │ └── readme.md ├── Get Reference Record │ ├── README.md │ └── script.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-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 ├── Multi Row Variable Set(MRVS) │ ├── InsertMRVSRecords.js │ └── readme.md ├── Record Activity Collector │ ├── ActivityCollector.js │ └── readme.md ├── Set Template │ ├── readme.md │ └── setTemplate.js ├── UpdateMultiple │ ├── Readme.md │ └── script.js ├── Watch_List_functions │ ├── readme.md │ └── removeSpecificUser.js ├── findDuplicate │ ├── GlideAggregateScript.js │ └── ReadMe.md ├── getEncodedQuery │ ├── code.js │ └── readme.md └── isValidGlideRecord │ ├── isValidGlideRecord.js │ └── readme.md ├── GlideSystem ├── Impersonate │ ├── impersonate.js │ └── readme.md ├── Session │ ├── readme.md │ └── session.js ├── Table │ ├── readme.md │ ├── tableExists.js │ └── truncateTable.js ├── Trigger Event │ ├── eventQueue.js │ ├── eventQueueScheduled.js │ └── readme.md ├── User Display Name │ ├── readme.md │ └── script.js ├── User │ ├── readme.md │ └── userID.js ├── date-time │ ├── beginningOfLastMonth.js │ ├── minutesAgoEnd.js │ ├── minutesAgoStart.js │ ├── monthsAgo.js │ ├── monthsAgoEnd.js │ ├── monthsAgoStart.js │ ├── quartersAgo.js │ ├── quartersAgoEnd.js │ ├── quartersAgoStart.js │ ├── readme.md │ ├── setDisplayValueInternalWithAlternates.js │ ├── yearsAgo.js │ └── yesterday.js ├── hasRoleExactly │ ├── readme.md │ └── script.js └── workflowFlush │ ├── readme.md │ └── workflowFlush.js ├── GlideTableDescriptor └── getFirstTableName() │ ├── GlideTableDescriptor.js │ └── readme.md ├── GraphQL ├── 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 ├── Inbound Actions ├── Advanced Scripts │ ├── cancel_catalog_item_from_email.js │ ├── create_catalog_item_from_email.js │ ├── readme.md │ └── update_catalog_item_from_email.js ├── Auto Reply Email │ ├── code.js │ └── readme.md ├── Automate creation of incidents through inbound actions │ ├── incidentCreation.js │ └── readme.md └── Email Text as Attachment │ ├── 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 │ ├── liveCItoTAsk.js │ └── readme.md ├── Import Sets Debug │ ├── README.md │ └── debugImportSet.js ├── Import Sets │ ├── README.md │ └── debug │ │ ├── README.md │ │ └── debugImportSet.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 │ ├── call_script_include.js │ └── readme.md ├── Call UI Message or System Property in Notification Mail Script │ ├── call_UIMessage_or_sysProperty.js │ └── readme.md ├── HTML Table Creation from ServiceNow Table │ ├── MailScript.js │ └── readme.md ├── Open Survey In Portal │ ├── open_survey.js │ └── readme.md ├── Print variables to mail │ ├── printVarsToMail.js │ └── readme.md └── RITM Reject Reason │ ├── README.md │ └── reject_reason_new.js ├── NOW Experience └── JSX Cheat Sheet │ └── readme.md ├── Notifications └── Conditional Trigger │ ├── Notification_AdvancedCondition.js │ └── Readme.md ├── Performance Analytics └── Configure Indicators in Batch │ ├── ConfigurePAIndicators.js │ └── README.md ├── Processors └── Dynamic Sitemap │ ├── README.md │ ├── dynamicSitemapProcessor.js │ └── snow-sitemap-results.png ├── README.md ├── RESTMessageV2 ├── AzureDevOps │ ├── azure.js │ └── readme.md ├── Google-Chat │ ├── readme.md │ └── sendgchatmessage.js ├── Web Scraping REST Message │ ├── code.js │ └── readme.md └── 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 │ ├── allowsCharsForPhnNumber.js │ └── readme.md ├── AllowAnyLanguage │ ├── allowanylanguage.js │ └── readme.md ├── Check if number has 10 digits │ ├── readme.md │ └── script.js ├── Email Address Validation │ ├── isEmail.js │ └── readme.md ├── Encode spaces for URLs │ ├── convert.js │ └── readme.md ├── Find Emoji │ ├── index.js │ └── readme.md ├── Format mobile into Australian mobile format │ ├── Format phone in Australian mobile format.js │ └── readme.md ├── IP Address Validation │ ├── readme.md │ └── validateIPInput.js ├── Indian Mobile Numbers │ ├── code.js │ └── readme.md ├── Match URL's from ServiceNow domain │ ├── ScreenShot_1.PNG │ ├── readme.md │ └── script.js ├── Negative RegExp for Condition Builder │ ├── NegativeRegExExample.js │ └── readme.md ├── Poland country code │ ├── ScreenShot_1.PNG │ ├── readme.md │ └── script.js ├── Remove Extra Spaces │ ├── README.md │ └── index.js ├── Remove newline and carriage return │ ├── readme.md │ └── remove cr and nl.js └── SSN Formatting │ ├── Index.js │ └── readme.md ├── Scheduled Jobs ├── Approval Reminder │ ├── change_reminder_scheduled_job.js │ ├── readme.md │ ├── requested_item_approval_reminder_approver.js │ └── requested_item_approval_reminder_requestor.js ├── Auto close changes requests updated 30 days prior │ ├── readme.md │ └── script.js ├── Create Scheduled Imports Graphviz file │ ├── README.md │ └── script.js ├── Daily detection of customer updates made in 'Default' update set │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── script.js ├── Deactivate INC in 90 days │ ├── 90daysInactiveScript.js │ └── readme.md ├── 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 │ ├── ScreenShot_1.PNG │ ├── ScreenShot_2.PNG │ ├── readme.md │ └── script.js ├── Paginated Export │ ├── Paginated Export.md │ └── paginatedExport.js ├── Remove Inactive and locked out users from All Groups and Roles │ ├── code.js │ └── readme.md ├── ScheduleAtSpecificDaysAndTimes │ ├── readme.md │ └── schedulejobcondition.js └── Survey Trigger Scheduled Script │ ├── readme.md │ └── survey_trigger_sj.js ├── Script Actions └── Custom Table Helper │ ├── Script Action.js │ └── readme.md ├── 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 │ ├── groupMember.js │ └── readme.md ├── Approval Rule Builder │ ├── ApprovalRuleBuilder.js │ └── readme.md ├── ArrayUtil │ ├── readme.md │ └── script.js ├── Auto Execute Import Set on File Attachment │ ├── CreateImportSetAndRunTransform.js │ ├── CreateSysTrigger.js │ └── readme.md ├── BackfillAssignmentGroup │ ├── BackfillAssignmentGroup.js │ └── readme.md ├── BenchmarkRunner │ ├── BenchmarkRunner.js │ └── readme.md ├── CSV Parser │ ├── CSVParser.js │ └── readme.md ├── CatalogUtils │ ├── CatalogUtils.js │ └── readme.md ├── Check User Has Role │ ├── UserHasRole.js │ └── readme.md ├── 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 ├── ConversationUtils │ ├── ConversationUtils.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 ├── CustomObjectUtils │ ├── CustomObjectUtils.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 │ ├── excelParser.js │ └── readme.md ├── Extending OOB TableUtils │ ├── EXT_TablesUtils.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 │ ├── getChoiceDisplayValue.js │ └── readme.md ├── Get Current User Information │ ├── getCurrentUserInformation.js │ └── readme.md ├── Get Field Label in Specific Language │ ├── readme.md │ └── script.js ├── Get Group Members │ ├── getGroupMembers.js │ └── readme.md ├── Get Reference Display Value │ ├── getReferenceDisplayValue.js │ └── readme.md ├── GetCallerDetails │ ├── Calling Script Include from client.js │ ├── Readme.md │ └── scriptinclude.js ├── GlideDateTimeUtils │ ├── ClientDateTimeUtils.js │ └── README.md ├── GlideRecord to JSON │ ├── gr2obj.js │ └── readme.md ├── GlideRecordHelper │ ├── readme.md │ └── script.js ├── HTMLUtils │ ├── readme.md │ └── script.js ├── Hybrid Script Include for AJAX or Server Side Parameters │ ├── ScriptInclude.js │ └── readme.md ├── Install base items with active cases │ ├── Readme.md │ └── script.js ├── JSONPath │ ├── JSONPath.js │ └── readme.md ├── JSONtoYAML │ ├── code.js │ └── readme.md ├── KBArticleExpPDF │ ├── ArticlePDFHelper.js │ └── readme.md ├── ListFieldUtil │ ├── ListFieldUtil.js │ └── readme.md ├── Logger │ ├── Logger.js │ └── README.md ├── ManagerRecursiveUtil │ ├── RecursiveByManager.js │ └── readme.md ├── 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 │ ├── numberPadding.js │ └── readme.md ├── OrderedRecords │ ├── orderedRecords.js │ └── readme.md ├── PII Redactor │ ├── piiRedaction.js │ └── readme.md ├── PerformanceAnalyticsUtils │ ├── PerformanceAnalyticsUtils.js │ └── readme.md ├── Project Base Line │ ├── Readme.md │ └── latestPlannedBaseline.js ├── Public Script Include search │ ├── readme.md │ └── script.js ├── Records Calculator │ ├── README.md │ └── RecordsCalculator.js ├── Regex utils │ ├── RegexUtils.js │ └── readme.md ├── Reparent Table │ ├── Readme.md │ └── script.js ├── RequestNotificationUtil │ ├── RequestNotificationUtil.js │ └── readme.MD ├── Retrieve Last Comment by Ticket │ ├── RetrieveLastCommentByTicket.js │ └── readme.md ├── Return Object │ ├── ReturnObject.js │ └── readme.md ├── Role Checker Util │ ├── checkUserRole.js │ └── readme.md ├── SRAPIUtil │ ├── SRAPIUtil.js │ └── readme.md ├── Scheduled Recursion │ ├── background_script.js │ ├── readme.md │ └── scheduled_recursion.js ├── Slack JSON Block Factory │ ├── Slacktory.js │ ├── readme.md │ └── sys_script_include_config.md ├── Standard Change Creator │ ├── readme.md │ ├── sys_script_include.js │ └── sys_script_include_config.md ├── StarterPack │ ├── AjaxClientScript.js │ ├── AjaxSI.js │ ├── classless.js │ ├── constants.js │ ├── readme.md │ ├── reference.js │ └── utilsExample.js ├── Stopwatch │ ├── Stopwatch.js │ └── readme.md ├── Store data in User Session │ ├── Readme.md │ └── storeDataInSession.js ├── StripHTML │ ├── StripHTML.js │ └── readme.md ├── SubProdLogger │ ├── SubProdLogger.js │ └── readme.md ├── Table List Copy Context Options │ ├── Copy Field Display Value Context Menu.js │ ├── Copy Field Name Context Menu.js │ ├── Copy Field Value Context Menu.js │ ├── Script Include.js │ └── readme.md ├── TableUtils Extension │ ├── Enhanced_TableUtils.js │ └── README.md ├── Testing Script Include Using Jasmine │ ├── Sample Calculator Script Include.js │ ├── Sample Jasmine Script.js │ └── readme.md ├── TimeZoneUtils │ ├── TimeZoneUtils.js │ └── readme.md ├── TinyURLHelper │ ├── TinyUrlHelper.js │ └── readme.md ├── Translations Import │ ├── Readme.md │ └── script.js ├── UnloadXml │ ├── readme.md │ └── script.js ├── UserCriteriaUtil │ ├── UserCriteriaUtil.js │ └── readme.md ├── UserUtil │ ├── UserUtil.js │ ├── readme.md │ └── userMemberOf.png ├── VariableHelper │ ├── readme.md │ └── variableHelper.js ├── attachments │ ├── Readme.md │ └── attachment.js ├── get field values for multiple records from a table │ ├── readme.md │ └── script.js ├── getCountFunction │ ├── callingSI.js │ ├── code.js │ └── readme.md ├── getGlideRecordObject │ ├── Readme.md │ └── getGlideRecordObject.js └── regexCheckerScript │ ├── readme.md │ └── regexCheckerScript.js ├── Scripted REST Api ├── Approval APIs │ ├── ApprovalRestResource.js │ ├── RejectRestResource.js │ ├── SRApprovalsAPI.js │ └── readme.md ├── CMDB API │ ├── CmdbApi.js │ ├── CreateCIs.js │ ├── CreateCiRelationship.js │ ├── DeleteCI.js │ ├── DeleteCiRelationship.js │ ├── RetrieveCiGroup.js │ ├── RetrieveCis.js │ ├── Retrieve_CI_Relationships.js │ ├── RetriveCiRelationshipTypes.js │ ├── UpdateCi.js │ └── readme.md ├── CURL Script to create incident via tableAPI │ ├── readme.md │ └── script.curl ├── CopyAI Generative AI example │ ├── image.png │ ├── readme.md │ └── script.js ├── Difference between two users │ ├── output.txt │ ├── readme.md │ └── script.js ├── Get_Choices │ ├── readme.md │ ├── script.js │ ├── script.png │ └── scripted_rest_resource.png ├── Promise API Call │ ├── promiseApiCall.js │ └── readme.md ├── Retrieve all variables from RITM │ ├── CHVarUtils_ScriptInclude.js │ ├── output_example.js │ ├── readme.md │ └── scripted_rest_api.js ├── Tag API │ ├── Screenshot 2023-10-11 at 12.51.24 PM.png │ ├── Screenshot 2023-10-11 at 12.51.59 PM.png │ ├── insert-tag.js │ └── readme.md └── compare roles │ ├── output.txt │ ├── readme.md │ └── script.js ├── Server Side ├── CallScriptIncludeWithParameters │ ├── readme.md │ └── script.js ├── CheckTableExtension │ ├── istableextended.js │ └── readme.md ├── Create Admin Users │ ├── create_admin_user.js │ └── readme.md ├── Create Tiny Url with API's │ ├── readme.md │ └── tinyUrl.js ├── CreateUpdateCIThroughIRE │ ├── createupdateciinire.js │ └── readme.md ├── DiscoveryDeviceHistory │ ├── devicehistory.js │ └── readme.me ├── ExecuteWorkOnMidServer │ ├── executeworkonmid.js │ └── readme.md ├── 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 │ ├── read csv logic.js │ └── readme.md ├── 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 Variable Choices │ ├── readme.md │ └── updateVariableChoices.js ├── User Criteria │ ├── Does User Match Criteria(s).js │ └── readme.md └── 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 │ ├── client_script.js │ ├── css.css │ ├── html.html │ ├── readme.md │ └── server_script.js ├── ApplyCSSDynamically │ ├── applycssdynamically.html │ ├── applycssdynamicallyclient.js │ ├── applycssdynamicallyserver.js │ └── readme.md ├── Batman Animation │ ├── Batman Background Image.jpg │ ├── Batman logo.png │ ├── client_script.js │ ├── html_template.html │ ├── readme.md │ └── style.css ├── Card Image Link │ ├── 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 │ └── readme.md ├── Catalog Item Explorer │ ├── README.md │ ├── client_script.js │ ├── css.scss │ ├── options_schema.json │ ├── script.js │ └── template.html ├── Change Notification Preferences │ ├── client.js │ ├── css.css │ ├── html.html │ ├── notification_preference.js │ ├── readme.md │ └── server.js ├── Check if user has specific role inside the widget │ ├── ClientScript.js │ └── readme.md ├── Clickable SVG Image │ ├── client.js │ ├── echarts.js │ ├── flight-seats.svg │ ├── html.html │ └── readme.md ├── Client side pagination │ ├── readme.md │ └── script.js ├── Configurable Card Widget │ ├── CSS-SCSS.scss │ ├── Client Script.js │ ├── HTML Template.html │ ├── Widget Options.json │ ├── image.png │ └── readme.md ├── Create diagram using GoJS library │ ├── body.html │ ├── client.js │ ├── readme.md │ └── style.css ├── Create diagram using Highcharts library │ ├── body.html │ ├── client.js │ └── readme.md ├── Custom Greetings in portal homepage │ ├── homepage-search-client.js │ ├── homepage-search.html │ └── readme.md ├── Drag & drop Widget │ ├── client.js │ ├── html.html │ ├── readme.md │ ├── remove_icon.png │ └── server.js ├── Export table in portal │ ├── export.html │ ├── export.js │ └── readme.md ├── Floater Feedback Widget │ ├── demo.JPG │ ├── feeback_floater.js │ └── readme.md ├── 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 │ ├── ServerScript.js │ ├── html.html │ └── readme.md ├── ImportXml │ ├── importXml.js │ └── readme.md ├── Incident Sound Alerts │ ├── incident_alerts_widget.js │ └── readme.md ├── Konami Code Easter Egg │ ├── KonamiCodeEasterEgg.js │ └── readme.md ├── Open in Platform │ ├── body.html │ ├── readme.md │ └── server.js ├── Portal widgets Performance Test │ ├── Readme.md │ └── code.js ├── Record process flow │ ├── PortalUtils.js │ ├── PortalUtilsBase.js │ ├── body.html │ ├── readme.md │ ├── 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 │ ├── client.js │ └── readme.md ├── Spiderman Animation │ ├── client_script.js │ ├── greengoblin.png │ ├── html_template.html │ ├── readme.md │ ├── spid.png │ ├── spider.mp3 │ └── style.css ├── Squid Game Themed Incident-Request-Knowledge │ ├── Squid Game Themed Incident-Request-Knowledge Widget Preview.png │ ├── readme.md │ ├── 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 │ ├── Squid Game Themed Simple List - Preview.png │ ├── readme.md │ ├── squid_game_coffin.png │ ├── squid_game_simple_list.css │ └── squid_game_simple_list.html ├── Squid Game Themed User Profile Card │ ├── Squid Game Themed User Profile Card - Back - Preview.png │ ├── Squid Game Themed User Profile Card - Front - Preview.png │ ├── readme.md │ ├── 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 │ ├── enhanced_action_sp_widget.png │ ├── readme.md │ ├── sp_widget_std_action.xml │ └── standard_ticket_config.png ├── Upload Files │ ├── body.html │ ├── client.js │ ├── readme.md │ ├── 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 │ ├── Service Portal - iFrame Widget.xml │ ├── client.js │ ├── optionsSchema.json │ ├── readme.md │ ├── server.js │ ├── style.scss │ └── template.html ├── Service Portal ├── Search Sources │ ├── Approvals.html │ ├── DataFetchScript.js │ └── Readme.md ├── dark-mode-switcher │ ├── avatarDropDown.js │ ├── dark_mode.scss │ ├── demo.gif │ ├── portal_theme.scss │ ├── readme.md │ └── themeSwitcherMenu.js ├── instance-badge │ ├── header.png │ └── readme.md ├── 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 ├── 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 ├── Transform Map Scripts ├── Choice Field Validator │ ├── choiceValidatorUtil.js │ ├── choice_validador1.png │ ├── choice_validador2.png │ └── readme.md ├── Conditional Coalesce │ ├── conditional_coalasce.js │ ├── conditional_coalesce.png │ └── readme.md └── 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 ├── Clone incident on Agent Workspace │ ├── clone_incident.js │ ├── readme.md │ └── workspace_client_script.js ├── Close child incident │ ├── clientScript.js │ ├── readme.md │ └── serverScript.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 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 │ ├── choice_dialog.js │ └── readme.md ├── Force to Update Set │ ├── readme.md │ └── script.js ├── GlideModalForm - Open New Record and Pass Query │ ├── code.js │ └── readme.md ├── Go to Agent Workspace Home Page │ ├── readme.md │ └── ui_action_script.js ├── Mark Records Inactive - List Action │ ├── listAction.js │ ├── readme.md │ └── scriptInclude.js ├── Open Email Client using UI Action │ ├── open_email_client.js │ └── readme.md ├── Open Record in Alternate Instance │ ├── 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 │ └── readme.md ├── 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 ├── Show Today Emails Logs │ ├── readme.md │ └── script.js ├── Try Catalog item in Portal view │ ├── Readme.md │ └── TryItInSP.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 │ ├── approval_summarizer_proc_po.png │ ├── approval_summarizer_proc_po.xml │ └── readme.md └── Variable Copy Context Options │ ├── element context.xml │ └── readme.md ├── UI Pages ├── Custom Alert using UI Page │ ├── client script.js │ ├── custom alert.js │ ├── image.png │ └── readme.md ├── Dynamic program status overview │ ├── Program details dynamic content block.xml │ ├── dynamic program status.JPG │ ├── program_list.html │ ├── program_list.js │ └── readme.md ├── EDM DocUnifiedSearch │ ├── EDMSearch.js │ ├── client script.js │ ├── code.html │ └── readme.md ├── 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 └── Real time log watcher │ ├── README.md │ ├── TestScriptInclude.js │ └── log_watcher.js ├── UI Scripts ├── Display number of created records │ ├── onLoad.js │ ├── readme.md │ └── 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 ├── Record Operation Utilities │ ├── readme.md │ └── script.js └── readme.md ├── calc.java ├── calc.js ├── emailslicer.py ├── function.py ├── multi-dimensionarry.cpp ├── selecsort.py ├── selection.py ├── switch.java ├── table.java ├── theme.html └── todo.js /Advanced Conditions/Group Approval Check/readme.md: -------------------------------------------------------------------------------- 1 | # Group Approval Check 2 | 3 | ### This is an email notification advanced condition script for approval requests that will check if an approval has already been granted prior to sending out a request. 4 | 5 | This script can be applied to any approval request notification on the sysapproval_approver table with no additional configuration necessary 6 | -------------------------------------------------------------------------------- /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/Calculate attachment hash code/calculateHash.js: -------------------------------------------------------------------------------- 1 | function calculateHash(attachmentId){ 2 | var attachmentStream = new GlideSysAttachment().getContentStream(attachmentId); 3 | var gDigest = new GlideDigest(); 4 | var sha256Hash = gDigest.getSHA256HexFromInputStream(attachmentStream); 5 | if (sha256Hash) { 6 | gs.info("Hash code of the attachment file: " + sha256Hash); 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /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/ExportAttachmentsToMidServer/readme.md: -------------------------------------------------------------------------------- 1 | The snippet can be used to export all attachments within any record in ServiceNow to the mid server. You could specify a relative file path within the server's agent folder and it will copy them into it. 2 | 3 | Sample Usage 4 | 5 | exportAttachmentsToMid("66a4daff2f9ff810ba1b52492799b6f1", "\\Incident\\INC00293930", "Mid Server 01"); 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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 Date Time/convertTimeZone.js: -------------------------------------------------------------------------------- 1 | var strConvertedDateTime=new GlideScheduleDateTime("2022-03-03 06:30:00").convertTimeZone("CET", "IST"); // Instantiate the object by passing the timezones 2 | var gdtConvertedDateTime = new GlideDateTime(strConvertedDateTime); //Call the method to convert the date time from CET to IST 3 | gs.info(gdtConvertedDateTime); //Print the converted value 4 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/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/Find out Duplicate Records/readme.md: -------------------------------------------------------------------------------- 1 | This script helps to find out duplicate records in the table. 2 | 3 | In this example I have shown how to find out records in incident table. 4 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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 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 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 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/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/Limit String and Add Elipses/script.js: -------------------------------------------------------------------------------- 1 | function addElipses(string, maxLength) { 2 | var maxLength = Number(maxLength); 3 | 4 | if (string.length > maxLength) { 5 | return string.substr(0, maxLength) + '...'; 6 | } 7 | 8 | return string; 9 | }; 10 | 11 | var StringName = 'hafsa asif razzak'; 12 | gs.info(addElipses(StringName, 5)); -------------------------------------------------------------------------------- /Background Scripts/List Stories and Tasks by User and Date Range/results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Background Scripts/Update All Store Apps/2023-10-13-12-17-09.png -------------------------------------------------------------------------------- /Background Scripts/User Has Role Exactly/readme.md: -------------------------------------------------------------------------------- 1 | # hasRoleExactly 2 | 3 | This background script might be useful if you come 4 | in a situation where it would be necessary to check 5 | whether the logged in user has a specific role. 6 | 7 | # Use Case: 8 | example: check if the user has a specific role by calling the role: hasRoleExactly('admin'); 9 | will return true if the user has the role and false otherwise 10 | 11 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /Browser Bookmarklets/Quick Notes/quick_note.html: -------------------------------------------------------------------------------- 1 | data:text/html, Quick Note 2 | -------------------------------------------------------------------------------- /Business Rules/Add itil role to ootb user query to also see inactive users/code.js: -------------------------------------------------------------------------------- 1 | //set condition field within user query business rule to: gs.getSession().isInteractive() && !gs.hasRole("admin,user_admin,itil") 2 | current.addActiveQuery(); //this will add an active query to the user's sys_user query if the user is in an interactive session and does not have admin, user_admin, or itil roles 3 | -------------------------------------------------------------------------------- /Business Rules/Add itil role to ootb user query to also see inactive users/readme.md: -------------------------------------------------------------------------------- 1 | A common request is to also allow itil users to also be able to see inactive user records. 2 | There are two pieces of code in the code.js file: 3 | 1) A conditional piece of code that should be added to the "Condition" field within the business rule 4 | 2) A single line that should be added to the "Script" field within the business rule 5 | -------------------------------------------------------------------------------- /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/Allow only unique insert/script.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/) { 2 | 3 | var gr = new GlideRecord(""); 4 | gr.addQuery("", current.); 5 | gr.query(); 6 | if (gr.next()) { 7 | gs.addErrorMessage("Entry for this already exists"); 8 | current.setAbortAction(true); 9 | } 10 | 11 | 12 | })(current, previous); 13 | -------------------------------------------------------------------------------- /Business Rules/Assign specific role to user/ScreenShot1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Assign specific role to user/ScreenShot1.PNG -------------------------------------------------------------------------------- /Business Rules/Assign specific role to user/ScreenShot2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Assign specific role to user/ScreenShot2.PNG -------------------------------------------------------------------------------- /Business Rules/Auto approve if previously approved/Readme.md: -------------------------------------------------------------------------------- 1 | The purpose of this BR is to avoid redundant approval actions if the ticket is sent to same approver. 2 | This should be a Before Insert Business rule that runs on the Approval table. 3 | Replace the table name accordingly in line 3 of the code to limit it to particular table. For instance, there may be need for auto-approval only for RITMs and not for Change requests. 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/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/readme.md: -------------------------------------------------------------------------------- 1 |

Count the number of associated incidents in Problem Form

2 |

Use - Case:

3 |

Created a field in the Problem form which shows the number of incident records associated with the same problem. This makes it easy for the helpdesk to find out if there are any linked incidents without scrolling down.

4 | -------------------------------------------------------------------------------- /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 catalog task for each row of MRVS/readme.md: -------------------------------------------------------------------------------- 1 | This code snippet will help you to generate tasks automatically for each row of MRVS present on RITM. This can be achieved by using a Before BR on RITM. 2 | Specifications for Business rule will be: 3 | 1. When = Before 4 | 2. Insert = true 5 | 3. Advanced = true 6 | 4. Then write the script provided in script.js into the script section of BR. 7 | -------------------------------------------------------------------------------- /Business Rules/Create comment on referenced record/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Create comment on referenced record/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Business Rules/Create comment on referenced record/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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 BR to get groupInfo of logged in User/onLoadClientScript.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | //Type appropriate comment here, and begin script below 3 | if (g_scratchpad.isMemberOf == true) { 4 | g_form.setReadOnly('u_choice', true); // to make the 'u_choice' read only 5 | g_form.setDisplay('u_work_item', false); // to hide the 'u_work_item' field 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /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 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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Generate event/ScreenShot_0.PNG -------------------------------------------------------------------------------- /Business Rules/Generate event/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Generate event/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Business Rules/Generate event/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Generate event/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Business Rules/Generate event/script.js: -------------------------------------------------------------------------------- 1 | (function executeRule(current, previous /*null when async*/ ) { 2 | //Business rule to generate new event 3 | 4 | //Adding new event to queue 5 | //Parameters: Event name, GlideRecord Object, parm1, parm2 6 | gs.eventQueue('custom_event.adminRoleAssigned', current, current.user, current.sys_created_by); 7 | 8 | })(current, previous); 9 | -------------------------------------------------------------------------------- /Business Rules/Make Attachment Mandatory/MakeAttachmentMandatory.js: -------------------------------------------------------------------------------- 1 | // Add below code to Before BR 2 | var attach = new GlideRecord('sys_attachment'); 3 | attach.addQuery('table_sys_id', current.sys_id); 4 | attach.addQuery('table_name', current.getTableName()); 5 | attach.query(); 6 | if (!attach.next()) { 7 | gs.addErrorMessage("Cannot submit without an attachment."); 8 | current.setAbortAction(true); 9 | } 10 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Manipulating system properties values/ScreenShot_0.PNG -------------------------------------------------------------------------------- /Business Rules/Manipulating system properties values/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Manipulating system properties values/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Business Rules/Manipulating system properties values/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Manipulating system properties values/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Business Rules/Mark an Email High Importance initiated from Email Client/readme.md: -------------------------------------------------------------------------------- 1 | This Business Rule can help agent mark an email High importance from Email Client. Out of Box there is no way an agent can mark an email High importance while drafting an email from email client. This Business rule can mark an email High importance when an exclamation (!) is added to the start of the subject in the Email Client 2 | -------------------------------------------------------------------------------- /Business Rules/Name Change Profile Update/readme.md: -------------------------------------------------------------------------------- 1 | This business rule is being used to update the live_profile record for a user if their first or last name changes. 2 | When a sys_user record is updated it runs a query against the live_profile table to match the document field with the sys ID of the user and then updates the name 3 | field of the live_profile record with the name value from the sys_user record. 4 | -------------------------------------------------------------------------------- /Business Rules/Pass server info to client/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Pass server info to client/example.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/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 invalid fiscal period in cost plan breakdown/Prevent invalid fiscal period on cost plan breakdown.js: -------------------------------------------------------------------------------- 1 | //before update 2 | //table cost_plan_breakdown 3 | //condition: 4 | fiscal_periodVALCHANGES^fiscal_period.fiscal_end_date_timeMORETHANcost_plan.end_fiscal_period.fiscal_end_date_time@hour@after@0^ORfiscal_period.fiscal_start_date_timeMORETHANcost_plan.start_fiscal_period.fiscal_start_date_time@hour@before@0^EQ 5 | -------------------------------------------------------------------------------- /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/QueryBR-restrict users to see their company records/readme.md: -------------------------------------------------------------------------------- 1 | This script is used to restrict logged in users to see only their company records. This is a generic script and can be used in any table where there is a Company field present 2 | which is associated to the User table. 3 | Query BR contains below specifications: 4 | 1. Advanced = true 5 | 2. When = Before 6 | 3. Query = true 7 | -------------------------------------------------------------------------------- /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/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/SCTASK_to_RITM/SCTASK_to_RITM.js: -------------------------------------------------------------------------------- 1 | /* 2 | Table: sc_task 3 | When to Run: after update 4 | Condition: current.comments.changes() && gs.isInteractive() 5 | */ 6 | 7 | //Script to update comments on RITM. 8 | 9 | var ritmGr = new GlideRecord('sc_req_item'); 10 | if(ritmGr.get(current.request_item.sys_id)){ 11 | ritmGr.comments = current.comments; 12 | } 13 | -------------------------------------------------------------------------------- /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/Warn for changed OOTB artifacts/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Business Rules/Warn for changed OOTB artifacts/screenshot.png -------------------------------------------------------------------------------- /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 Label For Attachment/add_label_for_attachment.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | var attachmentElement = top.document.querySelectorAll('[ng-if="c.showAttachments()"]'); 3 | 4 | if (attachmentElement[0]) { 5 | var label = top.document.createElement('label'); 6 | label.innerHTML = 'LABEL COMES HERE'; 7 | attachmentElement[0].prepend(label); 8 | } 9 | } -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Currency Validation/readme.md: -------------------------------------------------------------------------------- 1 | ## Currency Validation 2 | 3 | Use this catalog client script to validate the value of a variable used to get currency. As of now 3 things are being checked in the script but you can make changes as per requirement. 4 | 5 | 1) Characters after the $ sign should be numerics. 6 | 2) Entered value should have a decimal point. 7 | 3) There must be 2 digits only after the decimal. 8 | -------------------------------------------------------------------------------- /Catalog Client Script/MRVS Interact With Parent Form/Write to Parent Form.js: -------------------------------------------------------------------------------- 1 | Use the g_service_catalog.parent object to interact with the parent form from within a MVRS script 2 | 3 | //Retrieve a variable value from the parent form 4 | g_service_catalog.parent.getValue('variable_name'); 5 | 6 | //Set a variable value on the parent form 7 | g_service_catalog.parent.setValue('variable_name'); 8 | -------------------------------------------------------------------------------- /Catalog Client Script/MRVS Interact With Parent Form/readme.md: -------------------------------------------------------------------------------- 1 | Use this code snippet to interact with the parent form (i.e the main catalogue item) from within a catalog client script on a Multi-row variable set. 2 | 3 | The g_service_catalog object allows for accessing the "parent" GlideForm (g_form) object and its related functions 4 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Catalog Client Script/PopulateDropdown/demo_catalog.png -------------------------------------------------------------------------------- /Catalog Client Script/Remove reference icon from portal/remove-reference-icon-from-portal-onLoad.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | setTimeout(function() { 3 | var referenceElement = top.document.getElementsByClassName('btn btn-default bg-white lookup')[0]; 4 | 5 | if (referenceElement != undefined || referenceElement != null) 6 | referenceElement.remove(); 7 | 8 | }, 500); 9 | } -------------------------------------------------------------------------------- /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/Check all mandatory fields using mandatoryCheck()/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Client Scripts/Check all mandatory fields using mandatoryCheck()/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Client Scripts/Check all mandatory fields using mandatoryCheck()/readme.md: -------------------------------------------------------------------------------- 1 | **Client Script** 2 | 3 | Client script which is showing how to use g_form.mandatoryCheck() function, which allows to easily detect if any of mandatory field is not filled on record. 4 | 5 | **Example configuration** 6 | 7 | ![Coniguration](ScreenShot_1.PNG) 8 | 9 | **Example execution** 10 | 11 | ![Execution](ScreenShot_2.PNG) 12 | -------------------------------------------------------------------------------- /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/Get URL Parameters/readme.md: -------------------------------------------------------------------------------- 1 | # Get URL Parameters in Global,Scoped Application for Record & Catalog Item 2 | 3 | Many times there is a need to grab parameters from URL. This could be required at table form load or catalog item load and either in Global scope or custom scope application when redirection happened. Given script will help you in achieving this: 4 | 5 | [Click here for the script](script.js) 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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Client Scripts/Hide Work Notes section/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Client Scripts/Hide Work Notes section/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Client Scripts/Hide Work Notes section/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Client Scripts/Hide Work Notes section/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Client Scripts/Hide Work Notes section/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Client Scripts/Hide Work Notes section/script.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | //Script to hide work notes section, when incident is in state NEW 3 | 4 | //Get incident state 5 | var state = g_form.getValue('state'); 6 | 7 | //Check if incident is in state NEW (value = 1) 8 | if (state == 1) { 9 | 10 | //Hide work notes section 11 | g_form.setSectionDisplay('notes', false); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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/Make fields read only in specific states/code.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | var getStateValue = g_form.getValue('state'); 3 | if (getStateValue == '3') { 4 | var fields = g_form.getEditableFields(); 5 | for (var fieldLength = 0; fieldLength < fields.length; fieldLength++) { 6 | g_form.setReadOnly(fields[fieldLength], true); 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /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/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/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/Sync Ajax with no getXMLWait/readme.md: -------------------------------------------------------------------------------- 1 | # onSubmit Ajax validation with no getXMLWait 2 | 3 | Using getXMLWait() ensures the order of execution, but can cause the application to seem unresponsive, significantly degrading the user experience of any application that uses it. 4 | 5 | Also, the getXMLWait method is not available in scoped applications. 6 | 7 | This snippet simulates the behavior of the getXMLWait method. -------------------------------------------------------------------------------- /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/Verify if e-mail already exists with Ajax call/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/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 | -------------------------------------------------------------------------------- /Dynamic Filters/getMyDirectReports/example_manager_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Dynamic Filters/getMyDirectReports/example_manager_data.png -------------------------------------------------------------------------------- /Dynamic Filters/getMyDirectReports/one_of_my_direct_reports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Dynamic Filters/getMyDirectReports/one_of_my_direct_reports.png -------------------------------------------------------------------------------- /Dynamic Filters/getMyDirectReports/one_of_my_reports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/ECMASCript 2021/javascriptmode.png -------------------------------------------------------------------------------- /ECMASCript 2021/openrecord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Anonymise Data/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Anonymise Data/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Anonymise Data/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Fix scripts/Anonymise Data/ScreenShot_4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Anonymise Data/ScreenShot_4.PNG -------------------------------------------------------------------------------- /Fix scripts/Assign user list to a specific group/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Assign user list to a specific group/ScreenShot_2.PNG -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Clean update set/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Clean update set/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Clean update set/ScreenShot_3.PNG -------------------------------------------------------------------------------- /Fix scripts/Clean update set/ScreenShot_4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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 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/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/Measure code time execution/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Measure code time execution/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Fix scripts/Measure code time execution/ScreenShot_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Fix scripts/Measure code time execution/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Fix scripts/Post-clone Clear Email Queue/readme.md: -------------------------------------------------------------------------------- 1 | # Post-clone script for email properties 2 | 3 | To be used as a fix script or background script, meant to help with small adjustments needed per-environment after a clone. 4 | 5 | Notes: Make sure you fill in all of the instance names up top, with anything in your instance name before the [.service-now.com] 6 | 7 | This clears out the email queue. -------------------------------------------------------------------------------- /Fix scripts/Post-clone Email Properties Script/readme.md: -------------------------------------------------------------------------------- 1 | # Post-clone script for email properties 2 | 3 | To be used as a fix script or background script, meant to help with small adjustments needed per-environment after a clone. 4 | 5 | Notes: Make sure you fill in all of the instance names up top, with anything in your instance name before the [.service-now.com] 6 | 7 | This makes sure your email properties are disabled. -------------------------------------------------------------------------------- /Fix scripts/Run Subscription Job On Demand/code.js: -------------------------------------------------------------------------------- 1 | var summarizer = new SNC.SubscriptionSummarizer(); 2 | summarizer.runSummary(); 3 | -------------------------------------------------------------------------------- /Fix scripts/deleteMultiple/readme.md: -------------------------------------------------------------------------------- 1 | This script is recommended to be used (with caution) when it's necessary to delete multiple records from a table. 2 | 3 | deleteMultiple is considerably faster than deleteRecord 4 | 5 | As stated in the script, it's important to limit the amount of records being processed by this script at a time and never test this on Production without doing so on Development first 6 | -------------------------------------------------------------------------------- /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/readme.md: -------------------------------------------------------------------------------- 1 | This is a custom action that calculate the age of the ticket/incident on the basis of its created date which is started date and the date at which it is updated. 2 | 3 | 4 | Input Variable: 5 | 6 | 1. Start Date Type-Date/Time, Mandatory 7 | 2. End Date Type-Date/Time, Mandatory 8 | 9 | Output variable: 10 | 1. Ticket Age Type-string 11 | -------------------------------------------------------------------------------- /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/getPropertyFlowAction.js: -------------------------------------------------------------------------------- 1 | (function execute(inputs, outputs) { 2 | outputs.value = gs.getProperty(inputs.property); 3 | })(inputs, outputs); -------------------------------------------------------------------------------- /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/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/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Formula Builder/1.jpg -------------------------------------------------------------------------------- /Formula Builder/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/GlideAggregate/Grouping by three columns/ScreenShot_1.PNG -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/addTrend/addTrend.js: -------------------------------------------------------------------------------- 1 | 2 | var trend = new GlideAggregate('incident'); 3 | trend.addTrend('closed_at','month'); 4 | trend.addQuery('assignment_group','assignment_group_sysid'); 5 | trend.addQuery('state',7); // Closed state 6 | trend.addAggregate('COUNT'); 7 | trend.query(); 8 | while(trend.next()) { 9 | gs.print(trend.getValue('timeref') + ': ' + trend.getAggregate('COUNT')); 10 | } -------------------------------------------------------------------------------- /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/Convert date format/script.js: -------------------------------------------------------------------------------- 1 | var gd = new GlideDate(); //Intitialize GlideDate object 2 | gd.setValue('2021-13-10'); //you can pass date for which you need conversion 3 | //Now you can choose the format as required. Below are few examples 4 | gs.info(gd.getByFormat("dd-MM-yyyy")); 5 | gs.info(gd.getByFormat("yyyy/MM/dd")); 6 | gs.info(gd.getByFormat("dd/MM/yyyy")); 7 | -------------------------------------------------------------------------------- /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/duedate_generation.js: -------------------------------------------------------------------------------- 1 | var dateTime= new GlideDateTime(); 2 | var dc= new DurationCalculator(); 3 | dc.setStartDateTime(dateTime); 4 | //dc.setSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); 5 | dc.calcDuration(30*24*3600); // Provide duration for the priority here, here I have provided T6 priority duration which is 30 days. 6 | return dc.getEndDateTime(); 7 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /GlideModal/Information Message/glide_info.js: -------------------------------------------------------------------------------- 1 | var gm = new GlideModal("glide_info", true, 600); // glide_info is the OOB ui page. 2 | gm.setTitle("Info box"); //title of your info box 3 | gm.setPreference("title", "Welcome to ServicNow using GlideModal info box"); //Message shown in the info box 4 | gm.setPreference("onPromptComplete", function() {alert("You clicked on 'Ok'")}); 5 | gm.render(); 6 | -------------------------------------------------------------------------------- /GlideModal/Information Message/glide_warn.js: -------------------------------------------------------------------------------- 1 | var gm = new GlideModal("glide_warn", true, 600); //glide_warn is the OOB UI Page 2 | gm.setTitle("Info message without info icon"); //title of the box 3 | gm.setPreference("title", "Info message text"); //message you want to display 4 | gm.setPreference("onPromptComplete", function() {alert("You clicked on 'Ok'")}); 5 | gm.render(); 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/getUserRoles.js: -------------------------------------------------------------------------------- 1 | (function getUserRoles() { 2 | // sample user 3 | var userName = 'bow.ruggeri'; 4 | 5 | var roleQuery = new GlideQuery('sys_user_has_role') 6 | .where('user.user_name', 'bow.ruggeri') 7 | .select(['role$DISPLAY', 'role.active', 'user$DISPLAY', 'user.email']) 8 | .toArray(100); 9 | 10 | gs.log(JSON.stringify(roleQuery, null, 2)); 11 | })(); 12 | -------------------------------------------------------------------------------- /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/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/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 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/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 task records with at least on active child task/code.js: -------------------------------------------------------------------------------- 1 | var sysIds = []; 2 | 3 | var glideRecordTaskTable = new GlideRecord('task'); 4 | var glideRecordJoin = glideRecordTaskTable.addJoinQuery('task', 'sys_id', 'parent'); 5 | glideRecordJoin.addCondition('active', true); 6 | glideRecordTaskTable.query(); 7 | while(glideRecordTaskTable.next()){ 8 | sysIds.push(glideRecordTaskTable.getValue('sys_id')); 9 | } -------------------------------------------------------------------------------- /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/GlideRecord with Performance Enhancement Condtions/readme.md: -------------------------------------------------------------------------------- 1 | A sample GlideRecord code with conditions to enhance performance. 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/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/findDuplicate/GlideAggregateScript.js: -------------------------------------------------------------------------------- 1 | var q = new GlideAggregate('alm_asset'); 2 | q.addAggregate('COUNT', 'asset_tag'); 3 | q.groupBy('asset_tag'); 4 | q.addHaving('COUNT', '>', '1'); 5 | //q.addQuery('sys_updated_by','') 6 | q.query(); 7 | var listOfDupes = new Array(); 8 | while (q.next()) { 9 | gs.info(q.getRowCount()); 10 | listOfDupes.push(q.getValue('asset_tag')); 11 | } 12 | -------------------------------------------------------------------------------- /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/readme.md: -------------------------------------------------------------------------------- 1 | GlideSystem (referred as "gs") is used to get the current user session which we are using to set the custom key and value which are used in client side scripts. 2 | 3 | Example client script used to retrieve it 4 | 5 | ``` 6 | function onLoad(){ 7 | var value = g_user.getClientData("custom_key"); 8 | console.log("Client data "+value); 9 | } 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/GlideSystem/Table/truncateTable.js -------------------------------------------------------------------------------- /GlideSystem/User Display Name/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 | 8 | 9 | //output will be Display name of current logged in user 10 | //Example output : Welcome Abel Tuter 11 | -------------------------------------------------------------------------------- /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/beginningOfLastMonth.js: -------------------------------------------------------------------------------- 1 | // get the current date and time in the logged in user's time zone 2 | gs.info(new GlideDateTime().getDisplayValue()); 3 | // show the beginning of last month's date and time in the logged in user's time zone 4 | gs.info(gs.beginningOfLastMonth()); 5 | 6 | // output 7 | // x_scope_app: 2021-10-01 15:50:40 8 | // x_scope_app: 2021-09-01 05:00:00 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/minutesAgoEnd.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var minAgo = gs.minutesAgoEnd(5); //Returns a date and time for the end of the minutes (in brackets) a certain number of minutes ago. 4 | gs.info('End of 5 Minutes Ago: ' + minAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 14:31:23 8 | //*** Script: End of 5 Minutes Ago: 2021-10-04 18:26:59 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/minutesAgoStart.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var minAgo = gs.minutesAgoStart(5); //Returns a date and time for the start of the minutes (in brackets) a certain number of minutes ago. 4 | gs.info('Start of 5 Minutes Ago: ' + minAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 14:34:45 8 | //*** Script: Start of 5 Minutes Ago: 2021-10-04 18:29:00 9 | -------------------------------------------------------------------------------- /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/monthsAgoEnd.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var monthsAgo = gs.monthsAgoEnd(5); //Returns a date and time for the last day of the month a certain number of months (in bracket) ago 4 | gs.info('End of 5 Months Ago: ' + monthsAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 14:53:40 8 | //*** Script: End of 5 Months Ago: 2021-05-31 23:59:59 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/monthsAgoStart.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var monthsAgo = gs.monthsAgoStart(5); //Returns a date and time for the start of the month a certain number of months (in bracket) ago. 4 | gs.info('Start of 5 Months Ago: ' + monthsAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 15:00:53 8 | //*** Script: Start of 5 Months Ago: 2021-05-01 00:00:00 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/quartersAgoEnd.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var quartersAgo = gs.quartersAgoEnd(2); //Returns a date and time for the last day of the quarter, for a specified number of quarters ago 4 | gs.info('End of 2 Quarters Ago: ' + quartersAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 15:48:46 8 | //*** Script: End of 2 Quarters Ago: 2021-06-30 23:59:59 9 | -------------------------------------------------------------------------------- /GlideSystem/date-time/quartersAgoStart.js: -------------------------------------------------------------------------------- 1 | var now = gs.nowDateTime(); 2 | gs.info('Now: ' + now); 3 | var quartersAgo = gs.quartersAgoStart(2); //Returns a date and time for the first day of the quarter, for a specified number of quarters ago 4 | gs.info('Start of 2 Quarters Ago: ' + quartersAgo); 5 | 6 | //Output Example: 7 | //*** Script: Now: 2021-10-04 15:53:02 8 | //*** Script: Start of 2 Quarters Ago: 2021-04-01 00:00:00 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 | -------------------------------------------------------------------------------- /GlideSystem/workflowFlush/workflowFlush.js: -------------------------------------------------------------------------------- 1 | //For reference, the below code is a part of OOB 'incident events' Business Rule 2 | 3 | if (current.active.changesTo(false)) { 4 | gs.eventQueue("incident.inactive", current, current.incident_state, previous.incident_state); 5 | gs.workflowFlush(current); //Deletes any open scheduled job records in the Schedule (sys_trigger) table for the specified GlideRecord. 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 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/getGroups.js: -------------------------------------------------------------------------------- 1 | (function process(env) { 2 | let ret = []; 3 | new global.GlideQuery('sys_user_group') 4 | .whereNotNull('manager') 5 | .select('name', 'manager$DISPLAY') 6 | .forEach((g) => { 7 | ret.push({ 8 | id: g.sys_id, 9 | name: g.name, 10 | manager: g['manager$DISPLAY'] 11 | }); 12 | }); 13 | return ret; 14 | })(env); -------------------------------------------------------------------------------- /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 group query/schema.gql: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | mutation: Mutation 4 | } 5 | 6 | type Query { 7 | getGroups: [Group] 8 | } 9 | 10 | type Mutation { 11 | addUserToGroup(userID: ID!, groupID: ID!): GroupMember 12 | } 13 | 14 | type Group { 15 | id: ID 16 | name: String 17 | manager: String 18 | } 19 | 20 | type GroupMember { 21 | userName: String 22 | groupName: String 23 | } -------------------------------------------------------------------------------- /GraphQL/Sample users query/getUserRoles.js: -------------------------------------------------------------------------------- 1 | (function process(/*ResolverEnvironment*/ env) { 2 | const userid = env.getArguments().id != null ? env.getArguments().id : env.getSource().sys_id; 3 | let ret = []; 4 | new global.GlideQuery('sys_user_has_role') 5 | .where('user', userid) 6 | .select('role$DISPLAY') 7 | .forEach((r) => { 8 | ret.push(r['role$DISPLAY']); 9 | }); 10 | return ret; 11 | })(env); -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /GraphQL/Sample users query/schema.gql: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | getUser(id: ID!): User 7 | } 8 | 9 | type User { 10 | id: ID @source(value: "sys_id") 11 | name: String @source(value: "userName") 12 | roles: [Role] 13 | groups: [Group] 14 | } 15 | 16 | type Role { 17 | name: String 18 | } 19 | 20 | type Group { 21 | name: String 22 | manager: String 23 | } -------------------------------------------------------------------------------- /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/GraphQL Integration API/CI Resolver.js: -------------------------------------------------------------------------------- 1 | (function process(/*ResolverEnvironment*/ env) { 2 | 3 | ci = env.getSource(); // This will return the sys_id of CI. 4 | var now_gr = new GlideRecord('cmdb_ci'); 5 | now_gr.addQuery('sys_id',ci); // This will check, if the sys_id exist or not. 6 | now_gr.query(); 7 | return now_gr; // This will return the whole CI record. 8 | 9 | })(env); 10 | -------------------------------------------------------------------------------- /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/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/open_survey.js: -------------------------------------------------------------------------------- 1 | 2 | var survey = 'Click Here to take Survey '; 3 | template.print(survey); 4 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /Mail Scripts/RITM Reject Reason/README.md: -------------------------------------------------------------------------------- 1 | After finding that reject reasons added from Employee Center for Requests do not get added to the Approval record but instead the RITM record, I made a change to the reject_reason email script to include the RITM reject reason (if found) 2 | The changes calls the Script Include "RequestNotificationUtil" with an added function to call the RITM reject reason 3 | -------------------------------------------------------------------------------- /Processors/Dynamic Sitemap/snow-sitemap-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Record Producer/Create Records By Import Set/config1.png -------------------------------------------------------------------------------- /Record Producer/Create Records By Import Set/config2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Record Producer/Create Records By Import Set/config2.png -------------------------------------------------------------------------------- /Record Producer/Create Records By Import Set/config3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/allowanylanguage.js: -------------------------------------------------------------------------------- 1 | module.exports.trimNonCharacters = (str) => str.replace(/[^\p{L}\d()\s]+/ug, ''); 2 | -------------------------------------------------------------------------------- /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/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/convert.js: -------------------------------------------------------------------------------- 1 | var name = 'hafsa asif'; 2 | gs.info(encodeURIComponent(name.trim())); 3 | -------------------------------------------------------------------------------- /Regular Expressions/Encode spaces for URLs/readme.md: -------------------------------------------------------------------------------- 1 | convert spaces to %20 for creating dynamic urls 2 | -------------------------------------------------------------------------------- /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/Find Emoji/readme.md: -------------------------------------------------------------------------------- 1 | # Detect emoji in string 2 | 3 | Use this script to detect if string contains emoji -------------------------------------------------------------------------------- /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/IP Address Validation/readme.md: -------------------------------------------------------------------------------- 1 | This regex validates for ip address(ipv4) based on the input. 2 | 3 | Following are the valid IP address examples: 4 | 5 | 192.168.1.1 6 | 7 | 127.0.0.1 8 | 9 | 0.0.0.0 10 | 11 | 255.255.255.255 12 | 13 | 256.256.256.256 14 | 15 | 999.999.999.999 16 | 17 | 1.2.3 18 | 19 | 1.2.3.4 20 | 21 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Regular Expressions/Match URL's from ServiceNow domain/ScreenShot_1.PNG -------------------------------------------------------------------------------- /Regular Expressions/Poland country code/ScreenShot_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Regular Expressions/Poland country code/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/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 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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Scheduled Jobs/Daily detection of customer updates made in 'Default' update set/ScreenShot_2.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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Scheduled Jobs/Lock out users who have not logged into the system longer than 30 days/ScreenShot_2.PNG -------------------------------------------------------------------------------- /Scheduled Jobs/Paginated Export/Paginated Export.md: -------------------------------------------------------------------------------- 1 | # Paginated Export 2 | 3 | ServiceNow (wisely) limits the number of rows allowed in an export. However, they do not provide a way to break up exports into multiple files if you need to export more than the limit. Run this script as a scheduled job or scheduled flow instead of doing a scheduled export if you need to export large data sets. 4 | -------------------------------------------------------------------------------- /Scheduled Jobs/Remove Inactive and locked out users from All Groups and Roles/readme.md: -------------------------------------------------------------------------------- 1 | # Remove Inactive and locked out users from All Groups and Roles 2 | 3 | It is always a good practise to have a secure and clean working instance. Having users with specific criteria such as the user is inactive and has been locked out should not have any role or belong to any group. -------------------------------------------------------------------------------- /Scheduled Jobs/Survey Trigger Scheduled Script/readme.md: -------------------------------------------------------------------------------- 1 | ## Use the code snippets to trigger survey via scheduled script. 2 | 3 | ### Survey Trigger Scheduled Job 4 | survey_trigger_sj.js 5 | 6 | *Note: Please update the query and sys_id as per the comments in the script* 7 | -------------------------------------------------------------------------------- /Script Includes/API Model Template for New Application/AbstractStrategyBase.js: -------------------------------------------------------------------------------- 1 | var AbstractStrategyBase = Class.create(); 2 | AbstractStrategyBase.prototype = Object.extendsObject(ApplicationCore, { 3 | initialize: function (/* expected */) {}, 4 | run: function() { 5 | /** 6 | * do something here 7 | */ 8 | }, 9 | 10 | type: 'AbstractStrategyBase' 11 | }); -------------------------------------------------------------------------------- /Script Includes/API Model Template for New Application/ExampleStrategy1Base.js: -------------------------------------------------------------------------------- 1 | var ExampleStrategy1Base = Class.create(); 2 | ExampleStrategy1Base.prototype = Object.extendsObject(AbstractStrategy, { 3 | initialize: function (/* expected */) {}, 4 | run: function() { 5 | /** 6 | * do something here 7 | */ 8 | }, 9 | 10 | type: 'ExampleStrategy1Base' 11 | }); -------------------------------------------------------------------------------- /Script Includes/API Model Template for New Application/ExampleStrategy2Base.js: -------------------------------------------------------------------------------- 1 | var ExampleStrategy2Base = Class.create(); 2 | ExampleStrategy2Base.prototype = Object.extendsObject(AbstractStrategy, { 3 | initialize: function (/* expected */) {}, 4 | run: function() { 5 | /** 6 | * do something here 7 | */ 8 | }, 9 | 10 | type: 'ExampleStrategy2Base' 11 | }); -------------------------------------------------------------------------------- /Script Includes/Add and Remove Group Member/readme.md: -------------------------------------------------------------------------------- 1 | # Add and Remove Group Member 2 | I've developed a script include that facilitates the addition and removal of members from a group. 3 | Both the "addMember" and "removeMember" functions in this script include require the sys_id of the group and the user as input parameters. 4 | -------------------------------------------------------------------------------- /Script Includes/ArrayUtil/readme.md: -------------------------------------------------------------------------------- 1 | ArrayUtil API is a script include with useful functions for working with JavaScript arrays. 2 | The example shared helps removes duplicate items from an array using the 'unique' method 3 | -------------------------------------------------------------------------------- /Script Includes/ArrayUtil/script.js: -------------------------------------------------------------------------------- 1 | //Example Usage of the Script Include ArrayUtil 2 | var obj=[]; 3 | var arrayUtil = new ArrayUtil(); 4 | var gr= new GlideRecord('incident'); 5 | gr.addOrderBy('category'); 6 | gr.query(); 7 | while(gr.next()){ 8 | obj.push(gr.getValue('category')); 9 | } 10 | obj = arrayUtil.unique(obj); 11 | gs.info(obj); 12 | -------------------------------------------------------------------------------- /Script Includes/Auto Execute Import Set on File Attachment/readme.md: -------------------------------------------------------------------------------- 1 | # Auto Execute Import Set on File Attachment 2 | You have to create a data source and a transform map first. After that you can use Flow Designer with the trigger condition Attachment is added to the data source. Once the flow triggers, it will call the action which in turn will trigger the Script Include to create an Import Set and Transform Map. 3 | -------------------------------------------------------------------------------- /Script Includes/Check User Has Role/readme.md: -------------------------------------------------------------------------------- 1 | # User Has Role 2 | 3 | This script checks whether the user has a role or not. 4 | This script takes two arguments 5 | 6 | Argument #1: userId - userId of the record for which you need to validate the roles exists 7 | Argument #2: roleId - roleId is the sys_id of the role that we need to check whether exists against the provided userId -------------------------------------------------------------------------------- /Script Includes/Client and Server Callable Script Include/readme.md: -------------------------------------------------------------------------------- 1 | # Client and Server Callable Script Include 2 | 3 | Example of a script include that can be called via both client and server. -------------------------------------------------------------------------------- /Script Includes/ConversationUtils/README.md: -------------------------------------------------------------------------------- 1 | # Script Include: ConversationUtils 2 | 3 | A simple script include to create a Connect Chat conversation with a single user and send messages to the conversation. 4 | 5 | ## Example usage 6 | 7 | ``` 8 | var conversation = new ConversationUtils(gs.getUserID(), "Example Conversation"); 9 | conversation.sendMessage("Hello World"); 10 | ``` -------------------------------------------------------------------------------- /Script Includes/Create Multiple RITMS from MRVS/readme.md: -------------------------------------------------------------------------------- 1 | # Create Multiple RITMS from MRVS 2 | Use this script to submit multiple Requested Items with data being populated from the MRVS. 3 | Match the variables names in the Obj to the respective Catalog Item variable names and the MRVS variables to the variable names for the MRVS 4 | -------------------------------------------------------------------------------- /Script Includes/Delete Multiple Records Async/README.md: -------------------------------------------------------------------------------- 1 | This script include provides a way to delete multiple records asynchronously, with the option to define chunk sizes. 2 | It is useful for deleting huge amount of data without overoading the instance. 3 | Since this is a script for DELETE operations, use with caution! 4 | NB. The process needs to be triggered by one-time scheduled job. 5 | -------------------------------------------------------------------------------- /Script Includes/Deprecate Field/Readme.md: -------------------------------------------------------------------------------- 1 | # Deprecate Field 2 | 3 | This function `deprecateField` is design to depreacte particular field of the table so Customers will not use it for any further use. 4 | 5 | Example: 6 | 7 | ``` 8 | deprecateField('service_offering', 'task') 9 | ``` 10 | 11 | Result: 12 | ![Alt text](Result.png) 13 | -------------------------------------------------------------------------------- /Script Includes/Deprecate Field/Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Script Includes/Deprecate Field/Result.png -------------------------------------------------------------------------------- /Script Includes/Dynamic Dropdown List/Readme.md: -------------------------------------------------------------------------------- 1 | The client script and script include can be used to load a options of a dropdown list where dependency exist on another dropdownlist. Like Category - Subcategory. 2 | Adiitional functionality added in the client script is, when there are no options available for the selected dependent value, we can hide the dropdown field. 3 | -------------------------------------------------------------------------------- /Script Includes/Excel Parser/readme.md: -------------------------------------------------------------------------------- 1 | Server side Excel parser utility leveraging the GlideExcelParser API. 2 | 3 | Pass in the sys_id of an Excel attachment and get back an array of objects, with every row in the sheet being an element in the array. 4 | -------------------------------------------------------------------------------- /Script Includes/Find months between two dates/readme.md: -------------------------------------------------------------------------------- 1 | # getMonths 2 | 3 | Helper function that calculates total months between two specified dates e.g. total months between 2020-01-01 and 4 | 2022-01-01 is 24! 5 | 6 | ## Usage 7 | 8 | ```javascript 9 | var helper = new DateUtils(); 10 | 11 | gs.log(helper.getMonths('2020-01-01', '2022-01-01')); // This returns 24 12 | ``` 13 | -------------------------------------------------------------------------------- /Script Includes/Generate QR Code and attach to RITM/readme.md: -------------------------------------------------------------------------------- 1 | # Create QR Code 2 | This sample script uses a free QR Code API and does a REST call to the server and returns the QR code as image. Then attaches 3 | the QR code into Requested Item record. 4 | 5 | In the script, replace the Requested Item sys_id with sys_id of your record. Change the text to the text you want to appear in the QR Code. -------------------------------------------------------------------------------- /Script Includes/Get Approvers of a Ticket/readme.md: -------------------------------------------------------------------------------- 1 | # Get Approvers of a Ticket 2 | 3 | This script returns the number of approvers sys_id that are being requested for Approval -------------------------------------------------------------------------------- /Script Includes/Get Choice Display Value/readme.md: -------------------------------------------------------------------------------- 1 | # Get Selected Choice Display Value 2 | 3 | This scripts gets the display value of the selected choice. 4 | 5 | > 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/numberPadding.js: -------------------------------------------------------------------------------- 1 | module.exports.numberPadding = function (value) { 2 | return String(value).padStart(2, '0'); 3 | } 4 | -------------------------------------------------------------------------------- /Script Includes/Number Padding/readme.md: -------------------------------------------------------------------------------- 1 | Lets you pad your single digit number for better formating 2 | -------------------------------------------------------------------------------- /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/Reparent Table/Readme.md: -------------------------------------------------------------------------------- 1 | # Reparent Table 2 | 3 | This function `reparentTable` is to reparent the existing table to the another parent. 4 | 5 | This `glide.rollback.blacklist.TableParentChange.change` property can restrict user to reparent the table so in script we first set it to **false** before reparenting and later on changed it to its initially value once reparenting is done. 6 | -------------------------------------------------------------------------------- /Script Includes/RequestNotificationUtil/readme.MD: -------------------------------------------------------------------------------- 1 | If a Request is rejected through Employee Center, the rejection notes get added to the RITM record rather than the Approval record. Therefore, the OOB reject notification does not contain the rejection comments. 2 | RequestNotificationUtil is used in reject_reason_new notification email script to pull RITM reject reason (if available) 3 | -------------------------------------------------------------------------------- /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/StarterPack/readme.md: -------------------------------------------------------------------------------- 1 | Also available on Share here: https://developer.servicenow.com/connect.do#!/share/contents/6592535_script_include_starter_pack?t=PRODUCT_DETAILS 2 | 3 | and related to [CCB1193-K21 Script Includes: What are they and why should I care?](https://events.servicenow.com/widget/servicenow/knowledge2021/library/session/1612301555107001YVuE#1617832086855001eNVb) 4 | 5 | -------------------------------------------------------------------------------- /Script Includes/Stopwatch/readme.md: -------------------------------------------------------------------------------- 1 | # Stopwatch 2 | A script include that can be used as a stop watch when measuring the performance of a script or when want to show the elapsed time of an operation. 3 | 4 | 5 | ## Example Script 6 | ```javascript 7 | var watch = new Stopwatch(); 8 | watch.start(); 9 | gs.sleep(1000); // Do something 10 | watch.stop(); 11 | gs.log(watch.getElapsedTimeMilliseconds()); 12 | ``` -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Script Includes/UserUtil/userMemberOf.png -------------------------------------------------------------------------------- /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(); -------------------------------------------------------------------------------- /Script Includes/regexCheckerScript/readme.md: -------------------------------------------------------------------------------- 1 | Script Include to check regex 2 | 3 | This script include can be used in a report or any other script/BR/Action to check if a particular type of text or a field matches the required regex. 4 | Returns the sys_id of the records that match the regex. You can select your desired table, query and field, also update the required regex in the script. 5 | 6 | Thankyou. 7 | -------------------------------------------------------------------------------- /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/CURL Script to create incident via tableAPI/script.curl: -------------------------------------------------------------------------------- 1 | curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{\"short_description\" : \"This is a test incident via CURL script\",\"description\" : \"Description\",\"caller_id\" : \"Ishaan\",\"impact\" : \"1\",\"urgency\":\"1\"}" -u username:password https://instance_name.service-now.com/api/now/table/incident 2 | -------------------------------------------------------------------------------- /Scripted REST Api/CopyAI Generative AI example/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Scripted REST Api/CopyAI Generative AI example/image.png -------------------------------------------------------------------------------- /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/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/readme.md: -------------------------------------------------------------------------------- 1 | # This code will help to query choice table and get the data according to filter. Modify this according to requirement 2 | # References 3 | - Below is the reference of PDI, what is the configuration of choices 4 | ![scripted_rest_resource.png](scripted_rest_resource.png) 5 | - Below is the referecnce of PDI resources of Script 6 | ![script.png](script.png) -------------------------------------------------------------------------------- /Scripted REST Api/Get_Choices/script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Scripted REST Api/Get_Choices/script.png -------------------------------------------------------------------------------- /Scripted REST Api/Get_Choices/scripted_rest_resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/CheckTableExtension/readme.md: -------------------------------------------------------------------------------- 1 | The snippet validates whether a child table is extended from a parent table. You could provide both the table names as input and it would respond back with a boolean output. 2 | 3 | Sample Usage 4 | 5 | gs.info(isTableExtended("cmdb_ci", "cmdb_ci_win_server")); //true 6 | 7 | gs.info(isTableExtended("cmdb_ci", "cmdb_ci_hardwares")); //false 8 | -------------------------------------------------------------------------------- /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/Get all Catalog items associated to variable set/script.js: -------------------------------------------------------------------------------- 1 | var catlist = ''; 2 | var ItemGR = new GlideRecord("io_set_item"); 3 | ItemGR.addEncodedQuery('variable_set={add variable set sysid}'); 4 | ItemGR.query(); 5 | while (ItemGR.next()) { 6 | catlist = catlist + ItemGR.sc_cat_item +','; 7 | } 8 | 9 | gs.info('List of Catalog Items associated to the Variable set : ' +catlist); 10 | -------------------------------------------------------------------------------- /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/User Criteria/Does User Match Criteria(s).js: -------------------------------------------------------------------------------- 1 | /*Use the following to determine if a user passes an array of user criterias 2 | /*@param userID - String of a sys_user sys_id 3 | /*@param userCriteria - Array of user_criteria sys_ids to check again 4 | /*@return Boolean 5 | */ 6 | 7 | var userID = "", 8 | userCriteria = []; 9 | 10 | var result = sn_uc.UserCriteriaLoader.userMatches(userID , userCriteria); 11 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal Widgets/Batman Animation/Batman Background Image.jpg -------------------------------------------------------------------------------- /Service Portal Widgets/Batman Animation/Batman logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/doc/card_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal Widgets/Card Image Link/doc/card_result.png -------------------------------------------------------------------------------- /Service Portal Widgets/Card Image Link/doc/card_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/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/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/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/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal Widgets/Configurable Card Widget/image.png -------------------------------------------------------------------------------- /Service Portal Widgets/Configurable Card Widget/readme.md: -------------------------------------------------------------------------------- 1 | # Configurable Card Widget 2 | This widget can be used to show card-based pieces of information and can easily be modified in its content and style using widget options. 3 | 4 | ![alt text](https://raw.githubusercontent.com/debendu-das/code-snippets/service-portal-widget-configurable-card/Service%20Portal%20Widgets/Configurable%20Card%20Widget/image.png) 5 | -------------------------------------------------------------------------------- /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/Create diagram using Highcharts library/body.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |

5 | A spiderweb chart or radar chart is a variant of the polar chart. 6 | Spiderweb charts are commonly used to compare multivariate data sets, 7 | like this demo using six variables of comparison. 8 |

9 |
-------------------------------------------------------------------------------- /Service Portal Widgets/Drag & drop Widget/remove_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal Widgets/Drag & drop Widget/remove_icon.png -------------------------------------------------------------------------------- /Service Portal Widgets/Export table in portal/export.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /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/Floater Feedback Widget/demo.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Open in Platform/body.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | {{::options.button_text}} 4 | 5 |
6 | -------------------------------------------------------------------------------- /Service Portal Widgets/Open in Platform/readme.md: -------------------------------------------------------------------------------- 1 | Widget will create a button that will only be visable to users with the itil role that will take them to the same record in platform. will work with the form and standard ticket pages (or anywhere with the table and sysId in the url. 2 | 3 | see also [on Share](https://developer.servicenow.com/connect.do#!/share/contents/6592535_open_in_platform_widget?t=PRODUCT_DETAILS) 4 | -------------------------------------------------------------------------------- /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/Portal widgets Performance Test/Readme.md: -------------------------------------------------------------------------------- 1 | This code is helpful to check the Service Portal widget Performance. This code will show the time taken by the widgets to load. 2 | 3 | Steps to Use the Code: 4 | 5 | Step 1: Go to the Portal Page 6 | 7 | Step 2: Right Click on page and open Inspect Element 8 | 9 | Step 3: Open Console Tab 10 | 11 | Step 4: Copy and Past the code 12 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal Widgets/Spiderman Animation/spid.png -------------------------------------------------------------------------------- /Service Portal Widgets/Spiderman Animation/spider.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal Widgets/Standard Ticket Page Enhanced Action Widget/standard_ticket_config.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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/dark-mode-switcher/dark_mode.scss -------------------------------------------------------------------------------- /Service Portal/dark-mode-switcher/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/dark-mode-switcher/demo.gif -------------------------------------------------------------------------------- /Service Portal/instance-badge/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/instance-badge/header.png -------------------------------------------------------------------------------- /Service Portal/sn-avatar/2021-10-15-23-18-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/sn-avatar/2021-10-15-23-25-15.png -------------------------------------------------------------------------------- /Service Portal/sn-choice-list/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/sn-choice-list/screen1.png -------------------------------------------------------------------------------- /Service Portal/sn-choice-list/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/sn-choice-list/screen2.png -------------------------------------------------------------------------------- /Service Portal/sn-record-picker/2021-10-16-01-08-46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/sn-record-picker/2021-10-16-01-11-40.png -------------------------------------------------------------------------------- /Service Portal/sn-watchlist/sn-watchlist.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Service Portal/sn-watchlist/sn-watchlist.gif -------------------------------------------------------------------------------- /Service Portal/sp-date-picker/sp-date-picker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/sp-modal/script.js: -------------------------------------------------------------------------------- 1 | api.controller=function(spModal) { 2 | /* widget controller */ 3 | var c = this; 4 | 5 | var html = "

Test

"; 6 | // Use spModal to pop the HTML 7 | spModal.open({ 8 | title: 'This is test Modal: ', 9 | message: html, 10 | buttons: [ 11 | {label:'OK', primary: true} 12 | ] 13 | }).then(function(answer)){ 14 | console.log('this is callback'); 15 | }); 16 | }; 17 | -------------------------------------------------------------------------------- /Service Portal/sparkling/sparkling.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/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/README.md: -------------------------------------------------------------------------------- 1 | Open a record. Right click on any field label and select configure style. A list will open with all the styles applied on that field. Click on New button to create your custom style. Enter the code of style.css in Style field of style and done. You can use this code on any field in any table. This will give it a dark blue center aligned text on a white background. 2 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Transform Map Scripts/Choice Field Validator/choice_validador1.png -------------------------------------------------------------------------------- /Transform Map Scripts/Choice Field Validator/choice_validador2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Transform Map Scripts/Choice Field Validator/choice_validador2.png -------------------------------------------------------------------------------- /Transform Map Scripts/Conditional Coalesce/conditional_coalesce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/Transform Map Scripts/Conditional Coalesce/conditional_coalesce.png -------------------------------------------------------------------------------- /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/Add collapsible element in knowledge article/README.md: -------------------------------------------------------------------------------- 1 | This code snippet will allow you to use collapsible element within knowledge atricle which will make articles clean, organized and effective. 2 | 3 | ![Demo](https://github.com/abhrajyotikanrar/code-snippets/assets/25823899/e3ad356e-a5c5-4f2d-aafa-20f89b0da248) 4 | 5 | Please check out the above demo on how this code-snippet can be used. 6 | -------------------------------------------------------------------------------- /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/Create Update Set on DEV/README.md: -------------------------------------------------------------------------------- 1 | # Create Update Set on DEV 2 | 3 | A client UI Action for the Story form that opens up a new browser window with the Create New Update Set form on a specified DEV instance with Update Set name pre-filled with the Story number and short description. 4 | 5 | Helps reducing copy/paste work and to keep up with Update Set naming standards. 6 | -------------------------------------------------------------------------------- /UI Actions/Create incident task and relate to incident/readme.md: -------------------------------------------------------------------------------- 1 | This UI Action loads a modal for to create a new incident task that is linked to the incident that you generated it from. 2 | 3 | Suggested values: 4 | Name: Create Incident Task 5 | Table: Incident 6 | Client: true 7 | List v2: true 8 | Form Link: true 9 | 10 | Onclick: createIncidentTask() 11 | Condition: current.state != 7 -------------------------------------------------------------------------------- /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 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 Record in Alternate Instance/Scripted REST API/sys_ws_operation/sys_ws_operation_config.md: -------------------------------------------------------------------------------- 1 | General: 2 | 3 | HTTP Method: PATCH 4 | Relative Path: /record_exists 5 | 6 | Content Negotiation: 7 | 8 | Request formats: application/json,application/xml,text/xml 9 | Response formats: application/json,application/xml,text/xml 10 | 11 | Script: see `sys_ws_operation.js` for code. -------------------------------------------------------------------------------- /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/View in Portal Page/README.MD: -------------------------------------------------------------------------------- 1 | code-snippet used in UI Action SCript to view the current record in Service Portal Page using a redirect 2 | 3 | Example: 4 | //to view a KB article in the Service Portal: 5 | 6 | function goToPortal(){ 7 | var url = 'sp?id=kb_article_view&sys_kb_id=' + g_form.getUniqueValue(); 8 | g_navigation.openPopup(url); 9 | //g_navigation.open(url); 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/UI Macros/Purchase Order Approval Summarizer/approval_summarizer_proc_po.png -------------------------------------------------------------------------------- /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/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/UI Pages/Custom Alert using UI Page/image.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/Dynamic program status overview/dynamic program status.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manishak798/code-snippets/2039d84b5ba44772a1625520567869fc2b7eebc8/UI Pages/Dynamic program status overview/dynamic program status.JPG -------------------------------------------------------------------------------- /UI Pages/EDM DocUnifiedSearch/client script.js: -------------------------------------------------------------------------------- 1 | function cancel() { 2 | GlideDialogWindow.get().destroy(); 3 | return false; 4 | 5 | } 6 | 7 | function actionOK() { 8 | var emp = gel('quicksearch_assign').value; 9 | var doc = gel('quicksearch_doc').value; 10 | var cas = gel('quicksearch_case').value; 11 | var eid = gel('quicksearch_emp').value; 12 | //alert(emp); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /UI Scripts/Display number of created records/readme.md: -------------------------------------------------------------------------------- 1 | # Display number of created records 2 | 3 | Use case / Requirement : When trying to create a new record in a table, Display a message showing number of records already created by him/her in that table. 4 | 5 | Solution : Created a UI script to display number of records and call that UI script from an onLoad client script. 6 | -------------------------------------------------------------------------------- /UI Scripts/Restrict URL Hack using UI script/script.js: -------------------------------------------------------------------------------- 1 | var OriginalURL = window.parent.location.href; 2 | 3 | var ChangedURL = "https://" + window.location.host + "URL you want to monitor"; //"window.location.host" retrives the instance name 4 | 5 | if (!url.startURL(ChangedURL)) //check if URL doesn't starts as Original URL 6 | { 7 | window.location = OriginalURL; //Redirect to Original URL 8 | } 9 | -------------------------------------------------------------------------------- /emailslicer.py: -------------------------------------------------------------------------------- 1 | email = input("Enter Your Email: ").strip() 2 | 3 | username = email[:email.index('@')] 4 | domain = email[email.index('@') + 1:] 5 | 6 | print(f"Your username is {username} & domain is {domain}") 7 | -------------------------------------------------------------------------------- /function.py: -------------------------------------------------------------------------------- 1 | def myfunction(*kids): 2 | print("names of kids: "+kids[2]) 3 | myfunction("emli","kunal","tia") 4 | --------------------------------------------------------------------------------