From b9548d84716b4575a1b536c964e380ceec2587e8 Mon Sep 17 00:00:00 2001 From: Tim Dingle Date: Thu, 31 Oct 2024 22:09:28 -0500 Subject: [PATCH 1/2] Create content --- Client Scripts/Set field based on roles/content | 1 + 1 file changed, 1 insertion(+) create mode 100644 Client Scripts/Set field based on roles/content diff --git a/Client Scripts/Set field based on roles/content b/Client Scripts/Set field based on roles/content new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Client Scripts/Set field based on roles/content @@ -0,0 +1 @@ + From ba9c11e5926edba1832ee2e944a94a8c9ef46cae Mon Sep 17 00:00:00 2001 From: Tim Dingle Date: Thu, 31 Oct 2024 22:23:51 -0500 Subject: [PATCH 2/2] Add files via upload --- Client Scripts/Set field based on roles/Readme.md | 3 +++ .../Set field based on role.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Client Scripts/Set field based on roles/Readme.md create mode 100644 Client Scripts/Set field based on roles/Set field based on role.js diff --git a/Client Scripts/Set field based on roles/Readme.md b/Client Scripts/Set field based on roles/Readme.md new file mode 100644 index 0000000000..e9cae2011b --- /dev/null +++ b/Client Scripts/Set field based on roles/Readme.md @@ -0,0 +1,3 @@ +Scenario: If you want a boolean, like "u_assigned", to turn true if the logged-in user has a particular role. + +Application: Add the field to a record, then create a new client script. Give it a name, set the table, change = onLoad. Paste the snippet into the script area. \ No newline at end of file diff --git a/Client Scripts/Set field based on roles/Set field based on role.js b/Client Scripts/Set field based on roles/Set field based on role.js new file mode 100644 index 0000000000..dcdfa8fa52 --- /dev/null +++ b/Client Scripts/Set field based on roles/Set field based on role.js @@ -0,0 +1,14 @@ +function onLoad() { + // Check if the user has the 'admin' role + if (g_user.hasRole('admin')) { + g_form.setValue('u_assigned', false); // Set u_assigned (replace with applicable field name) to false if the user has the 'admin' role + } + + // Otherwise, check for the 'case_technician' (replace with applicable roles) roles + else if (g_user.hasRole('case_technician')) { + g_form.setValue('u_assigned', true); // Set the u_assigned (replace with applicable field name) field to true + + } else { + g_form.setValue('u_assigned', false); // Set u_assigned (replace with applicable field name) to false if they don't have the roles + } +} \ No newline at end of file