Copy link to clipboard
Copied
Hello,
I am trying to have two fields get auto-populated (Tolerance/Weight Range and Readability/Capacity) based on another field (MFR./Model).
I've got a lot of data but to give an example, here's the first two:
MFR./Model = ACCULAB PP-2060D
Tolerance/Weight Range = 50 g ± 0.01 g
Readbaility/Capacity = 0.001g / 60g
MFR./Model = ACCULAB VIC-123
Tolerance/Weight Range = 100 g ± 0.010 g
Readbaility/Capacity = 0.001g / 120g
How should my custom validation script look like?
I'd appreciate your help. Thank you
Copy link to clipboard
Copied
Try this code:
if (event.value=="ACCULAB PP-2060D") {
this.getField("Tolerance/Weight Range").value = "50 g ± 0.01 g";
this.getField("Readbaility/Capacity").value = "0.001g / 60g";
} else if (event.value=="ACCULAB VIC-123") {
this.getField("Tolerance/Weight Range").value = "100 g ± 0.010 g";
this.getField("Readbaility/Capacity").value = "0.001g / 120g";
} // etc.
else {
this.getField("Tolerance/Weight Range").value = "";
this.getField("Readbaility/Capacity").value = "";
}
Copy link to clipboard
Copied
Hello,
I tried this inputting this
if (event.value=="ACCULAB PP-2060D") { this.getField("Tolerance/Weight Range").value = "50 g ± 0.01 g"; this.getField("Readbaility/Capacity").value = "0.001g / 60g"; } else if (event.value=="ACCULAB VIC-123") { this.getField("Tolerance/Weight Range").value = "100 g ± 0.010 g"; this.getField("Readbaility/Capacity").value = "0.001g / 120g";
However, it's giving me this error:
SyntaxError: missing } in compound statement
6: at line 7
I attached a screenshot of the error. Thank you
Copy link to clipboard
Copied
Right, because it's missing... Add it to the end of the code.
Copy link to clipboard
Copied
Got it. Thank you.
Here's the code I tried and was able to enter but still didn't work.
For the tolerance / weight range, here's what I have on my custom calculation script:
if (MFR/Model=="ACCULAB PP-2060D") {
this.getField("Tolerance").value = "50 g ± 0.01 g";
} else if (event.value=="ACCULAB VIC-123") {
this.getField("Tolerance").value = "100 g ± 0.010 g";}
For the readability/capacity, here's what I have on my custom calculation script:
if (MFR/Model=="ACCULAB PP-2060D") {
this.getField("Readability").value = "0.001g / 60g";
} else if (event.value=="ACCULAB VIC-123") {
this.getField("Readability").value = "0.001g / 120g";}
For the MFR/Model, I left the custom calculation script blank because this is what the first two depends on to be auto populated.
Am I thinking this incorrectly? What am I doing wrong 😕
Copy link to clipboard
Copied
Check the Javascript console for errors.