01-06-2012 11:24 AM
Anyone know how to default a value in a field based on
a) screen load
and
b) a decision/field choice from another field
I thought the following would work to default the description field on the edit address screen to 'Mailing' but its not doing anything - any ideas?
Ext.override(Mobile.SalesLogix.Address.Edit, {
applyContext: function() {
Mobile.SalesLogix.Address.Edit.superclass.applyContext.apply(this, arguments);
this.fields['Description'].setValue('Mailing');
}
});
Solved! Go to Solution.
01-06-2012 12:25 PM
Matt,
There is additional info (on Mobile) posted on the "partner's" side of the forum under:
Mobile Developer & Discussion.. suggest you look there.
01-06-2012 02:58 PM
@RJL While the other thread helps, this is a special case so I'll go ahead and explain it here.
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.
01-06-2012 03:06 PM
Thanks - I suspected something like that (but didn't know how to handle it) when I saw the 'cleanAddressEntry' function on the contact edit - makes sense.
I assume this function above is also why my exists validator works at the account level but not at the contact level.
Thanks again.
01-06-2012 03:38 PM
That did the trick - thanks again.
04-19-2012 03:29 AM
I tried the same thing at my end its giving following error in fire bug.
Ext.override(Mobile.SalesLogix.Account.Edit, {
applyContext: function() {
Mobile.SalesLogix.Account.Edit.superclass.applyContext.apply(this, arguments);
alert("i m called");
}
}),
Please let me know whats going wrong at my end.
Regards,
Gaurang