2

I have overridden the 'New' button on Leads page to auto populate 'Owner' field for a specific business process that happens later. This works well in browser but not in the Salesforce1 App.we using "Professional Edition" Is there any reason for it?

Note:I checked also "Available for Salesforce mobile apps and Lightning Pages"

Please advise on this.

<apex:page standardController="Lead">

<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>

<script id="clientEventHandlersJS" language="javascript">
sforce.connection.sessionId = '{!$Api.Session_ID}';

console.log('!!!Name=');
var fname = '{!JSENCODE($User.FirstName)}';
var lname = '{!JSENCODE($User.lastName)}';
var name = fname+' '+lname;

if( (sforce.one != 'undefined') && (sforce.one != undefined) ) {
    sforce.one.navigateToURL('/00Q/e?lea21=1&nooverride=1&retURL=%2F00Q%2Fo&CF00N28000008YR6L_lkid='+window.UserContext.userId+'&CF00N28000008YR6L='+name+'',true); 
}
 else {
 console.log('!!web');
     window.top.location.href = '/00Q/e?lea21=1&nooverride=1&retURL=%2F00Q%2Fo&CF00N28000008YR6L_lkid='+window.UserContext.userId+'&CF00N28000008YR6L='+name+''; 
 }
</script>
</apex:page>
1

Plain and simple, you can use it like this one-liner:

sforce.one.createRecord('Lead',null,{ 
    FirstName : "John",
    LastName : "Doe",  
});

From the Summer '17 Release Notes - Prepopulate Fields on a Record Create Panel

Speed up record creation with prepopulated field values. The sforce.one.createRecord function now includes defaultFieldValues (optional) so you can define fields on a record create panel, including fields not displayed on the panel. This change applies to Lightning Experience and the Salesforce1 mobile browser app.

Users must have create access to prepopulated fields. Errors during saving that are caused by field access limitations do not display error messages.

Caution 1:

The this feature from Summer'17 works only if you put your Visualforce Page to API v40.0 or higher.

Caution 2:

Objectnames and Fieldnames are CASE-SENSITiVE! So lastname is not LastName and only LastName is correct

See also:

https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/salesforce1_dev_jsapi_sforce_one.htm

https://developer.salesforce.com/docs/atlas.en-us.208.0.lightning.meta/lightning/ref_force_createRecord.htm

| improve this answer | |
1

field auto populate or URL hack does not work in Salesforce one and Lightning as well.

You need to create custom page and then populate the fields. There is no way to pass parameters to standard pages in Salesforce1 with the sforce.one.createRecord method.

Only way would be to use the sforce.one.navigateToURL method and use a custom Visualforce page for the new record. You can pass parameters as needed to a Visualforce page.

Now we can prepopulate field. FOr more details check @Uwe Heim's answer.

sforce.one.createRecord('Lead',null,{ 
    FirstName : "John",
    LastName : "Doe",  
});
| improve this answer | |
  • 1
    As of Summer'17 you can add default values now if you page is API v40.0+ – Uwe Heim Aug 28 '17 at 18:26
0

As per the previous answer, URL hacks and onclick JavaScript buttons don't work in Salesforce1.

An alternative to Visualforce in this case could be to use a Global Action to create the lead, AFAIK this works fine in Professional Edition. Using an action, you can create a layout just for that type of lead (excluding any fields that are irrelevant for that type) and can use formulas to set predefined values for any fields, including the owner field.

| improve this answer | |
0

SF1 Lead Record Type overriding standard new button

I've had similar issues by overriding the standard new button. As you can see, the SF1 styling is not there, and when i click on continue, it dumps me into the classic desktop page layout.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.