change OperationType in different scenarios

On certain occasions, I would like to specify a different target web-method for the “fetch” operation type than is specified in the DataSource. This may typically happen in different dynamic forms using the same DS but fetching the data based on different search criteria.

The DSRequest object allows the operationType name to be specified but (as far as I can see), not its value. So, I can’t see how I could specify this in the dynamic form’s fetchData method.

I don’t really want to use callOperation because I don’t want to lose the paging semantics and other benefits of going through the DS.

I have looked through the docs and searched the forum but if the answer is there, I am missing it.

Any assistance would be appreciated.

Thanks.

Sounds like you want multiple operationBindings on your DataSource.

I effectively want multiple wsOperations for the same OperationType.

For example, in different forms, I may want to fetch Customers by SalesManagerId or CustomerId or CustomerSurname. In my webservice, I have three Fill methods:-

FillBySalesManagerId
FillByCustomerId
FillBySurname

In the DataSource, I can only specify a single wsOperation for any given operationType.

So, when I call fetchData on each individual form, how can I tell the DS to use a different wsOperation to the one specified in the DS definition?

See dsRequest.operationId. You can have mutliple operationBindings of the same operationType with different settings (such as wsOperation)

If there’s somewhere that this feature could have been linked to in the documentation so that you could have found it more easily, please suggest.

I spotted operationId before I posted. Here is the help.

Perhaps its just me but, I read the above as suggesting that something can be done with the operationId to “on the server, use dsRequest.getOperationId() to detect the passed operationId and invoke the correct server code.”

I am using webservices and don’t have the opportunity to do anything with the operationId server-side. So, you don’t have to do anything to help me find the documentation. I guess the bottom line is that I don’t actually understand the documentation, at least not in my particular context ie., for web-services as opposed to a server.

Sorry to be so thick.

You’re not so thick :slight_smile: The docs weren’t exactly crystal clear on this use case. Try this revised doc:

I’m not sure my Wife would agree with you :slight_smile:

Anyway, to use an American term, here’s the “skinny”, as far as I am able to understand.

When using a .NET web service (or any web service, I suppose), I needed to specify my “operationId” value in two places. First of all as an adjunct to the operationType:

operationBindings: [
	{ operationType: "fetch", operationId: "fillByCustId", wsOperation: "FillBySmsCustId" }
	,{ operationType: "fetch", operationId: "fill", wsOperation: "Fill" }
	,{ operationType: "fetch", wsOperation: "FillBySurname" }
	],

Secondly, as a request parameter:

addGrid.fetchData(null, function (dsResponse, data, dsRequest) {
	if (data.length >= 1 ) addGrid.selectRecord(data[0]) },
	{ useHttpProxy: true, operationId: "fillByCustId" } );

If I had seen code snippets like the above, as a web service user, I would have “got it” although I appreciate that this would not necessarily be the case for all users.

I noticed some other behaviour that isn’t obvious so I will pass this on in case it is not intended to be this way.

In the operationBindings code (above), the third “fetch” operationType has a wsOperation specified as “FillBySurname” but no specified operationId. If you make a fetchData() call and don’t specify an operationId, SmartClient doesn’t associate the operationId-less fetchData call with the operationId-less operationBinding (in the above example { operationType: “fetch”, wsOperation: “FillBySurname” }) – SmartClient will default to the first “fetch” operationBinding in the array of bindings.

If you specify an operationId as a request parameter that is incorrect or simply doesn’t exist in the array of operationBindings, SmartClient will again default to, in this case, the first “fetch” operationType in the array of operationBindings.

If you specify an operationId as a request parameter that is correct and can be matched to an operationBinding object in the array of operationBindings, then SmartClient will use the correct wsOperation.

So, in summary if SmartClient cannot match the operationId in a request parameter to an item in the array of operationBindings or there are more than one binding for the same operationType but no operationId is specified as a request parameter, SmartClient uses the first matching operationType it finds in the list of operationBindings.

At least, it did do for me.

Hope this helps.