• Madhusudan Singh 19
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 6
    Replies
Dear Friends,

I am currently facing a scenario in Salesforce for which I am seeking the optimal solution.

ABC Credit Union provides support to its customers located in over 20 countries. There are 100 Service Cloud users based in India who handle customer inquiries received through the Email channel. To manage these inquiries, we have implemented Email-to-Case, Omnichannel, and skill-based routing.

We've introduced a custom field on the Case object to capture the Customer Jurisdiction (e.g., US, IND, UK, AUS, etc.), and we've also added new Picklist values to the standard Case Type field (such as Trade, Ebanking, Mandate, etc.), which now has around 20 Picklist values.

Currently, for each value of Jurisdiction and Case Type, we have created specific skills. For example, if there are 20 Jurisdictions and 20 Case Types, we have created 40 skills. Consequently, an agent like Jack, who handles cases for Jurisdictions US and IND and Case Types Trade and EBanking, has been assigned four skills (US, IND, Trade, and EBanking).

However, there has been a last-minute change in requirements. Business Analysts (BAs) have modified the arrangement. Now, in the Indian jurisdiction, Jack should only support Trade cases, and for the US jurisdiction, he should handle EBanking case types.

Due to the way skill-based routing operates, Jack is currently receiving cases for both India (IND) and EBanking. We are seeking your advice on the best approach to address this requirement.

One proposed solution is to create new skills such as 'US_Trade,' 'US_Ebanking,' 'IND_Trade,' and 'IND_Ebanking.' We would then remove Jack's existing skills and assign him the new skills of 'IND_Trade' and 'US_Ebanking.'

It's worth noting that the number of countries and case types may increase in the future, and there could be additional fields introduced, like Case Sub Type, which may impact how cases are routed to agents.

Hello,

I am facing Unable to lock row when I am updating hierarchical custom settings that is being updated in trigger(On Contact Object) context. This error I am getting when I am importing Contacts from Import wizard.
I am trying to import around 2000 records.

Thanks in advance.

Hello Geeks,

I have a scenario below.

1. 3rd party WEB-BASED application has to subscribe to a platform event. So that their end users will be notified.
2. 3rd party SERVER has to subscribe to a Change Data Capture Event. So that their system can make the required changes to their database.

Wanted to know In both cases what details I need to share with 3rd party system so that they can subscribe to events.

Regards
Madhusudan Singh
Hello Geeks,

I have a scenario below.

1. 3rd party web-based application has to subscribe to a platform event. So that their end users will be notified.
2. 3rd party server has to subscribe to a platform event. So that their system can make required changes to their database

Wanted to know what all details I need to share with 3rd party system so that they can subscribe to both platform event.

Regards
Madhusudan Singh
Hi,

I have a string as 2021-07-22T13:13:01Z, I wanted to convert it to user's timezone. How can I do this.

Regards
Madhusudan Singh
I am using the EinsteinVision_HttpBodyPart (https://github.com/muenzpraeger/salesforce-einstein-vision-apex/blob/master/src/classes/EinsteinVision_HttpBodyPart.cls) approach to create a file in Sharepoint from Salesforce. EinsteinVision_HttpBodyPart
And consuming it in my below method, with this approach files are creating but it is corrupted.
public static void fileUploadCallout(string idStr) {        
    List<contentversion> cvList = new List<contentversion>();
    cvList = [select id, title, ContentDocumentId, FileExtension, versionData from contentversion where Id = :idStr limit 1];
    if(!cvList.isEmpty())     
    {
        string fileName = cvList[0].Id;
        if(cvList[0].FileExtension!=null && cvList[0].FileExtension!='') {
            fileName = fileName + '.' + cvList[0].FileExtension;  
        }  
        //callout ePOR service
        string contentType = EinsteinVision_HttpBodyPart.GetContentType();
        
        //  Compose the form
        string form64 = '';
        form64 += EinsteinVision_HttpBodyPart.WriteBoundary();
        form64 += EinsteinVision_HttpBodyPart.WriteBlobBodyParameter('file', EncodingUtil.base64Encode(cvList[0].versionData), fileName);
        
        blob formBlob = EncodingUtil.base64Decode(form64);
        string contentLength = string.valueOf(formBlob.size());
        
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('callout:Sharepoint/_api/web/GetFolderByServerRelativeUrl(\'/sites/SalesforceFiles/Shared%20Documents/Test1\')/Files/add(url=\''+fileName+'\',overwrite=true)');
        req.setBodyAsBlob(formBlob);
        req.setHeader('Connection', 'keep-alive');
        req.setHeader('Content-Length', contentLength);
        req.setHeader('Content-Type', contentType);
        req.setTimeout(120000);
        Http http =new Http();
        HTTPResponse res = http.send(req);
    }
}

There was one more approach I used as below, with that Files were creating but if we upload PNG file then its content was distorted and colors were fading. For PDF files few blocks themselves were removed. But at least something was visible.
 
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Sharepoint/_api/web/GetFolderByServerRelativeUrl(\'/sites/SalesforceFiles/Shared%20Documents/Test\')/Files/add(url=\''+fileName+'\',overwrite=true)');
req.setBodyAsBlob(fileContent); // this is blob file content
req.setHeader('Content-Type','application/octet-stream');
req.setHeader('Content-Length', String.valueOf(req.getBodyAsBlob().size()));
req.setMethod('POST');      
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());

 
Hi,

