Set lookup field value in mobile app

Hi all ,

I have a custom business rule in mobile app were i need to set the value of a lookup filed of the records. but i just can't find the way how to do it.

for example:



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

    // The name of the business rule.

    name: "MyRULE",

    // Business rule type: custom.

    ruleType: Terrasoft.RuleTypes.Custom,

    triggeredByColumns: ["Product"],

      events: [Terrasoft.BusinessRuleEvents.Load],

    // Handler function.

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

        record.set("Product",{value:  , displayValue: });

        // Asynchronous return of values.

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

    }

});

 

But this does not work.. i get :

record.set("Product",{value:  , displayValue: });

base-model.js:453 Uncaught TypeError: value.toLowerCase is not a function

 

Can you help ?

 

Thanks.

Eran.

 

Like 0

Like

2 comments

Hi Eran,

Here is how you should write a set function:

set(columnName, value, fireEventConfig)

Here is an example of how to set lookup fields:

record.set("ActivityCategory", ActivityCategory.Store.getById("8b16d130-313e-4b12-a12e-73a2dd8d33cf"), true);

Please note, the value parameter should always contain a record, if this lookup is not loaded in your mobile app then you should do a request to a database in order to get it instead of Store.getById.

Thanks Dmytro,

You are right, I needed to request the database to fetch the lookup record, and only then I could use the  " set(columnName, <lookup record>, fireEventConfig)  "

Show all comments