共用方式為


LookupTable.CreateLookupTables Method

Creates custom field lookup tables and corresponding code masks.

Namespace:  [LookupTable Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/LookupTable.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/LookupTable.asmx?wsdl

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/LookupTable/CreateLookupTables", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/LookupTable/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/LookupTable/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub CreateLookupTables ( _
    ltds As LookupTableDataSet, _
    validateOnly As Boolean, _
    autoCheckIn As Boolean _
)
'Usage
Dim instance As LookupTable
Dim ltds As LookupTableDataSet
Dim validateOnly As Boolean
Dim autoCheckIn As Boolean

instance.CreateLookupTables(ltds, validateOnly, _
    autoCheckIn)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/LookupTable/CreateLookupTables", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/LookupTable/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/LookupTable/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CreateLookupTables(
    LookupTableDataSet ltds,
    bool validateOnly,
    bool autoCheckIn
)

Parameters

Remarks

If you create a non-text lookup table such as type Cost, Date, Duration, or Number, you still need to programmatically create a code mask. Project Web App hides the code mask for non-text lookup tables in the New Lookup Table page, but creates a code mask for the call to CreateLookupTable. For an example that creates a Duration lookup table, see CreateLookupTablesMultiLang. For more examples, see Using the ProjTool Test Application in Project Server 2010.

The pre-event for CreateLookupTables is LookupTableEventReceiver.OnCreating and the post-event is OnCreated.

Note

The pre- and post-events for CreateLookupTables expose LookupTableMultiLangDataSet in the e parameter of event handlers, rather than a LookupTableDataSet.

To use datasets in event handlers, set a reference to the Microsoft.Office.Project.Schema.dll assembly. For more information, see How to: Write and Debug a Project Server Event Handler. For more examples, see Using the ProjTool Test Application in Project Server 2010.

Warning

When you use the PSI to create or update a number lookup table, do not add values that have more than two decimal places.

The CreateLookupTables method enables you to save a number with more than two decimal places. When you create a custom field that uses the number lookup table, Project Professional 2010 rounds the number custom field values to two decimal places and shows them as strings in the drop-down list to select a value. When you select a value, Project Professional 2010 converts the string back to a number. The process shows an error, because the numeric value with only two decimal places does not exist.

Project Server Permissions

Permission

Description

ManageEnterpriseCustomFields

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

Examples

The following code is a pre-event handler for CreateLookupTables that gets data from different tables in a LookupTableMultiLanguageDataSet.

using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
public class LookupTableEvents : LookupTableEventReceiver
{
    public override void OnCreating(PSLibrary.PSContextInfo contextInfo, 
        LookupTablePreEventArgs e)
    {
        int lutLanguage = 
            (int)e.LookupTableInformation.LookupTableLanguages.Rows[0]["LCID"];
        Guid lutMultiUid = 
            (Guid)e.LookupTableInformation.LookupTables.Rows[0]["LT_UID"];
        string lutMultiValue = 
            (string)e.LookupTableInformation.LookupTableValues.Rows[0]["LT_VALUE_TEXT"];
        . . .
}

See Also

Reference

LookupTable Class

LookupTable Members

LookupTable Web Service

CreateLookupTablesMultiLang

Other Resources

Using the ProjTool Test Application in Project Server 2010