LookupTable.CreateLookupTablesMultiLang method

Office 2013 and later

Creates multilanguage custom field lookup tables and corresponding code masks.

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

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


Type: WebSvcLookupTable.LookupTableMultiLangDataSet

LookupTableMultiLangDataSet containing data in the datatables.

Type: System.Boolean

Validate only, do not create.

Type: System.Boolean

If true, check in after creating.

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 on the New Lookup Table page, but creates a code mask for the call to CreateLookupTable. The Example section includes sample code that creates a Duration lookup table. For more examples, see Using the ProjTool Test Application.

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

For example, the e parameter in an OnCreating event handler exposes a LookupTableMultiLanguageDataSet object. The following code shows examples of how to get data from different tables such as LookupTableLanguages, LookupTables, and LookupTableValues.

using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
public class LookupTableEvents : LookupTableEventReceiver
    public override void OnCreating(PSLibrary.PSContextInfo contextInfo, 
        LookupTablePreEventArgs e)
        int lutLanguage = 
        Guid lutMultiUid = 
        string lutMultiValue = 
        . . .

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.

Caution noteCaution

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 CreateLookupTablesMultiLang 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




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

The following code fragment creates a lookup table named Test Duration LUT of type Duration. LookupTableWS is an arbitrary name for a reference to the LookupTable Web service. To test the code, add it to a sample console application. For more information, see Prerequisites for ASMX-based code samples in Project 2013.

The comments include names of the tables changed in the Published database after the call to CreateLookupTablesMultiLang.

using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
private const string LOOKUPTABLEWEBSERVICE = "_vti_bin/PSI/LookupTable.asmx";
private string baseUrl = "http://ServerName/ProjectServerName"/
private static WebSvcLookupTable.LookupTable lookupTable =
    new WebSvcLookupTable.LookupTable();
LookupTableWS.LookupTableMultiLangDataSet lutMultiDS = 
    new LookupTableWS.LookupTableMultiLangDataSet();

// Initialize the LookupTable Web service for Windows logon.
lookupTable.Url = baseUrl + LOOKUPTABLEWEBSERVICE;
lookupTable.Credentials = CredentialCache.DefaultCredentials;
. . .
private void btnCreateNonTextLUT_Click(object sender, EventArgs e)
    LookupTableWS.LookupTableMultiLangDataSet lutMultiDS = 
        new LookupTableWS.LookupTableMultiLangDataSet();

    // Create the main LookupTable row in MSP_LOOKUP_TABLES.
    LookupTableWS.LookupTableMultiLangDataSet.LookupTablesRow lutMainRow =
    lutMainRow.LT_UID = Guid.NewGuid();
    lutMainRow.LT_FILL_ALL_LEVELS = false;
    lutMainRow.LT_PRIMARY_LCID = 1033;
    lutMainRow.LT_SORT_ORDER_ENUM = (byte)PSLibrary.LookupTables.SortOrder.Ascending;
    lutMainRow.LT_NAME = "Test Duration LUT";

    // Create the 1-level mask structure in MSP_LOOKUP_TABLE_MASK_STRUCTURES.
    LookupTableWS.LookupTableMultiLangDataSet.LookupTableMaskStructuresRow lutMaskStructureRow =
    lutMaskStructureRow.LT_UID = lutMainRow.LT_UID;
    lutMaskStructureRow.LT_MASK_STRUCT_LENGTH = (int)PSLibrary.LookupTables.ANY_LENGTH_SEQUENCE;
    lutMaskStructureRow.LT_MASK_STRUCT_LEVEL = 1;
    lutMaskStructureRow.LT_MASK_STRUCT_TYPE_ENUM = (byte)PSLibrary.LookupTables.MaskSequence.DURATION;

    // Create the 1-level mask value in MSP_LOOKUP_TABLE_MASK_VALUES.
    LookupTableWS.LookupTableMultiLangDataSet.LookupTableMaskValuesRow lutMaskValueRow =
    lutMaskValueRow.LCID = 1033;
    lutMaskValueRow.LT_UID = lutMainRow.LT_UID;
    lutMaskValueRow.LT_MASK_STRUCT_LEVEL = 1;
    lutMaskValueRow.LT_MASK_VALUE_SEPARATOR = ".";

    // Create the value structure in MSP_LOOKUP_TABLE_STRUCTURES.
    LookupTableWS.LookupTableMultiLangDataSet.LookupTableStructuresRow lutStructureRow =
    lutStructureRow.LT_UID = lutMainRow.LT_UID;
    lutStructureRow.LT_STRUCT_UID = Guid.NewGuid();

    // Create values (one value per LCID) in MSP_LOOKUP_TABLE_VALUES.
    LookupTableWS.LookupTableMultiLangDataSet.LookupTableValuesRow lutValueRow =
    lutValueRow.LCID = 1033;
    lutValueRow.LT_VALUE_DESC = "This is root level A";
    lutValueRow.LT_VALUE_DUR = 30;
    lutValueRow.LT_VALUE_DUR_FMT = (byte)PSLibrary.Task.DurationFormat.Hour;
    lutValueRow.LT_STRUCT_UID = lutStructureRow.LT_STRUCT_UID;

    // Create the lookup table.
    bool validateOnly = false;
    bool autoCheckIn = true;
    lookupTable.CreateLookupTablesMultiLang(lutMultiDS, validateOnly, autoCheckIn);