Hi - I am trying to halt users from creating all but a 3 model types. We need users to be able to see other model types, but not generate them (so this is not something we can do via the filter).
I created an event-driven macro with:
- Event: "Model is to be created with type and name (Vetoable)"
- Can only be started by an event
- "Use veto against default creation" is checked
- Triggers are report with the code below
var allowedTypes = [Constants.MT_ENTERPRISE_BPMN_COLLABORATION, Constants.MT_ENTERPRISE_BPMN_PROCESS, Constants.MT_FUNC_ALLOC_DGM];
var modelType = Context.getProperty("model_type");
if (!containsInt(allowedTypes, modelType)) {
Dialogs.MsgBox("You are not allowed to create this model type.\nPlease contact the admin team if you believe you are seeing this in error.");
Context.setProperty("event.veto", 1);
} else {
Context.setProperty("event.veto", 0);
}
return;
}
The macro works in generating the dialog box on the other model types, but it vetos creation regardless of model type.
When I look at the code of the auto-generated macro, the last line is
Context.setProperty("event.veto", 1);
Why is the macro setting it to veto no matter what? Isn't the entire purpose that it should be vetoed or not according to what happens in the report?
How do I have it still allow the creation of the three allowed model types and ensure it opens properly in Connect?
Hi Jorge - You can see in the report code that I set the veto in the if statement of the report.
But the problem is this:
- In order to run a macro in Connect, it must trigger a report
- The report uses the if statement to decide whether to veto or not
- The veto is set on the report level, not the macro level, so the model is created anyway no matter which if statement is used
- I cannot pull the report veto into the macro because the code is automatically generated; if I do this, the macro will not work in Connect