Check condition of two separate dropdown lists

45 views
Skip to first unread message

Brenda Bourgette

unread,
Jan 18, 2023, 3:41:57 PM1/18/23
to Adobe LiveCycle Developers
Hi,

I am new to this group.  I am trying to check the value of a dropdown (Request Type) if this is "Departure" and a different dropdown list (Employee Status) is "Permanent" then I want a specific subform to appear.

Here is my code but it's not working, I have it on the "Change" event on the (Employee Status) dropdown button.

//hide or show Resignation Letter

if ((this.xfa.event.change == "Permanent") && (requestType.xfa.event.change == "Departure"))  ;
{  
     form1.Resignation_Letter_Subform.presence = "visible";  
}  

else {
    form1.Resignation_Letter_Subform.presence = "hidden";  
}


fred.pantalone

unread,
Jan 18, 2023, 4:05:00 PM1/18/23
to Adobe LiveCycle Developers
I think it will work if you check requestType.rawValue instead of the change event value of that field. Your logic isn't concerned with the change event of of the request type field it's running on the change event of the employee status. Don't forget to consider the case where the user changes the request type. You might be better off putting this code on the calculate event of Resignation_Letter_Subform and checking the rawValue of both dropdowns.

Brenda Bourgette

unread,
Jan 18, 2023, 4:45:01 PM1/18/23
to Adobe LiveCycle Developers
Thank you but it still doesn't work.  I put this code in the Calculate event of the subform "Resignation Letter" with language set to JavaScript.

//hide or show Resignation Letter

if ((Subform1.employeeStatus.rawValue == "Permanent") && (Subform1.requestType.rawValue == "Departure"))  ;

{  
     form1.Resignation_Letter_Subform.presence = "visible";  
}  

else {
    form1.Resignation_Letter_Subform.presence = "hidden";  
}

Brenda Bourgette

unread,
Jan 18, 2023, 5:28:05 PM1/18/23
to Adobe LiveCycle Developers
Thanks for your help.  I got it to work with this code in the Calculate event of the subform "Resignation Letter" with language set to JavaScript :

//hide or show Resignation Letter

if (Subform1.employeeStatus.rawValue == "Permanent")

if (Subform1.requestType.rawValue == "Departure")  

{  
     form1.Resignation_Letter_Subform.presence = "visible";  
}  

else {
    form1.Resignation_Letter_Subform.presence = "hidden";  
}

Brenda Bourgette

unread,
Jan 18, 2023, 5:33:48 PM1/18/23
to Adobe LiveCycle Developers
However... if I later change the dropdown of the Request Type to something else the Resignation letter is still there.  Any suggestions?

Brenda Bourgette

unread,
Jan 18, 2023, 5:59:21 PM1/18/23
to Adobe LiveCycle Developers
I was able to get it all to work, not sure if this was the most efficient code though.  Thank you Fred for setting me on the right path.

//hide or show Resignation Letter

if (Subform1.requestType.rawValue == "Departure")  


if (Subform1.employeeStatus.rawValue == "Permanent")

{  
     form1.Resignation_Letter_Subform.presence = "visible";  
}  

else {

    form1.Resignation_Letter_Subform.presence = "hidden";  
}

if (Subform1.requestType.rawValue == "Leave without pay")  


if (Subform1.employeeStatus.rawValue == "Permanent")

if (Subform1.employeeStatus.rawValue == "Temporary")

{  
     form1.Resignation_Letter_Subform.presence = "hidden";  
}  
else {

    form1.Resignation_Letter_Subform.presence = "hidden";  
}
if (Subform1.requestType.rawValue == "Maternity/Paternity Leave")  


if (Subform1.employeeStatus.rawValue == "Permanent")

if (Subform1.employeeStatus.rawValue == "Temporary")

{  
     form1.Resignation_Letter_Subform.presence = "hidden";  
}  
else {

    form1.Resignation_Letter_Subform.presence = "hidden";  
}

fred.pantalone

unread,
Jan 19, 2023, 9:50:43 AM1/19/23
to Adobe LiveCycle Developers
I'm glad you made some progress. However, your code is not efficient!

It looks like you have only one case where the resignation letter subform should be visible and that is when request=departure AND employee=permanent - in every other case that subform should be hidden. If this logic is correct then look at this code and see if it satisfies the requirement:

//hide or show Resignation Letter
if ((Subform1.requestType.rawValue == "Departure")  && (Subform1.employeeStatus.rawValue == "Permanent"))
{  
     form1.Resignation_Letter_Subform.presence = "visible";  
}  
else 

Brenda Bourgette

unread,
Jan 19, 2023, 10:50:50 AM1/19/23
to Adobe LiveCycle Developers
Thanks again Fred.  I also needed a permanent or temporary departure checklist subform to appear.  If "Departure" was chosen then the  SubformChecklistPerm  and the  Resignation_Letter_Subform  needed to be displayed .  For all other choices just the  SubformChecklistTemp  needed to be displayed.  It turns out I didn't need the field "EmployeeStatus".   I put the code below on the  SubformChecklistPerm on the Calculate event and it seems to work okay.

//hide or show Checklist for permanent or temporary departure and Resignation letter if needed


if (Subform1.requestType.rawValue == "Departure")  
{  
     form1.SubformChecklistPerm.presence = "visible";
     form1.SubformChecklistTemp.presence = "hidden";
     form1.Resignation_Letter_Subform.presence = "visible";      
}  
else {

    form1.SubformChecklistPerm.presence = "hidden";
    form1.SubformChecklistTemp.presence = "visible";
    form1.Resignation_Letter_Subform.presence = "hidden";
}

Brenda Bourgette

unread,
Jan 19, 2023, 12:34:43 PM1/19/23
to Adobe LiveCycle Developers
I appreciate your help on this Fred.  But I don't really understand why the code went on the Calculate event.  I usually use Calculate for math reasons.  Can you please explain why I needed the code on the Calculate?  Thank you.

fred.pantalone

unread,
Jan 19, 2023, 3:38:18 PM1/19/23
to Adobe LiveCycle Developers
Script in the calculate event leverages a very powerful dependency mechanism so that when a referenced object is modified, the event will fire. So, for example, when you reference field A in field B's calc script, this reference is tracked in the dependency table. When field A is modified, the mechanism knows it has to fire the calc event for field B. Not the best description but I hope you get the gist of it. Let me know if you don't. 
Reply all
Reply to author
Forward
0 new messages