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

Function validation drop-down menu

Participant ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

Hi
can someone please help me to solve this function?
I inserted this function in the "validation" drop-down menu:

 

if(event.value=="MORTGAGE LOAN"){this.getField("PERSONAL LOAN N").value=this.getField("BANK").value;}
if(event.value=="CREDIT OPENING"){this.getField("PERSONAL LOAN N").value=this.getField("BANK_2").value;}

 

The drop-down menu is called COMMITMENTQEQ
I inserted this function in the calculation script to make the text of the drop-down menu more readable this.getField("COMMITMENT TYPEQEQ").setItems(["MORTGAGE\nMORTGAGE","CREDIT OPENING"]);

When I select the text "OPENING\nCREDIT", the text "MORTGAGE\nMORTGAGE" always appears in the drop-down menu
When I select the text "MORTGAGE\nMORTGAGE", in the menu
the drop-down text always shows "MORTGAGE\nMORTGAGE"

Thank you for your help

TOPICS
JavaScript

Views

1.3K

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
2 ACCEPTED SOLUTIONS
Community Expert ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

- It's not a good idea to use line-breaks in the items of a drop-down. It's an undocumented "feature", and it's buggy. I would avoid it.

- The strings in your setItems method don't match those in your validation script.

"MORTGAGE LOAN" != "MORTGAGE\nMORTGAGE"

- You have no default value in the Validation script, so when none of the two conditions are true, nothing happens to the target field, basically.

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 ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

LATEST

You can execute the script

this.getField("CREDIT").setItems(["CREDIT\nOPENINGS", "MORTGAGE\nLOAN", "PERSONAL\nLOAN"]);

in the Javascript console.

 

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 ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

- It's not a good idea to use line-breaks in the items of a drop-down. It's an undocumented "feature", and it's buggy. I would avoid it.

- The strings in your setItems method don't match those in your validation script.

"MORTGAGE LOAN" != "MORTGAGE\nMORTGAGE"

- You have no default value in the Validation script, so when none of the two conditions are true, nothing happens to the target field, basically.

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
Participant ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

ok
I'm sorry, I failed to understand one thing.
I have a drop down menu called CREDIT.
In the calculation script I inserted this function:
this.getField("CREDIT"). setItems (["LOAN\nPERSONAL","MORTGAGE\nMORTGAGE","OPENING\nCREDIT"]);
When I go to select from the drop down menu the text
"MORTGAGE
MORTGAGE"
or the text
"OPENING
OF CREDIT",
I always get the text
"LOAN
PERSONAL".

Is there an error in the function, or in these cases does the drop-down menu work like this and it doesn't allow you to bring up the various selected texts?

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 ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

When you use setItems it will reset the dropdown to the first entry.

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
Participant ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

Okay
Do you have any alternative solutions please?

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 ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

Why does you use setItems in a calculation script?

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
Participant ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

The drop-down menu field is small and the full text listed in the options menu cannot be read well

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
Participant ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

I think I solved the problem this way.
I insert this function in the calculation script of the "CREDIT" menu

this.getField("CREDIT").setItems(["CREDIT\nOPENINGS", "MORTGAGE\nLOAN", "PERSONAL\nLOAN"]);

Then I insert this function in the custom key script of the "CREDIT" field
this.getField("CREDIT").valueAsString.replace(/\n/," ");

Then in the custom validation script of the "CREDIT" field I insert this function

if(event.value == "MORTGAGE\nMORTGAGE")this.getField("PERSONAL LOAN N").value = this.getField("BANK").value;
if(event.value == "CREDIT OPENINGS")this.getField("PERSONAL LOAN N").value = this.getField("BANK_2").value;
if(event.value == "PERSONAL\nLOAN")this.getField("PERSONAL LOAN N").value = this.getField("BANK_3").value;

Finally, I go back to the "CREDIT" field calculation script and delete the function
this.getField("CREDIT").setItems(["CREDIT\nOPENINGS", "MORTGAGE\nLOAN", "PERSONAL\nLOAN"]);
leaving the script empty

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 ,
Feb 02, 2023 Feb 02, 2023

Copy link to clipboard

Copied

LATEST

You can execute the script

this.getField("CREDIT").setItems(["CREDIT\nOPENINGS", "MORTGAGE\nLOAN", "PERSONAL\nLOAN"]);

in the Javascript console.

 

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 ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

When you use setItems it will reset the dropdown to the first entry.

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