Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

resolveNode is not working perfectly... or something else?

Avatar

Level 2

Hi Volks,

I have a pdf form with few date fields (weekdays), and a button what is chek these datefields. here is the code:

if ((xfa.resolveNode("date_m[1]").rawValue == null) || (xfa.resolveNode("date_m[1]").rawValue == "")) {

          app.alert("Check the date fields from Monday to Friday!");

 

}

else if ((xfa.resolveNode("date_m[2]").rawValue == null) || (xfa.resolveNode("date_m[2]").rawValue == "")) {

          app.alert("Check the date fields from Monday to Friday!");

 

}

else if ((xfa.resolveNode("date_m[3]").rawValue == null) || (xfa.resolveNode("date_m[3]").rawValue == "")) {

          app.alert("Check the date fields from Monday to Friday!");

 

}

else if ((xfa.resolveNode("date_m[4]").rawValue == null) || (xfa.resolveNode("date_m[4]").rawValue == "")) {

          app.alert("Check the date fields from Monday to Friday!");

 

}

else if ((xfa.resolveNode("date_m[0]").rawValue == null) || (xfa.resolveNode("date_m[0]").rawValue == "")) {

          app.alert("Check the date fields from Monday to Friday!");

 

}

else {

          app.alert("Dates OK!");

}

The intresting thing is that the date_m[0] is not working (if this one is empty or not),  I get the  same result: "Dates Ok", and I dont know why...

If I delete the last else if part (with the date_m[0]) everithing working perfectly....

What can be the problem?

Thanks,

encleadus

1 Accepted Solution

Avatar

Correct answer by
Level 8

Ya that is weird it shouldn't be doing that. Try using this script:

if (hasEmpty(date_m))
xfa.host.messageBox("Check the date fields from Monday to Friday!");
else
xfa.host.messageBox("Dates OK!");


function hasEmpty(oField){
for (var a=0;a<oField.all.length;a++){
  if (oField.all.item(a).isNull || oField.all.item(a).rawValue=="")
   return true;
}
return false;
}

Kyle

View solution in original post

6 Replies

Avatar

Correct answer by
Level 8

Ya that is weird it shouldn't be doing that. Try using this script:

if (hasEmpty(date_m))
xfa.host.messageBox("Check the date fields from Monday to Friday!");
else
xfa.host.messageBox("Dates OK!");


function hasEmpty(oField){
for (var a=0;a<oField.all.length;a++){
  if (oField.all.item(a).isNull || oField.all.item(a).rawValue=="")
   return true;
}
return false;
}

Kyle

Avatar

Level 2

Hi, thanks for the help. I will check it, but I am on site at the moment.

Encleadus

Avatar

Level 2

Thanks for this code, is working perfectly.

Can you change a littlebit for me please, because it is include the weekends as well, and these are can be blank. I cannot change the field names becase I builded up a full batch processing to insert the form data into a database...

The weekend fields are date_m[5] and date_m[6].

Thanks in advance.

encleadus

Avatar

Level 8

Replace oField.all.length with 5.

Kyle

Avatar

Level 2

Thanks Kyle,

This one is worked great as well!

encleadus

Avatar

Level 2

I don't understand this livecycle (perhaps, because I am not a programer).... I think this is a software bug.

The problem is the same. If you have any time capacity can you chek this code, please?

if ((xfa.resolveNode("hours_m1[0]").rawValue) + (xfa.resolveNode("hours_m2[0]").rawValue)+ (xfa.resolveNode("hours_m3[0]").rawValue)+ (xfa.resolveNode("hours_m4[0]").rawValue)+ (xfa.resolveNode("hours_m5[0]").rawValue)+ (xfa.resolveNode("hours_m6[0]").rawValue)+ (xfa.resolveNode("hours_m7[0]").rawValue)+ (xfa.resolveNode("hours_m8[0]").rawValue) == (xfa.resolveNode("standardhours_m[0]").rawValue) + (xfa.resolveNode("overtime6_m[0]").rawValue)+ (xfa.resolveNode("overtime10_m[0]").rawValue)) {

 

}

else {

          app.alert("Monday: Activity hours are not equal with Standard, Overtime, Nightshift/Weekend hours.");

}

if ((xfa.resolveNode("hours_m1[1]").rawValue) + (xfa.resolveNode("hours_m2[1]").rawValue)+ (xfa.resolveNode("hours_m3[1]").rawValue)+ (xfa.resolveNode("hours_m4[1]").rawValue)+ (xfa.resolveNode("hours_m5[1]").rawValue)+ (xfa.resolveNode("hours_m6[1]").rawValue)+ (xfa.resolveNode("hours_m7[1]").rawValue)+ (xfa.resolveNode("hours_m8[1]").rawValue) == (xfa.resolveNode("standardhours_m[1]").rawValue) + (xfa.resolveNode("overtime6_m[1]").rawValue)+ (xfa.resolveNode("overtime10_m[1]").rawValue)) {

 

}

else {

          app.alert("Tuesday: Activity hours are not equal with Standard, Overtime, Nightshift/Weekend hours.");

}

thanks,

encleadus