Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Bronze Super Contributor
Posts: 192
Registered: ‎07-17-2011

Mobile - Edit view, lookup

Have lookup working correctly for insert and edit with one exception.

 

When I click the record | edit the lookup field is not populated.  If I do a lookup the lookup field and the corresponding hidden field populate.

 

What am I missing?

 

 createLayout: function() {           

   return this.layout || (this.layout = [               

    {                   

      label: this.accountNameText,                   

      name: 'Account',                   

      textProperty: 'Name',                   

      type: 'lookup',                   

       validator: Mobile.SalesLogix.Validator.exists,                   

       view: 'account_related'               

     }, {                   

      name: 'ClinicName',                   

      type: 'hidden'             

       }         

  ]);     

  }

Highlighted
Bronze Contributor
Posts: 95
Registered: ‎07-11-2011

Re: Mobile - Edit view, lookup

The 'textProperty' part of the row object points to the property of the current SData object. Meaning in your querySelect for that view you may have something like:

 

        querySelect: [

            'Account/AccountName',

            'AccountManager/UserInfo/FirstName',

            'AccountManager/UserInfo/LastName',

            'CreateDate',

            'CreateUser'

        ],

 

AccountName and UserInfo are the 'textProperty' of 'Account' and 'AccountManager'  (the name formatter handles taking the UserInfo object and getting the first/last name rendered properly).

 

So the first thing I would do is make sure your querySelect has a Account/Name, or if it is like the eval database your textProperty should be AccountName  (which would match Account/AccountName in the querySelect).

 

To see that in the code, the Edit view does a 'get all values' for all of the fields. In Controls/LookupField.js, you see in getValue it calls:

                text = U.getValue(val, this.textProperty);

 

With the U being Utility, which looks like:

        getValue: function(o, name, defaultValue) {

        ...

                if (typeof current[key] !== 'undefined')

                    current = current[key];

        ...

 

So it loops through the object (the 'name' part of the row object in layout) looking for that key (the textProperty) so it looks for Account['AccountName'] - which in SData Query (which is hql?) notation is Account/AccountName.

 

Highlighted
Bronze Super Contributor
Posts: 192
Registered: ‎07-17-2011

Re: Mobile - Edit view, lookup

Here is what I have now (below).  Stil not getting the fields populated on edit.  Could I have something wrong with the relationships?  The entity Device has a parent relationship to each of the entities below.

 

Thanks for all your help on this.

 

Norman

 

querySelect: [

            'Account/AccountName',

            'ClinicName', // = Account.AccountName

            'Warehouse/Warehouse_code',

            'Warehouse_code', // = Warehouse.Warehouse_Code

            'Product/ActualId'

            'Product_number', // = Product.Actual.Id

]

.

.

.

{

      name: 'Warehouse',

      textProperty: 'Warehouse_code',

      label: 'wh',

      type: 'lookup',

      view: 'warehouse_related'

},{

      label: this.accountNameText,

      name: 'Account',

      textProperty: 'AccountName',

      type: 'lookup',

      validator: Mobile.SalesLogix.Validator.exists,

      view: 'account_related'

},{

      name: 'Product',

      textProperty: 'ActualId',

      label: 'product #',

      type: 'lookup',

      view: 'product_related'

}

Highlighted
Bronze Super Contributor
Posts: 192
Registered: ‎07-17-2011

Re: Mobile - Edit view, lookup

I finally got this to work.  I was mirroring a contact lookup.  There are a lot of other things in that form which may not be needed.

 

This time I mirrored how Lead Source lookup works on Account | Edit.

 

Works like a charm.