GS

Hello folks,

I am trying to sort a list of connections occurrences of a object, by the NAME of the occurrence of the target object. But I could not figure it out by myself how to do.

I have a piece of code of what I am doing:

var aCxn = p_aObjOcc.Cxns()

for(var k=0; k<aCxn.length; k++) {

                        obj = aCxn[k].TargetObjOcc();

                        var aCxn2 = obj.Cxns()

                        aCxn2 = ArisData.sort( aCxn2, Constants.AT_NAME, Context.getSelectedLanguage() )}

But this is not working. I know I should change the parameter Constants.AT_NAME to something that would order by the name of the occurrences of the target objects, but I dont know how to.

Any tip about how I should solve this is very very much appreciated.

Thank you very much,

Gustavo

 

by Florian Rese
Posted on Wed, 06/22/2016 - 09:20

Hi Gustavo,

as per the ARIS script help the command TargetObjOcc() is depreceated and instead the command getTarget() is recommended to be used.

Also you want to sort an array of object occurrences by an attribute, whereas the attribute values are only stored in the definition of an object as per my understanding. Maybe you need to retrieve the definition corresponding to each of the occurrences of the target object and then sort this list by the name attribute or as a shortcut use getObjDefName(int p_nLocale) which returns the "Name" attribute from the definition of this occurrence. 

Hope this is of any help.

Cheers

Florian

0
by Gustavo Senise Author
Posted on Thu, 06/23/2016 - 19:12

In reply to by FlorianRese

Thank you very much for your guideness Florian!

I´ve changed the way I am getting the related objects. Instead of doing by the connections, I am using the getConnectedObjOccs. It seems it is much better to achieve what I need. The code is now like this:



var aCxn = p_aObjOcc.getConnectedObjOccs([Constants.ST_VAL_ADD_CHN_SML_1], Constants.EDGES_OUT);

for(var k=0; k<aCxn.length; k++) {

    obj = aCxn[k];

    var aCxn2 = obj.getConnectedObjOccs([Constants.ST_VAL_ADD_CHN_SML_1], Constants.EDGES_OUT);

    aCxn2 = ArisData.sort( aCxn2, Constants.AT_NAME, Context.getSelectedLanguage() )}

 

Cheers,

Gustavo

 

0
by Tricarico Romain
Posted on Wed, 06/22/2016 - 11:36

Hi Gustavo,

Try this code to order your CxnOcc list  (case insensitive) :

var aCxn = p_aObjOcc.Cxns();

for(var k=0; k<aCxn.length; k++) {
     obj = aCxn[k].getTarget();
     var aCxn2 = obj.Cxns();
     aCxn2.sort(sort_cxnoccs_by_name);  //here the list is sorted
}
function sort_cxnoccs_by_name(a, b){
    var nameA = a.getDefinition().Name(lng).toLowerCase().trim();
    var nameB = b.getDefinition().Name(lng).toLowerCase().trim();
    if(nameA < nameB){
        return -1
    }else{
        return 1;
    }
}

I did not try it, but it should work.

Let me know if it solves your problem.

Best Regards,

Romain Tricarico

www.bpmap.fr

0
by Gustavo Senise Author
Posted on Thu, 06/23/2016 - 19:16

In reply to by BPMap

Thank you very much for you code Romain!

I´ve changed the way I was retrieving the related objects, and now I am getting an ordered list. Take a look at my previous answer to Florian to see the code.

I haven´t tested your solution, but I might use it some other time.

Merci beaucoup mon ami!

Best Regards,

Gustavo

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