See the following examples of custom record related basic searches:
- search by internalId
- search by a custom boolean field
Please note that in custom record searches it's necessary to provide the the 'recType' parameter indicating the custom record type.
Sample 1 (search by internalId) :
This request searches for custom records of record type Id 130 (needs to be replaced by a valid record type Id defined by user) and returns a record with internalId=2, if such a record exists.
SOAP request
<soapenv:Body> <urn:search> <urn:searchRecord xsi:type="urn2:CustomRecordSearch"> <urn2:basic> <urn3:recType internalId="130" type="customRecordType"/> <urn3:internalId operator="anyOf" xsi:type="urn1:SearchMultiSelectField"> <urn1:searchValue internalId="2" type="customRecord" xsi:type="urn1:RecordRef"/> </urn3:internalId> </urn2:basic> </urn:searchRecord> </urn:search></soapenv:Body>
C#/.NET sample code matching the SOAP request above
// provide the 'rectype' parametermyCustRecSearch.basic.recType = new RecordRef();myCustRecSearch.basic.recType.internalId = "130";myCustRecSearch.basic.recType.type = RecordType.customRecordType;myCustRecSearch.basic.recType.typeSpecified = true;// specify the internalIdmyCustRecSearch.basic.internalId = new SearchMultiSelectField();myCustRecSearch.basic.internalId.searchValue = new RecordRef[1];myCustRecSearch.basic.internalId.searchValue[0] = new RecordRef();myCustRecSearch.basic.internalId.searchValue[0].internalId = "2";myCustRecSearch.basic.internalId.searchValue[0].type = RecordType.customRecordType;myCustRecSearch.basic.internalId.searchValue[0].typeSpecified = true;myCustRecSearch.basic.internalId.@operator = SearchMultiSelectFieldOperator.anyOf;myCustRecSearch.basic.internalId.operatorSpecified = true;// Invoke the web services search() operationSearchResult response = service.search(myCustRecSearch);
Sample 2 (search by a boolean custom field):
This request searches for custom records of record type Id 130 (needs to be replaced by a valid record type Id as defined by user) and returns all records where a custom boolean field with InternalId="custrecord128" is true/checked.
SOAP request
<soapenv:Body> <urn:search> <urn:searchRecord xsi:type="urn2:CustomRecordSearch"> <urn2:basic> <urn3:recType internalId="130" type="customRecordType"/> <urn3:customFieldList> <urn1:customField internalId="custrecord128" xsi:type="urn1:SearchBooleanCustomField"> <searchValue>true</searchValue> </urn1:customField> </urn3:customFieldList> </urn2:basic> </urn:searchRecord> </urn:search></soapenv:Body>
C#/.NET sample code matching the SOAP request above
// instantiate a search objectCustomRecordSearch myCustRecSearch = new CustomRecordSearch();myCustRecSearch.basic = new CustomRecordSearchBasic();// provide the 'rectype' parametermyCustRecSearch.basic.recType = new RecordRef();myCustRecSearch.basic.recType.internalId = "130";myCustRecSearch.basic.recType.type = RecordType.customRecordType;myCustRecSearch.basic.recType.typeSpecified = true;// specify the sought custom fieldmyCustRecSearch.basic.customFieldList = new SearchCustomField[1];SearchBooleanCustomField myCustField1 = new SearchBooleanCustomField();myCustField1.internalId = "custrecord128";myCustField1.searchValue = true;myCustField1.searchValueSpecified = true;myCustRecSearch.basic.customFieldList[0] = myCustField1;// Invoke the web services search() operationSearchResult response = service.search(myCustRecSearch);
No comments:
Post a Comment