LookupTable.UpdateLookupTables Method

Creates, modifies, or deletes data in custom field lookup tables. UpdateLookupTables creates lookup tables and corresponding code masks if the LookupTableDataSet includes new lookup tables, modifies existing lookup tables, and deletes lookup tables that are not in the LookupTableDataSet.

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

Syntax

'Declaration
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/LookupTable/UpdateLookupTables", 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 Sub UpdateLookupTables ( _
    ltds As LookupTableDataSet, _
    validateOnly As Boolean, _
    autoCheckIn As Boolean, _
    language As Integer _
)
'Usage
Dim instance As LookupTable
Dim ltds As LookupTableDataSet
Dim validateOnly As Boolean
Dim autoCheckIn As Boolean
Dim language As Integer

instance.UpdateLookupTables(ltds, validateOnly, _
    autoCheckIn, language)
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/LookupTable/UpdateLookupTables", 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 UpdateLookupTables(
    LookupTableDataSet ltds,
    bool validateOnly,
    bool autoCheckIn,
    int language
)

Parameters

Remarks

UpdateLookupTables updates data in existing lookup tables. To create or delete lookup tables, you can also use CreateLookupTables and DeleteLookupTables.

To delete a lookup table value, first use the ReadLookupTablesByUids method to get a complete LookupTableDataSet, and then use the LookupTableDataSet.LookupTableTrees.Rows[index].Delete method, which marks the row for deletion. See the Example section.

To update one or more lookup tables, use ReadLookupTablesByUids to get all of the data tables necessary for each lookup table, and then modify the returned LookupTableDataSet to use for the ltds parameter in UpdateLookupTables.

You can also use ReadLookupTables with a null reference (Nothing in Visual Basic) for the xmlFilter parameter. In the following example, lookupTable is an instance of the LookupTableWebService.LookupTable class, and lookupTableDataSet is an instance of a LookupTableDataSet.

bool autoCheckOut = false;
string xmlFilter = null;
int language = 0;
lookupDataSet = lookupTable.ReadLookupTables(xmlFilter, autoCheckOut, language);
// Add, delete, or modify lookup table rows 
bool validateOnly = false;
autoCheckOut = true;
lookupTable.UpdateLookupTables(lookupTableDataSet, validateOnly, autoCheckOut, language);
// Call lookupTable.CheckInLookupTables

Note

If you use ReadLookupTables and specify xmlfilter values, you may not get all of the tables necessary for an update. In that case, UpdateLookupTables results in a general unhandled exception.

Project Server Permissions

Permission

Description

ManageEnterpriseCustomFields

Modify the definitions of enterprise custom fields and lookup table values. Global permission.

Examples

The following example reads a specified lookup table and deletes a specified row in the table. The lookupTable parameter in the DeleteLookupTableRow sample method is a LookupTable object with valid Url and Credentials properties. The language parameter is an integer for the LCID; for example, 1033 is U.S. English. LookupTableWebSvc is an arbitrary reference name to the LookupTable.asmx Web service. For more information about using the code sample, see Prerequisites for Reference Code Samples.

public string DeleteLookupTableRow(LookupTableWebSvc.LookupTable lookupTable,
    Guid lutGuid, int row, int language)
{
    string result = "";
    string fmtResult = "Lookup table: {0}. ";
    string tableName = "[unknown]";
    string rowName = "";

    LookupTableWebSvc.LookupTableDataSet lutDs = new LookupTableWebSvc.LookupTableDataSet();

    Guid[] lutList = new Guid[] { lutGuid };
    bool autoCheckOut = false;

    lutDs = lookupTable.ReadLookupTablesByUids(lutList, autoCheckOut, language);
    int numRows = lutDs.LookupTableTrees.Rows.Count;

    foreach (DataRow lutRow in lutDs.LookupTables)
    {
        if ((Guid)lutRow[lutDs.LookupTables.LT_UIDColumn] == lutGuid)
        {
            tableName = (string)lutRow[lutDs.LookupTables.LT_NAMEColumn];
            break;
        }
    }

    if (row < numRows)
    {
        rowName = lutDs.LookupTableTrees[row].LT_VALUE_TEXT;
        lutDs.LookupTableTrees.Rows[row].Delete();

        lookupTable.CheckOutLookupTables(lutList);
        bool validateOnly = false;
        lookupTable.UpdateLookupTables(lutDs, validateOnly, autoCheckOut, language);
        bool forceCheckIn = false;
        lookupTable.CheckInLookupTables(lutList, forceCheckIn);

        fmtResult += "Row {1} deleted: {2}";
        result = string.Format(fmtResult, tableName, row, rowName);
    }
    else
    {
        fmtResult += "Requested row {1} greater than number of rows {2}.";
        result = string.Format(fmtResult, tableName, row, numRows);
    }
    return result;
}

See Also

Reference

LookupTable Class

LookupTable Members

WebSvcLookupTable Namespace

Other Resources

Locale ID (LCID) Chart

Walkthrough: Creating a Hierarchical Lookup Table