Announcement

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

    clientCustom and asynchronous transformRequest

    Hi,

    I am creating custom DataSource using local data stored in PouchDB.
    To implement filtering according to AdvancedCriteria, I need to fetch all records and filter them app-side.

    Here is dummy code:
    Code:
    transformRequest: function(dsRequest) {
      getAllRecordsFromDBAndReturnPromise().then(allRecords => {
        const dsResponse = {
          status: isc.DSResponse.STATUS_SUCCESS,
          data: this.applyFilter(records, dsRequest.data || {}, dsRequest),
        };
        this.processResponse(dsRequest.requestId, dsResponse);
      });
    }
    This does not work however as during the call to applyFilter dsRequest.data is not initial criteria, but undefined.
    It was not clear to me in transformRequest documentation, that you need to return dsRequest or dsRequest.data even for clientCustom protocol. Lack of return means implicitly returning undefined which is then saved to dsRequest.data back in datasource.sendDSRequest.
    On the moment promise resolves and we continue processing, dsRequest is already modified by:
    Code:
      var transformedData = this.transformRequest(dsRequest);
      // correct the common error of returning the dsRequest itself incorrectly, which is
      // never right since the dsRequest contains various widgets and other data
      // inappropriate to send to the server.
      if (transformedData !== dsRequest) {
        dsRequest.data = transformedData;
      }
    Maybe you could update documentation about that or ignore undefined result from transformRequest.

    Best regards,
    Janusz

    #2
    The first line of the docs is [quote]For a dataSource using client-side data integration, return the data that should be sent to the dataURL.[/url] and the inline sample shows a return statement.

    Comment


      #3
      Sure, but n-th line of the docs says: Special case: If the dataProtocol is "clientCustom" the SmartClient system will not attempt to send data to the server in any way

      So you can assume that no matter what you will return or not, it shouldn't matter.

      Comment


        #4
        You are transforming the DSRequest, so, it transforms the DSRequest. Later, when you try to execute the clientCustom protocol, you have the transformed DSRequest.

        Comment

        Working...
        X