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.