Hello,
I am experimenting with the velocity expression validation which can be defined on a DS field. We are using the latest nightly and testing on FireFox.
I have managed to get a basic expression working on one of my DS fields. The expression that is working uses the $record variable and checks for some dummy text string to be present in the text field.
(The reference field is one of our own simple types, which has a text member variable)
I tried to go to the next level by referencing another field of the DS, beyond the record scope. But all my attempts are failing. I have tried a number of combinations as follows, they are all giving me nullpointer errors on the 'contains' function or syntax errors.
I access the reference field because I know that it was working using the simple expression. In real life I will be accessing other field of the DS.
These are the relevant extracts of our DS definitions.
This is the definition of the 'incidents' instance I am referencing in my expression.
Could you please indicate what I am doing wrong here. Is it the array access which I am approaching incorrectly or is it the $dataSource variable that needs another syntax or something?
thanks a lot!
I am experimenting with the velocity expression validation which can be defined on a DS field. We are using the latest nightly and testing on FireFox.
I have managed to get a basic expression working on one of my DS fields. The expression that is working uses the $record variable and checks for some dummy text string to be present in the text field.
Code:
$util.contains($record.reference.text, 'test')
I tried to go to the next level by referencing another field of the DS, beyond the record scope. But all my attempts are failing. I have tried a number of combinations as follows, they are all giving me nullpointer errors on the 'contains' function or syntax errors.
Code:
$util.contains($dataSource.incidents(0).reference.text, 'test') $util.contains($dataSource.incidents[0].reference.text, 'test') $util.contains($dataSource.incidents.get(0).reference.text, 'test') $util.contains($ListTool($dataSource.incidents, 0).reference.text, 'test')
These are the relevant extracts of our DS definitions.
Code:
<DataSource ID="FineSessDTO__-1_4_1_100011_100008" dropExtraFields="true" sparseUpdates="true"> <fields> <field name="sessDtoId" canEdit="false" defaultValue="-2000000" type="integer" primaryKey="true" required="true" hidden="true" /> <field name="fines" type="247__-1_4_1_100011_100008" javaClass="dto.incident.FineDTO" multiple="true" /> <field name="appeals" type="384__-1_4_1_100011_100008" javaClass="dto.incident.AppealDTO" multiple="true" /> <field name="fineFees" type="403__-1_4_1_100011_100008" javaClass="dto.contract.FineFeeDTO" multiple="true" /> <field name="incidents" type="237__-1_4_1_100011_100008" javaClass="dto.incident.IncidentDTO" multiple="true" /> <field name="involvedParties" type="383__-1_4_1_100011_100008" javaClass="dto.incident.InvolvedPartyDTO" multiple="true" /> </fields> <serverObject ID="FineSessStore" lookupStyle="new" className="server.stores.fine.FineSessStore"/> <operationBindings> <binding operationId="IFineOutpost.checkIncident" operationType="custom" serverMethod="checkIncident"/> <binding operationId="IFineOutpost.completeIncident" operationType="custom" serverMethod="completeIncident"/> <binding operationId="IFineOutpost.getNewFine" operationType="custom" serverMethod="getNewFine"/> <binding operationId="IFineOutpost.generateNewInstance" operationType="fetch" serverMethod="generateNewInstance"/> </operationBindings> </DataSource>
Code:
<DataSource ID="237__-1_4_1_100011_100008" dropExtraFields="true" sparseUpdates="true"> <fields> <!-- more fields --> <field sraId="1496" name="reference" title="reference" type="silkString" javaClass="parameter.SraString" isBusinessKey="true" crud="15" > <validators> <validator type="serverCustom" validateOnChange="true"><serverCondition><![CDATA[$util.contains($dataSources.incidents[0].reference.text, 'jasa')]]></serverCondition><errorMessage>This is a validation test</errorMessage></validator></validators> </field> <!-- more fields --> </fields> </DataSource>
thanks a lot!
Comment