Skip to main content
Participant
October 30, 2024
Question

Auto-populating a field based on another field

  • October 30, 2024
  • 1 reply
  • 692 views

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

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
October 30, 2024

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 = "";
}
Participant
October 31, 2024

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

try67
Community Expert
Community Expert
October 31, 2024

Right, because it's missing... Add it to the end of the code.