Get primary key of inserted row

LabKey Support Forum (Inactive)
Get primary key of inserted row fb9200  2015-05-04 10:15
Status: Closed
 
Hi all,

I use the LABKEY.Query.insertRows() function as the example LABKEY shows to insert a record into a list. In the insertion, I want to get the url with the id number(primary key).

I tried this successCallback function:

successCallback: function(data){
                     window.location =
                        '/wiki/home/Study/demo/page.view?name=confirmation&userid='
                        + LABKEY.Security.currentUser.id;
             },

But this id number does not show my list primary number. Could someone help me about this? How to get the primary key number in the insert function?

Thank you very much.

Anny
 
 
bront responded:  2015-05-04 11:02
hi,

I think you may need to examine the data object passed to the successCallback function.

You might try adding something like the following into the callback and then viewing the results in the JavaScript console.

console.log('success data : ', data);
console.log('success data : ', data.result[0].rows[0].id);

Hope this helps.

cheers,

bront
 
fb9200 responded:  2015-05-05 14:23
Hi Bront,

Thank you very much. I find I can use 'data.rows[0].primarykey' directly.

Best regards,

Anny