Question:
How do I default the Saleslogix description field on the edit address screen to ‘Mailing’?
Answer:
The main issue is that for Address Edit the applyContext function is never called.
The Address Edit view flow is:
Contact Detail View
Contact Edit View (may query for default values (and call applyContext on itself) or use passed values)
Address Edit View — always gets passed the existing value from the previous Edit view. Therefore applyContext never happens since there is no $template request for default values, it always uses the passed values.
Meaning if you want to set a default value (to be passed) you would have to do it in the Contact View (and all views that have an address field), something like:
Ext.override(Mobile.SalesLogix.Contact.Edit, {
applyContext: function() {
Mobile.SalesLogix.Contact.Edit.superclass.applyContext.apply(this, arguments);
console.log(‘setting description’);
this.fields[‘Address’].setValue({‘Description’:’Mailing’});
}
});
*Note that AddressField stores an object with all the address parts as keys.
So for:
a) Typical cases (not EditorFields which AddressField inherits) your approach is correct, using applyContext to provide a direct ‘default value’ for new insertions.
b) Take a peek at Contact/Edit — in the init() function it binds to the onchange event of the Account field. In the handler, onAccountChange, it sets a field based on a property of the new Account object.



