Question

Adding attachment 'Description' to attachment timeline tiles

Having figured out how to do this I thought I would post the solution.

Sometimes the name of an uploaded file does not indicate what the contents are, the description is needed.  Out of the box this description is not displayed on an attachment timeline tile.  The steps to add the description follow.

The Creatio page on configuring the timeline is Timeline.  The scheme of things is roughly table 'TimelinePageSetting' configures the timeline for a section, while table 'TimelineTileSetting' is for configuring individual tiles.

Create two modules (Advanced settings > +Add), which I will call "UsrFileTimelineItemViewWithDescription" and "UsrFileTimelineItemViewModelWithDescription".

Add the following to "UsrFileTimelineItemViewWithDescription":

define("UsrFileTimelineItemViewModelWithDescription", ["UsrFileTimelineItemViewModelWithDescriptionResources", "FileTimelineItemViewModel"
      ],
      function() {
            Ext.define("Terrasoft.configuration.UsrFileTimelineItemViewModelWithDescription", {
                  alternateClassName: "Terrasoft.UsrFileTimelineItemViewModelWithDescription",
                  extend: "Terrasoft.FileTimelineItemViewModel",
            });
      }
);

Within this schema add a localizable string with the code "NotesLabel" ('Notes' being the name of the column within the table that holds attachments, the table name being the section name suffixed with "File", e.g., "OpprtunityFile") . Set the value to "Description", it will be the label of the field in the timeline.

Add the following to "UsrFileTimelineItemViewModelWithDescription":

define("UsrFileTimelineItemViewWithDescription", ["FileTimelineItemView"], function() {
      Ext.define("Terrasoft.configuration.UsrFileTimelineItemViewWithDescription", {
            extend: "Terrasoft.FileTimelineItemView",
            alternateClassName: "Terrasoft.UsrFileTimelineItemViewWithDescription",
            getBodyViewConfig: function() {
                  var bodyConfig = {
                        "name": "BodyContainer",
                        "itemType": Terrasoft.ViewItemType.CONTAINER,
                        "classes": {
                              "wrapClassName": ["timeline-item-body-container"]
                        },
                        "items": [
                              this.getTextWithLabelContainerViewConfig("Resources.Strings.NotesLabel", "Notes")
                        ]
                  };
                  var imagePreviewConfig = this.callParent(arguments);
                  bodyConfig.items.unshift(imagePreviewConfig);
                  return bodyConfig;
            }
      });
});

Execute the following SQL to obtain the current 'TimelineTileSetting' table 'Data' entry for attachments:

SELECT encode("Data", 'escape')
AS text_column
FROM "TimelineTileSetting"
WHERE "Name" = 'Files'

I used JSON Formatter to format the JSON output.

Change "viewClassName" and "viewModelClassName" to reflect the modules created earlier.

Add the following 'columns' configuration:

"columns":[{"columnName":"Notes","columnAlias": "Notes"}]

The JSON should now look along the lines of:

{
    "typeColumnValue":"529bc2f8-0ee0-df11-971b-001d60e938c6",
    "entitySchemaName":"##ReferenceSchemaName##File",
    "viewModelClassName":"Terrasoft.UsrFileTimelineItemViewModelWithDescription",
    "viewClassName":"Terrasoft.UsrFileTimelineItemViewWithDescription",
    "orderColumnName":"CreatedOn",
    "authorColumnName":"CreatedBy",
    "captionColumnName":"Name",
    "columns":[
        {
            "columnName":"Notes",
            "columnAlias":"Notes"
        }
    ]
}

I used Minify JSON to re-minify the JSON.

Update 'TimelineTileSetting' with the following query:

UPDATE "TimelineTileSetting"
SET "Data" = '{"typeColumnValue":"529bc2f8-0ee0-df11-971b-001d60e938c6","entitySchemaName":"##ReferenceSchemaName##File","viewModelClassName":"Terrasoft.UsrFileTimelineItemViewModelWithDescription","viewClassName":"Terrasoft.UsrFileTimelineItemViewWithDescription","orderColumnName":"CreatedOn","authorColumnName":"CreatedBy","captionColumnName":"Name","columns":[{"columnName":"Notes","columnAlias": "Notes"}]}'
WHERE "Name" = 'Files'

Refresh the browser cache, if necessary generating the source code for all schemas and compiling the app.

Like 1

Like

2 comments

A quick correction, the final UPDATE query 'Data' column is binary data, so the query should be:

UPDATE "TimelineTileSetting"
SET "Data" = decode('{"typeColumnValue":"529bc2f8-0ee0-df11-971b-001d60e938c6","entitySchemaName":"##ReferenceSchemaName##File","viewModelClassName":"Terrasoft.UsrFileTimelineItemViewModelWithDescription","viewClassName":"Terrasoft.UsrFileTimelineItemViewWithDescription","orderColumnName":"CreatedOn","authorColumnName":"CreatedBy","captionColumnName":"Name","columns":[{"columnName":"Notes","columnAlias": "Notes"}]}', 'escape')
WHERE "Name" = 'Files'

 

Nice! Thanks for sharing.

Ryan

Show all comments