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

Auto-populating a field based on another field

New Here ,
Oct 30, 2024 Oct 30, 2024

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

TOPICS
How to , PDF forms

Views

214

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 ,
Oct 30, 2024 Oct 30, 2024

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

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
New Here ,
Oct 31, 2024 Oct 31, 2024

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

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 ,
Oct 31, 2024 Oct 31, 2024

Copy link to clipboard

Copied

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

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
New Here ,
Nov 05, 2024 Nov 05, 2024

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 😕

catherine_6136_0-1730821979961.png

 

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 ,
Nov 05, 2024 Nov 05, 2024

Copy link to clipboard

Copied

LATEST

Check the Javascript console for errors.

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