Skip to main content
added 269 characters in body
Source Link
user7727
  • 71
  • 1
  • 7

If I use standard "New Case" publisher action button.. select appriopriate RecordType, I will land on same page (i.e. Standard Page Layout) and after filling the form.. I am able to create new service ticket where same feature is not working with above code. :(

If I use standard "New Case" publisher action button.. select appriopriate RecordType, I will land on same page (i.e. Standard Page Layout) and after filling the form.. I am able to create new service ticket where same feature is not working with above code. :(

Source Link
user7727
  • 71
  • 1
  • 7

"Submit" button is not working with sforce.one.createRecord

I am very new to Salesforce1 (& on Mobile development too), currently working on one POC where I am creating custom VF page (enabled on Mobile) just like Case record type selection page. On this page, I am showing limited Case Record Type option to user and on selection I am redirecting user to case creation page (Standard UI/page layout) using "sforce.one.createRecord("case", caseRtId);".

After filling the form when user is clicking on "Submit" button nothing is happen and case record too is not created.

Please guide.

<apex:page standardController="Account" extensions="SelectService_Mobile_VFCExt" docType="html-5.0" standardStylesheets="false" showheader="false" sidebar="false">
<apex:stylesheet value="{!URLFOR($Resource.Mobile_Design_Templates, 'Mobile-Design-Templates-master/common/css/app.min.css')}"/>
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>

 <script>
      function createServiceTicket() {
          var e = document.getElementById("{!$Component.form.CaseRecordTypeSelect}");
          var caseSelected = e.options[e.selectedIndex].value;              
          
          sforce.one.createRecord("case", caseSelected);
        }
  </script>
<apex:form id="form">
    <apex:outputPanel id="FormPanel">
        <apex:outputLabel >Select Service Ticket Type</apex:outputLabel>
        <apex:selectList value="{!selectType}" size="1" id="CaseRecordTypeSelect">
            <apex:selectOptions value="{!serviceTktTypeItems}"></apex:selectOptions>
        </apex:selectList>
    </apex:outputPanel>
</apex:form>

<script type='text/javascript'>
     Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel", 
        onData:function(e) { 
            //alert('Submit called');
            Sfdc.canvas.publisher.publish({name: 
                "publisher.setValidForSubmit", payload:"true"}); 
    }});
    
     
    Sfdc.canvas.publisher.subscribe({ name: "publisher.post", 
        onData: function(e) { 
        alert("call some remote action here"); 
        
        createServiceTicket();
    }});
 </script>
</apex:page>

The VF Controller code will look like:

public class SelectService_Mobile_VFCExt {
    
    public String selectType{set; get;}
    public List<SelectOption> serviceTktTypeItems {set; get;}

    public SelectService_Mobile_VFCExt(ApexPages.StandardController controller) {
        
        serviceTktTypeItems = new List<SelectOption>();
        serviceTktTypeItems.add(new SelectOption('<record type id>','RecordType 1'));
        serviceTktTypeItems.add(new SelectOption('<record type id>','RecordType 2'));
        serviceTktTypeItems.add(new SelectOption('<record type id>','RecordType 3'));
           
    }

}