0

We are currently using an s-control override on the New button to provide a default value for the Name field on various custom objects. For lightning experience, we have to replace this functionality with a different kind of override. I know that I can provide initial values via lightning actions, but this means having to create a button for each record type, and also won't replace the new button on list view pages, etc.

How are other people handling this? We have a temporary workaround of a visualforce page that then calls sforce.one.createRecord() (Summer '17 can pass in default values), but as I asked here, this creates some problems of its own.

2

What about

sforce.one.createRecord()

?

It has been significantly improved with Summer'17 and now you can even add default values. Plain and simple, you can use it like this one-liner:

sforce.one.createRecord('Opportunity',null,{ 
    Name : "2017-10-01 - Power Corp. - Big Deak - 999k",
});

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 name is not Name and only Name 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

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.