Hi Bart,
I’m doing it in parallel.
No I don’t get logout from Matrix.
So i’m using the batchRequest to retrieve the metadata then create a standard page asset within a loop there a callback method to set the metadata schema and then set the metadata fields.
function matrixGetChildern() {
var parent = document.getElementById(“newrent”).value;
js_api.getChildren({
“asset_id”:“204030”,
“levels”:2,
“type_codes”:[
“page_standard”
],
“link_types”:[
“SQ_LINK_TYPE_1”,
“SQ_LINK_TYPE_2”
],
“get_attributes”:0,
“dataCallback”:getMeta
})
}
function getMeta(object) {
var id;
var sname;
var str = JSON.parse(JSON.stringify(object));
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”:409449,
“type_code”:“page_standard”,
“asset_name”:sname,
“link_type”:1
}
}
},
“dataCallback”:setMeta
});
}
}
function setMeta(o){
//var t = JSON.parse(o);
//alert(t);
var i = o[1].id;
var title = o[0][‘Event.Title’];
var sdate = o[0][‘Event.Start.Date’];
var edate = o[0][‘Event.End.Date’];
var leadtext = o[0][‘Event.Lead.Text’];
var description = o[0][‘Event.Short.Description’];
var pagetype = o[0][‘Page.Type’];
var school = o[0][‘Page.School’];
var location = o[0][‘Event.Venue’];
var disOnHome = o[0][‘Display.On.Homepage’];
var eventAuthor = o[0][‘Event.Author’];
var pageEventType = o[0][‘Page.Event.Type’];
var fsd = formatDate(sdate);
var fed = formatDate(edate);
var fst = formatTime(sdate);
var fet = formatTime(edate);
//alert(i);
/js_api.editMetadataSchema({
“assetid”:i,
“schemaid”:“364176”,
“set”:1,
“granted”:1,
“cascades”:1
});/
js_api.batchRequest({
“functions”:{
“0”:{
“function”:“editMetadataSchema”,
“args”:{
“asset_id”:i,
“schemaid”:“364176”,
“set”:1,
“granted”:1,
“cascades”:1
},
“blocking”:1
},
“1”:{
“function”:“setMetadataAllFields”,
“args”:{
“asset_id”:i,
“field_info”:{
“364178”:title,
“364184”:leadtext,
“364185”:description,
“10702”:pagetype,
“15953”:school,
“364179”:fsd,
“364180”:fed,
“364183”:location,
“409662”:disOnHome,
“364181”:fst,
“364182”:fet,
“15965”:pageEventType
}
}
}
}
});
}
Thanks
Danny