I am integrating salesforce with SharePoint where I have to send files directly to SharePoint from the browser without creating File/Attachment inside salesforce.

With the SharePoint REST API, I am able to create a file in Sharepoint but when I download the file, it is corrupted.
If the uploaded file is of PNG type then once it is uploaded if we view it image content is incomplete and colors are faded.
If we upload pdf file then some portion of pdf will be missing after upload.

But when I create an Attachment with the same base64 encoded string, I am able to view the complete and correct file.
 
public static void createFileInSharepoint(String fileName, Blob fileContent, String folderName){
	HttpRequest req = new HttpRequest();
	req.setEndpoint('callout:Sharepoint/_api/web/GetFolderByServerRelativeUrl(\'/sites/SalesforceFiles/Shared%20Documents/'+folderName+'\')/Files/add(url=\''+fileName+'\',overwrite=true)');
	req.setBodyAsBlob(fileContent);
	req.setHeader('Content-Type','application/octet-stream');
	request.setHeader('Content-Length', String.valueOf(req.getBodyAsBlob().size()));
	req.setMethod('POST');		
	Http http = new Http();
	HTTPResponse res = http.send(req);
	System.debug(res.getBody());
}

I went through multiple blogs, but many articles are old and not working anymore.

Please help.

Regards
Madhusudan Singh
Hello,

I am integrating SharePoint with salesforce and trying to download the file from Sharepoint to the browser without storing it in Salesforce.
I am able to get file data from SharePoint using APEX HTTP Callout but don't know how can I push it to the browser.

Regards
Madhusudan Singh
Hello Folks,

In one of my sandbox when I try uploading a file to any record of any object, I get below error
Error: Your organization has exceeded the request limit for the service you are trying to access.

User-added image
When I check the storage of the sandbox I see there is space available.
User-added image
User-added imageIf a Job Item is deleted then those job tasks should also get deleted which are the subset of the tier values of the Job Items, but if a job task having a higher tier value available but then its subset should not get deleted.

In the above example is Job Item JI1 is deleted then JobTask JT7 and JT3 should also be deleted.
JT6 should not be deleted as it has a higher tier value(Tier7)
JT5 should not be deleted as it is a subset of the tier value of JT6
JT4 should not be deleted as it is a subset of the tier value of JT6 and JT5
JT2 should not be deleted as it is a subset of the tier value of JT6, Jt5, JT4
JT1 should not be deleted as it is a subset of the tier value of JT6, Jt5, JT4, JT2

JT7 should be deleted as it is not a subset of any Job Task
JT3 should be deleted as it is a subset of the Job Task which is getting deleted and it is also not a subset of any other Job Task that should not be deleted

Any idea how can we do it?

I tried a few logic but it didn't work out, can anyone please help me.
Hi All,

I have doubts in below question, please correct me if my understanding is wrong.

1. A company has reference data stored in multiple custom metadata records that represent default information for certain geographic regions. When a contact is inserted, the default information should be set on the Contact from the Custom Metadata records based on the Contact's Address Information.
What is the optimal way to automate this?
A. Workflow Rules
B. Visual Flow
C. Process Builder
D. Apex Trigger

My Answer: We can use process bulder to set default value using Custom Metadata

2. Which scenario requires a developer to use an Apex callout instead of Outbound Messaging?
A. The callout needs to be invoked from workflow rule.
B. The target system uses a REST API
C. The target system uses a SOAP API
D. The callout needs to be asynchronous

