This topic contains 2 replies, has 0 voices, and was last updated by chuckles 8 years, 10 months ago.

  • Author
    Posts
  • #6811

    chuckles

    Sorry guys and gals,

    Having a senior moment. In C#, webservices… trying to select all open invoices by a specific customer..Think I’ve got all of the other parts in place, just can’t remember how to select a specific customer by internal id. Any help out there?

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

  • #6812

    ashishshukla

    Hi,

    Here is the C# code –

    private List GetCustomerSpecificOpenInvoices(string customerId)

    {

    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;

    if (!string.IsNullOrEmpty(customerId))

    {

    SearchMultiSelectField customer = new SearchMultiSelectField();

    RecordRef customerRef = new RecordRef();

    customerRef.internalId = customerId;

    customerRef.type = RecordType.customer;

    customerRef.typeSpecified = true;

    RecordRef[] customerRefArray = new RecordRef[1];

    customerRefArray[0] = customerRef;

    customer.searchValue = customerRefArray;

    invoiceSearchBasic.entity = customer;

    }

    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;

    }

  • #6813

    chuckles

    thanks very much for your response

You must be logged in to reply to this topic.