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 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 @@ +