MV

Anyone know of a way to check if a model may be open using the Aris reports API (not the macro API)?

I'm implementing a script that performs a number of updates in the Aris repository including changes to multiple objects and models. This is an all or nothing scenario where none of the updates should be performed if a model that I plan to updates has been opened by someone else also logged into the server. 

by Francois Du Toit
Posted on Thu, 12/06/2012 - 13:20

Hi Martin,

 

The only way I got this to work is to use a macro. You can then call the script from the macro after closing open models...

Hope this helps.

Francois

0
by Martin van Niekerk Author
Posted on Thu, 12/06/2012 - 13:27

Thanks Francois. Unfortunately Macros can only detect open models on your own client. I need a way to detect models currently opened by other users on the server.

0
by Rahul Nagar
Posted on Mon, 01/21/2013 - 14:04

In reply to by dtse

 

Hi Martin,

 

I think there is some confusion. A macro if it is deployed on a server, you will get to execute it on server. Hence, if you write a macro to check if a model is open and deploy that macro on the server it will let you know if a model is open even by some other user. 

 

Besides, while checking if the model is open using a report, you can use 'lock' and subsequently 'unlock' API on the model. When you do 'lock' to a model and if the model is already open you will get an error in the 'LockResult' and by using the API 'getErrorMessage()' you can check if the model is open or is it locked by some user.

 

Hope this resolves your query.

 

Ragards

Rahul

0
by Francois Du Toit
Posted on Thu, 12/06/2012 - 14:35

Hi Martin,

Idea is that you try to set a model flag, if it does not allow you to set the flag, the model is open. Catch the error and go from there...

var lng = Context.getSelectedLanguage();

function main() {
    var selMods = ArisData.getSelectedModels();
    for(var mc = 0; mc < selMods.length; mc++) {
        var curSel = selMods[mc];
        try {
            curSel.changeFlag(Constants.MODEL_PRINT_LANDSCAPE, true);
        }
        catch(e) {
            var modOpen = true;
        }
    }
}

main();

You could also possibly use an attribute instead of a flag... Thought there should be a flag, that's why I started there :)

Hope that helps,

Francois

0
by Jens Heylmann
Posted on Thu, 12/06/2012 - 14:35

Martin, you can use a hack like this:

var models = ArisData.getSelectedModels();
for( var i = 0; i < models.length; i++ ) {
    var model = models[i];    
    if( !isWriteable( model ) )
        Dialogs.MsgBox( "Model is not writeable: " + model.Name(-1) );
}

function isWriteable( m ) {
    try{
        var bpc = m.getBgColor()
        return m.setBgColor( bpc );
    }catch( e ) {
        return false;    
    }
}

 

Regards,

Jens

0
by Harry Ratia
Posted on Tue, 09/09/2014 - 13:58

In reply to by Jens Heylmann

Hi,

 

I tried this piece of code today but seem to get en exception/error every time when trying to change the background colour of a model, regardless of if it is open or closed.

Does anyone have an idea of why the object is seen as read-only even if the model is closed?

 

Thanks for any input!

 

/ Harry R

 

Addition: In fact later today I found the reason for this behaviour - the report script did not have the "Writes to database" checkbox selected.

Thanks to mr Torsten Haase, describing this in this article:

 

 

0
by Didier Nowak
Posted on Thu, 12/06/2012 - 14:39

Hello,

You can use this trick : Try to change the background color, if it fails, then this means the model is opened (or locked) :-)

E.g. :

var oldBg = model.getBgcolor

try{

model.setbgcolor(black)

}catch(err){

model is open...

}

0
by Martin van Niekerk Author
Posted on Thu, 12/06/2012 - 15:31

Thanks! Neat little hack.

0
by Ilya Seletkov
Posted on Wed, 01/16/2013 - 12:26

Hello, All!

Info about error ("Unable to save modified objects.") is always written to log file. It doesn't depend on using try-catch block or not.

----

16.01.2013 16:12:28 INFO:  app=ARIS Business Architect for SAP; user=iseletkov@172.30.208.85; pid=; exe=ARIS Business Architect for SAP; ip=172.30.208.85; pattern=ArchitectmySAP Script-ID=test/c58e1690-5fbc-11e2-5d51-08002700dc64 16.01.2013 16:12:28 SEVERE: error running Model.changeFlag(1024, true): An error occurred in the report object model. Unable to save modified objects. ---   In case of using setColor() method there are about 20 error string in file and 1Gb per year. Does anybody know how to avoid loging this kind of errors?   Thanks!
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