Tuesday, 6 May 2014

Working with custom button in service cloud console and the regular salesforce.com application

Hi,

I am going to explain how to work with custom button in service cloud console mode and the regular salesforce.com application.

Basically we have a requirement i.e we need to create a list button for populating some of the fields from parent record.This should works in regular salesforce.com application  and service cloud console mode.

If we use " window.open " method for both it won't work for service cloud console mode in a proper way.So we need to use different things to work with both .The following things are useful whenever you want to construct an url from custom button for both service cloud console mode and regular salesforce.com app.

if (typeof(srcUp) == 'function') {
srcUp('/a1z/e?retURL=%2F{!Acccount.Id}&CF00Ne0000000u_lkid={!Contact.Id}');
} else {
window.open('/a1z/e?retURL=%2F{!Acccount.Id}&CF00Ne0000000u_lkid={!Contact.Id}','_parent');
}

Here,we check to see if the srcUp method is defined with "if(typeof(srcUp)=='function')".If we are in the Service Cloud Console ,this condition will evaluate to true.If it is false and we are in the regular app, we use the javascript "window.open" method to open our target url in a new window.

For more information please look into below url:
Click here for more information



Sunday, 4 May 2014

Showing Attachment Preview and related record detail by passing attachment id in salesforce.com

Hi,

Here in the following example i am using one custom component ,visualforce page and an extension.Here the custom component is used to display preview of attachment by getting the id from visualforce page where it is included.In this component i am using "Object" ,"embed" html tags to show preview of attachment.

Component Code:
===============
<apex:component >
<apex:attribute name="height" type="String" description="TODO: Describe me"/>
<apex:attribute name="width" type="String" description="TODO: Describe me"/>
<apex:attribute name="value" type="String" description="TODO: Describe me"/>
<object data="/servlet/servlet.FileDownload?file={!value}" type="application/pdf" width="{!width}" height="{!height}">
 <embed src="/servlet/servlet.FileDownload?file={!value}" width="{!width}" height="{!height}"/>
</object >
</apex:component>

Visualforce Page:
=============
<apex:page standardcontroller="Attachment" extensions="Attachradiocls1" sidebar="false">
    <h1 style="padding:10px;width:100%;float:left; font-size:24px; color:#015ba7;">ABC Company</h1>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <td style="width: 283px; vertical-align:top; background:#CCC;border-right: #F0F0F0 2px solid;">
                <div style="margin:20px;">
                <h1>Contact Info</h1>
                <table>
                    <tr>
                        <td>
                            Contact Name:
                        </td>
                        <td>
                            {!contobj.Name}
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Contact Email:
                        </td>
                        <td>
                            {!contobj.Email}
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Lead Source:
                        </td>
                        <td>
                            {!contobj.Leadsource}
                        </td>
                    </tr>
                </table>
                </div>
            </td>
            <td>
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                        <c:Pdfcomponent value="{!attachment.id}" width="824px" height="1135px"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</apex:page>

Extension Code:
==============
public with sharing class Attachradiocls1 {
    public Contact contobj{get;set;}
    public Attachradiocls1 (ApexPages.Standardcontroller stdcontroller){
        contobj=new Contact();
        String id=ApexPages.CurrentPage().getParameters().get('id');
        if(id!=null && id!=''){
            Attachment att=[select id,name,parentId,body from attachment where id=:id];
            //body=att.body.tostring();
            contobj=[select id,name,Email,LeadSource from Contact where id=:att.parentId];
        }
        
    }
}

Output:
======





What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...