Monday, 29 July 2019

Issue : Activity History 'Type' field Defaults to 'Call' when we send an email.

Solution:

In the setting when you look into task fields --> Type --> click edit link in 'email' and check the "Send Email Default" box.


Friday, 5 August 2016

Salesforce Header and Sidebar is not displaying in visualforce Page

To resolve this issue, if you see inline=1 in the URL of the visualforce page, then that is the reason for the header and sidebar is not displayed.

To  resolve this issue, please use this below script in the visualforce page to display the sidebar and header.

<script>

if (location.href.match(/inline=1/)) window.top.location=location.href.replace(/inline=1/, '');
</script>

Monday, 1 August 2016

Add LiveChat User Information into Live Chat Transcript Object using Deployment API

As we all know we can get the custom detail of the users/visitors who clicks the live chat icon in the website. In salesforce the details of the users/visitors will be available for the Agent in the visitor detail page but, when you are trying to pull the reports for that data which resides in the Visitor detail page, it is not possible.

If we want those data for reporting we need to do some code change in the website page as well as we need to create some fields in the Live Agent Transcript Object.

Here is the code,

<html>

<script type='text/javascript' src='https://c.la3-c1cs-was.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la3-c1cs-was.salesforceliveagent.com/chat', 'XXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX');
liveagent.addCustomDetail("9.First Name", "Priya").saveToTranscript("First_Name__c");
liveagent.addCustomDetail("8.Last Name", "Mohanraj").saveToTranscript("Last_Name__c");
liveagent.addCustomDetail("7.Email", "priyamohanraj754@gmail.com").saveToTranscript("Email__c");
liveagent.addCustomDetail("4.Display Name", "Priya").saveToTranscript("Display_Name__c");
liveagent.addCustomDetail("3.User Name", "priya").saveToTranscript("User_Name__c");
liveagent.addCustomDetail('5.Language', 'English').saveToTranscript("Language__c");
liveagent.addCustomDetail('6.Country', 'India').saveToTranscript("Country__c");
liveagent.addCustomDetail('1.User ID', '1234').saveToTranscript("User_ID__c");
liveagent.addCustomDetail('2.Full Name', 'Priya Mohanraj').saveToTranscript("Full_Name__c");

</script>
<img id="liveagent_button_online_XXXXXXXXXXXXXXXX" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('XXXXXXXXXXXXXXX')" src="https://english.na2.force.com/liveagentbutton/resource/XXXXXXXXXXXXXXX/livechatbtnonline" />
<img id="liveagent_button_offline_XXXXXXXXXXXXXXX" style="display: none; border: 0px none; " src="https://english.na2.force.com/liveagentbutton/resource/XXXXXXXXXXXXXXXX/livechatbtnoffline" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('XXXXXXXXXXXXX', document.getElementById('liveagent_button_online_XXXXXXXXXXXXXXX'));
liveagent.showWhenOffline('XXXXXXXXXXXXXXXX', document.getElementById('liveagent_button_offline_XXXXXXXXXXXXXXX'));
});</script>

</html>

In the above code saveToTranscript is doing the magic. If we give this method along with the custom detail then, it will save the data in the Transcript object in the mentioned field. The fields which are mentioned inside of the SaveToTranscript method is a custom fields which we needs to be created in the LiveAgent Transcirpt object in salesforce.

Thanks

Happy Coding!!!

Friday, 29 July 2016

On Click on apex:outputText Tag.


Lets see how to use onclick on the <apex:outputText> Tag.

Its very simple, but it took 3 hours to find the solution for it.

Here you go,

Its just a simple code on Account Object.

VF Page

<apex:page standardController="Account" extensions="outputfielddblclick_extn" id="pg1">
<apex:form id="frm1" >
<apex:pageBlock id="pb1">
<apex:pageBlockSection id="pbs1" >
<apex:outputpanel id="counter">
<table>
 <tr>
<td> <apex:outputText value="Account Name"></apex:outputText> </td>
<td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td>                 
<td> <apex:outputText value="{!Account.Name}"/>
<apex:actionSupport event="ondblclick" action="{!justdisplay}" rerender="counter" status="s1"/>        <!-- Status is not a mandatory -->
</td>
</tr>
</table>
</apex:outputpanel> 
<apex:actionStatus id="s1"> <!-- This status is used in the actionSupport. Its not mandatory -->
<apex:facet name="start">
loading....
</apex:facet>
</apex:actionStatus>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Below is the apex class,

public class outputfielddblclick_extn {

    public outputfielddblclick_extn(ApexPages.StandardController controller) {

    }
    public void justdisplay()
    {
        system.debug('RRRRRRRRInside FunctionRRRRRRRR');
        // your logic here
    }
}

