Skip to main content
kenneth kam chuh21426993
Known Participant
May 8, 2023
Answered

Check or uncheck box based on other fields

  • May 8, 2023
  • 1 reply
  • 1939 views

Hi, Sorry I am a noob

I have a situation like this

If a work is deemed to be VH or H (Very high or High) Risks, the employee is not allowed to work after hours. 

So I want the checkbox "Not allowed" to be checked when R (Risk) is displayed as VH or H and lock the "Allowed" and "Monitor Only" checkboxes. 

 

So far this is what I have done but it does not seem to perform what I expected:

1) Set up a JavaScript under Actions

2) The following script in the "Not Allowed" checkbox

var R = this.getField("Risk").valueAsString;
if(R=="H"||R=="VH"){event.value = "Yes";}

 

This topic has been closed for replies.
Correct answer try67
Yes, you can add my code to that one.

1 reply

try67
Community Expert
Community Expert
May 8, 2023

You can't use the check-box's actions for that. Use the custom Validation script of the Risk field, instead, with this code:

var R = event.value;

this.getField("Not Allowed").checkThisBox(0, (R=="H" || R=="VH"));

 

kenneth kam chuh21426993
Known Participant
May 8, 2023

Thank you for this. 

I already have the following script in the Risk Field (R). Can you advice how to add your script on top of my existing script in the Risk Field (R)?

var L = this.getField("LReaction").valueAsString;
var C = this.getField("CReaction").valueAsString;
var R = L+C;
if(R=="A1"||R=="B1"||R=="B2"||R=="C2"||R=="D3"||R=="D4"||R=="E3"||R=="E4"||R=="E5")
event.value = "M";
else if(R=="C1"||R=="D1"||R=="D2"||R=="E1"||R=="E2")
event.value = "L";
else if(R=="A2"||R=="A3"||R=="B3"||R=="B4"||R=="C3"||R=="C4"||R=="D5")
event.value = "H";
else if(R=="A4"||R=="A5"||R=="B5"||R=="C5")
event.value = "VH";
else
event.value = "";

 

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 8, 2023
Yes, you can add my code to that one.