I’m trying to utilize the batchRequest operation to use the response of the createAsset ID to be use in the editMetadataSchema function. So basically I’m trying to clone an exciting asset metadata into a new metadata schema.
I’ve read this post about a workaround on parsing the keywords within the batch operation and try suggested solution with no luck of retrieving ID respond on createAsset function.
here is the below code
function getAsset() {
var parent = document.getElementById(“newrent”).value;
js_api.getChildren({
“asset_id”:“204050”,
“levels”:2,
“type_codes”:[
“page_standard”
],
“link_types”:[
“SQ_LINK_TYPE_1”,
“SQ_LINK_TYPE_2”
],
“get_attributes”:0,
“dataCallback”:cloneObject
})
}
function cloneObject(object) {
var id;
var sname;
var str = JSON.parse(JSON.stringify(object));
alert(str);
for(var i = 0;i < str.length;i++){
id = str[i].asset_id;
sname = str[i].name;
idArray.push({“id”:str[i].asset_id});
js_api.batchRequest({
“functions”:{
“0”:{
“function”:“getMetadata”,
“args”:{
“asset_id”:id
},
“blocking”:1
},
“1”:{
“function”:“createAsset”,
“args”:{
“parent_id”:364915,
“type_code”:“page_standard”,
“asset_name”:sname,
“link_type”:1
}
},
“2”:{
“function”:“editMetadataSchema”,
“args”:{
“assetid”:"%results_0_1_id%",
“schemaid”:“364176”,
“set”:1,
“granted”:0,
“cascades”:0
}
}
},
“dataCallback”:finish
});
}
}
Danny