Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Test for existence of field on form

Avatar

Level 2

Hello,

How do I test, using JavaScript, whether a specific field exists on a form or not?  I tried the following, but not  quite working:

if (xfa.layout.absPage(pg1.sfCap.sfCapLeft.Table2.Row2) == -1 )

{

}

Note: For the form where I tried this, the Row2 does not exist at all

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The resolveNode function (see http://help.adobe.com/en_US/livecycle/9.0/designerHelp/001395.html) can be used to retrieve the value of a specific node within a table row. You will still need to determine the row count and iterate over the table row instances in conjunction with resolveNode().

Steve

View solution in original post

4 Replies

Avatar

Former Community Member

You could test if the row count of a table. For example, form1.page1.subform1.table._row.count could be compared to form1.page1.subform1.table._row.occur.min to test if a new row had been dynamically added to the form.

Steve

Avatar

Level 2

So there's no exists() function that can return whether an item is found on a form or not?  I'm trying to create a fragment that will work for multiple forms, but part of the solution is that it must be able to determine if a certain item exists on a form AND that the code does not fail just because the item isn't found at all.  Thanks.

Avatar

Correct answer by
Former Community Member

The resolveNode function (see http://help.adobe.com/en_US/livecycle/9.0/designerHelp/001395.html) can be used to retrieve the value of a specific node within a table row. You will still need to determine the row count and iterate over the table row instances in conjunction with resolveNode().

Steve

Avatar

Level 2

Thanks; I'll give that a try.

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] ----