function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anil IngleAnil Ingle 

'defaultFieldValues' is not working in sforce.one.createRecord

Hello All,

I am working in Lightning Experience. On button click we creating opportinity with passing accountId using sforce.one.createRecord.
Salesforce redirect to opportunity but doesn't carry Account Name(AccountId).

Please check the following Code.

<script>
    function MyApp() {
        this.createOpportunity = function() {
            var custAccountId = '{!accountId}';
            sforce.one.createRecord("Opportunity", null, "defaultFieldValues:{ 'AccountId' : '"+custAccountId+"'}" );
        };
    } 

    var app = new MyApp();

    function btnCreateOppt() {
        app.createOpportunity();
    }
</script>

...
...
...

<div style="display:{!if((rfqDetail.Opportunity__c == ''),"normal","none")};">
<apex:commandButton action="{!ViewOpportunity}" value="Create" oncomplete="btnCreateOppt();" reRender="{!if((displayErrorPopUp), 'errorPopup','redirectOppt')}">
</apex:commandButton>
</div>

Please let me know, if any thing mistake