• U Chauhan
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 8
    Questions
  • 2
    Replies
Can we show vf page or lwc component inside enhanced BOT as we need to show survey feedback form after chat ends in enhanced BOT
Can we show vf page or lwc component inside enhanced BOT as we need to show survey feedback form after chat ends in enhanced BOT.
For standard bot in chat button e can have post chat url but since enhanced bot does not connect with button so is there any work around so that we can get survey form insite enhanced bot
Hello everyone please help me if anyone faced this issue.
So I have backup of an org but I don't have access to that org anymore.
There are lots of metadata so how can I get the dependencies with the help of backup and how can I migrate it to new sandbox avoiding dependencies error.

Thanks.

here is my code.
//Apex Controller
public class ListviewResultClass {
    
    @Auraenabled
    public static list<listview> getListViews(string obj){
        list<listview> allListViews=[select Name from listview where sobjectType=:obj];
        system.debug(allListViews);
        return allListViews;
    }
    @Auraenabled
    public static ListViewDataTable getListViewData(string obj,string listView_Name) {
        
        ListView listViewResult = [select id, developername,sobjectType  from listview where sobjectType=:obj AND Name=:listView_Name];
        system.debug(listViewResult);
        String endpoint = String.format(
            'https://proseraa5-dev-ed.my.salesforce.com/services/data/v50.0/sobjects/{0}/listviews/{1}/describe/',
            new String[] { listViewResult.sobjectType, listViewResult.id }
        );  
        
        HttpRequest req = new HttpRequest();
        req.setEndpoint( endpoint );
        req.setMethod( 'GET' );
        req.setHeader( 'Content-Type', 'application/json' );
        req.setHeader( 'Accepts', 'application/json' );
        req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
        HttpResponse res = new Http().send( req );
        System.debug( res);
        System.debug( res.getBody() );
        
        ListViewDescribeResult result = (ListViewDescribeResult)JSON.deserialize( res.getBody(), ListViewDescribeResult.class );
        system.debug('query :'+result.query);
        system.debug('deserialized result :'+result);
        
        //ApexPages.StandardSetController controller = new ApexPages.StandardSetController( Database.getQueryLocator( result.query));
        ListViewDataTable dataTable = new ListViewDataTable();
        dataTable.describeResult = result;
        dataTable.records = database.query(result.query);
        system.debug('record List===== :'+dataTable.records);
        return dataTable;  
    }
    
    public class ListViewDataTable {
        
        @Auraenabled
        public List<SObject> records { get; set; }
        
        @Auraenabled
        public ListViewDescribeResult describeResult { get; set; }
        
    }
    public class ListViewDescribeResult {
        
        @Auraenabled
        public ID id { get; set; }
        
        @Auraenabled
        public String query { get; set; }
        
        @Auraenabled
        public String sobjectType { get; set; }
        
        @Auraenabled
        public List<Map<String, String>> columns { get; set; }
        
    }      
}
************Component***************
<aura:component controller="ListviewResultClass" implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="ListView" type="List"/>
    <aura:attribute name="mydata" type="object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="bShowListView" type="boolean" default="false"/>
    
    <div>
        <p class="title">Select Object</p>
        <lightning:select class="single" aura:id="InputSelectSingle" label=" " onchange="{!c.onSingleSelectChange}">
            <option text="None"/>
            <option text="Account"/>
            <option text="Contact"/>
            <option text="Lead"/>
            <option text="Opportunity"/>
        </lightning:select><br/><br/>
    </div>
    
    <div>
        <p class="title">Select List View</p>
        <lightning:select class="single" aura:id="InputSelectListView" label=" " onchange="{!c.onListViewChange}">
            <aura:iteration items="{!v.ListView}" var="item">
                <option text="{!item.Name}"/>
            </aura:iteration>
        </lightning:select><br/>      
    </div>
    
    <aura:if isTrue="{!v.bShowListView}">
        <lightning:datatable data="{!v.mydata}"
                             columns="{!v.mycolumns}"
                             keyField="id"
                             hideCheckboxColumn="true"/>
    </aura:if>
