Announcement

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

    RestDataSource performCustomOperation JSON

    Using version: v101p_2016-03-07_LGPL
    When I execute a performCustomOperation on a JSON RestDataSource the reply is validated using the schema, this is not what I expect and this is new behaviour. Furthermore, rawData is altered as well, the value is not copied. It would be useful to allow skipJSONValidation (=option on DataSource) on a per operationBinding and setting this default to true for custom operationType.

    #2
    Any response on this? I like to add this behavior to my current build, but only if this will be changed in the upstream builds.

    Comment


      #3
      JSON replies received by a DataSource are parsed into approach JavaScript types according to the declared field type, but this has always been the case, and is a necessity of the way the system works; you cannot, for instance, populate a DataSource field of type "date" with just the JavaScript Strings that would be available from raw JSON - that would be a usage issue.

      If you want to work with raw JSON, you can use RPCRequests and rpcRequest.evalResult - but here again, providing untyped (String) data to components that expect to use typed data (Dates, Booleans, Numbers) would still be invalid, so there seems little point in taking this approach unless the data will never be used with UI components.

      Comment


        #4
        In my mind it does makes sense, let me explain: I have a customer DataSource and I want to perform a task on the customers. My call will be something like isc.DataSource.get('customer').performCustomOperation('myCoolTask',..).
        This operation returns a taskId which I can monitor on the Task DataSource. TaskId isn't a field on customer, but the operation 'myCoolTask' does belong to the Customer!
        So if skipJSONValidation is enabled per operationBinding instead of per DataSource this cool feature will work.
        As a developer I know this call won't return valid customer record, that's the main case I am using the operationType 'custom' in the first place.

        Comment


          #5
          To sum up, you have an operation that returns data that is totally unrelated to the schema of the DataSource. You can either:

          1. use rpcRequest.evalResult, as previously suggested - the operation won't technically be a DataSource request, but for clarity you could put the method you use to invoke it on your RestDataSource instance

          OR

          2. just add the field TaskId to your RestDataSource, even though it doesn't appear in normal responses. As long as it's marked hidden:true, it won't appear in any DataBoundComponents related to this DataSource.

          Comment


            #6
            Note on other solution is to use dataSource.dropExtraFields:false. This should be fine as long as your server isn't returning extra data that you want to be ignored.

            Comment

            Working...
            X