Announcement

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

    Any way to add properties in dsRequest to send to server?

    v12.1p_2020-12-19/LGPL Development Only

    I using RestDatasource to fetch data from server, while using transformRequest() method , i added some property into dsRequest , it seems that additional property are not serialized and send to server. this is my RestDataSource configuration.

    Code:
    isc.RestDataSource.create({
      ID: "countryDS",
      dataFormat: "json",
      fields: [
        { name: "countryCode", title: "Code" },
        { name: "countryName", title: "Country" },
        { name: "capital", title: "Capital" }
      ],
      cacheAllData: false,
      operationBindings: [{
        operationType: "fetch",
        dataProtocol: "postMessage",
        dataURL: "./Handler1.ashx",
        requestProperties: {
          httpHeaders: {
            DataName: "OrderTypeLookup",
            DataType: "View"
          },
        }
      }],
      transformRequest: function (dsRequest) {
        dsRequest.masterRequest = true;
        dsRequest.authorityKey = "idojdsfj823479jr9234srh";
        dsRequest.data = JSON.stringify({ abc: 1234 });
        this.Super("transformRequest", arguments);
      },
    })
    the default json object dsRequest send to server
    Code:
    {
    "dataSource": "countryDS",
    "operationType": "fetch",
    "textMatchStyle": "exact",
    "componentId": "abcde",
    "data": "{"abc":"1234"}",
    "oldValues": null
    }
    i would like add more properties into json object for dsRequest which something like this ( added "masterRequest" and "authorityKey" property
    Code:
    {
    "dataSource": "countryDS",
    "operationType": "fetch",
    "textMatchStyle": "exact",
    "componentId": "abcde",
    "masterRequest:"true",
    "authorityKey": "idojdsfj823479jr9234srh",
    "data": "{"abc":"1234"}",
    "oldValues": null
    }
    Last edited by chuan9797; 9 Aug 2023, 19:04.

    #2
    The correct way to add additional properties to the dsRequest object is through the rpcRequest.params attribute. Take a look at the documentation here ("Server inbound data formats" section) for further details. Additionally, it's suggested to review the documentation for RestDataSource.transformRequest() to know more about how to implement it.

    Best Regards
    Isomorphic Software

    Comment

    Working...
    X