Hi Experts,
I need to hide a row in adobe forms. If the Overall Discount(%) value in sales order is not present then the row will hide.
var Disc = xfa.resolveNodes("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent[*]").length;
for (var i=0; i<=Disc; i++) {
var TypeWord = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].Description").value;
if(TypeWord == "Overall Discount (%)"){
this.rawValue = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].CalculatedAmount").value;
}
else
{
Design.tablesf.Table2.Row3.presence = "hidden";
}
}
Now the Discount value present in sales order also hide the Row.
Experts Please help.
Regards,
Sai
Solved! Go to Solution.
Views
Replies
Total Likes
Use the below in the Row3 init event and remove all the script from the Discount field in Row3.
var Disc = xfa.resolveNodes("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent[*]").length;
var discountMatched = false;
for (var i=0; i<=Disc; i++) {
var TypeWord = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].Description").value;
if(TypeWord == "Overall Discount (%)"){
Discount.rawValue = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].CalculatedAmount").value;
discountMatched = true;
if(Discount.rawValue == 0.00){
this.presence="hidden";
}
}
else{
this.presence="hidden";
}
if(discountMatched == true) {
break;
}
}
The script doesn't make clear, how the form is build.
Where does this execute from? Might be a field, but where exactly is it located?
Also, what type of field is "Description", a static text or a field?
Finally, Design.tablesf.Table2.Row3 is another table in the form with just on instance of Row3 or what?
Hi radzmar,
Thank you for your reply.
1. This script is used in Sales order form.
2. Description Here I mentioned in the "XML" tag.
3."Design.tablesf.Table2.Row3 " which is the path to hide the Row
Any help regarding this would be highly appreciated.
Thanks & Regards,
Sai
Hi,
okay, but still not detailed enough.
Is tablesf, Table2 or Row3 repeated for each data item (PriceComponent)?
Hi,
tablesf.Table2.Row3 is the Path of the Discount Row.It is not for all data it is only applicaple for Discount.
PriceAndTax.PriceComponent.Description. CalculatedAmount-->XML path for Dicount
Thanks,
Sai
Well, from your information I assume Design.tablesf.Table2.Row3 has just one occurence. You can probably control the presence of the row with this script in the layout:ready event.
var bHasDiscount = xfa.record.FormPurchaseOrder.PriceAndTax.resolveNodes('PriceComponents.[Description.value eq "Overall Discount (%)"]').length === 0 ? false : true; Design.tablesf.Table2.Row3.presence = bHasDiscount ? "visible" : "hidden";
Share your form if you can, need to check the script in the form.
vkatoch07@gmail.com on google drive.
Thanks
You need to break the loop once the desired value is matched, so put "break;" keyword in your if block.
if(TypeWord == "Overall Discount (%)"){
this.rawValue = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].CalculatedAmount").value;
break;
}
make your else block like below:
else{
this.Table2.Row3.presence="hidden";
}
As per the email conversation, you can achieve the desired result from below logic.
Add the below logic in the init event of Discount field as your all data comes from xml.
if(Row3.Discount.rawValue== 0)
then hide >
this.Table2.Row3.presence="hidden";
Hi,
I tried both the ways.
I used the recent script which you gave and the discount amount value appears zero even after giving overall discount value.
Thanks,
Sai
Use the below in the Row3 init event and remove all the script from the Discount field in Row3.
var Disc = xfa.resolveNodes("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent[*]").length;
var discountMatched = false;
for (var i=0; i<=Disc; i++) {
var TypeWord = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].Description").value;
if(TypeWord == "Overall Discount (%)"){
Discount.rawValue = xfa.resolveNode("xfa.record.FormPurchaseOrder.PriceAndTax.PriceComponent["+ i +"].CalculatedAmount").value;
discountMatched = true;
if(Discount.rawValue == 0.00){
this.presence="hidden";
}
}
else{
this.presence="hidden";
}
if(discountMatched == true) {
break;
}
}
Views
Likes
Replies