My Answer: B
Answer: Outbound message works only when target system uses SOAP API

3. A company represents their customers as Account that have an External Id field called Customer_Number__c. They have a custom order(Order__c) object with a lookup to Account, to represent Orders that are placed in their external order management system(OMS). When order is fulfilled in the OMS, a REST call to salesforce should be made that creates an Order record in Salesforce and relates to the proper Account. What is the optimal way to implement this?
A. Perform a REST EGT on the Account and a REST POST to update the Order__c with Account's record Id.
B. Perform a REST GET on the Account and a REST PATCH to upsert the Order__c with the Account's record Id
C. Perform REST PATCH to upsert thr Order__c and specify the Account's Customer_Number__c in it.
D. Perform a REST POST to update the Order__c and specify the Account's Customer_Number__c in it.

My Answer: C
Reason: Ask is to create an Order, option D will update an Order whereas Option C will upsert an Order

4. Universal Container needs to integrate with a Heroku service that resizes product images submitted by users. What are two alternatives to implement the integration and protect against malicious calles to the Heroku's endpoint? Select two

A. Create a workflow rule with an outbound message allowing the heroku app to automatically store the resized images in salesforce
B. Create a trigger that uses an @future Apex HTTP callout passing JSON serialized data and some form of pre-shared secret key, so that the Heroku app can authenticate requests and store resized images in Salesforce
C. Create a workflow rule with an outbound message and select send session Id so that the Heroku app can use it and send the resized images back to salesforce
D. Create a trigger that uses an @future Apex HTTP Callout passing JSON serialized data, therefore the Heroku app can automatically reply back to the callout with the resized images in salesforce

My Answer: BC
Reason: rest of the option seems to be irrelvant in this scenario

5. What is a benifits of using a WSDL with APEX
A. Enables the user to not pass a session ID where it is not necessary
B. Allows for classes to be imported into Salesforce
C. Reduce the number of callouts to third-party web services
D. Allows for web services to be tested and achieve code coverage

My Answer: No need to traverse the nodes of the response and we can stick to ORM model

Regards
Madhusudan Singh
Hi All,

I have doubts about the below questions. can you help me in and correct me if my analysis is wrong

1. A developer is writing a Visualforce page that queries accounts in the system and presents a data with the results. The users wnat to be able to filter the results based on up to five fields. However, the users want to pick the five fields when they run the page. WHich feature of the Apex code is required to facilitate this solution?
A. REST API
B. SOSL Queries
C. Dynamic Schema binding
D. describeSObjects

My Answer: D
Reason: We can use describeSObjects methods to get field lists of an object

2. A developer built a component to be used at the front desk for guests to self-register upon arrival at a kiosk. The developer is now asked to create a component for the Utility Tray to alert users whenever a guest has arrived at front desk. What should be used?
A. DML Operation
B. Component Event
C. Application Event
D. Changelog

My Answer: C
Reason: Application event can be handled out of parent child context

3. A developer created a new trigger that insers a Tast when a new Lead is created. After deploying to product, an outside integration is periodically reporting errors. Which change should be the developer make to ensure the integration is not affected with minimal impact to business logic?
A. use a Try/Catch block after insert statement.
B. Remove the Apex Class from the Integration User's Profile
C. Deactivate the trigger before the Integration runs
D. Use the Database method with allOrNone set to False

My Answer: D
Reason: We can minimize failure by using Database method with allOrNone set to False

4. Universal Containers has a visualforce page that displays a table of every Container__c being rented by given Account. Recently this page is failing because some of the customers rent over 100000 containers. What should a developer change about the visualforce page to help with the page load errors
A. Implement pagination with an OffsetController
B. Implement pagination with a StandardSetController
C. Use lazy loading and transient List variables
D. Use Javascript remoting with SOQL OffsetController

My Answer: B
Reason: We can implement pagination with a StandardSetController

5. A developer is trying to decide between creating a visualforce component or a lightning component for a custom screen. Which functionality consideration impacts the final decision?
A. Will the screen make use of a JavaScript framework?
B. Will the screen be accessed via a mobile app?
C. Does screen need to be accessbile from the Lightning Experience UI
D. Does the screen need to be rendered as a PDF

My Answer: D
Reason: rendering screen to pdf is not supported in Lightning component, and all new components we can create in lightning and cal lit VF page using lightning out Application hence my vote for D

