1

I need my Remote Event Receiver to install to the "Site Pages" library without referencing the Title/name, but rather use the ID (119) or GUID. I can't use title because the support for multiple languages.

I have tried a couple different things, but get ClientRequestException.

public void InstallRER(ClientContext ctx)
    {   Guid g = new Guid("00bfea71-c796-4402-9f2f-0eb9a6e71b18");
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.BaseTemplate.Equals("119")));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.BaseTemplate.Equals(119)));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.TemplateFeatureId.Equals(119)));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.BaseTemplate.Equals(ListTemplateType.WebPageLibrary)));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.TemplateFeatureId.Equals(g)));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.BaseType.Equals("WebPageLibrary")));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.BaseType.Equals((int)ListTemplateType.WebPageLibrary)));
        ctx.Load(ctx.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(list => list.BaseType.Equals("DocumentLibrary") && (list.BaseTemplate.Equals(119))));
        ctx.ExecuteQuery();
        List SitePageList = ctx.Web.Lists.FirstOrDefault();
        EventReceiverDefinitionCreationInformation CheckedIn = new EventReceiverDefinitionCreationInformation();
        CheckedIn.EventType = EventReceiverType.ItemCheckedIn;
        OperationContext op = OperationContext.Current;
        Message m = op.RequestContext.RequestMessage;
        CheckedIn.ReceiverUrl = m.Headers.To.ToString();
        CheckedIn.ReceiverName = name;
        CheckedIn.Synchronization = EventReceiverSynchronization.Synchronous;
        SitePageList.EventReceivers.Add(CheckedIn);
        ctx.ExecuteQuery();
    }

Appreciate any help I can get!

2

Try this( the error caused by Equal in Linq based on my testing).

Guid g = new Guid("00bfea71-c796-4402-9f2f-0eb9a6e71b18");
                context.Load(context.Web.Lists, lists => lists.Include(list => list.Title, list => list.EventReceivers).Where(l => l.TemplateFeatureId == g));
                context.ExecuteQuery();
                List SitePageList = context.Web.Lists.FirstOrDefault();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.