RunBlock is the feature that allows the codeless addition of customized lists and screens to CRM. In theory you do not need to create either ASP pages or .NET dlls to add application extensions. In practice Runblock's limitations mean that most customizations rapidly need the developer to use the APIs to achieve the results they need. But when it comes to creating Lists against either internal tables, new entities or even external tables then RunBlock is very handy.
The RunBlock action can be called from Tabs, ButtonGroups and List hyperlinks.
I am going to discuss the following examples
Runblock calling a List - under the Company Context
Runblock calling a List (wrapped in a block)
Building a Search or Filter screen with Runblock Runblock calling a List - under the Company Context
This example reproduces the listing of opportunities from under the Company Tab
Create new Tab under Admin>System>Tabs>User that calls Runblock and your new list.
When creating List blocks that are to be called from a particular context it is most important that the primary key of the entity is context is included in the view the List is based on.
In this example we want to call a list of opportunities within the company context and we must therefore base the List block on a view that contains the comp_companyid field. For example the existing OpportunityList is based on vListOpportunity
CREATE VIEW vListOpportunity AS SELECT RTRIM(ISNULL(Pers_FirstName, '')) + ' ' + RTRIM(ISNULL(Pers_LastName, '')) AS Pers_FullName, Pers_PersonId, Pers_CreatedBy, Opportunity.*, Comp_Name, Comp_CompanyId, Comp_CreatedBy, Comp_SecTerr, Pers_SecTerr, Pers_PrimaryUserId, Comp_PrimaryUserId, Pers_ChannelID, Comp_ChannelID, CASE WHEN (Oppo_Certainty IS NULL OR Oppo_Certainty = 0) THEN 0 ELSE (Oppo_Forecast * Oppo_Certainty) / 100 END AS Oppo_Weighted, Chan_ChannelId, Chan_Description, Comp_EmailAddress, Pers_EmailAddress FROM Opportunity LEFT OUTER JOIN Person ON Pers_PersonId = Oppo_PrimaryPersonId LEFT OUTER JOIN Company ON Comp_CompanyId = Oppo_PrimaryCompanyId LEFT OUTER JOIN Channel ON Oppo_ChannelId = Chan_ChannelId WHERE Oppo_Deleted IS NULLNote
Beware of using existing blocks like OpportunityList
using runblock as there is hardcoded behaviour associated with them.
When adding a list called via RunBlock you can use the Tab SQL clause to restrict the display of the tab, just like any system action. Runblock calling a List (wrapped in a block)
RunBlock can either allow you to call the List directly or via a 'Block'. You can define a block by choosing the 'block' tab option within the administration area: Administration -> Customization -> [Entity]
Blocks can be based on any of the following
Knowledge Base Block
Org Chart Block
Each of these block types can be called via RunBlock. Known Limitations
When you define a block based on a List there are two fields that invite you to decide whether or not on the list page you want a 'New' button and thew block that could called.
Show New Button: Yes/No
New Button Action:
The New Button Action should be the name of the screen block that allows you to enter a new record.
There are plenty of issues with using this approach such as 1
) Security (DIVE rights) - The User Security rights are ignored and the New button is always displayed. 2
) Display of TopContent - Loses Context. Building a Search or Filter screen with Runblock
As we can see from the list above we can call blocks other than those based on screens and lists. Although we can call containers unfortunately there is no communication between the blocks. We can not create a container holding a search screen and a list and expect it to work. Note:
There is a big 'quirk' when trying to call Lists from the My CRM area (User, System Menu).
a) To avoid errors the Tab entry SQL field must contain the name of the column that the underlying view is expecting e.g. oppo_assigneduserid otherwise it will pass default user_userid and create an error.
b) Also be aware that it is only fixed to show the records linked to the current logged on user not the user selected in the My CRM top content menu.