• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check or uncheck box based on other fields

Explorer ,
May 08, 2023 May 08, 2023

Copy link to clipboard

Copied

Hi, Sorry I am a noob

I have a situation like this

kennethkamchuh21426993_0-1683580215716.png

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

kennethkamchuh21426993_1-1683580446846.png

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

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

 

TOPICS
General troubleshooting , How to , JavaScript , PDF forms

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
May 08, 2023 May 08, 2023

Copy link to clipboard

Copied

Yes, you can add my code to that one.

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2023 May 08, 2023

Copy link to clipboard

Copied

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"));

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2023 May 08, 2023

Copy link to clipboard

Copied

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 = "";

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2023 May 08, 2023

Copy link to clipboard

Copied

Yes, you can add my code to that one.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2023 May 08, 2023

Copy link to clipboard

Copied

LATEST

Thanks a lot for this! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines