This is what my test code looks like:
var formIdentity = input as FormIdentity; var formContainerBlock = formIdentity.GetFormBlock(); var webhookActorModels = formContainerBlock.Content.Property.GetPropertyValue<IEnumerable<WebhookActorModel>>("CallWebhookAfterSubmissionActor").ToList(); if (webhookActorModels == null || webhookActorModels.Count() > 0) { webhookActorModels[0].BaseUrl = "google.com"; } formContainerBlock.Content.SetPropertyValue("CallWebhookAfterSubmissionActor", webhookActorModels);
And the error I get:
When is this code being executed? Try calling your block of code when the content is being created.
context.Locate.ContentEvents().CreatingContent += CreatingContent;
https://docs.developers.optimizely.com/content-management-system/v11.0.0-cms/docs/resolving-current-content-context
This is what my test code looks like:
And the error I get: