5

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>

6
  • I'm not seeing that, how is this happening for you? Do you have any VF overrides? Multiple Record Types?
    – Kris Gray
    Commented Feb 14, 2014 at 0:14
  • What do you mean with VF overrides? The sforce.one.createRecord is javascript that is being called from my VF page.
    – KoenVM
    Commented Feb 14, 2014 at 8:46
  • Maybe try with the next release which comes out in a few weeks. If it's still happening id suggest filling a bug.
    – Kris Gray
    Commented Feb 14, 2014 at 16:13
  • Can you also give more repro steps? What's the be page code look like?
    – Kris Gray
    Commented Feb 14, 2014 at 16:14
  • It's a very simple page. I updated the question to show the code. Basically, it checks if you are in the Salesforce1 context. If yes, it uses the sforce.one.createRecord . If not, it redirects to the edit view for a new visit report which is a child of account.
    – KoenVM
    Commented Feb 17, 2014 at 8:10

1 Answer 1

2

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.

2
  • Maybe I can somehow check when arriving back on my VF page if I came there via the cancel. I'll have a look and let you know. It's unfortunate though that when using the createrecord, that you can't specify a return location like you can do in regular salesforce.
    – KoenVM
    Commented Feb 18, 2014 at 17:23
  • I agree. It's a bit late but maybe next release we can fix that.
    – Kris Gray
    Commented Feb 18, 2014 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .