0

I downloaded an example application for using some web services with an online system.

I am not sure if all code below is needed but it is what I got and what I am trying to do is to use the search function.

I start by calling searchCustomer with an ID I have:

partnerRef.internalId = searchCustomer(customerID);

And the code for searchCustomer:

private string searchCustomer(string CustomerID)
        {

            string InternalID = "";

            CustomerSearch custSearch = new CustomerSearch();
            CustomerSearchBasic custSearchBasic = new CustomerSearchBasic();

            String nameValue = CustomerID;
            SearchStringField entityId = null;

                entityId = new SearchStringField();
                entityId.@operator = SearchStringFieldOperator.contains;
                entityId.operatorSpecified = true;
                entityId.searchValue = nameValue;
                custSearchBasic.entityId = entityId;

            String statusKeysValue = "";
            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;

            SearchResult response = _service.search(custSearch);

            if (response.status.isSuccess)
            {

                processCustomerSearchResponse(response);




                    if (seachMoreResult.status.isSuccess)
                    {

                        processCustomerSearchResponse(seachMoreResult);

                        return InternalID;
                    }
                    else
                    {
                        _out.error(getStatusDetails(seachMoreResult.status));

                    }

            }
            else
            {
                _out.error(getStatusDetails(response.status));
            }

            return InternalID;
        }

In the code above processCustomerSearchResponse gets called

processCustomerSearchResponse(response);

The code for this function is:

public string processCustomerSearchResponse(SearchResult response)
{
    string InternalID = "";
    Customer customer;

        customer = (Customer)records[0];
        InternalID = customer.internalId;

        return InternalID;
}

What the original code did was to write some output in the console but I want to return the InternalID instead. When I debug the application InternalID in processCustomerSearchResponse contains the ID I want but I don't know how to pass it to searchCustomer so that function also returns the ID. When I debug searchCustomer InternalID is always null. I am not sure on how to edit the code under response.status.isSuccess to return the InternalID, any ideas?

Thanks in advance.

1 Answer 1

1

When you call processCustomerSearchResponse(response);, you need to store the return value in memory.

Try modifying your code like this:

 InternalID = processCustomerSearchResponse(response);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.