Kentico 10 - Custom action on page update - kentico

I am looking to perform a custom action when a content editor in Kentico 10 updates a page and it eventually gets published.
To be more specific we have a custom page type for products which also as an "Updated" checkbox allowing the editor to mark it as updated. When this happens (gets marked as updated) I would like to send an email out to users that have a registered interest in this product that it has been updated.
I was looking through the documentation and came across Global Events here: https://docs.kentico.com/k10/custom-development/handling-global-events/reference-global-system-events#Reference-Globalsystemevents-DocumentEvents
I was wondering if using global events to intercept the save action when the editor updates the product is the way to go here or if there is a better approach.

Kentico does n't have this functionality out of the box, but we can achieve this by writing Custom code for Global Event and a scheduler (if No.of mails is large)
Recommended steps:
Attach custom code to Global event handler while publish specific document publish after event
public override void Init()
{
// Assigns custom handlers to the appropriate events
WorkflowEvents.Publish.After += new EventHandler(DocumentPublishCustomEvent);
}
In the custom code, if required page is published then make entries into custom table for email to be sent [This step is optional you can send mail from custom event handler directly if only few mails to be sent]
3.Implement custom scheduler to pick the user info from custom table and send email to user.
Note: Ideally you can use email Template for send emails

Using Global events is one way of doing this, another way would be to use Kentico's Advanced workflow engine (If you have the EMS license):
https://docs.kentico.com/k10/managing-website-content/configuring-the-environment-for-content-editors/configuring-workflows/designing-advanced-workflows
You could create a custom workflow step and action which the editors would put the page into and which would send emails to interested people - https://docs.kentico.com/k10/managing-website-content/configuring-the-environment-for-content-editors/configuring-workflows/designing-advanced-workflows/creating-custom-action-workflow-steps
If you do not have the EMS License, using Global events seems like the way to go, but I don't see the updated flag field as necessary, you could easily check in the global event handler if the product arrived at the "Published" workflow step in the basic workflow and then send the email to the interested parties.

Related

Send an email (using flow) when the text field changes in PowerApps

I have a PowerApps App which is linked to a SharePoint List. When the user makes some changes to the text field in the app; I want the flow to send the user an email regarding the update.
I've been trying to track the SharePoint List entry and see if the entry is modified, then send an email. But so far I'm unable to do so.
I've been able to send an email when a text field changes to a specific text; but I'm looking for something where a particular entry in the list is changed.
When an item is created or modified > Condition (Column is equal to Yes) > Send email based on the condition
You don't need Powerapps for the same, what I mean is you need Flow for this.
Create and Run your flow on SharePoint directly.
In your flow check whatever your field is changed, if changed then you can send the user email.
You do not need to depend on Powerapps, Flow can alone work for this scenario.
Ensure you are using the Sharepoint When an item is created or modified Trigger in Power Automate (the tool formerly known as Flow)
Add a Trigger Condition for the column in question. Something along the lines of #triggerBody()?.Status,'Pending')
Trigger Conditions are not very well documented at the moment, but provide a powerful way to control when a Power Automate runs.

Creating form data via rest doesn't trigger autoresponder

Kentico 10. When I make a rest request to post data to the kentico form module I get a successful http 201 back and I can see the data created in the kentico interface. This particular form I am posting data to has an autoresponder set up.
I have a default smtp server set up and can successfully email out through it, which leads me to believe that the autoresponder on the form does not get triggered when data is created in the kentico form via rest. I never see the autoresponder attempt to send an email in either the email queue module or the event viewer (with the proper web.config key set).
Is that the intended behavior, to not trigger the autoresponder when forms module data is created via a rest request? If so, any idea how to get it to trigger?
Yes you are correct. Kentico REST is meant to perform simple CRUD operations. Essentially what you doing is the same as if you do it inside the admin i.e. go inside admin -> forms -> your form name -> recorded data and add new record. It doesn't trigger anything like sending email or Redirect to URL etc.
What you can do if you want to send email using form global events and on insert send email yourself. Here is the example of using global events

Plugins for incoming and outgoing emails in CRM 2011

