This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A duplicate property value [PropertyName] was encountered error

Hello everyone!

Today I stumbled upon an odd error. Couldn't really figured out what's wrong. So I have a VAF running in my vault during Before Create New Object Finalize event handler.

The script meant to set properties before the object is created. The first run after deployment is smooth sailing. However, on the second object creation and so on, it threw an error "A duplicate property value [PropertyName] was encountered". I double checked the variable returns only one value not multiple. Below is the snippet on how I set the properties after getting the data from the searching. Is this a known issue or a bug? Or perhaps I should add something to the script?

var oResults = env.Vault.ObjectSearchOperations.SearchForObjectsByCondition(oSc, true);
int theobjID = 0;               

                if (oResults.Count > 0)
                {
                    
                    foreach (ObjectVersion routing in oResults)
                    {
                        if (routing.ObjVer.Type == 101) 
                        {
                            theobjID = routing.ObjVer.ID;

                            break;
                        }
                        break; //to make it run only once 
                    }
                }
                

                var Remarks = env.Vault.PropertyDefOperations.GetPropertyDefIDByAlias("BP.PD.Remarks");
                aPropVal.PropertyDef = Remarks;
                aPropVal.TypedValue.SetValue(MFDataType.MFDatatypeMultiLineText, fData[4]);
                aPropVals.Add(-1, aPropVal);

                var TheGroup = env.Vault.PropertyDefOperations.GetPropertyDefIDByAlias("BP.PD.Groups");
                aPropVal.PropertyDef = TheGroup;
                aPropVal.TypedValue.SetValue(MFDataType.MFDatatypeLookup, theobjID);
                aPropVals.Add(-1, aPropVal);

                env.Vault.ObjectPropertyOperations.SetProperties(env.ObjVer, aPropVals);


Thank you in advance!

Parents Reply
  • What I don't understand is, why the first attempt of object creation has no issue and then the error starts appearing on the next attempt. The properties collection is totally empty from what I can tell. As you can see on the code snippet above that the data on the first PropertyValue is coming from an array and the second one is a lookup of an object id from the searching function.

Children
  • Where do you create aPropVals? 

  • I created that at the very top outside of the function as a public variable. I added multiple PropertyValue like below but still getting the same error. 

    PropertyValue aPropVal1 = new PropertyValue();
    var Remarks = env.Vault.PropertyDefOperations.GetPropertyDefIDByAlias("BP.PD.Remarks");
    aPropVal1.PropertyDef = Remarks;
    aPropVal1.TypedValue.SetValue(MFDataType.MFDatatypeMultiLineText, fData[4]);
    aPropVals.Add(-1, aPropVal1);
    
    PropertyValue aPropVal2 = new PropertyValue();
    var TheGroup = env.Vault.PropertyDefOperations.GetPropertyDefIDByAlias("BP.PD.Groups");
    aPropVa2.PropertyDef = TheGroup;
    aPropVa2.TypedValue.SetValue(MFDataType.MFDatatypeLookup, theobjID);
    aPropVals.Add(-1, aPropVal2);