jscript to uncheck/check NN - exclusive PKs and PFKs

Hello everybody,

what does the script look like to uncheck/check all not nulls exclusive primary keys and primary foreign keys?

my try (ignoring PK & PFKs):


if(IteratedAttribute.NotNull == true){
IteratedAttribute.NotNull = false;}

Thanks in advance!

Hi Tomtom,

that’s correct. Below you can find a function that sets all attributes in all entities to null. Please note that in Settings | Options in section Physical Model you can change option “Allow Null Attributes in Keys”. This will enable the Not Null checkbox on various dialogs.

function main(){

Model.Lock();
for (e=0; e<Model.Entities.Count; e++)
{
Entity = Model.Entities.GetObject(e);
for (k=0; k<Entity.Attributes.Count; k++)
{
Attribute = Entity.Attributes.GetObject(k);
if(Attribute.NotNull == true)
Attribute.NotNull = false;
}
}
Model.RefreshModel();
Model.UnLock();
}

Regards,

Vaclav

Thanks for the quick answer,

maybe the question was not clear enough. I would like to uncheck all NotNull fields without unchecking the NotNulls from primary keys and primary foreign keys.

Thanks

Hi,

try replacing

if(Attribute.NotNull == true)
Attribute.NotNull = false;

for

if(Attribute.NotNull && !Attribute.IsPrimaryKey)
Attribute.NotNull = false;

Regards,
Lukas

Problem solved :slight_smile:

Thank you