It's been awhile since I've needed to work with Web Services and am a bit rusty.
I'm doing a quick POC with WS and have run into an error that I'm not sure what to do with: "The specified internal id is not allowed."
Basically, I'm searching for a custom record, changing one of it's fields and trying to save it back. Here is the code:
public bool FindDoctorsOrder(string orderID) { try { // Create a new search object CustomRecordSearchBasic crsb = new CustomRecordSearchBasic(); // Tell the search what type of record to look for crsb.recType = new RecordRef(); crsb.recType.internalId = "35"; crsb.internalId = new SearchMultiSelectField(); crsb.internalId.searchValue = new RecordRef[1]; crsb.internalId.searchValue[0] = new RecordRef(); crsb.internalId.searchValue[0].internalId = orderID; crsb.internalId.@operator = SearchMultiSelectFieldOperator.anyOf; crsb.internalId.operatorSpecified = true; _service.preferences = new Preferences(); _service.preferences.ignoreReadOnlyFields = true; _service.preferences.ignoreReadOnlyFieldsSpecified = true; Login(); SearchResult result = _service.search(crsb); if(result.status.isSuccess && result.recordList.Length > 0) { Trace.WriteLine("Found Record"); // Change the status and save it (just a test) CustomRecord record = result.recordList[0] as CustomRecord; SelectCustomFieldRef statusField = FindCustomField<SelectCustomFieldRef>("custrecord_phys_order__status", record.customFieldList); if(statusField != null) { statusField.value.internalId = "4"; // try saving the record WriteResponse response = _service.add(record); if(response.status.isSuccess) { Trace.WriteLine("Saved record"); } else { Trace.WriteLine("Failed saving record"); Trace.WriteLine(response.status.statusDetail[0].message); } } } else { Trace.WriteLine("Didn't find record"); } _service.logout(); } catch(Exception e) { Trace.WriteLine(e.Message); } return false; }It's the call to add() that is failing. No exceptions, just the error in the status message of WriteResponse.Anyone have any ideas for me? Like I said, I'm a bit rusty but the error is vague. Even if I don't make any changes to the record and try to save it fails with the same exact error.SOAP <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Header> <preferences xmlns="urn:messages_2_5.platform.webservices.netsuite.com"> <ignoreReadOnlyFields>true</ignoreReadOnlyFields> </preferences> </soap:Header> <soap:Body> <add xmlns="urn:messages_2_5.platform.webservices.netsuite.com"> <record xsi:type="q1:CustomRecord" internalId="14" xmlns:q1="urn:customization_2_5.setup.webservices.netsuite.com"> <q1:created>2007-11-04T10:00:00-08:00</q1:created> <q1:lastModified>2007-11-05T11:47:00-08:00</q1:lastModified> <q1:owner internalId="-5"> <name xmlns="urn:core_2_5.platform.webservices.netsuite.com">Steve Klett</name> </q1:owner> <q1:recType internalId="35"> <name xmlns="urn:core_2_5.platform.webservices.netsuite.com">Physicians Order</name> </q1:recType> <q1:customFieldList> <customField xsi:type="SelectCustomFieldRef" internalId="custrecord_phys_order__type" xmlns="urn:core_2_5.platform.webservices.netsuite.com"> <value internalId="2" typeId="36"/> </customField> <customField xsi:type="SelectCustomFieldRef" internalId="custrecord_phys_order__so_link" xmlns="urn:core_2_5.platform.webservices.netsuite.com"> <value internalId="8197" typeId="-30"/> </customField> <customField xsi:type="SelectCustomFieldRef" internalId="custrecord_phys_order__status" xmlns="urn:core_2_5.platform.webservices.netsuite.com"> <value internalId="3" typeId="37"/> </customField> </q1:customFieldList> </record> </add> </soap:Body> </soap:Envelope> <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <documentInfo xmlns="urn:messages_2_5.platform.webservices.netsuite.com"> <nsId>WEBSERVICES_483002_110620073644420191510021714_7e59d51fe012a</nsId> </documentInfo> </soapenv:Header> <soapenv:Body> <addResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com"> <writeResponse> <ns1:status isSuccess="false" xmlns:ns1="urn:core_2_5.platform.webservices.netsuite.com"> <ns1:statusDetail type="ERROR"> <ns1:code>USER_ERROR</ns1:code> <ns1:message>The specified internal id is not allowed.</ns1:message> </ns1:statusDetail> </ns1:status> </writeResponse> </addResponse> </soapenv:Body> </soapenv:Envelope>
Thanks,Steve