diff --git a/Client-Side Components/Client Scripts/Dynamic Greeting Based on Time/GreetingMessage.js b/Client-Side Components/Client Scripts/Dynamic Greeting Based on Time/GreetingMessage.js new file mode 100644 index 0000000000..c3fafb6373 --- /dev/null +++ b/Client-Side Components/Client Scripts/Dynamic Greeting Based on Time/GreetingMessage.js @@ -0,0 +1,7 @@ + +// Type: onLoad | Table: incident +function onLoad() { + var hr = new Date().getHours(); + var msg = (hr < 12) ? "Good Morning!" : (hr < 18) ? "Good Afternoon!" : "Good Evening!"; + g_form.addInfoMessage(msg + " Please provide the details of your issue."); +} diff --git a/Client-Side Components/Client Scripts/Dynamic Greeting Based on Time/README.MD b/Client-Side Components/Client Scripts/Dynamic Greeting Based on Time/README.MD new file mode 100644 index 0000000000..ed72ca3792 --- /dev/null +++ b/Client-Side Components/Client Scripts/Dynamic Greeting Based on Time/README.MD @@ -0,0 +1,18 @@ +How it Code work Step by Step + +Trigger: +This script runs onLoad (when the Incident form is opened). +It only applies to the Incident table. +Get current hour: +new Date().getHours() → fetches the current system hour (0–23 format). +Example: 9 = 9 AM, 15 = 3 PM, 20 = 8 PM. +Condition (Ternary Operator): +If hour is < 12 → Morning +Else if hour < 18 → Afternoon +Else → Evening +Add Info Message: +g_form.addInfoMessage(...) shows a friendly banner on top of the form. +Example output: +Morning (9 AM) → “Good Morning! Please provide the details of your issue.” + +Evening (8 PM) → “Good Evening! Please provide the details of your issue.”