If you double click on the Account Name, it will call the "justdisplay()" method in the class.

Below is the output screen.


It will work on apex:outputfield also.

Happy Coding!!!

Tuesday, 8 December 2015

Automate the Approval Process

We can use process builder  and trigger to automate the Approval Process in salesforce.

Now we are going to see, how process builder is used for automation.

First we need to create the Approval Process in Salesforce.

Approval Process:


Choose the Object, you want to create the Approval Process.

For creating the Process Builder, I have used "Jump Start Wizard"  in Approval Process.

 

Then the below page will get displayed.

Here I have given the

Name for the Approval Process.
Given the criteria as Type = "Customer-Direct , Customer-Channel"
Approver as Manager.

 
Click Save. The below page will appear.



Click on "View Approval Process Detail Page". The below page will get displayed.



I have a custom field called "Approval Status field". It contains the "Submitted,Approved,Rejected,Recalled" values.

In the Initial Submission Actions Section,  click on Add New -> Field Update. The below page will get displayed.

I have given the

1. Name
2. choose the Approval Status Field.
3. Choose the "Submitted" value in the "A specific Value" Field.

Click on save.

Do the similar steps for "Final Approval Action" and "Final Rejection Action".

For Approval Action give "Approved".
For Final Rejection Action give "Rejected".

Then Activate the Approval Process. It looks like below.


Process Builder


From setup Click on "Process Builder" under "Create". click New Button. below screen will appear. Give the Name and Description. Click Save.

 
The below screen will appear.

Click on "Add Object". Choose the "Account" object and you can choose either "only when record is created" or "when a record is created or edited". Here I have choose "Only when record is created".
 Now we to give criteria, Inorder to execute the Process Builder. Here I have given "No Criteria - Just execute".


Now we have to define the Action. Click on "Add Action" link in the Process builder and choose action type "Submit for Approval". Give the Action Name, Choose the Approval Process that you have created. choose the submitter as "Current User" and click Save.

If you want to schedule, you can schedule the Actions. this is similar to Time trigger workflow.

Now Activate the Process Builder.

Note: Once process Builder is activated. we cant edit the Process Builder. In order to edit, we have to clone the Process builder.


So when ever Account record is created, it will automatically submit the record for Approval. No need of custom code to automate this.






Wednesday, 27 May 2015

Using the isTest(seeAllData = true) Annotation



If we set the annotation @isTest(seeAllData = true) in the test class then that class will have access to all data in the organization.

Example Class:

  1. @isTest(seeAllData = true)
  2. Public Class Test_AccountClass
  3. {
  4.                 Static testmethod void testAccountMethod1()
  5.                 {
  6.                                 Account ac = [select Name from account Limit 1];
  7.                                 System.assert(ac != null);
  8.                 }
  9.                 Static testmethod void testAccountMethod2()
  10.                 {
  11.                                 // This method will also have access to all org data.
  12.                 }
  13. }
If we are using only @isTest, then it will not have access to all org data, but it will have access to the object that are used to manage our organization.

Object used for manage Organization:

  • User
  • Profile
  • Organization
  • AsyncApexJob
  • CornTrigger
  • RecordType
  • Apex Class
  • Apex trigger
  • Apex Component
  • Apex Page

Example Class:

  1. @isTest
  2. Public Class Test_AccountClass
  3. {
  4.                 @isTest(seeAlldata = true)
  5. Static testmethod void testAccountMethod1()
  6.                 {
  7.                                 // this method will have access all the org data.
  8.                                 Account ac = [select Name from account Limit 1];
  9.                                 System.assert(ac != null);
  10.                 }
  11.                 @isTest Static testmethod void testAccountMethod2()
  12.                 {
  13.                                 // This method will have access only to the above mentioned object.eg:User
  14.                                 User u =[select Id,Name from User Limit 1];
  15.                                 System.assert(u != null);
  16.                 }
  17. }
This annotation will work for the test class saved using the salesforce API version 24.0 or latter calls. For earlier version i.e. 23.0 or earlier continues to have access to all data in the organization and its data access is unchanged.

Email Link in Email Template

Sometimes we may come across the requirement for email Templates like User has to click the email link and the link should redirect to the compose page of the email.

Here is the solution for that,

1. While creating the email Template, choose the HTML email template.


In this Template, I have added my signature. when the user click on the email it should go to compose page. for that I need to select the email and click on link in the tool bar.



Once the link is clicked, the dialog box will appear. There we have to give the values like below.


Once we give the mail link like this, it will redirect to the email compose page.