Regards
Madhusudan Singh
Hi All,

I have doubts about the below questions.

1. An org has a requirement that the shipping address on the account must me validated by a thir-party web service, before the account is allowed to be inserted. What is the optimal way to meeth this requirement?
A. Make a callout to the web service from a custom Visualforce controller.
B. Make a callout to the web service from a standard Visualforce controller
C. Make a callout to the web service from an after insert trigger
D. Make a callout to the web service from a before insert trigger

My Answer: A
Reason: In this scenario we cannot validate Account on trigger and we cannot use standard visualforce controller as it will invoke standard process of inserting Account hence my vote for A

2. A developer needs to store variables to control the type and behaviour of a Lightning Web Component. Which feature should be ensure that the variales are testable in both Production and all Sandboxes.
A. Custom Metadata
B. Custom Object
C. Custom Setting
D. Custom Variable

My Answer: A
Reason: Other options are irrelvant

3. A developer wants to call an Apex Server-side controller from a Lightning Aura Component. What are two limitations to the data being returned by the Controler?
A. Only basic data types and sObjects are supported as return types from Apex Controllers called by Lightning Aura Components.
B. Basic data types are supported, but defaults, such as maximum size of number, are defined by the objects that they map to.
C. List of custom apex classes cannot be returned by Apex controllers called by Lightning Aura Components
D. A custom Apex class can be returned, but only the values of public instance properties and methods annotated with @AuraEnabled are serialized and returned

My Answer: BD
Reason: Field defaults are controlled on object level, we can return custom Apex type of data to lightning controller

4. A company manages information about their product offerings in custom objects named catalog Item, Catalog Item has a master-detail field to catalog, and each catalog may have as many as 100000 catalog items. Both custom objects have a CurrencyIsoCodes should be changed as well. What should a developer use to update the CurrencyIsoCodes on the Catalog Items when the Catalog's CurrencyIsoCodes changes?
A. An after insert trigger on Catalog that updates the Catalog Items if the Catalog's CurrencyIsoCodes is different
B. An after insert trigger on Catalog item that updates the Catalog Item if the Catalog's CurrencyIsoCodes is different
C. A Database.Schedule and Database.Batchable class that queires the Catalog object and updates the catalog items if the catalog CurrencyIsoCodes is different
D. A Database.Schedulable and Database.Batchable class that queries the catalog Item object and updates the Catalog Items if the Catalog CurrencyIsoCodes is different

My Answer: D
Reason: can do it on trigger as max rows can be updated is 10000 hence we need to go with batch class
Hi All,
I am preparing for PD2 and have an exam scheduled on coming Sunday, thought to double confirm with forums for few questions.

1. Consider the following queries. For these queries, assume that there are more than 200000 Account records. These records include soft-deleted records; that is, deleted records are still in Recycle Bin. Notre that there are two fields that are marked as External Id on the Account. These fields are Customer_Number__c and ERP_Key__c
a. SELECT Id FROM Account WHERE Id IN :aListVariable
b. SELECT Id FROM Account WHERE Name !='' AND IsDeleted = false
c. SELECT Id FROM Account WHERE Name != NULL
d. SELECT Id FROM Account WHERE Name != '' AND Customer_Number__c = 'ValueA'

My Answer: A,D
Reason: Perfroming SOQL on Id field or ExternalID field will be faster as they are indexed.

2. An Apex trigger creates and Order__c record every time an Opportunity is won by Sales Rep. Recently a trigger is creating two orders. What is the optimal method for a developer to troubleshoot this?

a. Set up debug logging for each Sales Rep, then monitor the logs for errors and exceptions.
b. Run the Apex test classes for the apex trigger to ensure the code still has sufficient code coverage
c. Turn off all the Workflow Rules, then turn on one at a time to see which one causes the errors
d. Add system.debug() statements to the code and use the developer console logs to trace the code

My Answer: D
Reason: This is easier process for debuging, Option A is asking to create debug log for all users hance it will be useless

3. A developer wishes to improve the runtime performance of the Apex calls by caching results on the client
a. Set a cookie in the browser for use upon return to the page
b. Call the setStorable() method on the action in the JavaScript client-side code.
c. Decorate the server-side method with @AuraEnabled(cacheable=true)
d. Decorate the server-side method with @AuraEnabled(storable=true)

