This topic contains 1 reply, has 0 voices, and was last updated by adamsharpe 8 years, 2 months ago.

  • Author
    Posts
  • #6782

    jmagnusson

    Hi,

    We’ve noticed that fields that are missing data in a saved search row will not even show. Is it somehow possible to tell the web service that all fields should show up, even if they’re empty? And if not, is it possible to get a specification for a saved search, telling us which fields can exist for a row?

    Thanks,
    This is a cached copy. Click here to see the original post.

  • #6783

    adamsharpe

    I noticed that when pulling columns from a Saved Search, you have to specify the columns you want returned. (Stupid, and annoying I know.)

    Using this code, I am able to pull the following three fields from my saved search (InternalID, TransactionDate, SerialNumber):

    var service = Service.Context();

    var serialNumbers = “”;

    var tsa = new TransactionSearchAdvanced

    {

    savedSearchScriptId = “customsearchtest_assemblies”

    };

    service.searchPreferences = new SearchPreferences { bodyFieldsOnly = false };

    tsa.criteria = new TransactionSearch()

    {

    basic = new TransactionSearchBasic()

    {

    internalId = new SearchMultiSelectField

    {

    @operator = SearchMultiSelectFieldOperator.anyOf,

    operatorSpecified = true,

    searchValue = new[] {

    new RecordRef() {

    type = RecordType.assemblyBuild,

    typeSpecified = true,

    internalId = assemblyBuildId

    }

    }

    }

    }

    };

    // Construct custom columns to return

    var tsr = new TransactionSearchRow();

    var tsrb = new TransactionSearchRowBasic();

    var orderIdCols = new SearchColumnSelectField[1];

    var orderIdCol = new SearchColumnSelectField();

    orderIdCols[0] = orderIdCol;

    tsrb.internalId = orderIdCols;

    var tranDateCols = new SearchColumnDateField[1];

    var tranDateCol = new SearchColumnDateField();

    tranDateCols[0] = tranDateCol;

    tsrb.tranDate = tranDateCols;

    var serialNumberCols = new SearchColumnStringField[1];

    var serialNumberCol = new SearchColumnStringField();

    serialNumberCols[0] = serialNumberCol;

    tsrb.serialNumbers = serialNumberCols;

    tsr.basic = tsrb;

    tsa.columns = tsr;

    var response = service.search(tsa);

    if (response.status.isSuccess)

    {

    var searchRows = response.searchRowList;

    if (searchRows != null && searchRows.Length >= 1)

    {

    foreach (SearchRow t in searchRows)

    {

    var transactionRow = (TransactionSearchRow)t;

    if (transactionRow.basic.serialNumbers != null)

    {

    return transactionRow.basic.serialNumbers[0].searchValue;

    }

    }

    }

    }

    return serialNumbers;

You must be logged in to reply to this topic.