You are viewing limited content. For full access, please sign in.

Question

Question

Update Multivalue Field that is tied to a group in Laserfiche 10.2

SDK
asked on May 25, 2017

Good Morning All,

     I am working on creating a Solution for a client to integrate an AS400 system with Laserfiche. We have about 90% of the functionality working, by creating web services that the 400 can call to process data. I am stuck at the point of trying to update a multivalue field that is a part of a group. I use my existing logic and I get a Laserfiche.RepositoryAccess.MultiStatusException "Unknown Error [9538]". I will post my code and see if anyone has any suggestions.

//Basic Code to Update a Field in Laserfiche
using (EntryInfo ei = Entry.GetEntryInfo(EntryID, newLogin.LaserficheSession))
{
     try
     {
          FieldValueCollection fvs = ei.GetFieldValues();
          ei.Lock(LockType.Exclusive);
          fvs[FieldName] = SetStatus;
          ei.Unlock();
          ei.SetTemplate(template, fvs);
          ei.Save();
      }
      catch(Exception ex1)
      {
           WriteLog("Error for File " + EntryID.ToString() + " message is " + ex1.Message);
       }
}
//Code for Multivalue Field
using (EntryInfo ei = Entry.GetEntryInfo(EntryID, newLogin.LaserficheSession))
{
      FieldValueCollection fvs = ei.GetFieldValues();
      ei.Lock(LockType.Exclusive);
      string fieldName = fieldNametextBox.Text;
      FieldInfo f = Field.GetInfo(fieldName, newLogin.LaserficheSession);
      TemplateInfo template = Laserfiche.RepositoryAccess.Template.GetInfo("Contributions", newLogin.LaserficheSession);
      if (f.IsMultiValue)
      {
          if (f.FieldType == FieldType.String || f.FieldType == FieldType.List)
          {
                object[] fieldVal = (object[])fvs[fieldName];
                int i = 0;
                foreach (object obj in fieldVal)
                {
                    string formattedVal = f.ValueToString(obj);
                    if(formattedVal == fieldValuetextBox.Text)
                    {
                        object[] conStat = (object[])fvs["Contribution Status"];
                        string ss = "Locked";
                        object oo = (object)ss;
                        conStat[i] = oo;
                        fvs["Contribution Status"] = conStat;                                    
                     }
                     i++;
                 }
           }
        }
        else
        {
             if (f.FieldType == FieldType.String || f.FieldType == FieldType.List)
             {
                  object fieldVal = (object)fvs[fieldName];
                  string formattedVal = f.ValueToString(fieldVal);
              }
        }
        ei.Unlock();
        ei.SetFieldValues(fvs);
        ei.Save();
    }                 


                    //fvs[FieldName] = newValue;
                    //ei.Unlock();
                    //ei.SetTemplate(template, fvs);


                }

If I check the debugger the FieldValueCollection has the correct information and it errors on the ei.Save(); Method. If anyone has any suggestions I would greatly appreciate it.

Capture.PNG
Capture.PNG (6.08 KB)
0 0

Answer

SELECTED ANSWER
replied on May 25, 2017

Error 9538, in this case, means roughly "you're using an older version of the SDK to talk to the server and it can't be sure that it can make your changes to the fields without clobbering the field group relationships."

I'd try updating to RepositoryAccess 10.2 and see if that fixes it.

0 0

Replies

replied on May 25, 2017

Thank you my good friend, this fixed the issue. Is there any code that you could share that works with metadata groups and group numbers? I am using an index identifier to select the row I want to update. I don't see any sample code available. Thanks for your input!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.