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

  • Author
    Posts
  • #6809

    chuckles

    When trying to search open invoices, I try setting the search filter for status = “Open”. no luck…on basic search it seems to wants SearchEnumMultiSelectField. Am I not holding my mouth right. Does anyone have a snippet? Webservices, C#.
    This is a cached copy. Click here to see the original post.

  • #6810

    ashishshukla

    Hi,

    Below is the C# code to search for invoices with status = Open

    private List GetOpenInvoices()

    {

    TransactionSearch invoiceSearch = new TransactionSearch();

    TransactionSearchBasic invoiceSearchBasic = new TransactionSearchBasic();

    SearchEnumMultiSelectField invoiceStatus = new SearchEnumMultiSelectField();

    string[] statusArray = new string[1];

    statusArray[0] = “_invoiceOpen”;

    invoiceStatus.searchValue = statusArray;

    invoiceStatus.@operator = SearchEnumMultiSelectFieldOperator.anyOf;

    invoiceStatus.operatorSpecified = true;

    invoiceSearchBasic.status = invoiceStatus;

    SearchEnumMultiSelectField recType = new SearchEnumMultiSelectField();

    string[] transactioType = new string[1];

    transactioType[0] = “_invoice”;

    recType.searchValue = transactioType;

    recType.@operator = SearchEnumMultiSelectFieldOperator.anyOf;

    recType.operatorSpecified = true;

    invoiceSearchBasic.type = recType;

    SearchPreferences pref = new SearchPreferences();

    pref.bodyFieldsOnly = false;

    objService.searchPreferences = pref;

    invoiceSearch.basic = invoiceSearchBasic;

    Invoice invoiceRecord = null;

    List invoiceRange = new List();

    SearchResult invoiceResults = objService.search(invoiceSearch);

    if (invoiceResults.status.isSuccess == true && invoiceResults.status.isSuccessSpecified == true)

    {

    if (invoiceResults != null)

    {

    for (var i = 0; i < invoiceResults.recordList.Length; i++)

    {

    invoiceRecord = (Invoice)invoiceResults.recordList[i];

    invoiceRange.Add(invoiceRecord);

    }

    }

    }

    return invoiceRange;

    }

    Hope this will help.

    Thanks,

    Ashish

You must be logged in to reply to this topic.