• Hemant Sharma 46
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hello team,
 
I have written the visualforce code to change the presence status of an agent. Code is : 

User-added imageI want to know how the code will work ?
And what about these line : 
"<apex:includeScript value="/support/console/54.0/integration.js"/>"
 How it works and how do I implement its "value" attribute.
 
I also implemented the aura component code : 
 
aura compnent class :

User-added imagecontroller.js

User-added imageBoth visualforce page and aura compnent  is not responding. So please can anyone help me to resolve this.
 
I saw these documents  below :
 
https://developer.salesforce.com/docs/atlas.en-us.omni_channel_dev.meta/omni_channel_dev/sforce_api_console_setservicepresencestatus.htm
 
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_setservicepresencestatus.htm
 
I don't know what the problem is ?
 
Thanks and regards.
Hi,

Actually, I have a page where i can upload the excel file. I am reading the data from excel.
When I upload a simple excel file, code works as per expected.

But When i upload the passoword protected excel file, it throws the exception. It is not able to read the excel sheet data.

Controller
public class ContactImportController {
public String emailList {get; set;}
    public String recordData {get; set;}
    public Boolean recordDataFound {get; set;}
    public Integer recordDataTotal {get; set;}
    public Map<String,Integer> recordDataMap {get; set;}

    public void filterContact(){
        system.debug('emailList');
        system.debug(emailList);
        recordDataFound = false;
        if(emailList != null ){
            Set<String> emailSet = new Set<String>(emailList.split(','));
            system.debug(emailSet);
            Map<String,Integer> emailMap = new Map<String,Integer>();
            recordDataTotal = 0;
            for (AggregateResult ar : [SELECT Email emailId, Count(id) ContactCount FROM Contact WHERE Email =:emailSet GROUP BY Email]){
                system.debug(ar);
                recordDataTotal += (Integer) ar.get('ContactCount');
                emailMap.put((String) ar.get('emailId'),(Integer) ar.get('ContactCount'));
            }
            if(emailMap.size() != 0){
                recordDataFound = true;
                recordDataMap = emailMap;
                recordData = 'Success';
            }else{
                recordData ='No Contact List Found';
            }
        }else{
            recordData ='No Email List Found';
        }
    }

}


VF Page
<apex:page id="df" sidebar="false" controller="ContactImportController" showHeader="false" standardStylesheets="true" lightningStylesheets="true">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/jszip.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.js"></script>
    <style>
    h2{
        padding: 2px;
        margin: 0px;
    }
    </style>
    <div style="text-align: center;margin: 80px;">
        <form enctype="multipart/form-data">
            <h1> Select File for test the Contacts</h1>
            <input id="upload" type="file" accept=".xlsx" name="files[]" classs="slds-button slds-button_brand" style="margin: 20px;" />
        </form>
        <apex:form id="dfp">
            <apex:actionStatus startText="Processing...." id="status"></apex:actionStatus>
            <apex:actionFunction action="{!filterContact}" name="dfpFilterData" id="dfpFilterData" reRender="dfp" status="status" oncomplete="showData()">
                <apex:param name="firstParam" assignTo="{!emailList}" value="" />
            </apex:actionFunction>
            <apex:inputHidden value="{!recordData}" id="recordDataID"/>
            <apex:outputPanel rendered="{!recordDataFound}">
               <h2> <b>Total : {!recordDataTotal} </b> </h2>  
                <apex:repeat value="{!recordDataMap}" var="emailcon">
                    <h2>  Email: {!emailcon} ({!recordDataMap[emailcon]})</h2> 
                </apex:repeat>
            </apex:outputPanel>
            <script>
                var ExcelToJSON = function() {
            
                    this.parseExcel = function(file) {
                        var reader = new FileReader();
                
                        reader.onload = function(e) {
                            try{
                                var data = e.target.result;
                                var workbook = XLSX.readFile(data, {
                                    type: 'binary'                                   
                                });
                                workbook.SheetNames.forEach(function(sheetName) {
                                    // Here is your object
                                    var XL_row_object = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
                                    var json_object = JSON.stringify(XL_row_object);
                                    console.log(JSON.parse(json_object));
                                    if(json_object.length != 0){
                                        var emailList = '';
                                        JSON.parse(json_object).forEach( row => {
                                            if(row['E-mail']){
                                                emailList += row['E-mail']+',';
                                            }
                                        });
                                        emailList = emailList.slice(0, -1);
                                        console.log('emailList >>>');
                                        console.log(emailList);
                                        if(emailList.trim().length != 0){
                                            dfpFilterData(emailList);
                                        }else{
                                            alert("No Email Found");
                                        }
                                    }else{
                                        alert("No Data Found");
                                    }
                                })
                            }catch(e){
                                alert('Please select Excel File');
                                console.log(e);
                                document.getElementById('upload').value= [];
                            }
                        };
                
                        reader.onerror = function(ex) {
                        console.log(ex);
                        };
                
                        reader.readAsBinaryString(file);
                    };
                };
                
                function handleFileSelect(evt) {
                    try{
                        var files = evt.target.files; // FileList object
                        var xl2json = new ExcelToJSON();
                        xl2json.parseExcel(files[0]);
                    }catch(e){
                        alert('Please select Excel File');
                        console.log(e);
                    }
                }

                function showData(){
                    var val = document.getElementById('df:dfp:recordDataID').value;
                    console.log('val>>>>>>'+val);
                    if(val == 'No Contact List Found'){
                        alert('No Contact List Found');
                    }else if(val == 'No Email List Found'){
                        alert('No Email List Found');
                    }else{
                        alert(val);
                    }
                }
                document.getElementById('upload').addEventListener('change', handleFileSelect, false);
            </script>
        </apex:form>
    </div>
</apex:page>


​​​​​​​
Could anyone help me on this?

Thank You!!
Hello Friends,

When I reply on Case Email widget, two emails are sent to the user. 

Let me explain with the example.
I am buyer and I am sending an email to the company.
To = support@test.com
Subject - Product is not working.
Body - Preduct is not working.

When this email is send from my gmail account, a Case is created in a Salesforce.

Problem comes, when agent replies from the Case Widget Salesforce.
When agent replies, buyer can see two emails in his email box.
1. Email which the buyer sent.
2. Email which the agent replies from the Salesforce Org.

Could anyone let me know why this error is apperaing.

Thank You!!
Hi,

As per this document - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm

I can see that I should be able to use the "PATCH" in request. When I wrote the code, its working good in Sandbox but not in Production.

In Production, I can see the below error:
:Invalid HTTP method: PATCH

Could any one help why I am getting this error in production only?
Hi,

As per this document - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm

I can see that I should be able to use the "PATCH" in request. When I wrote the code, its working good in Sandbox but not in Production.

In Production, I can see the below error:
:Invalid HTTP method: PATCH

Could any one help why I am getting this error in production only?