![]() |
| Comments |
var db=ArisData.getActiveDatabase(); // path to the group var group=db.Group(["Rootfolder" , "Models"] , 1033); var model=ArisData.getSelectedModels()[0]; model.ChangeGroup(group);
Hi Mr. Srinivas, this is your code . Hope this is what you need, have a nice day
- Login or register to post comments

Hi Misha,
Thank you very much for your code, But unfortunately its not working, Can you please let me know why you gave 1033 there? Please see the below code:
var outFile = null;
var g_nloc = null;
function main(){
var groups = null;
groups = ArisData.getSelectedGroups();
var db=ArisData.getActiveDatabase(); // path to the group
var group=db.Group(["All ICD's" , "Information carrier diagram"] , 1033);
g_nloc = __toLong(Context.getSelectedLanguage());
outFile = Context.createOutputObject(Context.getSelectedFormat(), Context.getSelectedFile());
outFile.Init(g_nloc);
formatOutput(outFile);
outFile.BeginTable(100, Constants.C_BLACK, Constants.C_WHITE, Constants.FMT_LEFT, 0);
outFile.TableRow();
outFile.TableCell("Model name", 24, getString("TEXT1"), 14, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_CENTER | Constants.FMT_VCENTER, 0);
for(var i = 0; i < groups.length; i++) { // iterate through all groups
var j = 0;
var k = 0;
var models = groups[i].ModelListFilter(Constants.MT_INFO_CARR_DGM);
for(k = 0; k < models.length; k++){ // iterate through all models in the group
models[k].ChangeGroup(group);
outFile.TableCell(models[k].Name(g_nloc), 50, getString("TEXT1"), 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_CENTER | Constants.FMT_VCENTER, 0);
}
var childGroups = groups[i].Childs(true);
for(j = 0; j < childGroups.length; j++){ //iterate through all sub groups
var m = 0;
var childModels = childGroups[j].ModelListFilter(Constants.MT_INFO_CARR_DGM);
for(m = 0; m < childModels.length; m++){ // iterate through all models in the group
childModels[m].ChangeGroup(group);
outFile.TableRow();
outFile.TableCell(childModels[m].Name(g_nloc), 50, getString("TEXT1"), 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_CENTER | Constants.FMT_VCENTER, 0);
}
}
}
outFile.EndTable("", 100, getString("TEXT1"), 12, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
outFile.WriteReport(Context.getSelectedPath(), Context.getSelectedFile());
}
main(); Hi Srinivas
1033 is the language number for English, if you move your getSelectedLanguage command above the line var group=db and replace 1033 with g_nloc you will use the language you use with database login.
var group=db.Group(["All ICD's" , "Information carrier diagram"] , 1033);
"All ICD's" = Is this the name of the Main group/Root Group of the Database? if not you need to put in the correct name (usually Main Group)
"Information carrier diagram" = is this the group where you want to move to models to... remember you need to build the path of the group with above command
eg. var group=db.Group(["Main Group","Information", "Information Diagrams"] , g_nloc);
will read as/ or path in Aris Database, Main Group, next group under main group will be Information, within Information a group named "Information Diagrams" and this will be the group which you want to move your models to or you can just use the command
var oMoveToGroup = ArisData.getActiveDatabase().Group("Main group/1. Group/1.2 Sub Group/Move Models In Here", g_nloc);
But for both commands the groups must exist in the Database withing that order.
Ciska

Hi Ciska,
Thank you very much for your reply,
g_nloc = __toLong(Context.getSelectedLanguage()); var group=db.Group(["VBS/1. VBS PMT/Processes - Standard" , "All ICD's"] , g_nloc);

Here is the folder structure, I just want to move all the ICD's which are there in other folders to "All ICD's" folder. Though I have given the command like what you have mentioned in the previous reply but It was not at all moving. Can you please help me out? And the ICD's are having names like "Document(1), Document(2) etc., in all the folders, does this effect the code? Means same names in all the folders.
Then you need to:
var newgroup=db.Group(["VBS","1. VBS PMT","All ICD's"], g_nloc);
to Make sure that you got the correct group:
Dialogs.MsgBox(newgroup.Name(g_nloc)); // should be All ICD's
If it's spaces then the group could not be found (maybe the ' can cause problems);
I suppose that your script run from selected groups - now for each selected group find all the models of the type and move to newgroup, like you did in your code posted.
Although javascript is case sensitive I will advice to not name your variables the same as Aris objects - like group for instance.
Ciska

