Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Automatic row numbers in the dynamic table

Avatar

Former Community Member

Hi, with your help I've almost completed my table. My table has 18 rows and it has add row btn. Is it possible automate numbering of the rows so that when I add rows they will have numbers automaticly. I've tried indexing but it doesn't work.

this.rawValue=this.parent.index

I'm trying to improve also a calculation script and for some reason I do get and error. Will you be able to let me know where the errror is. My script is:

form1.SubTable.Table2.Row1[0].Total::calculate - (FormCalc, client)
if (AmountNet > 0) then
     Total = AmountNet + VAT

else (AmountNet == 0) and (ExchangeRate > 0)
     Total = AmountForeign /ExchangeRate
endif

I've checked with the check script syntax and it is ok, but i still do get an error.

I've attached a picture of what I get a a final doc.

Thanks a lot for your help!!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Looking at the form again, I think this is what you are after:

if(AmountNet > 0) then
    $ = AmountNet + VAT
elseif ((AmountNet  == null or AmountNet == 0) and ExchangeRate > 0) then
    $ = AmountForeign / ExchangeRate
endif

In the previous version the test was "when AmountNet == 0"; however this didn't check if the field was empty. The code above in red checks AmountNet for two conditions: if the field is empty OR if the user has put in £0.00. If either of these is true then the first part of the test is satisfied. The script then moves on to look at the value of the ExchangeRate separately.

Hope that helps,

Niall

View solution in original post

8 Replies

Avatar

Former Community Member

Hi, I just figure it out the answer for my frst question:

form1.SubTable.Table2.Row1[7].ItemNumber::ready:layout - (FormCalc, client)

this.rawValue=this.parent.index+1

But still need your help for second one,please

Avatar

Level 10

Not sure if that is the only problem, but I think you should only have one "=" in the (AmountNet == 0) statement - you're assigning a value, not testing a value.

Avatar

Level 10

Hi,

Having seen this form before, I suspect that you do want to test against both fields, therefore the script would look something like:

if(AmountNet > 0) then
    $ = AmountNet + VAT
elseif(AmountNet  == 0 and ExchangeRate > 0) then
    $ = AmountForeign / ExchangeRate
endif

the only thing to bear in mind is that even if the user has foreign values in and then inputs values in for GB, the GB will take precedence in the script and appear in the total field.

Hope that helps,

N.

Avatar

Former Community Member

Nial, thnaks for your help, the script you gave me is 50% solution I solved the error message but the calculation after second condition does not perform.

Would you have a look a the table please?

Thanks a lot

Avatar

Correct answer by
Level 10

Hi,

Looking at the form again, I think this is what you are after:

if(AmountNet > 0) then
    $ = AmountNet + VAT
elseif ((AmountNet  == null or AmountNet == 0) and ExchangeRate > 0) then
    $ = AmountForeign / ExchangeRate
endif

In the previous version the test was "when AmountNet == 0"; however this didn't check if the field was empty. The code above in red checks AmountNet for two conditions: if the field is empty OR if the user has put in £0.00. If either of these is true then the first part of the test is satisfied. The script then moves on to look at the value of the ExchangeRate separately.

Hope that helps,

Niall

Avatar

Former Community Member

Niall! Once again Thank you for your help!

I've seen the books you've recomended to Greg I'll try to read them to improve my scripting in LC.

If I can somehow to return your favor please let me know!

Best regards

Alex

Avatar

Former Community Member

Hello Dude,

Can you let me know what are books that gives scripting reference?

Regards,

Rakesh