Read Get Lookup Table Data using CSOM in Project Online Project Server

Read Get Lookup Table Data using CSOM:-

Read Get Lookup Table Data using CSOM in Project Online Project Server. In this post, I will explain to you to Read Get Lookup Table Data using CSOM in Project Online Project Server. In my previous post, i explained to you how to add the custom field using csom, how to add lookup table using csom and how to add the lookup type custom field using csom in project online. If you want to copy the custom field from one Project Online PWA to another Project Online PWA, then you can use this code.

Code for Read Get Lookup Table Data using CSOM in Project Online Project Server:-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.SharePoint;
using System.Data;
using PRCLNT = Microsoft.ProjectServer.Client;
using Microsoft.SharePoint.Client;
using System.Security;

using System.Xml.Linq;
using System.IO;
using System.Reflection;

namespace GetLookupTableUsingCSOM
    class Program
        static string UserName = "UserName";
        static string Passwords = "Password";
        public static string OnlinePWA = "PWA Path";
        static void Main(string[] args)
        public static void GetLookupTable()
            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));

                IEnumerable<PRCLNT.CustomField> Customfields = (ProjectCont.LoadQuery(ProjectCont.CustomFields));

                var lookupcoll = (ProjectCont.LoadQuery(ProjectCont.LookupTables));

                foreach (var lk in lookupcoll)
                    ProjectCont.Load(lk.Entries); ProjectCont.ExecuteQuery();
                    List<LooupMembers> LookupList = new List<LooupMembers>();
                    List<MaskLevel> MaskList = new List<MaskLevel>();
                    foreach (var item in lk.Masks)
                        MaskLevel mask = new MaskLevel();
                        mask.Separator = item.Separator;
                        mask.MaskType = item.MaskType;
                    foreach (var it in lk.Entries)

                        var jj = lk.Masks.FirstOrDefault();
                        char sap = jj.Separator[0];
                        string jjj = it.FullValue.Replace(sap.ToString() + it.FullValue.Split(sap)[it.FullValue.Split(sap).Length - 1].ToString(), "").ToString();
                        var hhh = (lk.Entries.AsEnumerable().Where(x => x.FullValue == it.FullValue.Replace((it.FullValue.Split(sap).Length > 1 ? sap.ToString() : "") + it.FullValue.Split(sap)[it.FullValue.Split(sap).Length - 1].ToString(), "").ToString()).FirstOrDefault());

                        LooupMembers LMember = new LooupMembers();
                        LMember.LT_UID = lk.Id;
                        LMember.LT_VALUE_TEXT = it.FullValue.Split(sap)[it.FullValue.Split(sap).Length - 1].ToString();
                        LMember.Lt_FullValue = it.FullValue;
                        LMember.LT_STRUCT_UID = it.Id;
                        LMember.LT_VALUE_SORT_INDEX = it.SortIndex;
                        LMember.LT_PARENT_STRUCT_UID = hhh == null ? Guid.Empty : hhh.Id;
                    //CreateLookupTable(lk.Id, lk.Name, LookupList, MaskList);


    public class LooupMembers
        public Guid LT_UID { get; set; }
        public string LT_VALUE_TEXT { get; set; }
        public string LT_VALUE_DESC { get; set; }
        public Guid LT_STRUCT_UID { get; set; }
        public Guid LT_PARENT_STRUCT_UID { get; set; }
        public decimal LT_VALUE_SORT_INDEX { get; set; }
        public string Lt_FullValue { get; set; }

    public class MaskLevel

        public string Separator { get; set; }
        public PRCLNT.LookupTableMaskSequence MaskType { get; set; }
        public string Length { get; set; }




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