Below is a Sample of .Net C# showing how to update a custom fields of different type in a Standard Record.
This sample only applies to WSDL version 2013.1 and below.
Sample Code (C#:)
SalesOrder salesOrder = new SalesOrder();
salesOrder.internalId = "1356";
StringCustomFieldRef stringCustomFieldRef = new StringCustomFieldRef();
stringCustomFieldRef.internalId = "custbody_test_string_field";
stringCustomFieldRef.value = "String Value Here";
DoubleCustomFieldRef doubleCustomFieldRef = new DoubleCustomFieldRef();
doubleCustomFieldRef.internalId = "custbody_test_decimal_field";
doubleCustomFieldRef.value = 8.8 ;
ListOrRecordRef custSelectValue = new ListOrRecordRef();
custSelectValue.internalId = "1";
SelectCustomFieldRef selectCustomFieldRef = new SelectCustomFieldRef();
selectCustomFieldRef.internalId = "custbody_test_record_field";
selectCustomFieldRef.value = custSelectValue;
ListOrRecordRef[] custMultiSelectValue = new ListOrRecordRef[2];
custMultiSelectValue[0] = new ListOrRecordRef();
custMultiSelectValue[0].internalId = "1";
custMultiSelectValue[1] = new ListOrRecordRef();
custMultiSelectValue[1].internalId = "2";
ListOrRecordRef[] multiSelect = new ListOrRecordRef[1];
MultiSelectCustomFieldRef multiSelectCustomFieldRef = new MultiSelectCustomFieldRef();
multiSelectCustomFieldRef.internalId = "custbodytest_multiselect_field";
multiSelectCustomFieldRef.value = custMultiSelectValue;
BooleanCustomFieldRef booleanCustomFieldRef = new BooleanCustomFieldRef();
booleanCustomFieldRef.internalId = "custbody_test_checkbox_field";
booleanCustomFieldRef.value = true;
DateCustomFieldRef dateCustomFieldRef = new DateCustomFieldRef();
dateCustomFieldRef.internalId = "custbody_test_date_field";
dateCustomFieldRef.value = DateTime.Today;
CustomFieldRef[] customFieldRef = new CustomFieldRef[6];
customFieldRef[0] = stringCustomFieldRef;
customFieldRef[1] = doubleCustomFieldRef;
customFieldRef[2] = selectCustomFieldRef;
customFieldRef[3] = multiSelectCustomFieldRef;
customFieldRef[4] = booleanCustomFieldRef;
customFieldRef[5] = dateCustomFieldRef;
//customFieldRef().customField = customField;
salesOrder.customFieldList = customFieldRef;
WriteResponse response = service.update(salesOrder);
salesOrder.internalId = "1356";
StringCustomFieldRef stringCustomFieldRef = new StringCustomFieldRef();
stringCustomFieldRef.internalId = "custbody_test_string_field";
stringCustomFieldRef.value = "String Value Here";
DoubleCustomFieldRef doubleCustomFieldRef = new DoubleCustomFieldRef();
doubleCustomFieldRef.internalId = "custbody_test_decimal_field";
doubleCustomFieldRef.value = 8.8 ;
ListOrRecordRef custSelectValue = new ListOrRecordRef();
custSelectValue.internalId = "1";
SelectCustomFieldRef selectCustomFieldRef = new SelectCustomFieldRef();
selectCustomFieldRef.internalId = "custbody_test_record_field";
selectCustomFieldRef.value = custSelectValue;
ListOrRecordRef[] custMultiSelectValue = new ListOrRecordRef[2];
custMultiSelectValue[0] = new ListOrRecordRef();
custMultiSelectValue[0].internalId = "1";
custMultiSelectValue[1] = new ListOrRecordRef();
custMultiSelectValue[1].internalId = "2";
ListOrRecordRef[] multiSelect = new ListOrRecordRef[1];
MultiSelectCustomFieldRef multiSelectCustomFieldRef = new MultiSelectCustomFieldRef();
multiSelectCustomFieldRef.internalId = "custbodytest_multiselect_field";
multiSelectCustomFieldRef.value = custMultiSelectValue;
BooleanCustomFieldRef booleanCustomFieldRef = new BooleanCustomFieldRef();
booleanCustomFieldRef.internalId = "custbody_test_checkbox_field";
booleanCustomFieldRef.value = true;
DateCustomFieldRef dateCustomFieldRef = new DateCustomFieldRef();
dateCustomFieldRef.internalId = "custbody_test_date_field";
dateCustomFieldRef.value = DateTime.Today;
CustomFieldRef[] customFieldRef = new CustomFieldRef[6];
customFieldRef[0] = stringCustomFieldRef;
customFieldRef[1] = doubleCustomFieldRef;
customFieldRef[2] = selectCustomFieldRef;
customFieldRef[3] = multiSelectCustomFieldRef;
customFieldRef[4] = booleanCustomFieldRef;
customFieldRef[5] = dateCustomFieldRef;
//customFieldRef().customField = customField;
salesOrder.customFieldList = customFieldRef;
WriteResponse response = service.update(salesOrder);
XML
No comments:
Post a Comment