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.2 and above.
Since 2013.2 Custom fields can be referred to by there Internal ID and there Script ID.
In the script below, the Green Highlighted area shows the Custom Field referred to by there Internal ID, and the Yellow Highlighted are shows Custom Field referred by there Script ID.
Sample Code (C#:)
SalesOrder salesOrder = new SalesOrder();
salesOrder.internalId = "1356";
// WSDL/Port 2013.2 version requires that you use scriptID or InternalID
StringCustomFieldRef stringCustomFieldRef = new StringCustomFieldRef();
stringCustomFieldRef.scriptId = "custbody_test_string_field";//ScriptID
//Internal ID Example Below
//stringCustomFieldRef.internalId = 323;
stringCustomFieldRef.value = "String Value Here";
DoubleCustomFieldRef doubleCustomFieldRef = new DoubleCustomFieldRef();
doubleCustomFieldRef.scriptId = "custbody_test_decimal_field";
doubleCustomFieldRef.value = 8.8 ;
ListOrRecordRef custSelectValue = new ListOrRecordRef();
custSelectValue.internalId = "1";
SelectCustomFieldRef selectCustomFieldRef = new SelectCustomFieldRef();
selectCustomFieldRef.scriptId = "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.scriptId = "custbodytest_multiselect_field";
multiSelectCustomFieldRef.value = custMultiSelectValue;
BooleanCustomFieldRef booleanCustomFieldRef = new BooleanCustomFieldRef();
booleanCustomFieldRef.scriptId = "custbody_test_checkbox_field";
booleanCustomFieldRef.value = true;
DateCustomFieldRef dateCustomFieldRef = new DateCustomFieldRef();
dateCustomFieldRef.scriptId = "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