Played around with this over the weekend. Still no joy with oldValues.
FYI, the scenario here is as follows:-
A datasource talking to a WSDL webservice using standard wsOperation(s) (no callOperation() involved).
A DynamicForm using the datasource (specified above) and an initial call to the form’s fetchData() method.
The web service returns a single record.
Initial changes are made to the data in the form.
The oldValues data is correct on the very first update.
On any subsequent changes to the form’s data, oldValues is not updated causing bogus optimistic concurrency errors on the server.
A code sample of the above is shown below. FYI, in the sample code, I have added some additional code to handle “oldVals”.
Can you clarify whether in the circumstances described, oldValues should be updated after each subsequent update back to the webservice? If so, kindly let me know what, if anything, I am doing wrong.
Thanks.
// Base sms DataSource class
// Custom "oldVals" support added
isc.defineClass("SmsDS", "DataSource").addProperties({ oldVals: [] });
isc.SmsDS.create({
ID: "standDS",
xmlNamespaces : { sms : "urn:sms.stand" },
recordXPath: "//sms:StandData/sms:CurrentStand",
serviceNamespace: "urn:sms.stand",
operationBindings: [
{ operationType: "fetch", wsOperation: "Fill" },
{ operationType: "update", wsOperation: "Update" }],
fields: [
{ name: "StandId", title: "Stand Id", primaryKey: "true", hidden: true},
{ name: "StandName", title: "Stand Name"},
{ name: "StandLocation", title: "Stand Location"},
{ name: "StandCode", title: "Stand Code"},
{ name: "AddId", title: "Address Id", hidden: true},
{ name: "StandPhone", title: "Stand Phone"},
{ name: "StandFax", title: "Stand Fax"},
{ name: "StandEmail", title: "Stand Email"}
],
transformRequest: function(dsRequest){
if (dsRequest.operationType == "update") {
var orig = isc.addProperties( {}, standDS.oldVals );
var curr = isc.addProperties( {}, dsRequest.data);
var stan = { OriginalStand: orig, CurrentStand: curr };
var structure = {
stand: {
StandData: stan
}
}
dsRequest.data = structure;
}
return dsRequest.data;
}});
isc.DynamicForm.create({
ID: "standForm",
dataSource: standDS,
autoDraw: false,
width: 250,
fields: [
{ name: "StandName" },
{ name: "StandLocation" },
{ name: "StandCode" },
{ name: "StandPhone" },
{ name: "StandFax" },
{ name: "StandEmail" },
{
name: "saveBtn",
title: "Save",
colSpan: 2,
align: "right",
startRow: true,
type: "button",
click: function() {
standForm.saveData(function (dsResponse, data, dsRequest) {
// Custom "oldVals" support added
standDS.oldVals = data },
{ useHttpProxy: true });
}
}]
});
standForm.fetchData(null, function(dsResponse, data, dsRequest) {
// Custom "oldVals" support added
standDS.oldVals = data[0] },
{ useHttpProxy: true } );
isc.HLayout.create({
showEdges:true,
height:250, membersMargin:5, layoutMargin:10,
members:[
standForm
]
})