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

Script Help! Lost on a certain calculation

Avatar

Level 1

So I am creating a purchase order sheet on livecycle and I have a table that has 5 colums: Catalog number, Description, Quantity, Unit Price, and Amount. I am looking for a calculation that when I input the catalog number, for example 7008, that it will automatically fill in the unit price for that catalog number. I want to do this so that when I publish this purchase order on my company's website, that they can select which catalog number they want and then it automatically fills in the unit price for them (so they can not change the unit price to whatever they want). Thanks for your help in advance... I am new at livecycle designer!

1 Accepted Solution

Avatar

Correct answer by
Level 2

as i am seeing the attachment as queued, i am attaching the document once again,

anyways please check that i have changed the untitled subform name to subform1

View solution in original post

16 Replies

Avatar

Level 6

Catalog may have hundreds of products and may prices change regularly. Having that scenario in mind having a script fill-in the value from a stored variable on the template will prompt you to change the version of template for every single change. You may use querying option but it requires DNS created along with Dataconnection script used. That DNS need to be created on each individual client machine, again not suitable for web posting scenario. If you have full suite of LC (which include LC Workflow) you can easily do with XML data transfer between the template and Workflow process. Let us know more about your setup and environment.

Avatar

Level 1

To be completly honest with you, like I said I am new to the adobe pdf creator and am not too familar with what you are saying. If you just know of a step by step process that I can use to just at least pair my catalog and unit price with in the script editor, then that would be great. I am not too concerning with placing it online right now, I just want to know of a step by step process of how to link the catalog number value with a unit price value. Thanks.

Avatar

Level 2

hi nbharpe,

if the Catalog Number is dropdown in the table you mentioned,

then in the Change Event of the Catalog Number Dropdown list field write the below script, Select Script Language as JavaScript.

var

catalog = this.boundItem(xfa.event.newText);

if

( catalog == "7008" )

{

body.Tablename.Row.unitprice.rawValue

= "10";

}

else

if ( catalog == "7009" )

{

body.Tablename.Row.unitprice.rawValue

= "20";

}

else if ....so on.

and make the unitprice field in the table as readonly, for this go to object pallete by selecting the unitprice field and in Value tab Select Type as ReadOnly.

Thanks,

Madhu.

Avatar

Level 1

Thanks for your response. I tried to input the formula that you gave me and it still did not work. I am not sure if I just did not input it correctly or what I will attach the file to see if you could take a look at it, and see what I am doing wrong.

Avatar

Level 2

hi,

I am unable to download the pdf attachment you have done, its showing status as Queued.

Thanks,

Madhu.

Avatar

Level 1

Madhu,

I tried to attach the file again, not sure why it was leaving it as queued but hopefully it works this time. I am guessing the only way to upload the file successfully on here is to just use the attach files feature at the bottom of the reply box.

Avatar

Level 2

hi nbharpe,

you have to change the path as per your hierarchy, that was the problem and you have written the script in Calculate Event but it should be written in Change Event

var

catalog =

this.boundItem(xfa.event.newText);

if

( catalog ==

"7008" )

{

subform1.Body.UnitPrice.rawValue

=

"125";

}

i have changed accordingly, and attaching the form.

Thanks,

Madhu.

Avatar

Correct answer by
Level 2

as i am seeing the attachment as queued, i am attaching the document once again,

anyways please check that i have changed the untitled subform name to subform1

Avatar

Level 1

Thank you very much for all your help. It works just like you said!

-Thanks,

nbharpe

Avatar

Level 1

madhu,

One more additional question for you. On my pdf file, you can see that I have multiple lines under each column (catalog number, description, amount, quantity, unit price). I now know how to customize the very first row of the order form, but when I tried to do the same thing to the second row, it did not work and instead of placing the unit price in the second row of the unit price colum it places it in the first row of the unit price column. Any ideas??

Avatar

Level 2

hi nbharpe,

As the Unitprice field was same for all the columns, it was going to the first row itself.

i have changed the field names and script accordingly as UP0, UP1,.....UP6 unitprice fieldnames.

please find the attachment of the updated form.

Thanks,

Madhu.

Avatar

Level 2

as it is showing queued i am uploading once again.

Avatar

Level 2

file attached,

if not give me your email id i will forward to that.

Thanks,

Madhu.

Avatar

Level 1

madhu,

yeah looks like it is still showing up as queued, so here is my email: nbharpe@gmail.com. Thanks for your help!

Avatar

Level 1

madhu,

not sure if you received my last message, but I am just going to give you my email one more time: nbharpe@gmail.com. Sorry if there is any confusion.

Avatar

Level 2

hi,

i have forwarded the sample form to your id mentioned.

Thanks,

Madhu.