DT

Hello,

I was wondering if there was any built in function or macro in ARIS that will automatically check to see if an object occures in multiple models, and if so, warn the modeller before they change the name of the object. This way, it'll prevent them from having to go through the properties and also help prevent accidental name changes.

I've dug around the macros and there is an event on "object name change (persistant)" but this only checks it after it's been saved. Similarly, on the object attributes change (vetoable), it checks prior to the name being changed.

What I am looking to do is have the following occur:

1) User clicks to do a name change

2) User changes name

3) User clicks out so name applies

4) Macro runs to validate if this object occures in multiple locations

    a) if it does, then give pop up warning asking if they are sure they want to change it because it will impact other models. If they hit okay, it keeps change. If they hit cancel, it reverts back to origional name

    b) If it doesn't, just change name

Thanks,

David

by David Tse Author
Posted on Wed, 03/07/2012 - 18:23

I wasn't able to get what I was looking since I don't believe there is any way to validate after an object's name is changed but before it is saved (only on the click or on save). I created the macro to check "on save" and I created a new attribute called "previousName" that stores the most recent name in case people decide not to revert the changes. 

This is how to code works:

  1. User modifies an object and hits save
  2. Macro auto runs on object name change
  3. Determines if the object occures in multiple models
  4. If it shows up in more than one (aka other than the current model), it will pop open a message warning the user that they are about to impact more than their own model
  5. If they hit "Ok", it saves the previousName to the current name and ARIS does the rest
  6. If they hit "Cancel," it resets the current name to the previousName 
  7. If the change only exists in one model, it will auto save the previousName to the current name

Here is a sample of the warning:

 

Here is the MACRO code (NOTE: Because previousName is a custom made attribute, you need to change the previousName GUID to what yours is)

var selModels = Context.getSelectedModels();
var nLocale = Context.getSelectedLanguage();
var selobjs = Context.getSelectedObjects();
var CONSTANT_PREVNAME = 68838;

for (var i=0;i<selobjs.length;i++)
{
    var occ = Designer.getOccs(selobjs[i]);
    var occModels = []; //this stores the model GUID so we know if we've seen it before
    //for every occurance of this object, we need to see which model it is in
    for (var y=0;y<occ.length;y++)
    {
        var found = false;
        var oModel = Designer.getModel(occ[y]);
        for (var x=0;x<occModels.length;x++)
        {
            if (occModels[x] == Designer.getGUID(oModel))
                found = true;
        }
        if (!found)
            occModels.push(Designer.getGUID(oModel));
    }
    
    //We now know how many models this object occures in. If it's in more than one
    //that we need to indicate that.
    var objType = Designer.getAttribute(selobjs[i], 389, null);
    var previousName = Designer.getAttribute(selobjs[i], CONSTANT_PREVNAME, null);
    var currentName = Designer.getAttribute(selobjs[i], Constants.AT_NAME, null);
    //We only run this if it shows up in more than one model
    if (occModels.length > 1)
    {
        var btnPressed = Dialogs.MsgBox("You are about to change a(n) " +objType+ "'s name to \""+currentName +"\". This object occures in " + (occModels.length - 1) + " other model(s).\nAre you sure you want to continue?", "Warning", Constants.MSGBOX_ICON_WARNING, Constants.MSGBOX_BTN_OKCANCEL);
        switch (btnPressed) { 
        case Constants.MSGBOX_RESULT_OK: 
            //We set the previousName to current one
            Designer.setAttributePersistent(selobjs[i],CONSTANT_PREVNAME,currentName,null);
            break; 
        case Constants.MSGBOX_RESULT_CANCEL: 
            Designer.setAttributePersistent(selobjs[i],Constants.AT_NAME,previousName,null);
            break; 
        default: 
            Dialogs.MsgBox("How did you click something else?"); 
        }
    }
    else
    {
        //This means that it only shows up in one model. This might mean it's a new object or just shows up once
        //either way, we need to set it's prevname to it's current name
        Designer.setAttributePersistent(selobjs[i],CONSTANT_PREVNAME,currentName,null);
    }
}

 

You will probably need to run a script to auto update all your objects with the previousName attribute set to the current name. Here is a REPORT that will do it. Once again, you need to change the GUID of the previousName attribute!

var oSelGroups = ArisData.getSelectedGroups(); 
var nLocale = Context.getSelectedLanguage();    // Selected database language 
for (var n = 0; n < oSelGroups.length;n++)
{
    var objectsList = oSelGroups[n].ObjDefList(true);
    for (var i = 0; i < objectsList.length; i++) 
    {
        var object = objectsList[i];                    // Current model 
        var objectName = object.Name(nLocale);      // Name of current model 
        var attr = object.Attribute(68838, nLocale); //CHANGE THAT NUMBER TO YOUR ATTRIBUTE NUMBER
        attr.setValue(objectName);
    }
}
0
by Edwin Verstraeten
Posted on Wed, 03/28/2012 - 09:30

Hi David,

One small suggestion from my side. You should use the GUID of the user defined attribute rather than the type number. Restart of the business server can, under some conditions cause the type number to change. This is most certainly so for an upgrade of the business server. The GUID on the other hand is stable and doesn't tend to change.

If you change the declaration like below:

// var CONSTANT_PREVNAME = 68838
var CONSTANT_PREVNAME = Context.getArisMethod().UserDefinedAttributeTypeNum("GUID of the attribute");

This change should make your macro more sustainable and upgrade proof.

Best regards,

Edwin

0
by David Tse Author
Posted on Wed, 03/28/2012 - 17:07

Awesome, thanks for the suggestion.

 

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