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?
Solved! Go to Solution.
Solved by Daniel.Dulzo. Go to Solution.
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);
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.RequiresValue=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
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.
Hi Daniel,
I'm sorry, my bad: I specified PropConstrTyp.MinimumValue unstead of MinimumLength.
Thank you for your help anyway
Erika