- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 03:14 PM
I hope you can help.
I created a simple Client Script on the Incident Table to make a date field "Read Only" depending on the values / entry of three specific fields. I have struggled for the syntax for the relevant Date field being populated (is NOTNULL / not empty), and after doing some reading I believe that I should be using "&&" instead of "||". So I re-worked the Syntax replacing the "||" with "&&" and the script fails and still have not found a solution for NOTNULL / not empty / populated
The Business Scenario is:
if an Account is flagged as an "Integrated Customer" and the "On hold reason" is "Awaiting Integrated Customer" and the "On hold until" date is populated, the set the "On hold until" field as read only. Admin role overrides. And if any of these are not true then the field will remain editable.
A slight complication may be that the "Integrated Customer" flag field is a "Reference" to the Account Table.
The script that appears to work but I question is as follows:
When I changed the Syntax to this it fails:
I just can't work out what the Syntax for the IF statement should be:
if ('ohd', '!==', '' || ic == 'true' || hr == '6')
to achieve this
IF the "On hold date" populated AND the "integrated Customer Flag" is "true" AND the "On hold reason" is "Awaiting integrated Customer (value of 6) THEN make the "On hold date" read-only.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 03:43 PM - edited 08-23-2024 03:47 PM
try changing the line in your second script from
if (ohd != '' || ic == true || hr == '6') to
if ((ohd != '') && (ic == true) && (hr == '6'))
and why have the extra "{}" around the lines that get the values and set the read-only? that shouldn't be a problem though.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 07:55 PM
Adding onto what Bert mentioned, here is how the script should look.
function onLoad() {
if (g_user.hasRole('admin'))
return;
var ohd = g_form.getValue('u_on_hold_until_date');
var ic = g_form.getValue('u_integrated_d2d');
var hr = g_form.getValue('hold_reason');
if (ohd != '' && ic == true && hr == '6')
g_form.setReadOnly('u_on_hold_until_date', true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 07:09 AM
@Bert_c1 @Sandeep Rajput Thanks both for your input. It was truly my inexperience. I am trying to teach myself as I go along. The issue was the "Integrated Customer" field is on the Account Table and "u_integrated_d2d" is a reference field, that I had not defined. I think I worked it out by looking at other queries in the system.
Long story short, I created a "Data Policy" which worked. I then cancelled this and recreated as a UI Policy with an onCondition script If User has the Admin Role, the 'On hold until' date is read-only is false.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 07:49 AM
@Damian Mudge Glad to know that you found the fix. Please feel free to reach in future if you need any scripting related help.