CRM Lists With No Meta Data - Full Column Object Properties / Methods List

If someone could point me in the right direction I would be really grateful.

As the subject suggests I am currently building a CRM List Object within an ASP page which does not reference Metadata. The list itself is working and returning the data as expected

var listObject = CRM.GetBlock("List");

listObject.SelectSql = "select *, datediff(day,Lead_CreatedDate,getdate()) as lead_v_age from vSummaryLead";

var lead_v_age = listObject.AddGridCol("lead_v_age",-1,true);

However, as you can see from the above the SQL statement returns a derived field (lead_v_age) which is being added to the list. Being a derived field it has no metadata within CRM so there is no translation and is not user friendly within the UI.

Looking at http://help.sagecrm.com/on_premise/en/2017R2/dev/Content/Developer/ASP%20Object%20Reference/CRMGridColBlock%20Object/AS_CRMGridColBlockObject.htm there are a number of properties available regarding the list columns:

Alignment. Sets the alignment of text within the column.
AllowOrderBy. Sorts entries in the list by the values in the column.
CustomActionFile. Hyperlinks a column to an ASP file.
CustomIdField. Allows a value to be passed to the custom file when the corresponding column is selected.
JumpEntity. Adds a hyperlink that opens the summary screen of an entity record.
ShowHeading. Shows or hides the column heading.
ShowSelectAsGif. Shows the values in the column as GIF image

The issue which I am having is that this does not cover all of the options which are available to list column, specifically:

Order By Desc
Default Order By
Caption (which I am trying to set via CreateScript)

Taking an educated guess and trying the following results in an error

lead_v_age.DefaultOrderBy = true
lead_v_age.OrderByDesc = true

Whilst the following appears to do nothing

lead_v_age.CreateScript = "Caption = 'Record Age'"

In summary for the derived field the caption, order by desc and default order by need to be set. In addition all fields must be sortable although and this is the last field in the list so does not get sorted by default.

  • 0

    I will try and answer these questions as best I can.

    Considering the code above.

    You can see that I have opened up the eWare.dll in Visual Studio's Object Browser.

    I am looking at the Class eWareGridColBlock.

    "DefaultOrderBy" does not have a definition in the API.

    "Caption" does not have a definition in the API. You may wish to consider the alias used within the SQL. It will draw the caption from the custom_captions table.

    "OrderByDesc" is defined as a Boolean BUT is in effect ignored because of the need to order columns by the first column (ascending) included in the grid unless within the session further control is provided AllowOrderBy.

    CreateScript is valid and can control any of the columns properties and interact with system variables.

    e.g.

    CreateScript = "Valid=false;ErrorStr='hello world'";

  • 0

    Thank you for that Jeff

    Adding the below line displays the error string as you would expect

    lead_v_age.CreateScript = "ErrorStr='Generated From The Create Script'"

    I was hoping that as both lists and screens are block objects that they would share some of the same properties. I assume then that the below does not work for lists as the list does not have a caption property.

    enty_v_name.CreateScript = "Caption = 'Record Type'"

    Unfortunately we don't seem to be able to use the object browser to view the list of classes within the eWare dll. My assumption is that when adding fields to a screen then this is invoking the eWareEntryGroupBlock class which includes the caption property.

    I don't understand then how this option is available within the UI. There is a property for Default Order By when amending the metadata through CRM itself. When the list is rendered from the metadata it must invoke these methods in order to build the page. I assume that these classes are used when CRM renders the HTML rather than just being available to the API.

  • 0

    Alison

    I know that lists (based on metadata) are controlled within their ordering by the primary key of the entity on which the list is based.. You can see this in SQL generated in the logs.

    So if the list is a person list then the SQL will end in "ORDER BY pers_accountid, Pers_PersonId". (Note the 'account' entity is used in some integrated systems).

    Properties such as 'Allow Order By' will change the User interface to allow the list to be reordered.

    If a field (for example pers_lastname) in a metadata defined list has the property 'Default Order By' set in the screen definition then this overrides the default order and the SQL will end in "ORDER BY pers_accountid, pers_lastname, Pers_PersonId".

    The UI field 'Default Order By' does not have an equivalent in the API. Not all internal operations processed by the eWare.dll are exposed to the API.

    If a list is not based on Metadata then the default order will be by the first column included in the list.

    In the example below the list will be ordered by 'pers_lastname'.

    var myBlock = CRM.GetBlock("list");

    myBlock.SelectSQL = "select * from vsummaryopportunity where pers_firstname is not null";

    var myLastname = myBlock.AddGridCol("pers_lastname");

    var myFirstname = myBlock.AddGridCol("pers_firstname");

    If the derived fields need to have a better translation then it is possible to add the necessary definitions into the meta data of the custom_edit and custom_captions tables.

    See the article:

    community.sagecrm.com/.../custom-edits-and-derived-fields-created-in-views.aspx

    There is a component to help create the necessary metadata for derived columns here:

    community.sagecrm.com/.../default.aspx