1

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'));

    }

}

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. :(

1

Finally I am able to solve this puzzle.. Here I just updated entity name as "Case" in "createRecord" method, updated line of code looks like :

sforce.one.createRecord("Case", caseSelected);

Wondering if createRecord's entity name is Case sensitive.. did quick google but was unable to find anything relative.. hope this may help others.

Thanks!!

0

Please give the correct path publisher.js

<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>

Hopefully it works!

  • I believe.. I am using same statement as mentioned in your suggestion. Here I also tried using below statement but result was same. 'code'<script type='text/javascript' src='/canvas/sdk/js/29.0/publisher.js'></script>'code' To double verify the same, I tried to comment same script statement and "Submit" button was stop working on Case's record selection page.. :( – user7727 Apr 4 '14 at 19:04

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.