Hi Ciska,
Dialogs.MsgBox(newgroup.Name(g_nloc));
for this line, I am not getting "All ICD's" name. May be that is the reason it is not moving. I have changed name like "All ICDs" and tried but in vain :(
Best Regards,
Srinivas.
What is your Root Group name (iow Main group) of the Database - It is VBS? Or is VBS a sub group?
The is working, I have setup the same sturcture as yours and I get it group, even with the ' in the name.
var newgroup = db.Group(["VBS","1. VBS PMT","All ICD's"] , g_nloc);
Dialogs.MsgBox(newgroup);
Dialogs.MsgBox(newgroup.Name(g_nloc));
Ciska

VBS is the main group, under VBS we have "1.VBS PMT
..jpg)
But for me I am getting empty dialog box, and in "All ICD's folder is also empty.
BR/Srinivas.
Is it "1. VBS PMT" or "1.VBS PMT" (with space after 1. or no space"). Is it the same in your script?
Well, alternatively what you can do is to find the group in ARIS via scripting by using the Find command
Find (int SearchKind, int ItemType, int AttrTypeNum, int LocaleId, String sAttrValue, int CompareFlags)
Ciska

Hi Ciska,
Thanks for your Inputs, Learnt some stuff from you. Anyways it was my fault, I have given one extra space thats why its not moving, Now the problem solved. Once again thank you very much :) :)
Have a nice day :)
Best Regards,
Srinivas.

Hi Ciska,
There is a problem now after moving the ICD's to a common folder. Now for some of the activites in EPC where this ICD are connected are missing, Means now we are getting activities with no ICD's in someplaces. Do you know what might be the cause for this? And in some ICD's documents are missing, like before it was three documents connected to that ICD, now after moving the ICD's to common folder using script we are finding only two. Please do the needful.
Thanks in advance,
Srinivas.
Hi,
Do the needful?
Check our access rights to the new folder, common problem, if assigments to models are not showing then the users to not have access to the folder where that model resides
Ciska
Hi,
May I know why are you so particular to run a script just to move a model when it can be done by manually dragging it to another folder within a database.
Are there any specfic advantages on running the script to move the model via script ?
Hi,
Yes, if you want to move all type of a certain model, then find and move will work, but I use this command to either re-create group structure or move models to the group they should belong to (like FAD's for example) and the decision logic is build into the script.
Ciska

Hi Tarun,
Yes we can do manually by dragging to other folder, but If it is a large number of models(in my case around 350) it will be difficult to move manually. Thats why I was trying to do that with script.
Thanks & Best Regards,
Srinivas.

Hello Srinivas,
Did you manage to solve the missing assignments to ICDs and the missing documents in the ICDs?
And what does it look like in your publishing environment, PMT, are the documents missing also there?
For moving a great number of models spread out in the database into a common folder, I suppose you could use the "Find" functionality in ARIS Explorer.
Once you have found the models (of a certain type) you can move them to the target group by drag & drop from the "Find" window and into the target group in the ARIS Explorer window.
Although the matter may be outdated now, I also tried moving models by the use of a script and it works. I just need to refresh the database view in ARIS Explorer after having run the script,
or else it looks like nothing was moved whereas the script actually did move the models to the target group. Note: The script is moving the models only and not the object definitions used by the models.
Please see sample of code below (my code editor here at ARIS Community does not work, sorry!):
var g_nLoc = 1033;
var g_oOutfile = null;
function main(){
var oCurrentDatabase=ArisData.getActiveDatabase();
var oAllICDsOfTheDatabase=new Array();
var oAllICDsOfTheDatabase=oCurrentDatabase.Find(Constants.SEARCH_MODEL,70); // Find all ICD model types (70) in the database;
var oTargetGroup=oCurrentDatabase.Group("Main group/VBS/1.VBS PMT/All ICD's" , g_nLoc);
var oCurrentModel=null;
g_oOutfile = Context.createOutputObject(Context.getSelectedFormat(), Context.getSelectedFile());
g_nLoc = Context.getSelectedLanguage();
g_oOutfile.Init(g_nLoc);
for( i0 = 0; i0 <= (oAllICDsOfTheDatabase.length - 1); i0++){
oCurrentModel=oAllICDsOfTheDatabase[i0];
g_oOutfile.OutputLn(oCurrentModel.Name(g_nLoc)+" was moved from group '"+oCurrentModel.Group().Name(g_nLoc)+"' to the new group '"+oTargetGroup.Name(g_nLoc)+"'", "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, 0);
oCurrentModel.ChangeGroup(oTargetGroup);
}
g_oOutfile.WriteReport(Context.getSelectedPath(), Context.getSelectedFile());
}
main();
Cheers! / Harry R

