Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 5

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

View solution in original post

11 Replies

Avatar

Level 10

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? 

Avatar

Level 2

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. 

Sai9_0-1673327592307.pngSai9_1-1673327627030.png

3."Design.tablesf.Table2.Row3 " which is the path to hide the Row

Sai9_2-1673328225966.png

Any help regarding this would be highly appreciated.

Thanks & Regards,

Sai

 

 

Avatar

Level 10

Hi,

 

okay, but still not detailed enough. 

Is tablesf, Table2 or Row3 repeated for each data item (PriceComponent)? 

Avatar

Level 2

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

Avatar

Level 10

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

 

 

 

Avatar

Level 5

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

vkatoch07@gmail.com on google drive.

Thanks

Avatar

Level 5

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

Avatar

Level 5

make your else block like below:

 

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

Avatar

Level 5

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

Avatar

Level 2

Hi,

I tried both the ways. 

Sai9_0-1673429336746.pngSai9_1-1673429365899.png

Sai9_2-1673429405334.png

I used the recent script which you gave and the discount amount value appears zero even after giving overall discount value.

Thanks,

Sai

Avatar

Correct answer by
Level 5

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