My Answer: C
Reason: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_storable_actions.htm having doubt as many places people are still saying B

4. When calling a Restful web service a developer receives a JSON payload that has a data hierarchy that is three levels deep. How can the developer describe the external data?
a. Deserialize the data and then process it.
b. Declare a class with three levels and deserialize the JSON typed with this class
c. Use the ANT migration tool, the custom metadata API, or the Dataloader
d. Use middleware to flatten the JSON and consume it as a new custom object

My Answer: B
Reason: Create an Inner class and deserialize it with the inner class

5. A visualforce page loads slowly due to the large amount of data it displays. Which strategy can a developer use to improve the performance?
a. Use the transient keyword for the List variables used in the custom controller
b. Use the lazy loading to load the data on demand, instead of in the controller's constructor
c. Use an <apex:actionPolar> in the page to load all of the data asynchronously.
d. Use Javascript to move data processing to the browser instead of the controller

My Answer: B
Reason: Option is well explanatory whereas other options will not fit in this requirement
 
Hi All,

What should I use for caching Apex results in client side. @AuraEnabled(cacheble=true) in apex class or. setStorable in client side?

Regards
Madhusudan Singh
Hi All, I need help in writing test class for class mentioned below-mentioned link.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_multiple_callouts.htm

It has two continuation Callouts, how can I pass multiple Mock responses for this class

Regards
Madhusudan Singh
Hi All
 
In lightning when I am trying to send email after selecting one of the template of  ‘Classic Email Template’ and explicitly adding an attachments, I am getting below errors.
  • You can't add attachments to an email that uses a Visualforce template. Remove the attachment and try again.
Please let me know what all options left for me.

Regards
Madhusudan Singh

I was doing layout comparison b/w classic vs Lightning for standard product object.
I found that many related list are not visible.
I can consider standard price as this will be merged to related list 'Price Books'. But there are other related list which are not visible in lightning but in classic we can view. I was checking this from same user account.
Please refer screenshot.

Related Lists of Product Object in Classic

Related Lists of Product Object in Lightning

Regards
Madhusudan Singh

Not able to use Lightning Component in VF, below is my code

ComponentForVisualForce.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
	<lightning:button label="GoToRecord" title="Neutral action" onclick="{! c.handleClick }"/>
</aura:component>
ComponentForVisualForceController.js
({
    handleClick : function(component, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt .setParams({
            "recordId": "5006F00001w4IH7QAM",
            "slideDevName": "detail"
        });
        navEvt.fire();
    }
})
Created LightningOut Application as below
ApplicationForVisualForce.app
<aura:application extends="ltng:outApp" >
    <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
    <aura:dependency resource="c:ComponentForVisualForce"/>
</aura:application>
Below is the VisualForce Which I am consuming it
ConsumeComponentForVisualForce.vfp
<apex:page >
    <apex:includeLightning />   
    <div id="LcDisplayId"></div>     
 <script>
    $Lightning.use("c:ApplicationForVisualForce", function() {
    $Lightning.createComponent("c:ComponentForVisualForce",
    { },
   "LcDisplayId",
    function(component) { });
 });
 </script>
</apex:page>

Regards
Madhusudan Singh
 

Hi All,

I have created a lightning component which I need to use in Visualforce. But whcih I try to navigate it gives error as could not use setParams of undefined in datable I am clicking on view details button which is calling handlerowaction function and there I am getting error because I am using  var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                    "recordId": row.Id
                });

I did below things

1. Create Lightning Component
2. Create Lightning Application and calling Lighting Component
3. Created Visualforce Page and calling Lightning application

Below is my code

