RB

Hello,

I have a problem to create an object on a opened model.

 

I write a macro with a custom UserDialog. The macro should be executed on a model.

This UserDialog transfer the user input to a report and the report create a object to a selected path and additionally it should create an object on the selected Model. 

 

But I get always an error code: 

oModel.createObjOcc(intSymbolNumber, oCreatedObject, resultX, resultY, true, true);  -->

 

 

I don´t get this errorcode, when the model is closed... 

Can someone help me? 

 

Thanks!!

 

by Kay Fischbach
Posted on Tue, 03/20/2018 - 12:21

Hi there.

The Problem

The first thing you need to understand is the difference between a Macro and a Report:

Taken from "The difference between ARIS Report and Macro" and simplified:

  • A report

    • is executed on server

  • A macro

    • is executed on client

So when you trigger the execution of a Report with a Macro, you are sending an order to the server - "do something".

The server will of course create the new object definition in the set group, but when it comes to modifying the model (yes, adding an object occurrence is a modification) it will run into the same error message your co-workers (if you have any) will run into when they try to open a model that is currently already opened:

And that's where the report will crash, because it can't modify the model while it is opened in read-only mode.

The solution

What you want to do to fix your problem: Don't use a Report. Use a Macro instead. As I've written above, a macro is something that is executed on the client... aka the client where the model is already opened, so there is absolutely no way it doesn't have write permissions for this model (as long as the model is opened by the person executing the macro, if someone else has opened the model you are out of luck).

To do that, you want to create a Macro like this (do not select "This macro runs this report:", instead leave the check at "User-defined macro"):

After you've completed the wizard you'll be thrown into an editor that looks really similar to a ARIS-script report editor. It's JavaScript too. But at the same time it's a little bit different. For example you can't use the method "CreateObjDef ( int ObjType, String sName, int localeId )" from the Group (Report class) class to create the Object Definition.

Instead you want to look into are the methods found in your Scrip Help here (open the script help by clicking the question mark in the upper right corner of your Architect software, then pick "ARIS Script"):

You can make use of those methods like this "Designer.openModel(oModelS[i], false, true, true);" (and yes, you really have to use the actual class name here in the report, just like you might have used "Context", "ArisData" or "Constants" in reports before).

So you still need the parent group object for your Object Definition creation, but instead of using "actualGroupObject.CreateObjDef ( int ObjType, String sName, int localeId )" from the Group (Report class) class, you want to use "Explorer.createObjDef ( Group p_parent, String p_name, int p_objType, int p_defaultSymbol )".

The second method you'll absolutely need is "Designer.createObjOcc ( Model targetModel, ObjDef def, int symbol, Point position )". Only use this method after you've opened the model with the method I mentioned earlier (or make sure that the model is already opened).

Don't forget to save your model after the modification ("Designer.save ( Model model )") and close the model ("Designer.closeModel ( Model model )"). Imagine you really manually work with the Designer, which steps would you need go through to do what you want to automate? Those exact steps are what you need to program here.

I hope this helps. Have fun with Macros.

 

 

 

 

0
by Frank Weyand
Posted on Tue, 03/20/2018 - 13:15

Thank you, Kay, for this explanation. Great!

0
by Rene Broll Author
Posted on Thu, 03/22/2018 - 11:08

Thanks Kai, it was verry helpfull!

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