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

Question

Question

Get field multi value using Search SDK

asked on September 15, 2014

Hello, 
I need to retrieve all the values ​​for the "DV_Chassi" field using the Search SDK.

 

 

Looking at the image above, we see that the field has multiple values​​, but the value returned is only this "AS58A9S651E7FGTY8".

 

I am using the following code.

 

using (Search LFSearch = new Search(this.Repositorio.GetCurrentRepositorySession()))
                {
                    LFSearch.Command = "{[]:[Status]<>\"04 Arquivar\"} & {[]:[Status]<>\"00 Pendencia\"} & {[]:[Status]<>\"07 Imagem Substituida\"} & {LF:Modified="
                                        + '\u0022' + dataModificacao.ToString("MM/dd/yyyy") + '\u0022' + "}";

                    LFSearch.Run();
                    
                    SearchListingSettings searchListingSettings = new SearchListingSettings();
                    searchListingSettings.AddColumn(SystemColumn.Id);
                    searchListingSettings.AddColumn(SystemColumn.Name);
                    searchListingSettings.EntryFilter = EntryTypeFilter.Documents;
                    
                    //Fields
                    searchListingSettings.AddColumns(new List<string>()
                        {
                            "DC_CNPJ", "DD_CNPJ_CPF", "DV_Marca", "DV_Chassi", "DV_Modelo"
                        });

                    List<ContratoSyncLaserfiche> listDocuments = new List<ContratoSyncLaserfiche>();

                    using (SearchResultListing searchResultListing = LFSearch.GetResultListing(searchListingSettings))
                    {
                        int num = searchResultListing.RowsCount;
                        for (int i = 1; i <= num; ++i)
                        {
                            // get the values formatted as strings; store the row
                            ContratoSyncLaserfiche document = new ContratoSyncLaserfiche();
                            string id = searchResultListing.GetDatumAsString(i, SystemColumn.Id);
                            document.EntryId = int.Parse(id.Replace(".", ""));
                            document.Chassi = searchResultListing.GetDatumAsString(i, "DV_Chassi");
                            document.CNPJCredor = searchResultListing.GetDatumAsString(i, "DC_CNPJ");
                            document.Devedor = searchResultListing.GetDatumAsString(i, "DD_CNPJ_CPF");
                            document.Fabricante = searchResultListing.GetDatumAsString(i, "DV_Marca");
                            document.Modelo = searchResultListing.GetDatumAsString(i, "DV_Modelo");

                            listDocuments.Add(document);
                        }
                    }

                    return listDocuments;
                }

How do I return all values​​?

"AS58A9S651E7FGTY8" and "8AJFZ29G8C6147999"

0 0

Answer

SELECTED ANSWER
replied on September 15, 2014

The entry listing only returns the first value, you can use EntryInfo.GetFieldValues() to retrieve all of the values for the field:

 


EntryInfo entryInfo = Entry.GetEntryInfo(document.EntryId, this.Repositorio.GetCurrentRepositorySession());
object objFieldValues = entryInfo.GetFieldValue("DV_Chassi");

object[] fieldValues = null;
if (objFieldValues is Array)
{
    fieldValues = (object[])objFieldValues;
}
else
{
    fieldValues = new object[1];
    fieldValues[0] = objFieldValues;
}

// fieldValues now contains an array of the values

 

2 0

Replies

You are not allowed to reply in this post.
replied on January 4, 2017

Can anyone provide the c# code to add a new value to an existing List using the sdk.

 

Thanks

You are not allowed to follow up in this post.

Sign in to reply to this post.