Announcement

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

    Advanced Criteria does not work when it is decoded from json string when it has relative date.

    Hi Support Team,

    We are licensed users of SmartGWT. version : 'v11.0p_2019-06-05/Enterprise Deployment'

    I am facing some problems when converting client json into serverside advanced criteria.

    We save criteria from filterbuilder and later we execute that criterion by converting server-side AdvancedCriteria.

    When we save, we are encoding criteria using the below code
    --
    JSONEncoder jsonEncoder = new JSONEncoder();
    jsonEncoder.setDateFormat(JSONDateFormat.DATE_CONSTRUCTOR);
    String condition =jsonEncoder.encode(filterBuilder.getCriteria().getJsObj());
    ------------------
    In Server code we create AdvancedCriteria using

    AdvancedCriteria ac = AdvancedCriteria.decodeClientCriteria(roadmap.getCondition());
    -----------------------------------------

    Condition String:
    { "_constructor":"AdvancedCriteria", "operator":"and", "criteria":[ { "fieldName":"startDate", "operator":"equals", "value":{ "_constructor":"RelativeDate", "value":"$today" } } ] }

    ----------------------------

    The error we are getting is:
    Trying to compare date type field 'startDate' with org.apache.commons.collections.map.LinkedMap type value in criterion 'equals'

    -----------------------

    Please advise what wrong thing we are doing


    Thanks,
    Revan

    #2
    You need to call:
    Code:
    ac.convertRelativeDates();
    "Normally there is no need to convert relative dates on the server, this is done by default on the client before the request is sent to the server. The primary purpose for converting relative dates on the server is when there is a need to store and use relative dates at a later point such as in an automated job without any involvement from the client."

    See the AdvancedCriteria.convertRelativeDates() and linked DataSource.convertRelativeDates(Criterion) javadocs for more details.

    Comment


      #3
      ac.convertRelativeDates();

      Worked, thank you very much

      Comment

      Working...
      X