Toad World® Forums

Issue adding entity to workspace

Hello,

Due to our organisation standards a set of columns has to be included in all tables. So we’ve developed a macro that create an “empty table”, this is, a table with this set of columns, ready to add other data columns.

One of our models has 3 workspaces, WS1, WS2 and WS3. When we create an entity then a shortcut is always placed in WS1, not in selected or active workspace. How can we get this? When adding an entity to model, is it possible to specify the WS where the shortcut will be created?

If we try to add the shortcut by code at the end of create table script, shortcut is placed in WS1 and WS3, even when WS2 was the active workspace.

Best regards,

Biel B.

Hi,

right click any area on WS2 or WS3 and choose Workspace Format. Go to tab General and uncheck the Auto Complete checkbox. The Auto Complete options affects shortcuts creation for new objects.

Regards,

Vaclav

Hi,

Right! This solves part of the problem. Now, how I can create the shortcut in the active workspace? If auto-complete property is turned off no shortcut is created, even including this code in the script:

//----------------------
var WS = App.ActiveWorkSpace;
var Entity;

Entity = Model.CreateNewObject(2002); // add new entity

//…
//code modeling new Entity
//…

var sc;
sc = WS.NewWorkSpaceShape(2502, Entity);
sc.Left = 100;
sc.Top = 100;
//----------------------

But nothing changes in active workspace.

Regards,

Biel B.

Hi,

use Model.RefreshModel(); to refresh all workspaces in your model. In documentation you can find also Model.RefreshWorkspace(WS.Id) method, but due to small bug it currently doesn’t work (will be fixed in next version).

Regards,

Vaclav

Right! Thanks again!

We’ve marked all WS as non-autocompleted and the macro adds the shortcut to the active WS. That’s just what we need!

Now, I would like to solve a little detail. During the entity adding process we test some conditions (like unique table name or unique attributes prefix). If some condition fails then an error is shown in log.
Is there a way to leave the custom form opened when an error occurs and close it if the process was ok? When I set “CloseAfterExecution” to false the form always remains opened.

Regards,

Biel B.

Hi,

unfortunately, there is no option like this.

Regards,
Lukas

Ok, thanks.

Regards,

Biel B.