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..52108efc00 --- /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 snippet of [spModalSweetAlerts.js] file. + +Setup: +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: + + +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 + 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'); + } +}