Hi all,
I can't to remove occurence and connection from model. I use Remove() method, but it has no effect. What could be reason for that this is not successful?
For example - I have simple report run on object. There are 2 lines in report:
var oOccs = ArisData.getSelectedObjOccs(); oOccs[0].Remove();
I tried unsuccessfully this code for connection:
oCxnList = oOccs[o].CxnOccList(); oCxnList[0].Remove();
or
oCxnList[0].Cxn().Delete(false);
Object and connection are still in model... :(
Do you have any idea?
P.S. What is difference between relations and connections?
Hi Vladimir,
Just out of curiosity what is your context when you are running the script. If the context is not set object then it will not give you anything in oOccs.
I do have a code which work in Cxns() for ObjOccs.
var lCxnOcc=selObjOcc.Cxns();
lCxnOcc[0].Remove();
And obviously the selObjOcc.Remove() also work.
Check if you are getting anything in the oOccs.
If you are still getting the error chekc with the Software AG. Is it with a particular release.
Sorry I can help only this much.
Thanks
Abhijit Das
Hi Abhijit,
thank you for your valuable feedback!
You are right, problem was in context - when I catch selected occurences, I have model opened of course and this is problem, model must be closed! So if I tried remove connection on model context or object definition context, connection was removed successfully!
In any case I don't understand difference between Cxns() and CxnOccList() methods, because I use always connection definiton, not connection occurence. I don't know when is suitable to use connection occurence...
Hi Vladimir,
The difference is quite simpel. The CxnOccList() returns the occurrence of all connections on a model. The Cxns() method returns the connection definitions (the actual definition of the connection in the database). In a macro you can remove the connection occurrences from the opened model, as well as the object occurrences on this model. You can't remove the definitions as long as the model is opened and the occurrences are still in scope (for undo purposes). You should be able to remove the definitions if you first save the model. Try the below example that removes all selected connections from a model, saves the model and then deletes all the connection definitions.
var oCxnOccs = Context.getSelectedCxnOccs(); var oCxnDefs = new Array(); var oModel = Designer.getModel(oCxnOccs[0]); for (occ in oCxnOccs) { oCxnDefs.push(Designer.getDefinition(oCxnOccs[occ])); // save the CxnDefs for deletion later on Designer.deleteOcc(oModel, oCxnOccs[occ]); } Designer.save(oModel); // now first save the model for (def in oCxnDefs) { Designer.deleteCxnDefPersistent(oCxnDefs[def]); // now delete the definition }
Best regards,
Edwin
Hi Vladimir,
If you do not execute the Designer.deleteCxnDefPersistent the definition stays in the database. You can check this by selecting the object and check the relationships tab in the properties window. If you manually delete a connection in a model, the definition stays available at all time.
Of course if the connection is no longer used, the definition is removed upon reorganization.
Best regards,
Edwin
Hi Vladimir,
There's a distinction between macros and reports. Reports run server side while macros run at client side. Beside this, macros can perform tasks on (by the client) opened models, where reports can't manipulate them. So if i need to do something on an opened model, i am forced to use the macro methods.
When working with the macro methods, note that the reports methods are not valid. You need to use the macro object model which is module based rather than object based.
Best regards,
Edwin
Hi Vladimir,
I absolutely agree with your points here. But you can easily check whether the model is opened by you or not.
Use the Designer.getOpenModels() method to determine all models opened by the active user in the same client.
Use the Designer.isOpen() method to check whether the model is open or not,
If the model is opened and it's not in the getOpenModels list, then you are not the current user of the (opened) model, so you can't perform updates on it.
But in essence, you're right.
Best regards,
Edwin