How can I go about saving lastInsertRowId
to a global variable that I can access later to UPDATE a column in my database? I know I am only able to access lastInsertRowId
at the point of trigger, but how can I save that and be able to access it in another location in my program.
I think you can use following of 2 options :
Save it using : Ti.App.Properties.setInt('lastInsertRowId', value);
and fetch it using Ti.App.Properties.getInt('lastInsertRowId');
Using this will make this value persistence ( means value will be available whenever app is launched ).
Save it using Alloy Globals ( only available for the current session of app)
Alloy.Globals.lastInsertRowId= value; //set
var value = Alloy.Globals.lastInsertRowId; //get