Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Contributor
Posts: 57
Registered: ‎04-02-2009
Accepted Solution

Defaulting a value on screen load in Saleslogix Mobile

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');
            }
        });

 

 

Matt Dockins
www.ppsfirm.com
Gold Super Contributor
Posts: 3,087
Registered: ‎03-19-2009

Re: Defaulting a value on screen load in Saleslogix Mobile

Matt,

 There is additional info (on Mobile) posted on the "partner's" side of the forum under:

  Mobile Developer & Discussion.. suggest you look there.

--
RJ Ledger - rjledger@rjlSystems.net +1 603.369.3047 x101

".. Innovators in Mobility - Experts in Workflow Automation..."
http://www.rjlSystems.net - blog: www.rjlSystems.net/blog.html
Highlighted
Bronze Contributor
Posts: 95
Registered: ‎07-11-2011

Re: Defaulting a value on screen load in Saleslogix Mobile

@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.

 

Copper Contributor
Posts: 57
Registered: ‎04-02-2009

Re: Defaulting a value on screen load in Saleslogix Mobile

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.

Matt Dockins
www.ppsfirm.com
Copper Contributor
Posts: 57
Registered: ‎04-02-2009

Re: Defaulting a value on screen load in Saleslogix Mobile

That did the trick - thanks again.

Matt Dockins
www.ppsfirm.com
New Member
Posts: 2
Registered: ‎04-19-2012

Re: Defaulting a value on screen load in Saleslogix Mobile

I tried the same thing at my end its giving following error in fire bug.

 

1. missing : after property id
2. Mobile.SalesLogix.Account.Edit is not a constructor
 
I am using follwoing code
 

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