Question

I am trying to add hierarchical set of lookup entries to a lookup table. But all the entries come in a single level. I am using managed client object model for the same. How do I implement indentation ?

            LookupTableCreationInformation linfo = new LookupTableCreationInformation();
            linfo.Id = Guid.NewGuid();
            linfo.Name = "Test 01";
            linfo.SortOrder = LookupTableSortOrder.Ascending;

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

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


            LookupEntryCreationInformfation LCntCrInf = new LookupEntryCreationInformation();
            LCntCrInf.Description = "Test";
            var id = Guid.NewGuid();
            LCntCrInf.Id = id;
            LCntCrInf.Value = new LookupEntryValue();
            LCntCrInf.Value.TextValue = "Aa";

            LookupEntryCreationInformation EntryInfo2 = new LookupEntryCreationInformation();
            EntryInfo2.Value = new LookupEntryValue();
            EntryInfo2.Value.TextValue = "Bb";
            EntryInfo2.ParentId = id;
            EntryInfo2.Description ="level2";
            EntryInfo2.Id = Guid.NewGuid();

            List<LookupEntryCreationInformation> lcreInfo = new List<LookupEntryCreationInformation>();
            List<LookupMask> lmaskCreIf = new List<LookupMask>();

            lmaskCreIf.Add(mask);
            lmaskCreIf.Add(mask2);

            lcreInfo.Add(LCntCrInf);
            lcreInfo.Add(EntryInfo2);

            linfo.Masks = lmaskCreIf;
            linfo.Entries = lcreInfo;

            ctx.LookupTables.Update();
            ctx.ExecuteQuery();

In the code I am adding two masks, and then two entries. I am assigning to the parent id of the second entry, the id of the first entry.

It doesnt seem to work.

Was it helpful?

Solution

That seemed to work fine for me:

lookup test

I just had to add the following to actually add the table: ctx.LookupTables.Add(linfo);

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top