</aura:component>
***********Controller*************
({
    onSingleSelectChange : function(component, event, helper) {
        var selectCmp = component.find("InputSelectSingle").get("v.value");
        console.log(selectCmp);
        var action =component.get("c.getListViews");
        action.setParams({"obj":selectCmp});
        action.setCallback(this,function(response){
            var state=response.getState();
            console.log(state);
            if(state==="SUCCESS"){
                component.set("v.ListView",response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    
    onListViewChange : function(component, event, helper) {
        component.set("v.bShowListView", false);
        var selectlist = event.getSource().get("v.value");
        var selectCmp1 = component.find("InputSelectSingle").get("v.value");
        console.log(selectlist);
        console.log(selectCmp1);
        var action=component.get("c.getListViewData");
        action.setParams({"obj":selectCmp1,"listView_Name":selectlist});
        action.setCallback(this,function(response){
            var state=response.getState();
            console.log(state);  //its giving error
            var result = JSON.stringify(response.getReturnValue());
            console.log('result2=='+result);
            if(state==="SUCCESS"){
                var displayColumns = response.getListViewData().describeResult.columns.filter( function( column ) { return column.hidden === 'false'; } ).map( function( column ) {
                return {
                    'label' : column.label,
                    'fieldName' : column.fieldNameOrPath ,
                    'type' : column.type
                };
            });

            component.set( 'v.mycolumns', displayColumns );
              component.set("v.mydata",response.getReturnValue().records);
               console.log(response.getReturnValue());
               component.set("v.bShowListView", true);
               
            }
        });
        $A.enqueueAction(action);
    },
   
})
I have written a class for salesforce to salesforce integration, i have also written test class but i am not able to get 75% code coverage please help me with this. Below is my code snap and test class.

User-added imagemock test class-
@isTest
global class HttpCalloutMockGenerator implements HttpCalloutMock {
    global HTTPResponse respond(HTTPRequest request) {   
        // Create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody('{"LastName":"Test"}');
        response.setStatus('OK');
        response.setStatusCode(200);
        return response; 
    }
}

Main Test Class
@isTest
private class SalesforceIntegrationCalloutsTest {
    
    @isTest static void testPostCallout() {
        Test.setMock(HttpCalloutMock.class, new HttpCalloutMockGenerator());
        test.startTest();  
        ContactCreationDestinationClass.createContactRecord('Test');
        test.stopTest();
        HttpRequest req = new HttpRequest();
        HttpCalloutMockGenerator mock = new HttpCalloutMockGenerator();
        HttpResponse res = mock.respond(req);
        // Verify that the response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        System.debug(res.getBody());
        System.assertEquals(200, res.getStatusCode());     
    }
}
// Please help me in writing test class for this custome controller in
// visualforce page
public class Cont_ServiceFieldManagement {
    list<String> sendingTo =new list<string>();
    list<id> idListAgent=new list<id>();
    set<id> idsetCustomer=new set<id>();
    public string agentId{get;set;}
    public list<field_Agent__c> agent{get;set;}
    public string agentCity {get;set;}
    public list<Customer_Service__c> orders{get;set;}
    public Customer_Service__c customer{get;set;}
    public string ProductName{get;set;}
    public date PurchaseDate{get;set;}
    public string serviceNeeded{get;set;}
    public string customerName{get;set;}
    public string phone{get;set;}
    public string email{get;set;}
    public string city{get;set;}
    public string address{get;set;}
    
    public Cont_ServiceFieldManagement(){
        
    }
    public pagereference save(){
        Customer_Service__c cust=new Customer_Service__c();
        cust.Product_Name__c=ProductName;
        cust.Purchase_Date__c=PurchaseDate;
        cust.Service_Required__c=serviceNeeded;
        cust.Customer_Name__c=customerName;
        cust.Phone__c=phone;
        cust.Email__c=email;
        cust.Submission_Date__c=date.today();
        cust.City__c=city;
        cust.Address__c=address;
        insert cust;
        PageReference tempPage = ApexPages.currentPage();            
        tempPage.setRedirect(true);
        return tempPage;
    }
    public pagereference cancel(){
        PageReference tempPage = ApexPages.currentPage();            
        tempPage.setRedirect(true);
        return tempPage;
        
    }
    public pagereference getorders(){
        orders=[select id,Product_Name__c,Customer_Name__c,city__c,field_agent__c from Customer_Service__c where city__c=:agentCity and field_agent__c=null];
        for(Customer_Service__c cust:orders){
                idsetCustomer.add(cust.id);
            
        }
        return null;
    }
    public pagereference getAgent(){
       agent=[select id,name,phone__c,email__c,city__c from field_agent__c where city__c=:agentCity] ;
        for(field_agent__c ag:agent){
                idListAgent.add(ag.id);
            sendingTo.add(ag.email__c);
        }
        return null;
    }
    public pagereference AssignAgent(){
        list<Customer_Service__c> custList=new list<Customer_Service__c>();
        list<Customer_Service__c> customerList=[select id,Product_Name__c,field_agent__c,status__c from Customer_Service__c where id in:idsetCustomer];
        for(Customer_Service__c cust:customerList){
            cust.Field_Agent__c=idListAgent[0];
            cust.status__c='Assigned';
             custList.add(cust);  
        }
        
        update custList;
        return null;
    }
    public pagereference sendEmail(){
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        semail.setToAddresses(sendingTo);
        semail.setSubject('New Work Order Assigned To You!!!');
        semail.setPlainTextBody('Hello!!!!! You have been assigned to new work orders');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail});
        PageReference tempPage = ApexPages.currentPage();            
        tempPage.setRedirect(true);
        return tempPage;
   }
}
How to create the visualforce page to get the following solution.
step1- Get all the objects list in sorted orde then on select any object it displays all the 
queriable fields of that object in sorted order where we can select multiple fields.
step2- Filter criteria (on giving input like startswith,endswith,contains,exact match,limit)
it retrives all the records of that object for selected fields and Each name of the record should 
be a link to the detail page of that specific record.
Whenever a Campaign member of type lead is inserted, check the RSVP field on campaign member, if it is blank and if the Lead RSVP field has value we would need to update that value on the Campaign member RSVP field.
Hi,
I have an Einstein Bot embedded in an external website (Not Community Cloud). I'd like to skip prechat questions when the end user (customer) is already authenticated in the external website.
How could I identify customer information and map it with the Salesforce Account/Contact information?
Thanks!
I have written a class for salesforce to salesforce integration, i have also written test class but i am not able to get 75% code coverage please help me with this. Below is my code snap and test class.

User-added imagemock test class-
@isTest
global class HttpCalloutMockGenerator implements HttpCalloutMock {
    global HTTPResponse respond(HTTPRequest request) {   
        // Create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody('{"LastName":"Test"}');
        response.setStatus('OK');
        response.setStatusCode(200);
        return response; 
    }
}

Main Test Class
@isTest
private class SalesforceIntegrationCalloutsTest {
    
    @isTest static void testPostCallout() {
        Test.setMock(HttpCalloutMock.class, new HttpCalloutMockGenerator());
        test.startTest();  
        ContactCreationDestinationClass.createContactRecord('Test');
        test.stopTest();
        HttpRequest req = new HttpRequest();
        HttpCalloutMockGenerator mock = new HttpCalloutMockGenerator();
        HttpResponse res = mock.respond(req);
        // Verify that the response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        System.debug(res.getBody());
        System.assertEquals(200, res.getStatusCode());     
    }
}
Hi,
I have an Einstein Bot embedded in an external website (Not Community Cloud). I'd like to skip prechat questions when the end user (customer) is already authenticated in the external website.
How could I identify customer information and map it with the Salesforce Account/Contact information?
Thanks!