/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the CustomFieldService. CustomFieldService customFieldService = (CustomFieldService) user.GetService(DfpService.v201308.CustomFieldService); // Set the ID of the drop-down custom field to create options for. long customFieldId = long.Parse(_T("INSERT_DROP_DOWN_CUSTOM_FIELD_ID_HERE")); // Create custom field options. CustomFieldOption customFieldOption1 = new CustomFieldOption(); customFieldOption1.displayName = "Approved"; customFieldOption1.customFieldId = customFieldId; CustomFieldOption customFieldOption2 = new CustomFieldOption(); customFieldOption2.displayName = "Unapproved"; customFieldOption2.customFieldId = customFieldId; try { // Add custom field options. CustomFieldOption[] customFieldOptions = customFieldService.createCustomFieldOptions(new CustomFieldOption[] {customFieldOption1, customFieldOption2}); // Display results. if (customFieldOptions != null) { foreach (CustomFieldOption customFieldOption in customFieldOptions) { Console.WriteLine("Custom field option with ID \"{0}\" and name \"{1}\" was created.", customFieldOption.id, customFieldOption.displayName); } } else { Console.WriteLine("No custom field options created."); } } catch (Exception ex) { Console.WriteLine("Failed to create custom field options. Exception says \"{0}\"", ex.Message); } }
public virtual CustomFieldOption updateCustomFieldOption(CustomFieldOption customFieldOption) { object[] results = this.Invoke("updateCustomFieldOption", new object[] { customFieldOption }); return ((CustomFieldOption) (results[0])); }