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
  • Hi all,

    I know this is a previous topic but just wondering on the scripting syntax.

    Based on the above scenario, understand that we have this property values aPropVals

    aPropVals.Add(-1, aPropVal2);


    Since we are using index -1, I am assuming that we are appending the value into this property values ?

    Is there any way we can remove all the values inside this property values ?

    I tried to perform below but it giving me parameter error ?

     

    aPropVals.Remove(-1)

Reply
  • Hi all,

    I know this is a previous topic but just wondering on the scripting syntax.

    Based on the above scenario, understand that we have this property values aPropVals

    aPropVals.Add(-1, aPropVal2);


    Since we are using index -1, I am assuming that we are appending the value into this property values ?

    Is there any way we can remove all the values inside this property values ?

    I tried to perform below but it giving me parameter error ?

     

    aPropVals.Remove(-1)

Children