CustomFields.CreateCustomFields method

Creates enterprise custom fields.

Namespace:  WebSvcCustomFields
Assembly:  ProjectServerServices (in ProjectServerServices.dll)


<SoapDocumentMethodAttribute("", RequestNamespace := "",  _
    ResponseNamespace := "",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub CreateCustomFields ( _
    cfds As CustomFieldDataSet, _
    validateOnly As Boolean, _
    autoCheckIn As Boolean _
Dim instance As CustomFields
Dim cfds As CustomFieldDataSet
Dim validateOnly As Boolean
Dim autoCheckIn As Boolean

instance.CreateCustomFields(cfds, validateOnly, _
[SoapDocumentMethodAttribute("", RequestNamespace = "", 
    ResponseNamespace = "", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CreateCustomFields(
    CustomFieldDataSet cfds,
    bool validateOnly,
    bool autoCheckIn


  • validateOnly
    Type: System.Boolean

    If true, validate the CustomFieldDataSet without creating the custom fields.

  • autoCheckIn
    Type: System.Boolean

    If true, check in the custom fields after they are created.


For descriptions of the properties that are used to create a custom field, see CustomFieldDataSet.CustomFieldsRow.


The CreateCustomFields method and the CreateCustomFields2 method, as well as Project Web App, all allow you to create an enterprise project custom field of type Flag, and set the custom field to be workflow controlled. However, Project Server workflows cannot control Flag custom fields. You should not set project custom fields of type Flag for workflow control.


The CreateCustomFields method ignores the locale setting of the computer running Project Server. The CreateCustomFields2 method can use locale-dependent values for formulas that calculate custom fields and graphical indicators.

Project Server Permissions




Allows a user to modify the definitions of enterprise custom fields and lookup table values. Global permission.


The following example uses CustomFieldWS as the name of a web reference to the Custom Fields web service (https://ServerName/ProjectServerName/_vti_bin/psi/CustomFields.asmx). The btnCustomField_Click event handler is for a button on a Windows Form application, such as LoginDemo in the Project SDK download.

using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
private Guid customFieldUid;
. . .
private void btnCustomField_Click(object sender, EventArgs e)
    string cfName = "Test Task Cost";
    Guid entityTypeUid = new Guid(PSLibrary.EntityCollection.Entities.TaskEntity.UniqueId);
    lookupTableUid = Guid.Empty;
    ltRowDefaultUid = Guid.Empty;
    byte cfType = (byte)PSLibrary.CustomField.Type.COST;
    byte rollup = (byte)PSLibrary.CustomField.SummaryRollup.Sum;

    customFieldUid = CreateCustomField(
        customFields, cfName,
        entityTypeUid, lookupTableUid, ltRowDefaultUid,
        cfType, rollup);

// Test method for creating a custom field.
public Guid CreateCustomField(
    CustomFieldsWS.CustomFields customFields,
    string cfName,
    Guid entityTypeUid,
    Guid lookupTableUid,
    Guid ltRowDefaultUid,
    byte cfType,
    byte rollup
    CustomFieldsWS.CustomFieldDataSet customFieldDataSet =
        new CustomFieldsWS.CustomFieldDataSet();
    CustomFieldsWS.CustomFieldDataSet.CustomFieldsRow cfRow =
    Guid cfUid = Guid.NewGuid();

    cfRow.MD_PROP_UID = cfUid;
    cfRow.MD_AGGREGATION_TYPE_ENUM = rollup;
    cfRow.MD_ENT_TYPE_UID = entityTypeUid;
    cfRow.MD_PROP_NAME = cfName;
    cfRow.MD_PROP_IS_REQUIRED = false;
    cfRow.MD_PROP_IS_LEAF_NODE_ONLY = false;
    cfRow.MD_PROP_TYPE_ENUM = cfType;

    if (lookupTableUid == Guid.Empty)
        cfRow.MD_LOOKUP_TABLE_UID = lookupTableUid;

    if (ltRowDefaultUid == Guid.Empty)
        cfRow.MD_PROP_DEFAULT_VALUE = ltRowDefaultUid;


        bool validateOnly = false;
        bool autoCheckIn = true;
        customFields.CreateCustomFields(customFieldDataSet, validateOnly, autoCheckIn);
    catch (SoapException ex)
        // Add exception handler for ex.
        cfUid = Guid.Empty;
tch (Exception ex)
        // Add exception handler for ex.
        cfUid = Guid.Empty;
    return cfUid;

See also


CustomFields class

CustomFields members

WebSvcCustomFields namespace

CreateCustomFields2(CustomFieldDataSet, Boolean, Boolean)

Other resources

Local and Enterprise Custom Fields

How to: Create an Enterprise Custom Field