SmartClient Version: v13.1p_2025-01-18/AllModules Development Only (built 2025-01-18)
Hello, please try the singleSourceValidation sample modified as in this testcase:
If you run it and click 'Save', you won't see a request. In fact, vm.getErrors() will indicate that the description is required. However, the applyWhen condition isn't satisfied, so I didn't expect this. Is it a bug, or am I missing something?
Hello, please try the singleSourceValidation sample modified as in this testcase:
Code:
<DataSource isSampleDS="true" ID="supplyItem" serverType="sql" tableName="supplyItem" titleField="itemName" testFileName="/examples/shared/ds/test_data/supplyItem.data.xml" dbImportFileName="/examples/shared/ds/test_data/supplyItemLarge.data.xml" > <fields> <field name="itemID" type="sequence" primaryKey="true"/> <field name="itemName" type="text" title="Item" length="128" required="true"/> <field name="SKU" type="text" title="SKU" length="10" required="true"/> <field name="description" type="text" title="Description" length="2000"> <validators> <validator type="required"> <applyWhen fieldName="SKU" operator="isNull"/> </validator> </validators> </field> <field name="category" type="text" title="Category" length="128" required="true" foreignKey="supplyCategory.categoryName"/> <field name="units" type="enum" title="Units" length="5"> <valueMap> <value>Roll</value> <value>Ea</value> <value>Pkt</value> <value>Set</value> <value>Tube</value> <value>Pad</value> <value>Ream</value> <value>Tin</value> <value>Bag</value> <value>Ctn</value> <value>Box</value> </valueMap> </field> <field name="unitCost" type="float" title="Unit Cost" required="true"> <validators> <validator type="floatRange" min="0" errorMessage="Please enter a valid (positive) cost"/> <validator type="floatPrecision" precision="2" errorMessage="The maximum allowed precision is 2"/> </validators> </field> <field name="inStock" type="boolean" title="In Stock"/> <field name="nextShipment" type="date" title="Next Shipment"/> </fields> </DataSource>
Code:
isc.ValuesManager.create({ ID: "vm", dataSource: "supplyItem" }) isc.DynamicForm.create({ ID: "dynamicForm", valuesManager: "vm", fields:[ {name:"itemName"} ] }); isc.IButton.create({ ID: "saveButton", title: "Save", click: "vm.saveData()" }); isc.IButton.create({ ID: "clearErrorsButton", title: "Clear Errors", click: "dynamicForm.clearErrors(true)" }); isc.IButton.create({ ID: "disableValidationButton", autoFit: true, title: "Disable Validation", click: function () { dynamicForm.disableValidation = !dynamicForm.disableValidation; this.setTitle((dynamicForm.disableValidation ? "Enable" : "Disable")+" Validation"); } }); isc.HStack.create({ ID: "buttons", height: 24, membersMargin: 10, members: [saveButton, clearErrorsButton, disableValidationButton] }); isc.VLayout.create({ membersMargin: 10, members: [dynamicForm, buttons] }); vm.fetchData({SKU:90600})