Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

FormCalc & nodes

Avatar

Former Community Member
Hello.In javascript we can easily do the following:

var oRecord = xfa.record.nodes.item(1);

and assign a node to a variable.

But in formcalc the same thing produces an error: "invalid property get operation.dataGroup doesn't have a default property". Can anyone explain this and maybe give a sollution? Thanks, jim.
6 Replies

Avatar

Level 4
FormCalc is a different Language than JavaScript. It has it's own node path format, expression syntax, and functions.



You need the FormCalc Reference.

Here's a link to all of the related XFA Documentation



http://partners.adobe.com/public/developer/xml/index_arch.html#afo



Thom Parker

WindJack Solutions


www.windjack.com

Avatar

Former Community Member
Thank you for your answer but these references are not a very big help actually.They don't even mention the syntax of 'for' or 'while' loop in formcalc! If anyone else has a more precise answer i would appreciate it.

Avatar

Level 4
I've used the following FormCalc code successfully in a Calculation Script for placing the current DB value into a text field. The DB table is "CustomerOrders" and the column is "Address"



All of these SOM expressions are equivalent



xfa.record.CustomerOrders.Address

$record.CustomerOrders.Address

$record..Address

$record.*[0].Address

$record.*[0].*[0]



I found the information for building these expressions in the Adobe documentation. I also looked around for FormCalc Loop operators. Didn't find any. From the FormCalc Language Specification it appears that such an animal does not exits.



Thom Parker

WindJack Solutions


www.windjack.com

Avatar

Former Community Member
Thanks for the answer, this helped, but the examples you gave return only the first tupple of column "Address" of table "CustomerOrders".If I want to have access to all of the data of column "Address" how am I going to achieve this? I have already tried $record.CustomerOrders.Address[*] but it returns only the first row, not all of them as i wish.

Avatar

Level 4
In general, Databases are structured for woriking on a single record at a time. I've worked on database software in several different programing languages and API's and in every one you have to walk the records to get all the data in a column. Designer JS is no different.



Here's some code that walks the records in a DB table.



var oDB = xfa.sourceSet.ProductData;

var oRec = xfa.record.ProductData;

oDB.open();

oDB.first();

while(!oDB.isEOF())

{

console.println(oRec.ProductName.value);

oDB.next();

}

oDB.close();



Thom Parker

WindJack Solutions


www.windjack.com

Avatar

Former Community Member
Thanks Thom, your code works fine.If someone wants this code in formcalc:



xfa.sourceSet.ProductData.open();

xfa.sourceSet.ProductData.first();



while( not xfa.sourceSet.ProductData.isEOF() ) do

$host.messageBox($record.ProductData.ProductName);

xfa.sourceSet.ProductData.next();

endwhile



xfa.sourceSet.ProductData.close();