Hello
I m trying to create an Aris Macro that insert a symbole based on a value of a model attribut.
I m getting the error : "Model not opened" : when i trie to insert the symbole in the model,
but not in every case : with some models it works fine, other not.
here is the code :
var g = Context.getSelectedGroups();
var tabg = new Array();
tabg[0]=g[0];
//Dialogs.MsgBox(Explorer.getChildren (g[0], g[0].getItemKind( )));
getcc(g[0]);
function getcc(gr){
var l = new Array();
if(gr!=undefined){
l=Explorer.getChildren(gr,gr.getItemKind());
for(var i=0; i<=l.length; i++){
nl=tabg.length;
if(l[i]!=undefined){ tabg[nl]=l[i];
// Dialogs.MsgBox(Explorer.getChildren ( g, g.getItemKind ( )));
getcc(l[i]);}
}
}}
var mod = new Array();
mod[0]=0;
for (j=0; j<=tabg.length; j++){
if(tabg[j]!=undefined){ var fff = Explorer.getChildren(tabg[j],Constants.CID_MODEL);
for(c=0; c<=fff.length; c++){
var nlj=mod.length;
if(Explorer.getChildren(tabg[j],Constants.CID_MODEL)[c]!=undefined){ mod[nlj] = Explorer.getChildren(tabg[j],Constants.CID_MODEL)[c];}
}}}
//var obl = Context.getSelectedObjects();
for(m=1; m<=mod.length; m++){
if (mod[m]!=undefined){
// Dialogs.MsgBox("It: "+mod[m].getType ( ));
if(mod[m].getType()=="65549"){
Designer.openModel(mod[m], false, false, true);
var op=false;
for(var o=0; o<=Designer.getOpenModels().length;o++){
if(Designer.getOpenModels ( )[o]==mod[m]){op=true;}}
if(op==false){Designer.openModel(mod[m], false, false, true);}
// Dialogs.MsgBox(Designer.getAttribute ( mod[m], 461527, null ));
// if( Designer.getAttribute ( mod[m], 461527, null )==Context.getArisMethod().UserDefinedAttributeValueTypeNum ( "b4941451-12c7-11ef-50c6-005056ad4831", "b4a9711f-12c7-11ef-50c6-005056ad4831"))
if( Designer.getAttribute ( mod[m], 461527, null )=="Approuvé")
{
if(Designer.isOpen(mod[m])==false){ Designer.openModel(mod[m], false, false, true);}//ajout
// var texoc= Designer.createTextOcc ( mod[m], 10, 10, "Approuvé", 0,false );
var db= Context.getLoginInfo( Context.getSelectedGroups()[0] ).getDatabase();
var odef=Designer.getObjDefByGUID (db, "4a241121-1433-11ef-438d-8f3c4ff26280" );
Designer.createObjOcc ( mod[m], odef, 65871, java.awt.Point(0,0) );
// Designer.setSize ( mod[m],texoc,java.awt.Dimension(500,500) );
}
if( Designer.getAttribute ( mod[m], 461527, null )=="En traitement")
{ //var texoc=Designer.createTextOcc ( mod[m], 10, 10, "En traitement", 0,false );
// Designer.setSize ( mod[m],texoc, java.awt.Dimension(500,500) );
if(Designer.isOpen(mod[m])==false){ Designer.openModel(mod[m], false, false, true);}//ajout
var db= Context.getLoginInfo( Context.getSelectedGroups()[0] ).getDatabase();
var odef=Designer.getObjDefByGUID (db, "4a241121-1433-11ef-438d-8f3c4ff26280" );
Designer.createObjOcc ( mod[m], odef, 65871, java.awt.Point(0,0) );
}
Designer.closeModel(mod[m]); //ajout
}
}
}
Dialogs.MsgBox("Opération terminée");
Hello Omar,
maybe this can help. Did you check if can write to the model? It could be a question of access rights or locking by another user.
Regards, Martin