I have two tables with identically named columns: one to hold the data, and one to hold the actual text/display names of the field labels (2 records, 1 for English and 1 for French). Using a relationship via a global, I can switch from one language to another methodically if I set each labels dataprovider to point to the label name via the relation.
My (newbie) question is: Instead, how can I loop through each label to show the text in the language chosen via the global and the realtionship?
Any help appreciated - I searched the forum for a similar post, but came up empty, so I’m sorry if this question has already been answered here.
//process all named elements on a form
for ( var i in elements ) {
//name labels that you want to process with prefix of "lbl_..."
if (elements[i].getName().substring(0,3) == "lbl") {
//assign a data value to the text property of a label
elements[i].text = relationshipName.fieldName
}
}
Thanks a lot David. How can I make sure that the correct field content gets placed on the corresponding labels using “relationshipName.fieldName”? I would imagine I have to set that to a variable also, and loop through each iteration…
I usually derive the field real name from the name I give it. Assuming you want the label data provider to be set to “group_name”, name the label “lbl_group_name”. Then this assignment will work:
With this naming convention a small block of code can be used to set as many labels on a form as you want.
And processing the whole element tree means you don’t have to assign a method to each individual label you put on the form – just attach the method to the form onRecordSelection() event.