Question

Bind lookup column in edit page

Hi,

I will have to auto populate/bind a lookup column based on other column value.

My scenario is : I have added a lookup object UsrTerritory -- Values are Domestic & International

I have added a column with the above lookup reference in Account called "UsrTerritory".

 

This column should auto bind to domestic if the country is india, else to international.

 

In Edit page I have mentioned like 

attributes: {

             "UsrTerritory":

            {

                dataValueType: Terrasoft.DataValueType.LOOKUP,

                dependencies: [

                    {

                        columns: ["Country"],

                        methodName: "GetTerritoryDetails"

                    }

                ]

            },

        },

 

 

    GetTerritoryDetails :function()

            {

                //var Country = this.get("Country").displayValue;

                 

                var esqOrder = this.Ext.create("Terrasoft.EntitySchemaQuery", {

                    rootSchemaName: "UsrTerritory"

                });

                esqOrder.addColumn("Id");

                esqOrder.addColumn("Name");

                

                var DomesticValue,InternationValue;

                    esqOrder.getEntityCollection(function (result) {

                         if (!result.success) {

                            this.showInformationDialog("Data query error");

                        return;

                         }

                        result.collection.each(function (item) {

                            if(item.get("Name") === "Domestic"){

                            DomesticValue = item.get("Id");

                            }

                            if(item.get("Name") === "International"){

                            InternationValue = item.get("Id");

                            }

                        });

                        if(this.get("Country").displayValue ==="India")

                        {

                            this.set("UsrTerritory", DomesticValue);

                        }

                        else{

                            this.set("UsrTerritory", InternationValue);

                        }

                    }, this);

            

            }

 

 

But am unable to achive in binding the column. It says undefined.

Please help

 

Like 0

Like

1 comments

Dear Sriraksha,

You are getting an 'undefined' value due to the fact, that in lookup fields you are supposed to pass an object, but not just GUID. In order to check what is set and stored in the lookup fields you can run a simple procedure: select a value in the lookup, set debugger to stop when selecting and check what is in there. You will see an object. Therefore, in your method you need to set an object to the lookup field. Be sure that such object has at least 2 fields required:

{    displayValue: "The text that will show in the field",             value: "unique value identifier"

}

Regards,

Anastasia

Show all comments