How to hide a Overall Discount(%) Row in adobe forms | Community
Skip to main content
Level 2
January 9, 2023
Solved

How to hide a Overall Discount(%) Row in adobe forms

  • January 9, 2023
  • 4 replies
  • 2077 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijay_Katoch

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;
}
}

4 replies

radzmar
Level 10
January 9, 2023

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? 

Sai9Author
Level 2
January 10, 2023

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

 

 

Vijay_Katoch
Community Advisor
Community Advisor
January 10, 2023

Share your form if you can, need to check the script in the form.

vkatoch07@gmail.com on google drive.

Thanks

Vijay_Katoch
Community Advisor
Community Advisor
January 10, 2023

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;
}

Vijay_Katoch
Community Advisor
Community Advisor
January 10, 2023

make your else block like below:

 

else{
this.Table2.Row3.presence="hidden";
}

Vijay_Katoch
Community Advisor
Community Advisor
January 11, 2023

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";

Sai9Author
Level 2
January 11, 2023

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