Vault Customization

Vault Customization

Reply
Contributor
ewcv
Posts: 22
Registered: ‎02-01-2012
Message 1 of 5 (261 Views)
Accepted Solution

create Item UPDs per Api - how to create PropConstr-objexts

261 Views, 4 Replies
03-30-2012 04:58 AM

the UPD is created by AddPropertyDefinition("Name", String,"Default_Value",null, null, null, null) and

UpdatePropertyDefinition(newId, ("Name", true, true, "Default_Val", new string() {"ITEM"} )

and is seen in Vault Explorer.

UpdatePropertyDefinitionInfo(newPropDef, eClsCtntSrcPropDefs, baseConstraints,null) fails: (IllegalInputParam [137]

the params:

eClsPropDefs[0] = new Autodesk.Connectivity.WebServices.EntClassCtntSrcPropCfg();

eClsPropDefs[0].EntClassId = "ITEM";

eClsPropDefs[0].CanCreateNewArray = new bool[] { false };

PropConstr[] baseConstraints = new Autodesk.Connectivity.WebServices.PropConstr[1];

baseConstraints[0] = new Autodesk.Connectivity.WebServices.PropConstr();

baseConstraints[0].CatId = -1;

baseConstraints[0].PropDefId = propInfo.PropDef.Id;

baseConstraints[0].PropConstrTyp = Autodesk.Connectivity.WebServices.PropConstrTyp.RequiresValue; baseConstraints[0].Val = "false";

but I don't have an ID for baseConstraints[0].Id

I noticed, when I assign e.g. a minimum length by Vault Explorer, there was a new entry in the table

PropConstraint with my newly created PropertyDefId and value.

I suppose, this PropConstraintId is the needes value, but I don't find a function like "AddPropertyConstraint"

What is to do?

So it sounds like you're trying to set multiple constraints for a property but you're only seeing one of the constraints being set? I'm not entirely sure what the problem might be without seeing more of the code you're using for creating the propety constraints array that you are passing into the UpdatePropertyDefinitionInfo() method, but I'd like to point out that you have to make sure all the contraints for the property are in that array, not just the ones you want to add. For example, to add a miminum length constraint, you could use code similar to the following:

 

PropConstr[] baseConstraints;

if(udp.PropConstrArray != null)

{

     baseContraints = new PropConstr[udp.PropConstrArray.Length + 1];

     udp.PropConstrArray.CopyTo(baseConstraints, 0);

}

else

     baseConstraints = new PropConstr[1]; 

int lastIndex = baseConstraints.Length - 1;

baseConstraints[lastIndex] = new PropConstr();

baseConstraints[lastIndex].CatId = -1;

baseConstraints[lastIndex].PropDefId = udp.PropDef.Id;

baseConstraints[lastIndex].PropConstrTyp = PropConstrTyp.MinimumLength;

baseConstraints[lastIndex].Val = "1";

udp = wsManager.PropertyService.UpdatePropertyDefinitionInfo(udp.PropDef, udp.EntClassCtntSrcPropCfgArray, baseConstraints, null);

 

Using this code, all constraints that were previously on the property are there, and a new constraint will be added. Also, you can verify that the constraints are added to the property by looking at the PropDefInfo object returned by the UpdatePropertyDefinitionInfo() method. If this still doesn't help, looking at more of the code you're using  to set up the parameters used for the UpdatePropertyDefinitionInfo() method might be helpful.

Employee
Daniel.Dulzo
Posts: 61
Registered: ‎05-25-2011
Message 2 of 5 (253 Views)

Re: create Item UPDs per Api - how to create PropConstr-objexts

03-30-2012 12:50 PM in reply to: ewcv

Hi ewcv,

 

I don't think the issue is because you don't have an ID for the PropConstr. I think you're issue is caused by your EntClassCtntSrcPropCfg array. If you're trying to put a new constraint on a property, I would suggest just passing in the existing EntClassCtntSrcPropCfg array from the PropDefInfo of the PropDef you're trying to update. For example, try the following:

 

// create the udp

udp = wsManager.PropertyService.AddPropertyDefinition("UDP", DataType.String, false, true, "Default", null, null, null, null);

udp = wsManager.PropertyService.UpdatePropertyDefinition(udp.PropDef.Id, "UDP", true, true, "Default", newstring[] { "ITEM" });

 

PropConstr[] baseConstraints = newPropConstr[1];

baseConstraints[0] = newPropConstr();

baseConstraints[0].CatId = -1;

baseConstraints[0].PropDefId = udp.PropDef.Id;

baseConstraints[0].PropConstrTyp = PropConstrTyp.RequiresValue;

baseConstraints[0].Val = "false";

 

udp = wsManager.PropertyService.UpdatePropertyDefinitionInfo(udp.PropDef, udp.EntClassCtntSrcPropCfgArray, baseConstraints, null);



Daniel Dulzo
Software Engineer
Autodesk, Inc.
Contributor
ewcv
Posts: 22
Registered: ‎02-01-2012
Message 3 of 5 (243 Views)

Betreff: create Item UPDs per Api - how to create PropConstr-objexts

04-02-2012 03:27 AM in reply to: ewcv

Hi Daniel,

thank you, but this helps only a few.

udp = wsManager.PropertyService.UpdatePropertyDefinition​(udp.PropDef.Id, "UDP", true, true, "Default", newstring[] { "ITEM" })  returns upd.EntClassCtntSrcPropCfgArray=null and upd.

PropConstrArray = null (see attachment Screenshot-PropDefInfo.JPG).

Because PropConstrTyp.Re​quiresValue=false is default, I tried with MinimumValue=1 and MaximumValue=100

UpdatePropertyDefinitionInfo​() is succesful, I see new 2 entries in table PropConstraint, but in Vault Explorer, i don't see minimum and maximum length (see Property.pdf).

I can assign all Item-categories, but no one has a minimum ormaximum length.

What do I have to do in addition?

Erika

Employee
Daniel.Dulzo
Posts: 61
Registered: ‎05-25-2011
Message 4 of 5 (233 Views)

Betreff: create Item UPDs per Api - how to create PropConstr-objexts

04-02-2012 08:17 AM in reply to: ewcv

So it sounds like you're trying to set multiple constraints for a property but you're only seeing one of the constraints being set? I'm not entirely sure what the problem might be without seeing more of the code you're using for creating the propety constraints array that you are passing into the UpdatePropertyDefinitionInfo() method, but I'd like to point out that you have to make sure all the contraints for the property are in that array, not just the ones you want to add. For example, to add a miminum length constraint, you could use code similar to the following:

 

PropConstr[] baseConstraints;

if(udp.PropConstrArray != null)

{

     baseContraints = new PropConstr[udp.PropConstrArray.Length + 1];

     udp.PropConstrArray.CopyTo(baseConstraints, 0);

}

else

     baseConstraints = new PropConstr[1]; 

int lastIndex = baseConstraints.Length - 1;

baseConstraints[lastIndex] = new PropConstr();

baseConstraints[lastIndex].CatId = -1;

baseConstraints[lastIndex].PropDefId = udp.PropDef.Id;

baseConstraints[lastIndex].PropConstrTyp = PropConstrTyp.MinimumLength;

baseConstraints[lastIndex].Val = "1";

udp = wsManager.PropertyService.UpdatePropertyDefinitionInfo(udp.PropDef, udp.EntClassCtntSrcPropCfgArray, baseConstraints, null);

 

Using this code, all constraints that were previously on the property are there, and a new constraint will be added. Also, you can verify that the constraints are added to the property by looking at the PropDefInfo object returned by the UpdatePropertyDefinitionInfo() method. If this still doesn't help, looking at more of the code you're using  to set up the parameters used for the UpdatePropertyDefinitionInfo() method might be helpful.



Daniel Dulzo
Software Engineer
Autodesk, Inc.
Contributor
ewcv
Posts: 22
Registered: ‎02-01-2012
Message 5 of 5 (230 Views)

Betreff: create Item UPDs per Api - how to create PropConstr-objexts

04-02-2012 11:56 PM in reply to: ewcv

Hi Daniel,

I'm sorry, my bad: I specified PropConstrTyp.MinimumValue unstead of MinimumLength.

Thank you for your help anyway

Erika

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.