// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the CustomFieldService.
CustomFieldServiceInterface customFieldService =
user.getService(DfpService.V201302.CUSTOM_FIELD_SERVICE);
// Get the LineItemService.
LineItemServiceInterface lineItemService =
user.getService(DfpService.V201302.LINEITEM_SERVICE);
// Set the IDs of the custom fields, custom field option, and line item.
Long customFieldId = Long.parseLong("INSERT_STRING_CUSTOM_FIELD_ID_HERE");
Long dropDownCustomFieldId = Long.parseLong("INSERT_DROP_DOWN_CUSTOM_FIELD_ID_HERE");
Long customFieldOptionId = Long.parseLong("INSERT_CUSTOM_FIELD_OPTION_ID_HERE");
Long lineItemId = Long.parseLong("INSERT_LINE_ITEM_ID_HERE");
// Get the custom field.
CustomField customField = customFieldService.getCustomField(customFieldId);
// Get the drop-down custom field.
DropDownCustomField dropDownCustomField =
(DropDownCustomField) customFieldService.getCustomField(dropDownCustomFieldId);
// Get the line item.
LineItem lineItem = lineItemService.getLineItem(lineItemId);
// Create custom field values.