Profile picture for user liju

I am new to ARIS scripting and was trying to write a script to fetch all the group names and child group names from a selected Group. Following is my code and it is only returning the Parent group. Can someone please tell me what is wrong with my code?

 

var nLocale = Context.getSelectedLanguage();

function main(){

    var oOutput = Context.createOutputObject();

    var aGroups=ArisData.getSelectedGroups();

    for (var i = 0; i < aGroups.length; i++) {            

    var oGroup = aGroups[i];                    // Current Group

    var sGroupName = oGroup.Name(nLocale);      // Name of current Group

 

    oOutput.OutputLn(sGroupName, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0);

    

    }

    oOutput.WriteReport();

}

main();

by Francois Du Toit
Posted on Thu, 08/17/2017 - 12:28

Hi Liju,

You are only outputting the SELECTED content, which is the one group you had highlighted when you run the report. You need to add the sub-groups for it to be included in the outcome.

Updated script, and I changed the output to output the full path, instead of just the group name.

var nLocale = Context.getSelectedLanguage();

function main(){

    var oOutput = Context.createOutputObject();

    var aGroups=ArisData.getSelectedGroups();

    

    var allGroups = new Array(); //var to capture all paths

    for(var agc = 0; agc < aGroups.length; agc++) { //go through selected list to find all sub-groups

        var grp = aGroups[agc];

        allGroups.push(grp);

        allGroups = allGroups.concat(grp.Childs(true));

    }

    //Output all groups

    for (var i = 0; i < allGroups.length; i++) {            

    var oGroup = allGroups[i];                    // Current Group

    var sGroupName = oGroup.Name(nLocale);      // Name of current Group

    var sPath = oGroup.Path(nLocale);           //Full path of current group

 

        oOutput.OutputLn(sPath , "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0);

    

    }

    oOutput.WriteReport();

}

main();

Rgs,

Francois

0
by Liju Ram Author
Posted on Sun, 08/20/2017 - 17:33

Thank alot Francois. Above code works as the way i wanted. I am stuck at a new thought though. I have a model in a folder which is again in another folder. Is it possible to run a report on the parent folder to find the number of the objects in the model deep down in it ?? I would really appreciate your input :) 

I wrote the following code for that and it is working on a single folder containing a value stream model. But if i try to run the same report on a model inside multiple folders then it is breaking. Can you please check this ?

var nLocale = Context.getSelectedLanguage();

function main() {

    

      var ogroups = ArisData.getSelectedGroups();

       var output = Context.createOutputObject();

    for (var i = 0 ; i < ogroups.length; i++ ){

      var ocurrentgroup = ogroups[i];

    }

    var objDefCount = ocurrentgroup.ObjDefList().length;

    var ochildren = ocurrentgroup.Childs();

      if ((ochildren.length > 0)) {

      for ( var h = 0 ; h < (ochildren.length - 1)+1 ; h++ ) {

        var ocurrentchild = ochildren[h];

  

       }

  }

    var omodels = ocurrentgroup.ModelList();

  if (omodels.length > 0) {

    for (var i = 0 ; i < (omodels.length - 1)+1 ; i++ ){

      var ocurrentmodel = omodels[i];

       }

    }

  var oobjdefs = ocurrentgroup.ObjDefList();

  if (oobjdefs.length > 0) {

    for (var i = 0 ; i < (oobjdefs.length-1)+1; i++ ){

      var ocurrentobjdef = oobjdefs[i];

      var sObjName = ocurrentobjdef.Name(nLocale);

output.OutputLn("Object " +(i+1) +":"+ sObjName, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 10);

    }

      output.WriteReport();

     }   

}

  main();

  

 

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock