Create Add Lookup Table using CSOM Project Online Project Server

Create Add Lookup Table using CSOM Project Online Project Server.

Create Add Lookup Table using CSOM Project Online Project Server. Create Add Lookup Table using CSOM Project Online Project Server. In my previous post, I told you about to add the custom field using csom. The lookup table is a collection of data that is stored in table format. In text type custom field user can enter custom field value manually. But in lookup type custom field user select the data by lookup table attached to the respective custom field.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using Microsoft.SharePoint.Client;
using PRCLNT = Microsoft.ProjectServer.Client;

namespace Add_Lookup_Table_Using_CSOM
    class Program
        static string UserName = "Project online username";
        static string Passwords = "project online password";
        public static string OnlinePWA = "project online pwapath";
        static void Main(string[] args)

            using (PRCLNT.ProjectContext ProjectCont = new PRCLNT.ProjectContext(OnlinePWA))//PWA Url
                SecureString passWord2 = new SecureString();
                foreach (char c in Passwords.ToCharArray()) passWord2.AppendChar(c);
                ProjectCont.Credentials = new SharePointOnlineCredentials(UserName, passWord2);
                 c => c.IncludeWithDefaultProperties(pr => pr.StartDate, pr => pr.CustomFields, pr => pr.Assignments, pr => pr.FinishDate, pr => pr.Owner.LoginName, pr => pr.Tasks, pr => pr.ProjectSiteUrl, pr => pr.PercentComplete, pr => pr.ProjectResources, pr => pr.CustomFields, pr => pr.EnterpriseProjectType));
                PRCLNT.LookupTableCreationInformation NewLookupTable = new PRCLNT.LookupTableCreationInformation();
                NewLookupTable.Id = Guid.NewGuid();
                NewLookupTable.Name = "Add LookupTable";
                NewLookupTable.SortOrder = PRCLNT.LookupTableSortOrder.Ascending;

                PRCLNT.LookupMask mask = new PRCLNT.LookupMask();
                mask.Length = 0;
                mask.MaskType = PRCLNT.LookupTableMaskSequence.CHARACTERS;
                mask.Separator = ".";

                PRCLNT.LookupMask mask2 = new PRCLNT.LookupMask();
                mask2.Length = 0;
                mask2.MaskType = PRCLNT.LookupTableMaskSequence.CHARACTERS;
                mask2.Separator = ".";

                PRCLNT.LookupEntryCreationInformation FirstLookupEntry = new PRCLNT.LookupEntryCreationInformation();
                FirstLookupEntry.Description = "1'st Description";
                var id = Guid.NewGuid();
                FirstLookupEntry.Id = id;
                FirstLookupEntry.Value = new PRCLNT.LookupEntryValue();
                FirstLookupEntry.Value.TextValue = "1'st Text";

                PRCLNT.LookupEntryCreationInformation SecondLookupEntry = new PRCLNT.LookupEntryCreationInformation();
                SecondLookupEntry.Value = new PRCLNT.LookupEntryValue();
                SecondLookupEntry.Value.TextValue = "2'nd Text";
                //set the parent id = the id of the previous item
                SecondLookupEntry.ParentId = id;
                SecondLookupEntry.Description = "2'nd Description";
                SecondLookupEntry.Id = Guid.NewGuid();

                PRCLNT.LookupEntryCreationInformation ThirdLookupEntry = new PRCLNT.LookupEntryCreationInformation();
                ThirdLookupEntry.Value = new PRCLNT.LookupEntryValue();
                ThirdLookupEntry.Value.TextValue = "3'rd Text";
                ThirdLookupEntry.Description = "3'rd Description";
                ThirdLookupEntry.Id = new Guid();
                ThirdLookupEntry.ParentId = Guid.Empty;

                List<PRCLNT.LookupEntryCreationInformation> ListOfEntries = new List<PRCLNT.LookupEntryCreationInformation>();
                List<PRCLNT.LookupMask> ListOfMasks = new List<PRCLNT.LookupMask>();

                NewLookupTable.Masks = ListOfMasks;
                NewLookupTable.Entries = ListOfEntries;





Create Add Lookup Table using CSOM Project Online Project Server

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!