09-30-2011 06:19 PM
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'
}
]);
}
10-03-2011 10:36 AM
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.
10-03-2011 11:30 AM
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'
}
03-23-2012 11:41 AM
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.