[progress Communities] [progress Openedge Abl] Forum Post: Jsdo Record Creation

  • Thread starter Thread starter spandau66
  • Start date Start date
Status
Not open for further replies.
S

spandau66

Guest
I'm attempting to create a new record, but when the record is passed across to the back End, I see the following error: Error parsing JSON: unexpected token: string. (15360) Now to elaborate: (Deletions, Modifications all work fine). The following is based on a Kendo Grid being populated with a JSDO Datasource. The issue is with the JSDO JSRecord construct being passed to the back end. Using the inline editing (Add New) on the Kendo Grid. The JSRecord construct is as expected and I can successfully create data (as seen below). { dsCostCodes: { prods:hasChanges: true, eCostCodes: [ { prods:rowState: "created", prods:clientId: "1463558559605-1258", Company: 0, CostCode: "18-05", Name: "test", ShortName: "test", AccountStatus: "", Deleted: false, Suspended: false, LedgerType: "", RetainedEarningsCostCode: "", RetainedEarningsExpenseCode: "", NotesKey: "", NonRecVATPercentage: 0, EmailAddress: "", UserList: "", UseInPCR: false, HasAttachments: false, HasContacts: false, HasNotes: false, xlcode4: "", ImportMode: "" } ] } } Kendo Grid binding to fields on a Viewer Panel. The JSRecord construct is as NOT expected and contains the "default" and "fields" definitions (as can be seen below - have removed all entries from "default" and "fields") { dsCostCodes: { prods:hasChanges: true, eCostCodes: [ { prods:rowState: "created", prods:clientId: "1463553648779-1258", Company: 9996, CostCode: "17-05", Name: "17-05", ShortName: "17-05", AccountStatus: "", Deleted: false, Suspended: false, LedgerType: "", RetainedEarningsCostCode: "", RetainedEarningsExpenseCode: "", NotesKey: "", NonRecVATPercentage: 0, EmailAddress: "", UserList: "", UseInPCR: false, HasAttachments: false, HasContacts: false, HasNotes: false, xlcode4: "", ImportMode: "", defaults: {}, fields: {}, idField: "_id", _defaultId: "" } ] } } It is this construct that is causing the JSON error highlighted above. When I select my Add Record button, I use the basic code structure grid.addRow(); which is then bound to the fields for input. I enter all the relevant fields. In my Save Event, I use the following construct: var sel = $scope.mainCostGrid.select(); var item = $scope.mainCostGrid.dataItem(sel); var jsdo = $scope.costCodeGridData.transport.jsdo; var rec = jsdo.eCostCodes.findById(item._id); jsdo.autoApplyChanges = false; jsdo.subscribe('AfterSaveChanges', function callback(jsdo, success, request) { jsdo.unsubscribe('AfterSaveChanges', callback, jsdo); if (success) { if (addingRecord) { .... } else { .... } } else { .... rec.rejectRowChanges(); } }, jsdo); if (addingRecord) { rec = jsdo.eCostCodes.add(item); } else { jsdo.eCostCodes.assign(item); } jsdo .saveChanges() .then(function () { console.log("after save"); }); I would appreciate suggests on why my JSRecord construct is different and IF I AM doing the above incorrectly... Martyn

Continue reading...
 
Status
Not open for further replies.
Back
Top