Get assetID of asset created with javascript api


(Mahearnpad) #1

I want to be able to create a folder asset, then in the same script, create a number of folder assets under this first folder.


OK, I can do these things separately - but what I'm having trouble with is how to get the assetID of the first created folder asset, so that I can pass that to the createAsset method for the child assets to be created.



Is this possible?


(Benjamin Pearson) #2

Look at the return value of createAsset() if the asset was created successfully, it should return the name, assetid and the linkid of the new asset.


(Mahearnpad) #3

[quote]
Look at the return value of createAsset() if the asset was created successfully, it should return the name, assetid and the linkid of the new asset.

[/quote]



Thanks Benjamin. It'd be good if the documentation was more detailed as to return values from methods.


(Benjamin Pearson) #4

[quote]
Thanks Benjamin. It'd be good if the documentation was more detailed as to return values from methods.

[/quote]



I will get them added into the manual. Thanks for your input.


(Anton Babushkin) #5

If you're using Firefox or a Webkit browser (or even IE8 for that matter) you can also use the console.log() function to find out what JSON the callback function is giving back to you.


i.e. createAsset(…, …, function(data){ console.log(data) });



If you're in Firefox it's pretty easy to go through an inspect the object afterwards.


(Josh Sherwood) #6

[quote]
Thanks Benjamin. It'd be good if the documentation was more detailed as to return values from methods.

[/quote]



Thanks for the feedback Michael. The Javascript API chapter in the Web Services manual now lists the return parameters (or success message) for all functions.


(Mahearnpad) #7

[quote]
Thanks for the feedback Michael. The Javascript API chapter in the Web Services manual now lists the return parameters (or success message) for all functions.

[/quote]



Thanks for the replies and thanks for updating the documentation. We can consider this thread closed.