2

I've a number of record types in my org..

My requirement is to change the view of Task Details for all record types except one named normal_task in salesforce1.. For all others i need to use the default task details page..

So i created a view using lightning component and implemented it via a visualforce page.

 <apex:page standardController="Task" >

<!-- for Normal_Task record type view -->
<apex:outputPanel rendered="{! Task.RecordType.DeveloperName ==  'Normal_Task'}">
    <apex:detail/>
    <script>
    var task_id = "{!Task.Id}";
    if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
        // Salesforce1 navigation
        //sforce.one.navigateToSObject(task_id);
    }
    else {
        // Set the window's URL using a Visualforce expression

    }
    </script>
</apex:outputPanel>



<!-- for custom record type views -->
<apex:outputPanel rendered="{! Task.RecordType.DeveloperName !=  'Normal_Task'}">
    <apex:includeLightning />
    <div id="lightning" />
    <div id="apex_taskDetail" style="display:none;">
        <apex:detail />
    </div>
    <script>
    var task_id = "{!Task.Id}";
    var program_id = "{!Task.merchandize__Program__c}";
    if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
        $Lightning.use("merchandize:task_detailsApp", function() {
            $Lightning.createComponent("merchandize:task_details",
              { 'task_id' : task_id, 'program_id' : program_id },
              "lightning",
              function(cmp) {
                // do some stuff
              });
        });
    }
    else{
        document.getElementById('apex_taskDetail').style.display = 'block';
    }
</script>
</apex:outputPanel>

Now the custom page is working fine..

Issue is with the default view..

i'm currently using apex:detail which doesn't get supported in salesforce1. Below is that part of the code..

 <!-- for Normal_Task record type view -->
<apex:outputPanel rendered="{! Task.RecordType.DeveloperName ==  'Normal_Task'}">
    <apex:detail/>
    <script>
    var task_id = "{!Task.Id}";
    if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
        // Salesforce1 navigation will not work because it is redirected to this visual force page
        //sforce.one.navigateToSObject(task_id);
    }
    else {
        // Set the window's URL using a Visualforce expression

    }
    </script>
</apex:outputPanel>

Gave a try with this navigation for salesforce1, but it will redirect to the same page

if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
     sforce.one.navigateToSObject(task_id);
}

is there a way to replicate the default detail page in salesforce1 via lightning components or via visualforce?

  • it is not naively provided. You need to build the UI using Vf or Lightning. – Tushar Sharma Feb 25 '16 at 9:02
  • oops are you sure? Know any tutorial to create the page with seperate tabs for detail page and related lists as in default page? – sreejith Feb 25 '16 at 9:37
  • Yes i am. You need custom code for that – Tushar Sharma Feb 25 '16 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.