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

Is there a way to allow end user to overwrite a auto populated text field

Explorer ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

I have a text field,"Text 2", that includes the following JavaScript in the calculation field that auto populates this text field from two previous text fields:

event.value = this.getField("Text A").valueAsString + " " + this.getField("Text B").valueAsString;

 

In most cases what would then populate the "Text 2" field would be correct, but sometimes the end user might want to alter the resulting text in "Text 2". Is there anything that could be added to the above script that would allow the end user overwrite what has auto populated in the "Text 2"?

 

Thank you in advance for time and help!

TOPICS
How to , JavaScript , PDF forms

Views

1.1K

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

correct answers 1 Correct answer

Community Expert , Apr 02, 2022 Apr 02, 2022

Hi,

For me it's possible. Write:

 

if (event.source && (event.source.name=="Text A" || event.source.name=="Text B")) event.value=this.getField("Text A").valueAsString+" "+this.getField("Text B").valueAsString;

 

Capture d’écran 2022-04-02 à 19.11.55.png

But as soon as you modify the "Text A" or "Text B" field the "Text 2" field is "Text A" value + " " +  "Text B" value.

@+

Votes

Translate

Translate
Community Expert ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

Answer is no.

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 ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

It is possible, actually, but you need to clearly define how it should work first.

Say the user changed the value manually, but then went back and changed either "Text A" or "Text B".

Should it then revert back to the calculated value, or should it keep the value they entered before?

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 ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

Ideally, once the user overwrites the calculated value, the field would keep the new value entered regardless of whether "Text A" or "Text B" was changed. 

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 ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

That's more tricky to do. You will need to keep a record of when the field was edited, in order to stop applying the calculated value to it.

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 ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

Hi,

For me it's possible. Write:

 

if (event.source && (event.source.name=="Text A" || event.source.name=="Text B")) event.value=this.getField("Text A").valueAsString+" "+this.getField("Text B").valueAsString;

 

Capture d’écran 2022-04-02 à 19.11.55.png

But as soon as you modify the "Text A" or "Text B" field the "Text 2" field is "Text A" value + " " +  "Text B" 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
Enthusiast ,
Apr 04, 2022 Apr 04, 2022

Copy link to clipboard

Copied

This doesn't make any sense, it's opposite of what OP asked for,

Ideally, once the user overwrites the calculated value, the field would keep the new value entered regardless of whether "Text A" or "Text B" was changed.

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 ,
Apr 04, 2022 Apr 04, 2022

Copy link to clipboard

Copied

LATEST

Very helpful--that works just as you described. 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