Conditional Drop Downs
- Adam Reyes
- Posts: 35
- Joined: Tue Mar 04, 2014
Hello,
I've used the following conditions before in forms but for some reason it doesn't seem to be working anymore. The following code continues to give me a return of "OSI" no matter which selection I choose. Is there something you can see wrong with the conditional code below?
fd.field('ContractsCAGECode').control().change(function(){
var cagecode = fd.field('ContractsCAGECode').control().value();
if (fd.field('ContractsCAGECode').control().value() == '1VZN4')
{
fd.field('Entity').control().value("AI");
}
else if (fd.field('ContractsCAGECode').control().value() == '5UBL3')
{
fd.field('Entity').control().value("ATG");
}
else if (fd.field('ContractsCAGECode').control().value() == '59W37')
{
fd.field('Entity').control().value("Stratus");
}
else (fd.field('ContractsCAGECode').control().value() == '097A3')
{
fd.field('Entity').control().value("OSI");
}
});
I've used the following conditions before in forms but for some reason it doesn't seem to be working anymore. The following code continues to give me a return of "OSI" no matter which selection I choose. Is there something you can see wrong with the conditional code below?
fd.field('ContractsCAGECode').control().change(function(){
var cagecode = fd.field('ContractsCAGECode').control().value();
if (fd.field('ContractsCAGECode').control().value() == '1VZN4')
{
fd.field('Entity').control().value("AI");
}
else if (fd.field('ContractsCAGECode').control().value() == '5UBL3')
{
fd.field('Entity').control().value("ATG");
}
else if (fd.field('ContractsCAGECode').control().value() == '59W37')
{
fd.field('Entity').control().value("Stratus");
}
else (fd.field('ContractsCAGECode').control().value() == '097A3')
{
fd.field('Entity').control().value("OSI");
}
});
Dear Adam,
I'm sorry for a late reply. Correctness depends on what type the field is. If the field is a Choice field than the code is correct, but if the field is a Lookup than control().value() returns Id of the lookup item and not the text: https://spform.com/javascript-framework ... eld-values
If the field is a lookup field, please, try to use the code below:
I'm sorry for a late reply. Correctness depends on what type the field is. If the field is a Choice field than the code is correct, but if the field is a Lookup than control().value() returns Id of the lookup item and not the text: https://spform.com/javascript-framework ... eld-values
If the field is a lookup field, please, try to use the code below:
Code: Select all
fd.field("Lookup").control('getSelectedText')
- Adam Reyes
- Posts: 35
- Joined: Tue Mar 04, 2014
Hi Alex,
The fields are both drop-down fields but for some reason this code doesn't seem to work so I've had to make a function for every single value which doesn't seem to be the ideal way to do it. Any thoughts on why the code wouldn't work for drop-down fields?
The fields are both drop-down fields but for some reason this code doesn't seem to work so I've had to make a function for every single value which doesn't seem to be the ideal way to do it. Any thoughts on why the code wouldn't work for drop-down fields?
Hi Adam,
Please try to complete your code with the "debugger;" option. Place it right in your code before the problem part, save the form, then open the form in browser with the browser console (F12). The code execution will stop on the "debugger;" command, so you will be able to test your code more properly in the browser console.
Please try to complete your code with the "debugger;" option. Place it right in your code before the problem part, save the form, then open the form in browser with the browser console (F12). The code execution will stop on the "debugger;" command, so you will be able to test your code more properly in the browser console.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 10 guests