Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello,
There is a way to Add/Modify the data table entry, by using a service "AddDataTableEntry" or "AddOrUpdateDataTableEntry", but I can also see that these services also have a return value (string) which is id. I would like to know what is this return 'id'?
Thanks
Aditya Mittal
Solved! Go to Solution.
From my own documentation when I dealed with it:
"Standard AddDataTableEntry service, returns the newly created id, which it's totally unuseful, you can't query entries by this id, but you can query entries with "key", then we return the corresponding newly created "key" value not the id."
Then based on the values passed as password I have this code to recover the real newly created key:
var result = ""; var rowValues = values.rows[0]; var nVmepk = me.pk.rows.length; var entry; for (var i=0;i<nVmepk;i++) { entry = me.pk.rows[i]; if ((entry.baseType==="INTEGER")||(entry.baseType==="LONG")) { result += (""+parseInt(rowValues[entry.name],10)); } else { result += rowValues[entry.name]; } }
The previous code depends on having a property called pk with Infotable Pk fields
this pk fields property can be filled with:
// -- Calculate Primary Keys var dsName = me.GetDataShape(); var ds = DataShapes[dsName]; var fields = ds.GetDataShapeMetadataAsJSON().fieldDefinitions; me.pk = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({ infoTableName : "InfoTable", dataShapeName : "FieldDefinition" }); me.pk.AddField({ name: "ordinal", baseType: "INTEGER" }); for (var property in fields) { if (fields.hasOwnProperty(property)) { if (fields[property].aspects) { if (fields[property].aspects.isPrimaryKey) { me.pk.AddRow({ name: property, isPrimaryKey: true, baseType: fields[property].baseType, description: fields[property].desription, dataShape: dsName, ordinal: fields[property].ordinal }); } } } }
Just my experience.
From my own documentation when I dealed with it:
"Standard AddDataTableEntry service, returns the newly created id, which it's totally unuseful, you can't query entries by this id, but you can query entries with "key", then we return the corresponding newly created "key" value not the id."
Then based on the values passed as password I have this code to recover the real newly created key:
var result = ""; var rowValues = values.rows[0]; var nVmepk = me.pk.rows.length; var entry; for (var i=0;i<nVmepk;i++) { entry = me.pk.rows[i]; if ((entry.baseType==="INTEGER")||(entry.baseType==="LONG")) { result += (""+parseInt(rowValues[entry.name],10)); } else { result += rowValues[entry.name]; } }
The previous code depends on having a property called pk with Infotable Pk fields
this pk fields property can be filled with:
// -- Calculate Primary Keys var dsName = me.GetDataShape(); var ds = DataShapes[dsName]; var fields = ds.GetDataShapeMetadataAsJSON().fieldDefinitions; me.pk = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({ infoTableName : "InfoTable", dataShapeName : "FieldDefinition" }); me.pk.AddField({ name: "ordinal", baseType: "INTEGER" }); for (var property in fields) { if (fields.hasOwnProperty(property)) { if (fields[property].aspects) { if (fields[property].aspects.isPrimaryKey) { me.pk.AddRow({ name: property, isPrimaryKey: true, baseType: fields[property].baseType, description: fields[property].desription, dataShape: dsName, ordinal: fields[property].ordinal }); } } } }
Just my experience.
Hi @amittal-3.
If the response provided by @CarlesColl answered your question, please mark it as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon