Sage CRM 2021: Add a view for custom entities to support the sending of emails in workflow and escalation rules.

1 minute read time.

Imagine that you have created a new custom entity called 'Project' for your system. Sage CRM provides the Advanced Customisation Wizard to allow you to do just this very easily as you can see in the image below.

You should notice that I created this entity as a child of company and person.

Depending on the options that you select when running the Advanced Customisation Wizard, Sage CRM will create an example 'stub' workflow. You can see that I have started to customise this workflow by adding a 'Send Email' rule.

I ran into a problem when I tried to create the Workflow Action 'Send Email'.

I therefore needed to create a new view called 'vNotificationProject'.

I added the view under the customisation area of the new entity 'Project'

Administration -> Customisation -> Project

This is the SQL used.

SELECT Project.*, vPersonPE.*, vCompanyPE.*, Users.*, Escalations.*
FROM Users INNER JOIN Project
ON Proj_UserId = User_UserId AND Proj_Deleted IS NULL
LEFT JOIN vPersonPE ON Proj_PersonId = Pers_PersonId AND Pers_Deleted IS NULL
LEFT JOIN vCompanyPE ON Proj_CompanyId = Comp_CompanyId
LEFT JOIN Escalations ON Proj_ProjectId = Escl_RecordID AND Escl_TableId = 10240 AND Escl_Deleted IS NULL
WHERE User_Deleted IS NULL

I based my view on the existing 'vNotificationOpportunity' view.

As I mentioned above, this assumes that the custom entity 'Project' is a child of Company and Person.
I also had to check in the metadata table 'custom_tables' to get the correct ID for the field 'escl_tableid'. This will be different in your system.

Once I had created the view then the workflow action 'Send Email' could be defined and the emails sent and stored as communications.