Article

"Uncaught TypeError:Cannot read property "modelName" error in the mobile app while opening the "Activities" section

Symptoms

When I set up the mobile app, all objects work fine, except for "Activity". When I try to access an activity, the following error is displayed - Uncaught TypeError:Cannot read property “modelName” of undefined.

I tried to delete all columns to add them again (thought maybe the "Type" column is causing this issue) - it didn't work. 

Once I changed the settings, I re-distributed access rights, cleared the cache and re-synchronized with the database. 

Solution

Some of the fields were removed on the activity card, and, most importantly, the “Participants” detail was removed. This detailed is required for correct operation of the "Activities" section.

By default, bpm'online only syncs the activities with the current user specified on the “Participants” detail.

If this detail is removed, the activities may not sync correctly.

A workaround for deleted objects used in parent packages:

- Create a custom schema (e.g., "MobileUtilitiesCustom").

Ext.define("Terrasoft.sdk.RecordPageMetadataApplier.Override", {
 
                override: "Terrasoft.sdk.RecordPageMetadataApplier",
 
 
 
                addEmbeddedDetail: function(modelName, operation) {
 
                               this.embeddedDetails[operation.name] = operation.values;
 
                               var values = operation.values;
 
                               var filter = values.filter;
 
                               var detailName = operation.name;
 
                               Terrasoft.sdk.RecordPage.addEmbeddedDetail(modelName, {
 
                                               name: detailName,
 
                                               title: values.caption,
 
                                               position: values.position,
 
                                               modelName: values.entitySchemaName,
 
                                               primaryKey: filter.masterColumn,
 
                                               foreignKey: filter.detailColumn,
 
                                               hidden: values.hidden
 
                               });
 
                },
 
 
 
                applyMetadata: function() {
 
                               this.callParent(arguments);
 
                               for (var itemName in this.removedMetadataItems) {
 
                                               if (!Terrasoft.util.isGuid(itemName) && Terrasoft.util.String.contains(itemName, "EmbeddedDetail")) {
 
                                                               this.addEmbeddedDetail(this.modelName, {
 
                                                                              name: itemName,
 
                                                                              values: {
 
                                                                                              entitySchemaName: itemName.substring(0, itemName.indexOf("Detail")),
 
                                                                                              filter: {
 
                                                                                                              masterColumn: "Id",
 
                                                                                                              detailColumn: "Id"
 
                                                                                              },
 
                                                                                              hidden: true
 
                                                                              }
 
                                                               });
 
                                               }
 
                               }
 
                }
 
});
 
 
 
Terrasoft.sdk.RecordPage.configureColumn = function(model, columnSetName, columnName, columnConfig) {
 
                var modelConfig = Terrasoft.ApplicationConfig.getModelConfig(model);
 
                var columnSetConfig = modelConfig.columnSets.get(columnSetName);
 
                if (!columnSetConfig) {
 
                               return;
 
                }
 
                var columnSetColumns = Terrasoft.sdk.RecordPage.getColumns(model, columnSetName);
 
                if (!columnSetColumns) {
 
                               return;
 
                }
 
                var columnSetColumn = columnSetColumns.get(columnName);
 
                var columnOriginalConfig;
 
                if (columnSetColumn) {
 
                               columnOriginalConfig = columnSetColumn.columnOriginalConfig;
 
                } else {
 
                               columnOriginalConfig = {};
 
                               columnConfig.hidden = true;
 
                               var modelInstance = Ext.ClassManager.get(columnSetConfig.modelName || model);
 
                               var realModelColumnConfig = modelInstance.ColumnConfigs.get(columnName);
 
                               columnConfig.columnType = realModelColumnConfig.columnType;
 
                               columnConfig.name = columnName;
 
                }
 
                Ext.merge(columnOriginalConfig, columnConfig);
 
                var contextModel = columnSetConfig.modelName || model;
 
                if (columnConfig.hidden) {
 
                               var columns = this.getColumnSetColumns(model, columnSetName);
 
                               columns.remove(columnName);
 
                } else {
 
                               var resolvedColumnConfig = this.resolveColumnConfig(contextModel, columnOriginalConfig,
 
                                                               !!columnSetConfig.modelName);
 
                               columnSetConfig.columns.configure(columnName, resolvedColumnConfig);
 
                }
 
};
 
 
 
Terrasoft.sdk.RecordPage.addColumn = function(model, columnConfig, columnSetName) {
 
                var modelConfig = Terrasoft.ApplicationConfig.getModelConfig(model);
 
                if (!columnSetName) {
 
                               columnSetName = modelConfig.primaryColumnSetName;
 
                }
 
                var columnSetConfig = modelConfig.columnSets.get(columnSetName);
 
                if (!columnSetConfig) {
 
                               return;
 
                }
 
                var contextModel = columnSetConfig.modelName || model;
 
                var isEmbeddedDetail = !!columnSetConfig.modelName;
 
                if (!columnConfig.hidden) {
 
                               columnSetConfig.columns.add(this.resolveColumnConfig(contextModel, columnConfig, isEmbeddedDetail));
 
                }
 
                this.addColumnToQueryConfig(model, columnConfig.name, columnSetName, isEmbeddedDetail);
 
                if (columnConfig.displayColumn) {
 
                               this.addColumnToQueryConfig(model, columnConfig.displayColumn, columnSetName, isEmbeddedDetail);
 
                }
 
};

- In the mobile application manifest (e.g., "UsrMobileApplicationManifestCustomMobile") specify the custom schema.

Like 0

Like

Share

0 comments
Show all comments