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
- 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.
You can execute the script
this.getField("CREDIT").setItems(["CREDIT\nOPENINGS", "MORTGAGE\nLOAN", "PERSONAL\nLOAN"]);
in the Javascript console.
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.
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?
Copy link to clipboard
Copied
When you use setItems it will reset the dropdown to the first entry.
Copy link to clipboard
Copied
Okay
Do you have any alternative solutions please?
Copy link to clipboard
Copied
Why does you use setItems in a calculation script?
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
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
Copy link to clipboard
Copied
You can execute the script
this.getField("CREDIT").setItems(["CREDIT\nOPENINGS", "MORTGAGE\nLOAN", "PERSONAL\nLOAN"]);
in the Javascript console.
Copy link to clipboard
Copied
When you use setItems it will reset the dropdown to the first entry.