CaseEmails.cmp

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" 
                access="global" 
                controller="EmailCaseList">
    <aura:attribute name="ParentId" type="String"/>
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="recordId" type="String"/>
    
    <aura:attribute name="allData" type="List"/>
    <aura:attribute name="currentPageNumber" type="Integer" default="1"/>
    <aura:attribute name="pageSize" type="Integer" default="10"/>
    <aura:attribute name="totalPages" type="Integer" default="false"/>
    <aura:attribute name="pageList" type="List" default="false"/>
    
    <!-- This attribute will hold the update records from data table-->
    <aura:attribute name="updatedRecord" type="Object[]" />
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
        <lightning:workspaceAPI aura:id="workspace" />

    <!-- You must define keyField as 'Id' to save the record back in Salesforce
 'onsave' attribute will executed when user clicks on save button -->
    
    <lightning:layout multipleRows="true" horizontalAlign="center">
        <div style="height: 300px">
                <lightning:datatable
                                     aura:id="emailDataTable"
                                     columns="{! v.columns }"
                                     data="{! v.data }"
                                     keyField="Id"
                                     hideCheckboxColumn="true"
                                     onrowaction="{! c.handleRowAction }"/>
        </div>
        <lightning:layoutItem padding="around-small" flexibility="auto">
            <lightning:button label="First" iconName="utility:left" iconPosition="left"
                              onclick="{!c.onFirst}" disabled="{! v.currentPageNumber == 1}"/>
            <lightning:button iconName="utility:chevronleft" iconPosition="left"
                              onclick="{!c.onPrev}" disabled="{! v.currentPageNumber == 1}"/>
            <lightning:button iconName="utility:chevronright" iconPosition="right" 
                              disabled="{! v.currentPageNumber == v.totalPages}" onclick="{!c.onNext}"/>
            <lightning:button label="Last" iconName="utility:right" iconPosition="right" 
                              disabled="{! v.currentPageNumber == v.totalPages}" onclick="{!c.onLast}"/>
        </lightning:layoutItem>
    </lightning:layout>
    
</aura:component>
 


CaseEmailsController.js

({
    doInit : function(component, event, helper) {
        var actions = [
            { label: 'View Details', name: 'ViewDetails' }
        ],
            fetchData = {
                id : 'id.',
                Subject : 'Subject'
            };
        
        component.set('v.columns', [
            {label: 'Status', fieldName: 'Status', type: 'text'},
            {label: 'Subject Link', fieldName: 'SubjectHyperlink', type: "url", typeAttributes: {label: { fieldName: 'Subject' } , target: '_blank'}},
            {label: 'Email Address', fieldName: 'ToAddress', type: 'text'},
            {label: 'Message Date', fieldName: 'MessageDate', type: 'text'},
            {type: 'action', typeAttributes: { rowActions: actions} }
        ]);
        
        helper.getEmails(component, helper);

    },
    

    
    onNext : function(component, event, helper) {        
        var pageNumber = component.get("v.currentPageNumber");
        component.set("v.currentPageNumber", pageNumber+1);
        helper.buildData(component, helper);
    },
    
    onPrev : function(component, event, helper) {        
        var pageNumber = component.get("v.currentPageNumber");
        component.set("v.currentPageNumber", pageNumber-1);
        helper.buildData(component, helper);
    },
    
    onFirst : function(component, event, helper) {        
        component.set("v.currentPageNumber", 1);
        helper.buildData(component, helper);
    },
    
    onLast : function(component, event, helper) {        
        component.set("v.currentPageNumber", component.get("v.totalPages"));
        helper.buildData(component, helper);
    },
    
    handleRowAction: function(component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        
        switch (action.name) {
            case 'ViewDetails':
                var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                    "recordId": row.Id
                });
                navEvt.fire();
                break;
            
        }
    }
    
})
 



CaseEmailsHelper.js

({
    getEmails : function(component, helper) {
        var action = component.get("c.getLimitedEmails");
        action.setParams({
            caseId: component.get("v.ParentId")
        });
        action.setStorable();
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
       var records =response.getReturnValue();
                console.log(records);
                records.forEach(function(record) {
                    if(record.Subject==null )
                          record.Subject='-'; 
                    record.SubjectHyperlink = '/'+record.Id; 
  
                    console.log(record.SubjectHyperlink);
                                }); 
                console.log('Response Time: '+((new Date().getTime())-requestInitiatedTime));
               component.set("v.totalPages", Math.ceil(response.getReturnValue().length/component.get("v.pageSize")));
                component.set("v.allData", records);
               component.set("v.currentPageNumber",1);
                helper.buildData(component, helper);
            }

        });
        var requestInitiatedTime = new Date().getTime();
        $A.enqueueAction(action);
    },
    
    
    /*
     * this function will build table data
     * based on current page selection
     * */
    buildData : function(component, helper) {
        var data = [];
        var pageNumber = component.get("v.currentPageNumber");
        var pageSize = component.get("v.pageSize");
        var allData = component.get("v.allData");
        var x = (pageNumber-1)*pageSize;
        
        //creating data-table data
        for(; x<=(pageNumber)*pageSize; x++){
            if(allData[x]){
                data.push(allData[x]);
            }
        }
        component.set("v.data", data);
    },
 })

