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

if statement in Java Script

Avatar

Level 1

Hi,

I just want to create a simple IF statement. I have looked at two text books and the on-line help but it still does not work.

I have two fields.

One is called "IfTest"

The other is called "PFValue"

If "A" is entered in field "IfTest" then I want the text message "50:50" to appear in the "PFValue" field. If "A" is not entered the I want "50:25:25" to appear.

The formula I have entered in field "PFValue" is :

ProFormaInv.Invoice.PFValueB::calculate - (JavaScript, client)

if (IfTest.rawValue == "A")

"50:50"

Else

"50:25:25"

But it does not work. What have I done wrong? I have attached the pdf form I am creating which is a Pro Forma Invoice.

Regards

Chris C

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Change the code to:

if(ProFormaInv.Invoice.IfTest.rawValue == "A")

{

this.rawValue="50:50";

}

else

{

this.rawValue="50:25:25";

}

Also, your best bet for getting involved in the Designer communinity and responses to your posts is in this forum: http://forums.adobe.com/community/livecycle/livecycle_es/livecycle_designer_es

The forum you are currently in is for Adobe Certified Trainers

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

Change the code to:

if(ProFormaInv.Invoice.IfTest.rawValue == "A")

{

this.rawValue="50:50";

}

else

{

this.rawValue="50:25:25";

}

Also, your best bet for getting involved in the Designer communinity and responses to your posts is in this forum: http://forums.adobe.com/community/livecycle/livecycle_es/livecycle_designer_es

The forum you are currently in is for Adobe Certified Trainers

Avatar

Level 1

Hello Gary,

Thanks for the reply. That works!

To be honest I find the Adobe site a bit confusing. I will join the forum you suggest.

I have been using Life Cycle for about four years but have managed to avoid "If's" till now. However I can see that I need to refine some of the forms that we use.

Regards

Chris Chalcraft

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----