Friday, July 5, 2019

Sample C# code for ItemSearchBasic

Below is a sample C# codes that will perform an ItemSearchBasic via Web Services.

The search contains two filters: (a) type anyOf _otherCharge and (b) Boolean Custom Field (checkbox) is true/checked.

This requires basic understanding in C# and Web Services to run properly.

            ItemSearchBasic isb = new ItemSearchBasic();
            SearchEnumMultiSelectField smsf = new SearchEnumMultiSelectField ();
            smsf.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
            smsf.operatorSpecified = true;

            isb.type = smsf;

            String[] strField = new String[1];
            strField[0] = "_otherCharge";
            isb.type.searchValue = strField;

            SearchBooleanCustomField saleItem = new SearchBooleanCustomField();
            saleItem.internalId = "custitem_online_sale";
            saleItem.searchValue = true;
            saleItem.searchValueSpecified = true;

            SearchCustomField[] scf = new SearchCustomField[1];
            scf[0] = saleItem;

            isb.customFieldList = scf;

            SearchResult s = _ws.search(isb);

No comments:

Post a Comment