c#按阶段返回netsuite中的所有客户

时间:2015-02-04 18:43:17

标签: c# netsuite

使用c#,我需要让NetSuite中的所有客户都在舞台上._customer

我现在正在使用它:

  private void ReturnAllCustomers()
    {
        // Instantiate a search object for customers. 
        CustomerSearch custSearch = new CustomerSearch();
        CustomerSearchBasic custSearchBasic = new CustomerSearchBasic();


        // Search the customer status which is a list field (16,13,15) 
        String statusKeysValue = "16,13,15";
        SearchMultiSelectField status = null;
        if (statusKeysValue != null && !statusKeysValue.Trim().Equals(""))
        {
            status = new SearchMultiSelectField();
            status.@operator = SearchMultiSelectFieldOperator.anyOf;
            status.operatorSpecified = true;
            string[] nskeys = statusKeysValue.Split(new Char[] { ',' });

            RecordRef[] recordRefs = new RecordRef[statusKeysValue.Length];
            for (int i = 0; i < nskeys.Length; i++)
            {
                RecordRef recordRef = new RecordRef();
                recordRef.internalId = nskeys[i];
                recordRefs[i] = recordRef;
            }
            status.searchValue = recordRefs;
            custSearchBasic.entityStatus = status;
        }

        custSearch.basic = custSearchBasic;

        // Invoke search() web services operation 
        SearchResult response = _service.search(custSearch);

        // Process response
        if (response.status.isSuccess)
        {
            // Process the records returned in the response and print to console
            // Get more records with pagination
            if (response.totalRecords > 0)
            {
                for (int i = 1; i <= response.totalRecords; i++)
                {
                    processCustomerSearchResponse(response);
                }
            }
            else
            {
            }
        }
        else
        {
        }

    }

它借鉴了一个基于状态搜索的类似想法。这会返回我的客户的一个奇怪的子集,但不是全部。

我也试过这样的事情: custSearchBasic.stage = CustomerStage._customer;

但是它咳嗽了,因为它希望这个阶段成为一个&#34; SearchEnumMultiSelectField&#34;类型。

Netsuite的帮助毫无用处,所以任何帮助都会受到赞赏。

1 个答案:

答案 0 :(得分:0)

客户阶段价值隐藏在(精彩)文档中。

CustomerSearch cs = new CustomerSearch();
cs.basic = new CustomerSearchBasic();
cs.basic.stage = new SearchEnumMultiSelectField();
cs.basic.stage.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
cs.basic.stage.operatorSpecified = true;
cs.basic.stage.searchValue = new string[] { "PROSPECT" };