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

Question

Question

SDK does not place value in template field

SDK
asked on November 22, 2019

Hi all,

I have an application developed with SDK, which imports a document into the repository and immediately puts a value in a template field.

However, randomly, this field is not entered in the document metadata, and the application does not present any error.

As I mentioned, this is sporadic, for example, of 50 documents that are imported, it may be that 12 does not put the template field data.

I can't recognize that this may be due, any help or suggestion would be greatly appreciated.

0 0

Replies

replied on November 22, 2019

It's hard to give specific suggestions without sample code or something that connects the failing cases. The only guess I can make is that there is an error thrown somewhere that is caught without reporting the problem to the user. I'd suggest auditing all of the catch statements in your project to make sure they report and/or rethrow.

1 0
replied on November 22, 2019

This would be the code I am using:

I import the document first:

 

public Boolean Importa_Documento(int id_Documento, string ruta)
        {
            logIn();
            Boolean import;

            try
            {
                using (DocumentInfo doc = Document.GetDocumentInfo(id_Documento, mySess))
                {
                    DocumentImporter DI = new DocumentImporter();
                    DI.Document = doc;

                    if (!doc.MimeType.Equals(""))
                        DI.ImportEdoc(doc.MimeType, ruta);
                    else
                        DI.ImportEdoc("pdf", ruta);

                }
                import = true;
                mensaje = "Documento importado satisfactoriamente";

                log.Registro("Documento importado satisfactoriamente");
            }
            catch (LaserficheRepositoryException ex)
            {
                import = false;
                mensaje = "Error: " + ex.ToString();

                log.Registro("Error al importar documento a Laserfiche: " + ex.ToString());
            }

            logOff();
            return import;
        }

 

Second, I add the value in the "Estado de Firma" field
(As you can see, I tried to delete the field and add it again, but the incident is the same)

public bool AgregaCampoEstadoFirma(int id, int estado)
        {
            bool agregaCampoEstado = false;

            logIn();

            try
            {
                EntryInfo doc = Entry.GetEntryInfo(id, mySess);
                FieldValueCollection FVC = doc.GetFieldValues();
                switch (estado)
                {
                    case 0:
                        FVC.Add("Estado de Firma", "En Proceso");
                        log.Registro("Campo estado de firma, nuevo valor: " + "En Proceso");
                        break;
                    case 1:
                        FVC.Remove("Estado de Firma");
                        log.Registro("Campo estado de firma eliminado satisfactoriamente");
                        FVC.Add("Estado de Firma", "Exitosa");
                        log.Registro("Campo estado de firma, nuevo valor: " + "Exitosa");
                        break;
                    case 2:
                        FVC.Remove("Estado de Firma");
                        log.Registro("Campo estado de firma eliminado satisfactoriamente");
                        FVC.Add("Estado de Firma", "Errónea");
                        log.Registro("Campo estado de firma, nuevo valor: " + "Errónea");
                        break;
                }

                doc.Lock(LockType.Exclusive);
                doc.SetFieldValues(FVC);
                doc.Save();
                doc.Unlock();

                agregaCampoEstado = true;
            }
            catch (LaserficheRepositoryException ex)
            {
                mensaje = "Error: " + ex.ToString();
                log.Registro("Error al modificar valor de campo Estado de Firma: " + ex.ToString());
            }
            finally
            {
                logOff();
            }

            return agregaCampoEstado;
        }

 

Even create a "log" class that stores what happens in the application step by step in a txt. In this txt, the record is stored: "Campo estado de firma, nuevo valor: " + "Exitosa"" and never enter the catch

However, at the audittrail level it is not recorded that the value has been added to the field

0 0
replied on December 5, 2019

I don't see anything obviously wrong with the code. If you can put together a minimal program that reliably demonstrates the problem, you should consider opening a support case.

1 0
replied on December 5, 2019

Try using operator[] to set the values, like this:

FVC["Estado de Firma"] = "Errónea";

You might have found a bug in the Add/Remove methods, which I don't think our code uses very often.

1 0
replied on December 12, 2019

Thank you both for your answers. After conducting a deeper analysis of the incidence presented, I discovered that there was no error in SDK. I comment, I have a web application integrated with the SDK code that I put in previous comments. When this application is executed, a workflow is executed in parallel. The error occurred because SDK modified the value of the field and the workflow returned it to the previous value, once I corrected this, everything works correctly. Thank you very much.

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

Sign in to reply to this post.