Create LightningoutApp

<aura:application extends="ltng:outApp" >
    <aura:dependency resource="c:CaseEmails"/>
    <aura:dependency resource="markup://force:*" type="EVENT"/>
</aura:application>

Calling in visualforce page

<apex:page standardController="Case" showHeader="false" showChat="false" sidebar="false" docType="html-5.0">
    <apex:includeLightning />
   
    <div id="LcDisplayId"></div> 
    
 <script>
      
    $Lightning.use("c:CaseEmailsApp", function() {
    $Lightning.createComponent("c:CaseEmails",
    { 
      ParentId : "5004B000007f987" 	},
   "LcDisplayId",
    function(component) {
        
    });
 });
 </script>
</apex:page>
Hi All,

What should I use for caching Apex results in client side. @AuraEnabled(cacheble=true) in apex class or. setStorable in client side?

Regards
Madhusudan Singh
Hello Geeks,

I have a scenario below.

1. 3rd party web-based application has to subscribe to a platform event. So that their end users will be notified.
2. 3rd party server has to subscribe to a platform event. So that their system can make required changes to their database

Wanted to know what all details I need to share with 3rd party system so that they can subscribe to both platform event.

Regards
Madhusudan Singh
Not able to use Lightning Component in VF, below is my code

ComponentForVisualForce.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
	<lightning:button label="GoToRecord" title="Neutral action" onclick="{! c.handleClick }"/>
</aura:component>
ComponentForVisualForceController.js
({
    handleClick : function(component, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt .setParams({
            "recordId": "5006F00001w4IH7QAM",
            "slideDevName": "detail"
        });
        navEvt.fire();
    }
})
Created LightningOut Application as below
ApplicationForVisualForce.app
<aura:application extends="ltng:outApp" >
    <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
    <aura:dependency resource="c:ComponentForVisualForce"/>
</aura:application>
Below is the VisualForce Which I am consuming it
ConsumeComponentForVisualForce.vfp
<apex:page >
    <apex:includeLightning />   
    <div id="LcDisplayId"></div>     
 <script>
    $Lightning.use("c:ApplicationForVisualForce", function() {
    $Lightning.createComponent("c:ComponentForVisualForce",
    { },
   "LcDisplayId",
    function(component) { });
 });
 </script>
</apex:page>

Regards
Madhusudan Singh
 

Hi All,

I have created a lightning component which I need to use in Visualforce. But whcih I try to navigate it gives error as could not use setParams of undefined in datable I am clicking on view details button which is calling handlerowaction function and there I am getting error because I am using  var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                    "recordId": row.Id
                });

I did below things

1. Create Lightning Component
2. Create Lightning Application and calling Lighting Component
3. Created Visualforce Page and calling Lightning application

Below is my code

CaseEmails.cmp

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" 
                access="global" 
                controller="EmailCaseList">
    <aura:attribute name="ParentId" type="String"/>
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="recordId" type="String"/>
    
    <aura:attribute name="allData" type="List"/>
    <aura:attribute name="currentPageNumber" type="Integer" default="1"/>
    <aura:attribute name="pageSize" type="Integer" default="10"/>
    <aura:attribute name="totalPages" type="Integer" default="false"/>
    <aura:attribute name="pageList" type="List" default="false"/>
    
    <!-- This attribute will hold the update records from data table-->
    <aura:attribute name="updatedRecord" type="Object[]" />
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
        <lightning:workspaceAPI aura:id="workspace" />

    <!-- You must define keyField as 'Id' to save the record back in Salesforce
 'onsave' attribute will executed when user clicks on save button -->
    
    <lightning:layout multipleRows="true" horizontalAlign="center">
        <div style="height: 300px">
                <lightning:datatable
                                     aura:id="emailDataTable"
                                     columns="{! v.columns }"
                                     data="{! v.data }"
                                     keyField="Id"
                                     hideCheckboxColumn="true"
                                     onrowaction="{! c.handleRowAction }"/>
        </div>
        <lightning:layoutItem padding="around-small" flexibility="auto">
            <lightning:button label="First" iconName="utility:left" iconPosition="left"
                              onclick="{!c.onFirst}" disabled="{! v.currentPageNumber == 1}"/>
            <lightning:button iconName="utility:chevronleft" iconPosition="left"
                              onclick="{!c.onPrev}" disabled="{! v.currentPageNumber == 1}"/>
            <lightning:button iconName="utility:chevronright" iconPosition="right" 
                              disabled="{! v.currentPageNumber == v.totalPages}" onclick="{!c.onNext}"/>
            <lightning:button label="Last" iconName="utility:right" iconPosition="right" 
                              disabled="{! v.currentPageNumber == v.totalPages}" onclick="{!c.onLast}"/>
        </lightning:layoutItem>
    </lightning:layout>
    
