var Asset = PlanningModel_1.getMembers("D_ASSET");
console.log(Asset.length);
var last_id = 0;
if(Asset.length > 1) {
last_id = Asset.length;
}
console.log("last id:");
console.log(last_id);
var str = Asset_1.getUnit();
var str1 = str.split("},{");
var entity = "";
var ID = "";
var DESCRIPTION = "";
var ASSET_TYPE = "";
var COMPANY_CODE = "";
var ASSET_CLASS = "";
var COST_CENTER = "";
var CWIP = "";
var Ar_ID = ArrayUtils.create(Type.string);
var Ar_DESCRIPTION = ArrayUtils.create(Type.string);
var Ar_ASSET_TYPE = ArrayUtils.create(Type.string);
var Ar_COMPANY_CODE = ArrayUtils.create(Type.string);
var Ar_ASSET_CLASS = ArrayUtils.create(Type.string);
var Ar_COST_CENTER = ArrayUtils.create(Type.string);
var Ar_CWIP = ArrayUtils.create(Type.string);
for(var x=0; x<str1.length; x++) {
var str2 = str1[x].split(",");
for(var y = 0; y<str2.length; y++) {
entity = str2[y].replace("[{", "");
entity = str2[y].replace("}]", "");
//ID
if(y === 0) {
ID = entity.split(":")[1];
ID = ID.replace('"','');
ID = ID.replace('"','');
Ar_ID.push(ID);
}
//DESCRIPTION
if(y === 1) {
DESCRIPTION = entity.split(":")[1];
DESCRIPTION = DESCRIPTION.replace('"','');
DESCRIPTION = DESCRIPTION.replace('"','');
Ar_DESCRIPTION.push(DESCRIPTION);
}
//ASSET_TYPE
if(y === 2) {
ASSET_TYPE = entity.split(":")[1];
ASSET_TYPE = ASSET_TYPE.replace('"','');
ASSET_TYPE = ASSET_TYPE.replace('"','');
Ar_ASSET_TYPE.push(ASSET_TYPE);
}
//COMPANY_CODE
if(y === 3) {
COMPANY_CODE = entity.split(":")[1];
COMPANY_CODE = COMPANY_CODE.replace('"','');
COMPANY_CODE = COMPANY_CODE.replace('"','');
Ar_COMPANY_CODE.push(COMPANY_CODE);
}
//ASSET_CLASS
if(y === 4) {
ASSET_CLASS = entity.split(":")[1];
ASSET_CLASS = ASSET_CLASS.replace('"','');
ASSET_CLASS = ASSET_CLASS.replace('"','');
Ar_ASSET_CLASS.push(ASSET_CLASS);
}
//COST_CENTER
if(y === 5) {
COST_CENTER = entity.split(":")[1];
COST_CENTER = COST_CENTER.replace('"','');
COST_CENTER = COST_CENTER.replace('"','');
Ar_COST_CENTER.push(COST_CENTER);
}
//CWIP
if(y === 6) {
CWIP = entity.split(":")[1];
CWIP = CWIP.replace('"','');
CWIP = CWIP.replace('"','');
Ar_CWIP.push(CWIP);
}
}
}
console.log(Ar_ID);
console.log(Ar_DESCRIPTION);
console.log(Ar_ASSET_TYPE);
console.log(Ar_COMPANY_CODE);
console.log(Ar_ASSET_CLASS);
console.log(Ar_COST_CENTER);
console.log(Ar_CWIP);
Application.showBusyIndicator();
var idx = last_id;
for(var i=0; i<Ar_ID.length; i++) {
idx = idx + 1;
g_properties = ({
id: Ar_ID[i],
description: Ar_DESCRIPTION[i],
hierarchies: {
H1: {parentId: Ar_ASSET_TYPE[i]},
},
properties: {
COMPANY_CODE: Ar_COMPANY_CODE[i],
ASSET_CLASS: Ar_ASSET_CLASS[i],
COSTCENTER: Ar_COST_CENTER[i],
CWIP: Ar_CWIP[i],
}
});
var result = PlanningModel_1.createMembers("D_ASSET",g_properties);
if(result)
{
Application.showMessage(ApplicationMessageType.Success,Ar_ID[i]+ "-New Asset Created Sucessfully");
}
else{
Application.showMessage(ApplicationMessageType.Error,Ar_ID[i]+ "-Failed to Create Asset");
}
console.log(result);
}
Application.hideBusyIndicator();
Table_1.getDataSource().refreshData();
2. Click on Browse -> select the Excel File -> click on Upload.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 |