From 07fe6e82cb07ab057bbc6dcb31ac8aa18a6bc988 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:15:34 +0530 Subject: [PATCH 1/3] spModalSweetAlerts.js spModal alerts are modern sweet alert to show the choices to be selected in an interactive way. Here, we are providing HR's to select the type of rewards in the modal page and populate a field with the selected value and show a message of the selected reward. --- .../spModalSweetAlerts.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/spModalSweetAlerts.js diff --git a/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/spModalSweetAlerts.js b/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/spModalSweetAlerts.js new file mode 100644 index 0000000000..47ebfddc3b --- /dev/null +++ b/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/spModalSweetAlerts.js @@ -0,0 +1,32 @@ +function onChange(control, oldValue, newValue) { + if (newValue == 'Yes') { + spModal.open({ + title: "Reward Type", + message: "Please select the category of Reward", + buttons: [{ + label: "Star Performer", + value: "Star Performer" + }, + { + label: "Emerging Player", + value: "Emerging Player" + }, + { + label: "High Five Award", + value: "High Five Award" + }, + { + label: "Rising Star", + value: "Rising Star" + } + ] + }).then(function(choice) { + if (choice && choice.value) { + g_form.addInfoMessage('Selected Reward: '+ choice.label); + g_form.setValue('reward_selected', choice.value); + } + }); + } else { + g_form.clearValue('reward_selected'); + } +} From e6f969459c356ec411cdc2d2d7a92e1984604872 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:23:44 +0530 Subject: [PATCH 2/3] readme.md spModal alerts are modern sweet alert to show the choices to be selected in an interactive way. Here, we are providing HR's to select the type of rewards in the modal page and populate a field with the selected value and show a message of the selected reward. --- .../spModal for Sweet Alerts/readme.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md diff --git a/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md b/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md new file mode 100644 index 0000000000..195ab859ce --- /dev/null +++ b/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md @@ -0,0 +1,27 @@ +In ServiceNow, Open catalog client Scripts [catalog_script_client] and paste the code snipper of [spModalSweetAlerts.js] + +Setup: +1. A catalog item having variable name Rewards[rewards] of type 'Select Box' with include none as true and 2 choices(Yes and No) +2. A Single line field named Reward Selected [reward_selected] which will hold the value which will be sleected from the spModal +3. Now, the onLoad catalog client script: + Type: onChange + Variable: rewards (as per step 1) + Script: [[spModalSweetAlerts.js]] + + + +Screenshots: + + +image + + +Rewards selected as 'Yes' + +image + +From the spModal popup select anyone of the reward, it should be populated in the Reward Selected field. +Along with that a message shows the same of the selection. + +image + From eff16fc3081097f235d662e71b0ab301e7985842 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:55:33 +0530 Subject: [PATCH 3/3] readme.md spModal alerts are modern sweet alert to show the choices to be selected in an interactive way. Here, we are providing HR's to select the type of rewards in the modal page and populate a field with the selected value and show a message of the selected reward. --- .../spModal for Sweet Alerts/readme.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md b/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md index 195ab859ce..52108efc00 100644 --- a/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md +++ b/Client-Side Components/Catalog Client Script/spModal for Sweet Alerts/readme.md @@ -1,13 +1,13 @@ -In ServiceNow, Open catalog client Scripts [catalog_script_client] and paste the code snipper of [spModalSweetAlerts.js] +In ServiceNow, Open catalog client Scripts [catalog_script_client] and paste the code snippet of [spModalSweetAlerts.js] file. Setup: -1. A catalog item having variable name Rewards[rewards] of type 'Select Box' with include none as true and 2 choices(Yes and No) -2. A Single line field named Reward Selected [reward_selected] which will hold the value which will be sleected from the spModal -3. Now, the onLoad catalog client script: - Type: onChange - Variable: rewards (as per step 1) - Script: [[spModalSweetAlerts.js]] - +1. A catalog item having variable name Rewards[rewards] of type 'Select Box'(include none as true) and 2 choices(Yes and No) +2. A Single line type field named 'Reward Selected' [reward_selected] which will hold the value selected by user from the spModal popup. +3. The onLoad catalog client script setup as below: +4. Type: onChange +5. Variable: rewards (as per step 1) +6. Script: [[spModalSweetAlerts.js]] + Screenshots: