/// <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.v201311.CustomFieldService);

      // Create custom fields.
      CustomField customField1 = new CustomField();
      customField1.name = "Customer comments #" + GetTimeStamp();
      customField1.entityType = CustomFieldEntityType.LINE_ITEM;
      customField1.dataType = CustomFieldDataType.STRING;
      customField1.visibility = CustomFieldVisibility.FULL;

      CustomField customField2 = new CustomField();
      customField2.name = "Internal approval status #" + GetTimeStamp();
      customField2.entityType = CustomFieldEntityType.LINE_ITEM;
      customField2.dataType = CustomFieldDataType.DROP_DOWN;
      customField2.visibility = CustomFieldVisibility.FULL;

      try {
        // Add custom fields.
        CustomField[] customFields =
            customFieldService.createCustomFields(new CustomField[] {customField1, customField2});

        // Display results.
        if (customFields != null) {
          foreach (CustomField customField in customFields) {
            Console.WriteLine("Custom field with ID \"{0}\" and name \"{1}\" was created.",
                customField.id, customField.name);
          }
        } else {
          Console.WriteLine("No custom fields created.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to create custom fields. Exception says \"{0}\"", ex.Message);
      }
    }
예제 #2
0
 public virtual CustomField updateCustomField(CustomField customField) {
   object[] results = this.Invoke("updateCustomField", new object[] { customField });
   return ((CustomField) (results[0]));
 }