Monday, January 28, 2019

C#/.NET search operation specifying the operator.


When performing a search in Web Services and using C# to perform the search operation there are a few things that you need to specify in order for the search to return the result successfully. One of the key components to doing a search in C# is specifying the operator. Below is sample code of Web Services search operation in C#.

    This search is a Custom Record Search Basic.
    // This is the internal ID of the custom record
    RecordRef rf = new RecordRef();
    rf.internalId = "4";
    CustomRecordSearchBasic crsb = new CustomRecordSearchBasic();
    SearchStringField ssf = new SearchStringField();
    ssf.@operator = SearchStringFieldOperator.notEmpty;
    ssf.operatorSpecified = true;
    crsb.recType = rf;
    crsb.name = ssf;
    SearchResult res = nss.search(crsb);

Code Description:
    This code is looking in custom record where the string field is not empty and where record type is that of internal ID 4

Note:
    If you do not set operatorSpecified to true when performing a search you will receive an error.

No comments:

Post a Comment