Showing posts with label VisualForce. Show all posts
Showing posts with label VisualForce. Show all posts

Tuesday, February 18, 2020

How To Open (Url Format) Visual Force Page in Lightning Experience

If you want to open/preview the visual force page in salesforce lightning experience,do you know  how to construct the final url?if not ,this post will help you with the necessary details.

Url format in Classic:

   BaseUrl + '/apex/' + Your PageName +'?AnyQueryParams=xxx'

Url format in Lightning :

  BaseUrl + '/one/one.app#/alohaRedirect/apex/' + Your PageName +'?AnyQueryParams=xxx'

Let take an example your page name is call and your passing the mobile as query param.The complete your will be like below.
https://srinivas4sfdc--dev.lightning.force.com/one/one.app#/alohaRedirect/apex/Call?mobile=8884876772


Output:





Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.




Hope this helps you..Enjoy..!

Thursday, January 2, 2020

Unable To Find My Visual Force Page In Utility Items Of App Settings In Lightning Experience

When your trying to customize any one of your lightning application and some times your trying to add your visual force page as a component but your visual force page is not showing there?

Then please check out the below settings.

Please goto your visual force page and check whether it's enabled to use in lightning application/lightning experience or not?

If not please enable the option "Available for Lightning Experience, Lightning Communities, and the mobile app"


Note: Not only in Utility Items,anywhere in lightning experience if your visual force page is not shown please check these settings.This could be the major issue in most of the cases.

Please comment or write us if you have any queries/requirements.

Please follow,bookmark,subscribe this site to receive daily updates.

Facebook - https://www.facebook.com/ILoveCodingYou/?ref=bookmarks

Hope this helps you..Enjoy..!


Tuesday, December 31, 2019

How To Open Visual Force Page From LWC Components

Please use below code snippet to open the visual force page from LWC.

