Building a List with an Editable CheckBox using the .NET API (in Sage CRM v7.1 SP2 and earlier)

2 minute read time.

This article has been prompted by a question about what API options exist to allow customization to include an editable CheckBox within a Grid or List. There are a few places in Sage CRM where lists are displayed with an editable CheckBox.

One location that has an Editable CheckBox within a List is within the Group Details page of a Static Group. The CheckBox allows a user to exclude a record from Email, Mail Merge and Export actions that might carried out on the group.

Another location is within the Maintain Relations screen of the RelatedEntities feature.

The two examples I have given here have been built in very different ways. This article will describe the .NET way of creating a List with editable CheckBoxes.

The Maintain Relation screen is produced by a call to a .NET DLL.

http://[servername]/[instancename]/eware.dll/Do?SID=199396848228700 &Act=432 &Mode=1 &CLk=T &Key0=1 &Key1=28 &Key2=30 &func=baseUrl &dotnetdll=RelatedEntities &dotnetfunc=RunREEdit &EntityLinkId=6000 &Entity1Id=28

The DLL is the RelatedEntities dll and the function that is invoked is RunREEdit().

Members of the Developer Program have access to the code that sits behind this page as the source code for the assembly is included in the Sage CRM v7.1 SDK.

It is very easy to add the column to the List as can be seen from the usage in the RelationshipMaintenance.cs file.

The HTML that this creates looks like.


Company Name   Notes Remove Relationship
Airfreight Solutions Effective 1/2007
American Gage Result of previous acquisition
     
     
     
     
     
     
     
     
Select/Deselect all

The Maintain Relationship screen uses the CheckBoxes to allow the users to mark relationships for deletion.

The HTML behind the button "Delete Selected Relationships" governs how CheckBoxes are used. The Button itself and its onClick behaviour will have been defined in the code of the DLL. This can be seen in the RelationshipMaintenance.cs file.

If we want to create a List with an editable CheckBox using the .NET interface then we would have to follow the following steps

  1. Create the List using the standard .NET classes. Add the CheckBox column using the GridColCheckBox() class.
  2. Check how each CheckBox value is uniquely identified.
  3. Create the behaviour that will ensure the field values are read when 'action' button is clicked. In an .NET page the separately named CheckBox values will be available through the Dispatch.ContentFields method.

  • Hi Jeff,

    I have used the .NET SearchPage to create a search which shows a results grid with editable checkboxes. The issue i have is trying to make an advanced search select field mandatory for the search. I have tried using the method described in one of your learning videos and also from the help guide but it just doesn"Tmt work.

    Is there an issue with required/validation on an Advanced SS in a .NET page? Any assistance will be much appreciated!

  • Jeff:

    Does this concept work for 7.3? I see that the title indicates that this article is for v7.1 SP2 and earlier. Therefore, I am assuming this article does not apply. I have searched the community for how to create an editable grid in 7.3. However, I cannot find anything. Is it possible? If so, can you point me in the right direction?

    Any assistance would be greatly appreciated!

    Thank you!

  • Hi,

    I don't seem to get this working with my custom entity. The extra column is a readonly data column showing 0, no checkbox. The html for the checkbox and the hidden field to hold the value aren't inserted. In what way is the id field that is needed for the naming of the checkbox chosen? I don't see a link between the list and the id field? Is there a required format for the selectSQL of the List?

    Thnks!

  • Perhaps I'm just overlooking this part of the code, but how does one set the value for each checkbox? More precisely how can I tell the checkbox which field in the query to use for its value. Currently every checkbox in my list has the companyid value for the company the user is in.

  • I just thought I would add a bit to this post.

    As the returned ContentFields is a KeyValuePair (System.Collections.Generic) list you can iterate through the result in a foreach loop.

    foreach (KeyValuePair key in Dispatch.ContentFields())

    {

    }

    However the actual ContentFields key/value's for the checkbox fields will only show the _HIDDEN fields which will always be NULL on the first click and will only show values on the second click. The data fields are not shown through the ContentFields method or some reason.

    However, luckily, the ContentFields method does expose an _CXBX key for each checkbox that was checked so all that is needed is to find all the _CXBX key's for the combobox field and write out the value. An example is (using rend_deleted as above):

    foreach (KeyValuePair key in Dispatch.ContentFields())

    {

    if (key.Key == "_CKBXrend_deleted")

    completeIds += "'" + key.Value + "',";

    }

    if(completeIds.length > 0)

    completeIds = completeIds.Substring(0,completeIds.Length - 1);

    the variable completeIds will then hold a string containing the id's of the records check which can then be used in a FindRecord where clause to update the records checked.