Question

Mobile auto population of field based on another field

Hi Community,

I have this scenario that I need to achieve in mobile

- In Case page I have "Department" lookup field, this "Department" lookup field is linked to "Department" object.

- "Department" object has "PrimaryContact" lookup field which is linked to "Contact" object

- Now when creating a case, once the user selects Department, the "Assignee" field should be auto populated based on the Department's PrimaryContact value.



Any idea how can i achieve this? Thanks in Advance

Like 0

Like

3 comments

Dear Fulgen, 

Please try the MUTUALFILTRATION rule in the mobile business rules from the academy page below:

https://academy.bpmonline.com/documents/technic-sdkmob/7-12/business-rules-mobile-application

Best regards, 

Dennis 

Dennis Hudson,

Thank you Dennis



Is there a way I can manipulate using esq and set the result directly to assignee field?

Dear Fulgen,

It’s possible to create a custom business rule for adding and deleting filtration. Please, use the academy article by the link below and check the second example:

https://academy.bpmonline.com/documents/technic-sdkmob/7-12/custom-business-rules-mobile-application

In order to set a query result directly to some field please use the function set(). Please feel free to read about the function in the beginning of the page from the article by the link above. Also it possible to use esq to manipulate data. Please find code example below. (Example 2)

 In order to apply the code create an empty module and insert the code to the module. Then use mobile wizard to create a replacing module of manifest and add the name of your module to attribute “PageExtensions” of corresponding page section. Please find code example below (in my case it’s section Activity, example 1).

Example 1:

{

                "SyncOptions": {

                                "SysSettingsImportConfig": [

                                                "DefaultMessageLanguage"

                                ],

                                "ModelDataImportConfig": [

                                                {

                                                                "Name": "Contact",

                                                                "SyncColumns": [

                                                                                "City"

                                                                ]

                                                },

                                                {

                                                                "Name": "City",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "SysLanguage",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "Activity",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "ActivityPriority",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "ActivityType",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "ActivityCategory",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "ActivityStatus",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "CallDirection",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "ActivityParticipant",

                                                                "SyncColumns": [

                                                                                "Activity",

                                                                                "Participant"

                                                                ]

                                                },

                                                {

                                                                "Name": "ActivityParticipantRole",

                                                                "SyncColumns": []

                                                },

                                                {

                                                                "Name": "ParticipantResponse",

                                                                "SyncColumns": []

                                                }

                                ]

                },

                "Modules": {},

                "Models": {

                                "Contact": {

                                                "RequiredModels": [

                                                                "Contact",

                                                                "City",

                                                                "SysLanguage"

                                                ],

                                                "ModelExtensions": [],

                                                "PagesExtensions": [

                                                                "MobileContactGridPageSettingsDefaultWorkplace"

                                                ]

                                },

                                "Activity": {

                                                "RequiredModels": [

                                                                "Activity",

                                                                "ActivityPriority",

                                                                "ActivityType",

                                                                "ActivityCategory",

                                                                "ActivityStatus",

                                                                "CallDirection",

                                                                "ActivityParticipant",

                                                                "Contact",

                                                                "ActivityParticipantRole",

                                                                "ParticipantResponse"

                                                ],

                                                "ModelExtensions": [],

                                                "PagesExtensions": [

                                                                "MobileActivityRecordPageSettingsDefaultWorkplace",

                                                                "UsrMobile1"(my module)

                                                ]

                                }

                }

}

Example 2:

Terrasoft.sdk.Model.addBusinessRule("Activity", {

    name: "ActivityResultByAllowedResultFilterRule",

    position: 1,

    ruleType: Terrasoft.RuleTypes.Custom,

    triggeredByColumns: ["Result"],

    events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Load],

    executeFn: function (record, rule, column, customData, callbackConfig) {

        var store = Ext.create('Terrasoft.store.BaseStore', {

    model: 'ActivityResult'

                                });

                var queryConfig = Ext.create('Terrasoft.QueryConfig', {

    columns: ['Id'],

    modelName: 'ActivityResult'

                                                });

                store.loadPage(1, {

    queryConfig: queryConfig,

    filters: Ext.create('Terrasoft.Filter', {

        property: 'Id',

        value: '6CBD22D4-F36B-1410-5E98-00155D043204'

                }),

            callback: function (records, operation, success) {

                var loadedRecord = records[0];

                var allowedResult = record.get("AllowedResult");

                var filterName = "ActivityResultByAllowedResultFilter";

                if (!Ext.isEmpty(allowedResult)) {

                    var allowedResultIds = Ext.JSON.decode(allowedResult, true);

                    var resultIdsAreCorrect = true;

                    for (var i = 0, ln = allowedResultIds.length; i < ln; i++) {

                        var item = allowedResultIds[i];

                        if (!Terrasoft.util.isGuid(item)) {

                            resultIdsAreCorrect = false;

                            break;

                        }

                    }

                    allowedResultIds.push(loadedRecord.get("Id").toUpperCase());

                    if (resultIdsAreCorrect) {

                        var filter = Ext.create("Terrasoft.Filter", {

                            name: filterName,

                            property: "Id",

                            funcType: Terrasoft.FilterFunctions.In,

                            funcArgs: allowedResultIds

                        });

                        record.changeProperty("Result", {

                            addFilter: filter

                        });

 

                    }

                    else {

                        record.changeProperty("Result", {

                            removeFilter: filterName

                        });

                    }

                } else {

                    record.changeProperty("Result", {

                        removeFilter: filterName

                    });

                }

                Ext.callback(callbackConfig.success, callbackConfig.scope, [true]);

            },

            scope: this

        });

    }

});

 

Best regards,

Norton

 

Show all comments