Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Drop down list selection calculation

Avatar

Level 2

Hi,

I have created an annual leave form with multiple line that calculate the work days between two dates.

What i am after is in the drop down list there are multiple choices of leave, If i select Flexi Time or Compassionate leave i want it to calculate the days into a different box so it dosnt take it out of the annual leave entitlement?

Is this possible? I am more than happy to upload my document for you to see

Thank you in advance

7 Replies

Avatar

Former Community Member

Well in case you calculate the number of working days within an own function you could easily assign this value to every field you want.

If I got you wrong please enhance your problem description a bit ;-)

Avatar

Level 2

Hi,

umm sort of what im after but i am wanting when he drop down box selects flexi days for the total to go into the other day box showing the days so it doesnt deduct from the annual leave allowance, does that make sense??

Avatar

Former Community Member

Well yes, put your logic for this into a script on to the change event of the drop down field.

You will see the text the user chose in this String: xfa.event.newText

Just code

if ( xfa.event.newText == "Flexi days" )

{

     this.ResolveNode("FieldA").rawValue = this.ResolveNode("FieldB").rawValue;

     this.ResolveNode("FieldB").rawValue = "";

}

Avatar

Level 2

for some reason its not working the answer isnt coming up in the box  and it is still deducting it from the annaul leave.

Any more suggestions?

Avatar

Former Community Member

Yes, a dropdown list always differes between: Technical Value (Key) and Display Value.

The Display Value in your case will be "Flexi days". However, possibly your key is different. xfa.event.newText refers to the key.

Just put this into the form and test it. You will then see the code that's selected and you need to adapt the "if" statement accordingly.

But this into change event:

xfa.host.messageBox(xfa.event.newText);

Also ensure that the pathing to your fields is correct when set their values. Consider the hierarchy of your subforms and elements.

Avatar

Level 2

Hi,

No, im afraid it is still not working, are you able to send any examples for it working?

thanks

Avatar

Level 2

Is anyone able to take a look at my form?