I need to create two plugins for CRM 2011
Whenever an email is incomging or outgoing I need to check if the email has any attachments in it. If yes I need to set one boolean value to true.
When user (user only, not workflow or automatic message etc.) answers some email I need to fire a plugin that checks incident's status (email is regarding to an incident) and depending on the status do some things.
I'm not really familiar with this whole email tracking concept. We have an email router configured, but that's all I can say.
What are the steps that I need to use in order to achieve plugins described?
For the first plugin I think "Create of email" is enough, right? What about the second plugin and how can I make sure that plugin is fired only when a real person sends an email?
For the first plugin:
To check for attachments for an email you will need to create a plugin which executes on create of the ActivityMimeAttachment entity, which is the entity which stores email attachments.
When an inbound email is processed by the Email Router (or tracked in the Outlook Client) the parent Email record is created first, and then an ActivityMimeAttachment record is created for each attachment.
If you try to check for attachments when an Email is created it will be executing before any attachments are created. However, you may also need a plugin to execute when an Email is created to set the 'Has Attachments' field to false.
The plugin on ActivityMimeAttachment will need to get the parent email activity and set the 'Has Attachments' field to true. This will handle both inbound and outbound emails.
Also note that for 100% accuracy you may need to consider the scenario of a user who is writing an email and adds an attachment, and then deletes it. This could be handled by a plugin running when attachments are deleted, but that logic can get complex (what if two attachments were added but only one was deleted?)
There is some useful sample code for dealing with the ActivityMimeAttachment entity here.
For the second plugin:
A plugin which executes on update of an email would then need to validate the following criteria:
The email direction is outbound (a user has answered an email, e.g. sent a reply)
The email status reason is Sent (the email has actually been delivered and is not saved as a draft)
The email sender and/or owner and/or created by is a real user (filter out automatic and workflow sent emails)
The regarding object is an incident
Then you can implement the required custom validation and logic.
The second item could potentially be achieved using a standard workflow, depending on how complex the custom logic is. If the logic is too complex for a standard workflow, a custom workflow activity might also be useful since additional logic or validation could be added without writing additional code.
For the 1. Plugin: Register on email create and on update (maybe users create the mail first and then update some attachments later)
For the 2. Plugin: Check the following:
plugin context depth should be 1 (this makes sure that no mail created by another plugin is processed)
Check the created by and created on behalf by fields on the email entity to be a non technical users and that no one is acting on behalf of another user creating this mail
Check that regarding object points to incident
If this is not sufficient enough and the users sends mails only via CRM Web GUI you can additionally set a special flag on the record via javascript to make sure that the mail was created using the gui. Than check this status flag in the plugin.

Custom E-Mail Event for Sharepoint Upon InfoPath Form Submit

A customer wants an e-mail notification sent to a select group of people when a new InfoPath form is submitted to a particular Document Library on their SharePoint 2007 setup.
Easy, right? Use a custom set of rules for an e-mail submission in InfoPath, plop in the addresses, use a fancy equation to construct a useful e-mail subject line... and done. Worked like a charm. Problem solved in just a few minutes...
However, the customer doesn't want the whole form e-mailed out or even attached to the e-mail. They only want a few select fields from the form in a very simple message.
I've tried writing an ItemAdded event handler from the SPItemEventReceiver base class, but it doesn't seem to do anything. Yes, I added the event handler to the GAC and created a Feature.xml and Elements.xml to register the event handler with SharePoint. But, I'm not sure if this is even the right event to customize. Is an item in a Document Library the same as an item in a List?
Has anyone had luck doing a similar e-mail notification event? Is there an easier way to accomplish what I'm attempting? Perhaps there's a way to do this easily through the SharePoint interface or edit the contents of the e-mail submission rule to be a simplified version of the form?
Any advice is greatly appreciated!
How about a very simple SharePoint Designer workflow that is triggered when the form is uploaded. From there you send an email and include content of the (exported) columns in an email body.

Notify Admin of an update in Sharepoint?

Is there a way to get an update by email when a user updates a wiki page or adds items into the document library?
Yes, you can simply create an alert on the relevant list (Wiki Pages list or the Document Library in question).
Using alerts you can subscribe to new, modified or deleted items and have details emailed to you immediately, daily or weekly.
From the Actions menu of a list or document library select the Alert Me option and then configure the alert accordingly.
If you like, there's a video showing how to create an alert on a list.

Resources