Page 1 of 1

how to get the ID of newly created object using Collection.CreateObject

Posted: Fri Jan 31, 2014 11:41 pm
by araskin3i

I have created a server side script which calls Collection.CreateObject to update a table in the Appery DB. it works great but I expected (according to the documentation at http://docs.appery.io/documentation/b...) that it will return a JSON object which has the ID of the newly created row. However I am not receiving this

stockreportHeader = Collection.createObject(DB_id, "stockReportHeader", {"stockId": stockreportHeader.stockId });

console.log("New stock report ID : ") + stockreportHeader;
I also tried:

console.log("New stock report ID : ") + stockreportHeader._id;

However the output in the trace shows that the stockreportHeader variable is empty. Any ideas?


how to get the ID of newly created object using Collection.CreateObject

Posted: Sat Feb 01, 2014 5:16 am
by Igor

Hello,

Could you share your script with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a?


how to get the ID of newly created object using Collection.CreateObject

Posted: Sat Feb 01, 2014 11:31 am
by araskin3i

Hi Igor.

I have shared out the script.

Regards,

Alon


how to get the ID of newly created object using Collection.CreateObject

Posted: Mon Feb 03, 2014 10:47 am
by Kateryna Grynko

Hi Alon,

This line is incorrect:preconsole.log("New stock report ID : ") + stockreportHeader;/pre
To output a variable 'stockreportHeader' in console use this code:preconsole.log("New stock report ID : " + stockreportHeader);/pre