</aura:component>
 


CaseEmailsController.js

({
    doInit : function(component, event, helper) {
        var actions = [
            { label: 'View Details', name: 'ViewDetails' }
        ],
            fetchData = {
                id : 'id.',
                Subject : 'Subject'
            };
        
        component.set('v.columns', [
            {label: 'Status', fieldName: 'Status', type: 'text'},
            {label: 'Subject Link', fieldName: 'SubjectHyperlink', type: "url", typeAttributes: {label: { fieldName: 'Subject' } , target: '_blank'}},
            {label: 'Email Address', fieldName: 'ToAddress', type: 'text'},
            {label: 'Message Date', fieldName: 'MessageDate', type: 'text'},
            {type: 'action', typeAttributes: { rowActions: actions} }
        ]);
        
        helper.getEmails(component, helper);

    },
    

    
    onNext : function(component, event, helper) {        
        var pageNumber = component.get("v.currentPageNumber");
        component.set("v.currentPageNumber", pageNumber+1);
        helper.buildData(component, helper);
    },
    
    onPrev : function(component, event, helper) {        
        var pageNumber = component.get("v.currentPageNumber");
        component.set("v.currentPageNumber", pageNumber-1);
        helper.buildData(component, helper);
    },
    
    onFirst : function(component, event, helper) {        
        component.set("v.currentPageNumber", 1);
        helper.buildData(component, helper);
    },
    
    onLast : function(component, event, helper) {        
        component.set("v.currentPageNumber", component.get("v.totalPages"));
        helper.buildData(component, helper);
    },
    
    handleRowAction: function(component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        
        switch (action.name) {
            case 'ViewDetails':
                var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                    "recordId": row.Id
                });
                navEvt.fire();
                break;
            
        }
    }
    
})
 



CaseEmailsHelper.js

({
    getEmails : function(component, helper) {
        var action = component.get("c.getLimitedEmails");
        action.setParams({
            caseId: component.get("v.ParentId")
        });
        action.setStorable();
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
       var records =response.getReturnValue();
                console.log(records);
                records.forEach(function(record) {
                    if(record.Subject==null )
                          record.Subject='-'; 
                    record.SubjectHyperlink = '/'+record.Id; 
  
                    console.log(record.SubjectHyperlink);
                                }); 
                console.log('Response Time: '+((new Date().getTime())-requestInitiatedTime));
               component.set("v.totalPages", Math.ceil(response.getReturnValue().length/component.get("v.pageSize")));
                component.set("v.allData", records);
               component.set("v.currentPageNumber",1);
                helper.buildData(component, helper);
            }

        });
        var requestInitiatedTime = new Date().getTime();
        $A.enqueueAction(action);
    },
    
    
    /*
     * this function will build table data
     * based on current page selection
     * */
    buildData : function(component, helper) {
        var data = [];
        var pageNumber = component.get("v.currentPageNumber");
        var pageSize = component.get("v.pageSize");
        var allData = component.get("v.allData");
        var x = (pageNumber-1)*pageSize;
        
        //creating data-table data
        for(; x<=(pageNumber)*pageSize; x++){
            if(allData[x]){
                data.push(allData[x]);
            }
        }
        component.set("v.data", data);
    },
 })

Create LightningoutApp

<aura:application extends="ltng:outApp" >
    <aura:dependency resource="c:CaseEmails"/>
    <aura:dependency resource="markup://force:*" type="EVENT"/>
</aura:application>

Calling in visualforce page

<apex:page standardController="Case" showHeader="false" showChat="false" sidebar="false" docType="html-5.0">
    <apex:includeLightning />
   
    <div id="LcDisplayId"></div> 
    
 <script>
      
    $Lightning.use("c:CaseEmailsApp", function() {
    $Lightning.createComponent("c:CaseEmails",
    { 
      ParentId : "5004B000007f987" 	},
   "LcDisplayId",
    function(component) {
        
    });
 });
 </script>
</apex:page>