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!