Is there a way to base the rights to publish a form in Episerver based on the presence of webhooks?

Vote:
 

We basically use two user groups in Episerver, web editors and extended web editors. Normally, both should be able to create and publish forms. However, only extended web editors should be able to publish a form if one or more webhooks have been specified. How, if at all possible, can this be achieved?

My initial thought was to use an InitializationModule and add a handler for the PublishingContent event. If the form has any webhooks I would then check the user type and present an error message if it isn't a extended web editor. The problem is that I cannot figure out a way way to access the webhooks information.

Any insight would be greatly appreciated.

#225019
Jul 02, 2020 10:09
Vote:
 

I think you are on the right track. Hook into the PublishingContent event, and check the propertyin this way:

myBlock.Property["CallWebhookAfterSubmissionActor"]

It's not strongly typed, so you will not get the autocomplete in Visual Studio.

#225022
Jul 02, 2020 10:41
Vote:
 

The webhook property is not part of the strongly typed properties on the FormContainer block, but you should be able to get it by doing as you've done with creating the handler, typecheck and cast e.Content to FormContainer and then getting the webhooks like this:

[nameOfCastedBlock].Content.Property.GetPropertyValue<IEnumerable<WebhookActorModel>>("CallWebhookAfterSubmissionActor").ToList();

#225023
Jul 02, 2020 11:10
Vote:
 

Thank you Tomas and Jørgen! I had not realized that since we use a custom actor the name of the property must match that class name. This is basically what I had to to:

myBlock.GetPropertyValue<IEnumerable<CustomWebhookActorModel>>("CustomCallWebhookAfterSubmissionActor")

Same same, but with a slight twist. Your answers made me understand that the webhook information really should be accessible and after awhile the penny dropped all the way :) 

#225050
Jul 03, 2020 8:30
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.