import { LightningElement,api,track,wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';

export default class CallPopup extends NavigationMixin(LightningElement)
{
    //Call this method from your .html file
 openVisualForcePage(event) 
 {

  const urlWithParameters = '/apex/YourVisualPageName?prop1=propval';
  console.log('urlWithParameters...'+urlWithParameters);
  this[NavigationMixin.Navigate]({
  type: 'standard__webPage',
  attributes: {
  url: urlWithParameters
  }
  }, false); //if you set true this will opens the new url in same window
 }
}

Note: The lightning-navigation works only in lightning experience and it will not work even if your using rendering your component in vf page (using lightning-out) in lightning experience or classic experience.

Hope this helps you..Enjoy..!

How To Build A Global Search URL In Lightning Experience Using Apex

If your in lightning experience on click of any actionable item you want to take the user to the Global Search and perform the search action using the dynamic search string.To get the url of the global search in lightning using apex please refer the below code.


String searchStr = 'Sree'; //Search String
String stringToEncode = '{"componentDef":"forceSearch:search","attributes":{"term":"'+searchStr+ '","scopeMap":{"type":"TOP_RESULTS"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"term":"'+ searchStr + '"}}}}';
String encodedStr = EncodingUtil.base64Encode(Blob.valueOf(stringToEncode)); //Base64 encoding
String redirectUrl='/one/one.app?source=aloha#'+encodedStr;

The format of url must be

     String redUrl = '/one/one.app?source=aloha#'+base64EncodedSearchString;

If you want to the same thing using java script please refer this post


Hope this helps you..Enjoy..!




Sunday, December 29, 2019

Continuation Integration In Salesforce

Problem: 

When multiple agents are using same visual force page (User Interface) and we are making an external call out to fetch the data from the back end systems,if the external service is taking more time (more than 5 sec) to respond ,all such transactions will be treated as a long running transactions in salesforce .At at any given point of time salesforce allows only 5 long running processes in system and it automatically terminates the other requests and it will not allow the agents to perform any other actions.

New Approach: 

Our salesforce system is more dependent on other services to provide the necessary data to the agent usually we will end up with same issue many times.So,we have decided to change the existing integration model and for all new integrations we have started using continuation frame work.In this frame work all the external call outs which are taking longer time ,all these long running requests will be converted into asynchronous callout and this will not be counted under the salesforce limits and also it will not stop the agents doing other works.

Usually agent can request for data on click of any button or action in visual force and this will make an external call out (step 1) and the app server will handover the request to continuation server before it returning to the visual force page  (steps 2–3) .The Continuation server sends the request to the Web service and receives the response (steps 4–7), then hands the response back to the app server (step 8). Finally, the response is returned to the Visual force page (step 9).



Hope this helps you..Enjoy..!

Monday, December 16, 2019

Continuation Method is Not Getting Called In Salesforce APEX

Please check the below points

  • Check whether this class is linked with any visual force page/lightning components,if it's not linked to any one of this then it will not executed.

  • If it's in visual force page please check whether your adding reRender attribute on the <apex:commandButton> or <apex:outputlink> tag where your invoking the Continuation.

Hope this helps you..Enjoy..!

Wednesday, December 11, 2019

How To Open a New Tab in Classic Console Using LWC Lightning Out

You have visual force and inside this your loading the LWC component using Lightning Out in Salesforce Classic Console.

Now,if you want to open a new sub tab (record detail page or visual force page) inside the console on click of a link (inside your LWC .html file) please use the below code.

test.html

<template>
     <lightning-card title="Additional Details" icon-name="custom:custom18">
       <template if:true={showform}>               
          <a href="javascript:srcUp('/apex/PageName?id=3773737');" target="_blank">Test</a>         
       </template>
    </lightning-card>
</template>

If it's not working or getting any issue please include the below 2 lines script files in your visual force page.

<apex:includeScript value="/soap/ajax/45.0/connection.js" />
<apex:includeScript value="/support/console/45.0/integration.js" />


Hope this helps you..Enjoy..!

Thursday, August 8, 2019

How to Display Hyperlink in Visual Force Page When Rendering in Lightning Experience


  • To do this we have to use the Salesforce Lightning Design System(SLDS) styles in visual force page.
  • In SLDS we have a style class called slds-text-link which will highlights the specified text with different color with underscore link.

Sample Source Code:


<apex:page standardController="Case"  sidebar="false" lightningStylesheets="true">
    <apex:slds />
    <apex:form id="formId" >
      
        <div class="slds-text-link">
            <apex:outputText>I Love Coding</apex:outputText>
            
        </div>
    </apex:form>
</apex:page>

Output:



Hope this helped you..Enjoy!..

How to Use SLDS Icons/SVGs in Visual Force Pages

To use Icons/Svgs in visual force pages below 2 steps is required

  • Include latest slds styles   <apex:slds />
  • apply use property in svg tag with required icon
       <use xmlns:xlink="http://www.w3.org/1999/xlink" 
           xlink:href="/apexpages/slds/latest/assets/icons/standard-sprite/svg/symbols.svg#call" />
                

<apex:page standardController="Case" docType="html-5.0" id="pageId" showHeader="false" showChat="false" sidebar="false" lightningStylesheets="true">
    <apex:slds />
    <apex:form id="formId" >
        <div class="slds-truncate sldswordWrap" >
            <span class="slds-icon_container slds-icon-standard-call" title="Dial To Bo">
                <svg class="slds-icon" aria-hidden="true">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/apexpages/slds/latest/assets/icons/standard-sprite/svg/symbols.svg#call" />
                </svg>
                <span class="slds-assistive-text">Description of icon when needed</span>
            </span>
        </div>
    </apex:form>
</apex:page>

Output:



Hope this helped you..Enjoy!..

How to Use Rendered Attribute With Html Tags

Scenario:

Basically if you want to conditionally show/hide in any visual force element we will use the "rendered=true/false".Let assume if your using any html tags like <div> <span> in your visual force page and you want to hide/show conditionally we can not use the "rendered=true/false" property with these html tags.

Solution:

In these type of situations you can use some standard css styles to show or hide html content on conditionally.


<div style="{!IF(AND(condition1,condition2),'display:block','display:none')}">

//display:block - Shows the content,it's similar to rendered="true"

//dispaly:none - Hides the content,it's similar to rendered="false"

Sample Code:

<div class="slds-truncate sldswordWrap" style="{!IF(AND(condition1,condition2),'display:block','display:none')}">
      <span class="slds-icon_container slds-icon-standard-call">
        <svg class="slds-icon" aria-hidden="true">
           <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/apexpages/slds/latest/assets/icons/standard-sprite/svg/symbols.svg#call" />
        </svg>
        <span class="slds-assistive-text">Description of icon when needed</span>
      </span>
</div>

Hope this helped you..Enjoy!..

Wednesday, July 10, 2019

How To Check Whether User is In Console or Not in Lightning Experience

Basically if you want to check whether user in Lightning experience console(sales/service consoles in lightning experience not the just lightning experience ) you can use the same sforce console methods which you have used in classic.This method will support in lightning experience with out any changes.

Sample code:

<apex:page> 
<apex:includeScript value="/support/console/42.0/integration.js" /> 
<apex:includeScript value="/support/api/41.0/interaction.js"/> 

<button onclick="openTab();" > Console openPrimaryTab</button> 

<script> 
function inConsole() { 
if (sforce.console.isInConsole()) { 
alert('In console'); 
}else { 
alert('Not in console'); 
} 
}
</apex:page>

Note:
Even after using this if it's not working please check you version of /support/api/42.0/integration.js. If your version is below 42 then it will not work.So,please change the version it will work automatically.

Hope this helped you..Enjoy!..

Wednesday, August 23, 2017

Salesforce Site Template is Not Coming in Force.com Site

If your Site Template is not coming on your there might be the below issues.

1. Site Template page has not been added for Site Template on Site Detail Page



2. If your using any visual force page in your sites and if your not adding Template to visual force page you will not be able show the template.Please add the template to each and every page.


<apex:page standardController="Case" showHeader="false">
    <apex:composition template="{!$Site.Template}">
        <apex:define name="body">
    <head>
              <apex:includeScript value="{!$Resource.dataTableJS}"/>
       <apex:stylesheet value="{!$Resource.dataTableCSS}" />
     </head>
   <apex:form>
      ----
      ----
   </apex:form>
 </apex:define>
   </apex:composition>
</apex:page>

Hope this helps you...Enjoy!

CSS Styles/Scripts Are Not Working in Salesforce Force.com Sites

If your styles/scripts are working perfectly in Sandbox and Production preview but if it's not working on Force.com sites which has hosted publicly on Sales force server below points might be the issue.

Your page is referring to some external CSS/JS files:

<apex:page>
 <head>
 <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />
<apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" /> 
</head>
<apex:form>
  ----
  ----
</apex:form>
</apex:page>

If your referring any styles/scripts from external sources with out storing them in Static Resource you will end up with problem Please store that files in Statistic resource and then use it then it will work in Force.com sites as well.


<apex:page>
 <head>
  <apex:includeScript value="{!$Resource.dataTableJS}"/>
  <apex:stylesheet value="{!$Resource.dataTableCSS}" />
</head>
<apex:form>
  ----
  ----
</apex:form>
</apex:page>


Your Static Resource is File not accessible publicly



If your using any static resource in your page and if that static resource is not accessible publicly (Cache Control set to Private) then styles will not reflect in Force.com sites.So mark your Static resources cache control as Public



Hope this helps you...Enjoy!