araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

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

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?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

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

Hello,

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

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

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

Hi Igor.

I have shared out the script.

Regards,

Alon

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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

Return to “Issues”