CustomFields.CreateCustomFields 方法
建立企業自訂欄位。
命名空間: WebSvcCustomFields
組件: ProjectServerServices (在 ProjectServerServices.dll 中)
語法
'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/CustomFields/CreateCustomFields", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/", _
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, _
autoCheckIn)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/CustomFields/CreateCustomFields", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CreateCustomFields(
CustomFieldDataSet cfds,
bool validateOnly,
bool autoCheckIn
)
參數
cfds
類型:WebSvcCustomFields.CustomFieldDataSetCustomFieldDataSet包含自訂欄位定義。
validateOnly
類型:System.Boolean如果true, CustomFieldDataSet驗證而建立的自訂欄位。
autoCheckIn
類型:System.Boolean如果true,存回後他們所建立的自訂欄位。
備註
如需說明用來建立自訂欄位的屬性,請參閱 < CustomFieldDataSet.CustomFieldsRow。
注意
CreateCustomFields方法和CreateCustomFields2方法,以及Project Web App,所有允許您建立的企業專案自訂欄位的類型標幟,並設定為工作流程控制的自訂欄位。不過,Project Server 工作流程無法控制標幟] 自訂欄位。您不應該設定為工作流程控制的旗標類型的專案自訂欄位。
秘訣 |
---|
CreateCustomFields方法會略過執行 Project Server 之電腦的地區設定。CreateCustomFields2方法可以使用地區設定相關值的自訂欄位] 和 [圖形標記計算的公式。 |
Project Server 權限
權限 |
描述 |
---|---|
可讓使用者修改企業自訂欄位與查閱表格值的定義。通用權限。 |
範例
下列範例會使用CustomFieldWS為 web 參考 (英文) Custom Fields web 服務 (https://ServerName/ProjectServerName/_vti_bin/psi/CustomFields.asmx) 的名稱。btnCustomField_Click事件處理常式是 Windows 表單應用程式,例如LoginDemo Project SDK 下載中的按鈕。
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 =
customFieldDataSet.CustomFields.NewCustomFieldsRow();
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.SetMD_LOOKUP_TABLE_UIDNull();
else
cfRow.MD_LOOKUP_TABLE_UID = lookupTableUid;
if (ltRowDefaultUid == Guid.Empty)
cfRow.SetMD_PROP_DEFAULT_VALUENull();
else
cfRow.MD_PROP_DEFAULT_VALUE = ltRowDefaultUid;
customFieldDataSet.CustomFields.Rows.Add(cfRow);
try
{
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;
}
請參閱
參照
CreateCustomFields2(CustomFieldDataSet, Boolean, Boolean)