Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • claudiobosticco
    replied
    Originally posted by Blama View Post
    Hi claudiobosticco,

    reading the latest blog post it seems that applyWhen is fully supported in 11.1/6.1.
    Hi Blama, I also noticed it, looking forward to try it.
    Last edited by claudiobosticco; 19 Jan 2017, 07:02.

    Leave a comment:


  • Blama
    replied
    Hi claudiobosticco,

    reading the latest blog post it seems that applyWhen is fully supported in 11.1/6.1.
    (Isomorphic: These are no longer doc'd in 6.1d)

    Best regards
    Blama

    Leave a comment:


  • claudiobosticco
    replied
    Hi Blama, I did notice that thread, but I was hoping that something has changed.
    Actually in the docs I don't see a warning about not using it.
    I still have to try the approach of the other thread.

    Leave a comment:


  • Blama
    replied
    Hi claudiobosticco,

    applyWhen wasn't supported a year ago when found it in the docs as well.
    I don't know if you like the solution, but validating dependent fields is currently best done using this approach as far as I now. (Isomorphic: Please correct me if I'm wrong.)

    Best regards
    Blama

    Leave a comment:


  • validator.dependentFields+applyWhen: dep. field not passed to serverCustom validator

    SmartClient Version: SNAPSHOT_v11.1d_2016-10-27/Enterprise Development Only (built 2016-10-27)

    Chrome on OSX El Capitan

    Hello, please modify the #fetchOperationFS sample like this:
    Code:
    isc.ListGrid.create({
        ID:"dsListGrid",
        width: "100%",
        height: "100%",
        minFieldWidth:80,
        autoFetchData: true,
        canEdit:true,
        dataSource: "supplyItem"
    });
    supplyItem.ds.xml :
    Code:
    <DataSource
        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" hidden="true"       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"/>
            <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>
                <validators>
                    <validator type="serverCustom" dependentFields="category">
                        <applyWhen operator="and">
                            <criteria>
                                <criterion fieldName="category" operator="equals" value="Adding Machine/calculator Roll"/>
                            </criteria>
                        </applyWhen>
                        <errorMessage>custom error message</errorMessage>
                        <serverCondition language="groovy">value.equals("Roll")</serverCondition>
                    </validator>
                </validators>
            </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>
    Then edit a row which has category:"Adding Machine/calculator Roll", and change the units to something other than Roll.
    You'll see in the logs that the category value is not used for the applyWhen and so the validator is inactive:

    Code:
     === 2016-10-28 09:53:11,588 [83-2] DEBUG RPCManager - Processing 1 requests.
      === 2016-10-28 09:53:11,589 [83-2] DEBUG RPCManager - Request #1 (DSRequest) payload: {
          criteria:{
              itemID:1
          },
          values:{
              itemID:1,
              units:"Ea"
          },
          operationConfig:{
              dataSource:"supplyItem",
              repo:null,
              operationType:"update",
              textMatchStyle:"exact"
          },
          componentId:"dsListGrid",
          appID:"builtinApplication",
          operation:"supplyItem_update",
          oldValues:{
              category:"Adding Machine/calculator Roll",
              itemName:"Adding Machine Roll 57x57mm Standard",
              itemID:1,
              unitCost:0.41,
              SKU:"45300",
              inStock:true,
              units:"Roll"
          }
      }
      === 2016-10-28 09:53:11,589 [83-2] INFO  IDACall - Performing 1 operation(s)
      === 2016-10-28 09:53:11,589 [83-2] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2016-10-28 09:53:11,589 [83-2] DEBUG DeclarativeSecurity - DataSource supplyItem is not in the pre-checked list, processing...
      === 2016-10-28 09:53:11,589 [83-2] DEBUG AppBase - [builtinApplication.supplyItem_update] No userTypes defined, allowing anyone access to all operations for this application
      === 2016-10-28 09:53:11,589 [83-2] DEBUG AppBase - [builtinApplication.supplyItem_update] No public zero-argument method named '_supplyItem_update' found, performing generic datasource operation
      === 2016-10-28 09:53:11,687 [83-2] DEBUG DefaultValidators - [builtinApplication.supplyItem_update] on field: 'units' for validator type 'serverCustom', 'applyWhen' is:
      {
          operator:"and",
          criteria:[
              {
                  fieldName:"category",
                  operator:"equals",
                  value:"Adding Machine/calculator Roll"
              }
          ]
      }
      record is:
      {
          itemID:1,
          units:"Ea"
      }
      === 2016-10-28 09:53:11,746 [83-2] DEBUG DefaultOperators - [builtinApplication.supplyItem_update] criterion (class com.isomorphic.criteria.criterion.SimpleCriterion): {
          operatorId:"equals",
          value:"Adding Machine/calculator Roll",
          fieldName:"category"
      }: And
      === 2016-10-28 09:53:11,746 [83-2] DEBUG DefaultOperators - [builtinApplication.supplyItem_update] value (null): isEqualToConfiguredValue
      === 2016-10-28 09:53:11,746 [83-2] DEBUG DefaultOperators - [builtinApplication.supplyItem_update] operand (class java.lang.String): "Adding Machine/calculator Roll": isEqualToConfiguredValue
      === 2016-10-28 09:53:11,746 [83-2] DEBUG DefaultOperators - [builtinApplication.supplyItem_update] passedOp (class java.lang.String): "Adding Machine/calculator Roll": isEqualToConfiguredValue
      === 2016-10-28 09:53:11,746 [83-2] DEBUG DefaultOperators - [builtinApplication.supplyItem_update] isEqualToConfiguredValue returnsfalse
      === 2016-10-28 09:53:11,746 [83-2] DEBUG DefaultOperators - [builtinApplication.supplyItem_update] And 0/0: false
      === 2016-10-28 09:53:11,746 [83-2] INFO  DefaultValidators - [builtinApplication.supplyItem_update] on field: 'units' conditional validator of type 'serverCustom' is: inactive
      === 2016-10-28 09:53:11,747 [83-2] INFO  SQLDataSource - [builtinApplication.supplyItem_update] Performing update operation with
          criteria: {itemID:1}    values: {itemID:1,units:"Ea"}
Working...
X