cancel URL for sforce.one.createRecord

I noticed that when you use sforce.one.createRecord, and you then hit the “Cancel” button, you get a blank page in Salesforce1.

Is there any way to specify the return url with this method?

Current page code:

<apex:page showHeader="true" sidebar="true" standardController="Account">
<apex:includeScript value="{!URLFOR($Resource.jQueryMobile, 'jquery-1.9.1.min.js')}"/>

<script>
    $(document).ready(function(){
        if( (typeof sforce != 'undefined') && (sforce != null) ) {

            // In Salesforce1, navigate to create record standard page
            sforce.one.createRecord('Visit_Report__c',null);    

        }
        else{
            window.location.href = "{!URLFOR($Action.Visit_Report__c.New,null,
                ['CF00Nb0000006PxKl_lkid' = Account.Id, 
                'CF00Nb0000006PxKl' = Account.Name, 
                'retURL'=URLFOR($Action.Account.View, Account.Id)], 
                true)}";
        }
    });
</script>

Answer

This makes sense now.

The createRecord() page opens in a dialog. When you cancel it, it hides and shows the page that was displayed previously which for you is just this blank page that called createRecord().

You cannot specify a page to go to after the cancel button has been clicked. You could load up a detail page in place then launch createRecord(), that way when they hit cancel they will see the alternate page. But thats it at the moment. Sorry.

Attribution
Source : Link , Question Author : KoenVM , Answer Author : Kris Gray

Leave a Comment