LS

Hi,

I am developing a small script that should be able to import excel data and generate a model.

However, I am unable to get connections between some objects of specific types, even though these connections can be created in the "Designer" module.

Concrete illustration of my problem:

  • My raw data in Excel:







     
  • Expected outcome:





     
  • What I get:

As you can see, there are some links missing. It WOULD work if the "Position" would be, for example, a "Function".

I try to connect (all) the objects with the following function:

function connect (source, target) {
    // This function "brute force" connects two objects
    
    var i = 0;
    var connection = null;
        
    while(!connection && i < 1000) {
        connection = model.CreateCxnOcc(true, source, target, i++, pointList);
    }
    
    //if(!connection) Dialogs.MsgBox("Still no connection")
}

so I think we can exclude that I chose the wrong CxnType (Type number of the relationship occurrence to be created -- in this case: i).

So, has anybody got an idea what could be the problem or has a different solution / workaround for this?

If you need some more code, please feel free to ask!

Many thanks,

Laurent

by Ellen Gambrell Pelletier
Posted on Thu, 08/22/2013 - 17:26

Hi Laurent -

Why are you not just setting the connection type in the code rather than iterating through 1000 connection types? This should work:

function connect (model, source, target) {
    var cxnType = null;
    var connection = null;
    var sourceType = source.ObjDef().TypeNum();
    var targetType = target.ObjDef().TypeNum();
    
    if ((sourceType == Constants.OT_EVT) && (targetType == Constants.OT_FUNC)) {
        // Event >> activates (43) >> Function
        cxnType = Constants.CT_ACTIV_1;
    } else if ((sourceType == Constants.OT_PERS_TYPE) && (targetType == Constants.OT_FUNC)) {
        // Person Type >> carries out (218) >> Function
        cxnType = Constants.CT_EXEC_2;
    } else if ((sourceType == Constants.OT_POS) && (targetType == Constants.OT_FUNC)) {
        // Position >> carries out (65) >> Function
        cxnType = Constants.CT_EXEC_1;
    }
    
    if (cxnType != null) {
        connection = model.CreateCxnOcc(true, source, target, cxnType, pointList);
    }
    
    return;
}
0
by Laurent Seiler Author
Posted on Fri, 08/23/2013 - 08:44

Hi Ellen,

First of all, thank you for your answer. It pointed me in the right direction and my script works now :)

I was not setting the exact connection type because

  • I wanted to save time and
  • because I didn't know to which object combinations the different types belong to.

I tried your code, and much to my regret it didn't solve my problem either (which was to be expected, as all those constant values were already covered by my function). However, I noticed that the argument order plays a major role here: a "Position" has to be the source of the connection. Therefore, I updated my function as follows:

function connect (source, target, stop) {
    // This function "brute force" connects two objects
    
    var i = 0;
    var connection = null;
        
    while(!connection && i < 1000) {
        connection = model.CreateCxnOcc(true, source, target, i++, pointList);
    }
    
    if(!connection && typeof(stop) == 'undefined') connect(target, source, true);
}

Short explanation: If the connection fails, try swapping the source and target value and try again -- straight and simple :)

Again, thank you very very much for your help!

Thanks,

Laurent

0
by Ellen Gambrell Pelletier
Posted on Mon, 08/26/2013 - 17:19

Source and target are definitely important in the code. Glad I could help!

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