// Get the CustomFieldService.
CustomFieldServiceInterface customFieldService =
user.getService(DfpService.V201308.CUSTOM_FIELD_SERVICE);
// Create custom fields.
CustomField customField1 = new CustomField();
customField1.setName("Customer comments #" + System.currentTimeMillis());
customField1.setEntityType(CustomFieldEntityType.LINE_ITEM);
customField1.setDataType(CustomFieldDataType.STRING);
customField1.setVisibility(CustomFieldVisibility.FULL);
CustomField customField2 = new CustomField();
customField2.setName("Internal approval status #" + System.currentTimeMillis());
customField2.setEntityType(CustomFieldEntityType.LINE_ITEM);
customField2.setDataType(CustomFieldDataType.DROP_DOWN);
customField2.setVisibility(CustomFieldVisibility.FULL);
// Add custom fields.
CustomField[] customFields =
customFieldService.createCustomFields(new CustomField[] {customField1, customField2});