• Philippe Uyttendaele
  • NEWBIE
  • 60 Points
  • Member since 2018

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 11
    Replies
Hi!

I'm trying to make an API call to populate some fields on a visual force page, but I'm catching this problem, does anyone have any idea what it could be?

System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY> at line 31.
 
public with sharing class pocAuthorizationManagement {
	
    public String email{get;set;}
    public String id_json{get;set;}
    public String inserted_at{get;set;}
    public String mobile_phone{get;set;}
    public String person_id{get;set;}
    public String term_id{get;set;}
    public String ip{get;set;}
    public String user_agent{get;set;}
    
    
    public pocAuthorizationManagement(ApexPages.StandardController stdController){
      
        Lead lead = (Lead)stdController.getRecord();
        lead = [SELECT Id, CPFTxt__c FROM Lead WHERE Id =: lead.Id];
        
        String leadCPF = lead.CPFTxt__c;
        
        String requestEndPoint = 'my-end-point;
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(requestEndPoint);
        request.setMethod('GET');
        HttpResponse response =  http.send(request);
        
        if(response.getStatusCode() ==  200){
            Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(response.getBody());
            System.debug(results);
            Map<String, Object> dataResults = (Map<String, Object>)(results.get('data'));
            email = String.valueOf(dataResults.get('email'));
            id_json = String.valueOf(dataResults.get('id'));
            inserted_at = String.valueOf(dataResults.get('inserted_at'));
            person_id = String.valueOf(dataResults.get('person_id'));
            mobile_phone = String.valueOf(dataResults.get('mobile_phone'));
            term_id = String.valueOf(dataResults.get('term_id'));
            
            Map<String, Object> sessionResults = (Map<String, Object>)(dataResults.get('session_metadata'));
            ip = String.valueOf(dataResults.get('ip'));
            user_agent = String.valueOf(dataResults.get('user_agent'));
            
        } else {
        	ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Algo de errado não está certo');
            ApexPages.addMessage(msg);
        }
   
    }

}
Exemple of my JSON.
{
   "data":[
      {
         "email":null,
         "id":"e729f678-8793-4793-a50a-2ad85b221139",
         "inserted_at":"2019-05-10T18:16:46",
         "mobile_phone":null,
         "person_id":"5557e08f-b569-47b9-993c-29fb85830724",
         "session_metadata":{
            "ip":"xxx",
            "user_agent":"{\"OS\": \"Android\", \"ip\": \"xxx\", \"Vendor\": \"Google Inc.\", \"AppName\": \"Netscape\", \"Browser\": \"Chrome\", \"OSVersion\": 9, \"Plataform\": \"Linux armv8l\", \"UserAgent\": \"Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"AppVersion\": \"5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"BrowserVersion\": 63.03239111}"
         },
         "term_id":"a174ac7e-be49-4ab2-8539-83e85367b866"
      },
      {
         "email":null,
         "id":"c7cec531-4057-4684-a6b9-6422e5138b9d",
         "inserted_at":"2019-05-10T18:16:46",
         "mobile_phone":null,
         "person_id":"5557e08f-b569-47b9-993c-29fb85830724",
         "session_metadata":{
            "ip":"xxx",
            "user_agent":"{\"OS\": \"Android\", \"ip\": \"xxx\", \"Vendor\": \"Google Inc.\", \"AppName\": \"Netscape\", \"Browser\": \"Chrome\", \"OSVersion\": 9, \"Plataform\": \"Linux armv8l\", \"UserAgent\": \"Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"AppVersion\": \"5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"BrowserVersion\": 63.03239111}"
         },
         "term_id":"a174ac7e-be49-4ab2-8539-83e85367b866"
      }
   ]
}

My debug at line 30:
{data=({email=null, id=e729f678-8793-4793-a50a-2ad85b221139, inserted_at=2019-05-10T18:16:46, mobile_phone=null, person_id=5557e08f-b569-47b9-993c-29fb85830724, session_metadata={ip=xxx, user_agent={"OS": "Android", "ip": "xxx", "Vendor": "Google Inc.", "AppName": "Netscape", "Browser": "Chrome", "OSVersion": 9, "Plataform": "Linux
 Thanks for your help!
I have a flow wrapped in a lightning component for a global action. 

The flow worked fine in the lightning component but the problem is the flow will run then go back to the start. I want the screen to disppear after the user clicks finish.

hen I added the e.force:closeQuickAction and click the global action the flow screen doesn't really open, but you can see it automatically close to the lower right hand corner of the computer screen. I'm not sure if I need to add something to my code below to only close the screen after the flow finishes but I'm not sure where the issue is with my code. 
 
<aura:component implements="force:appHostable, flexipage:availableForAllPageTypes, flexipage:availableForRecordHome,force:lightningQuickAction"  >

<aura:handler name="init"  value="{!this}" action="{!c.init}" />
<lightning:flow aura:id="flowData" />
    <br/>
    
</aura:component>
 
({
init : function (component) {
// Find the component whose aura:id is "flowData"
var flow = component.find("flowData");
// In that component, start your flow. Reference the flow’s Unique Name.
flow.startFlow("New_IT_Support_Case");
    
    // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
  },
})

 
Hello,
I would like to create an @Invocable APEX method that allows sending custom Event to visitor chat.

there exist an API, but this is javascript and not apex functions
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_sendCustomEvent.htm

anyone knows what are the available commands for that ?
Hello,
We are setting up a custom liveChat throught the rest API documentation.
--> from here : REST API LiveAgent (https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_understanding_resources.htm)

We are have used the possibility for our agents to upload specific documents and have them correctly integrated using costomEvents
--> from here : Send Custom Events (https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_sendCustomEvent.htm)

Now we are looking into automate this process with the help of Einstein Bots.
We have read the cookbook carefully
--> from here : Einstein Cookbook (https://developer.salesforce.com/docs/atlas.en-us.bot_cookbook.meta/bot_cookbook/bot_cookbook_overview.htm)

But i still cannot figure IF/HOW to have Einstein bots trigger these custom events as they are currently javascript based...
I guess i would need to have Einstein call an Invocable APEX but ... that would require the appropriate APEX commands which i am looking for.

Anyone has information on this ?

thanks very much !
Hello Everyone,

I have a very hard time woring with the LiveAgent Chat snap-in.

First of all, I can't manage to add fields that refer to other objects than the suggested ones (Case/Contacts).
 would like to add a Custom Object field, but i cannot manage to do that in the framework of the Snap-in. If i force it in the component code, i have a 'field validation error' recieved by the built-in SF code.
--> anyone see a way ?

I then decided to work with what i could and pass extraPrechatFormDetails as suggested in the documentation. the idea is to pass the element in a custom TranscriptField. It worked great in POC with hardcoded values. It got out of control when my colleague enabled translation on those...
Indeed the Label of the buttons are defined by Translation Workbench. Which means that at the time of the set of the extraprechat items (on the page where the snap-in lies), i have no idea of what the value of the label will be. hence i have no way to declare any of the extraPrechatItems...

Is there a way to have a workaround - or a way of doing -  for these

I managed to "pass" the built-in validation step with the help of the Class of the input button (original code taken from SFDC documentation deleting the hard coded value from fieldLabelToName and replacing line 64 by below code ):
createFieldsArray: function(fields) {
		if(fields.length) {
            
			return fields.map(function(fieldCmp) {
                this.addToExtra(fieldCmp);
				return {
					label: fieldCmp.get("v.label"),
					value: fieldCmp.get("v.value"),
                    name: fieldCmp.get("v.class").split(" ")[0] //Inserted by Philippe to make it pass Validation!
				};
			}.bind(this));
		} else {
			return [];
		}
	},

 
Hi!

I'm trying to make an API call to populate some fields on a visual force page, but I'm catching this problem, does anyone have any idea what it could be?

System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY> at line 31.
 
public with sharing class pocAuthorizationManagement {
	
    public String email{get;set;}
    public String id_json{get;set;}
    public String inserted_at{get;set;}
    public String mobile_phone{get;set;}
    public String person_id{get;set;}
    public String term_id{get;set;}
    public String ip{get;set;}
    public String user_agent{get;set;}
    
    
    public pocAuthorizationManagement(ApexPages.StandardController stdController){
      
        Lead lead = (Lead)stdController.getRecord();
        lead = [SELECT Id, CPFTxt__c FROM Lead WHERE Id =: lead.Id];
        
        String leadCPF = lead.CPFTxt__c;
        
        String requestEndPoint = 'my-end-point;
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(requestEndPoint);
        request.setMethod('GET');
        HttpResponse response =  http.send(request);
        
        if(response.getStatusCode() ==  200){
            Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(response.getBody());
            System.debug(results);
            Map<String, Object> dataResults = (Map<String, Object>)(results.get('data'));
            email = String.valueOf(dataResults.get('email'));
            id_json = String.valueOf(dataResults.get('id'));
            inserted_at = String.valueOf(dataResults.get('inserted_at'));
            person_id = String.valueOf(dataResults.get('person_id'));
            mobile_phone = String.valueOf(dataResults.get('mobile_phone'));
            term_id = String.valueOf(dataResults.get('term_id'));
            
            Map<String, Object> sessionResults = (Map<String, Object>)(dataResults.get('session_metadata'));
            ip = String.valueOf(dataResults.get('ip'));
            user_agent = String.valueOf(dataResults.get('user_agent'));
            
        } else {
        	ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Algo de errado não está certo');
            ApexPages.addMessage(msg);
        }
   
    }

}
Exemple of my JSON.
{
   "data":[
      {
         "email":null,
         "id":"e729f678-8793-4793-a50a-2ad85b221139",
         "inserted_at":"2019-05-10T18:16:46",
         "mobile_phone":null,
         "person_id":"5557e08f-b569-47b9-993c-29fb85830724",
         "session_metadata":{
            "ip":"xxx",
            "user_agent":"{\"OS\": \"Android\", \"ip\": \"xxx\", \"Vendor\": \"Google Inc.\", \"AppName\": \"Netscape\", \"Browser\": \"Chrome\", \"OSVersion\": 9, \"Plataform\": \"Linux armv8l\", \"UserAgent\": \"Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"AppVersion\": \"5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"BrowserVersion\": 63.03239111}"
         },
         "term_id":"a174ac7e-be49-4ab2-8539-83e85367b866"
      },
      {
         "email":null,
         "id":"c7cec531-4057-4684-a6b9-6422e5138b9d",
         "inserted_at":"2019-05-10T18:16:46",
         "mobile_phone":null,
         "person_id":"5557e08f-b569-47b9-993c-29fb85830724",
         "session_metadata":{
            "ip":"xxx",
            "user_agent":"{\"OS\": \"Android\", \"ip\": \"xxx\", \"Vendor\": \"Google Inc.\", \"AppName\": \"Netscape\", \"Browser\": \"Chrome\", \"OSVersion\": 9, \"Plataform\": \"Linux armv8l\", \"UserAgent\": \"Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"AppVersion\": \"5.0 (Linux; Android 9; SAMSUNG SM-G9650 Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36\", \"BrowserVersion\": 63.03239111}"
         },
         "term_id":"a174ac7e-be49-4ab2-8539-83e85367b866"
      }
   ]
}

My debug at line 30:
{data=({email=null, id=e729f678-8793-4793-a50a-2ad85b221139, inserted_at=2019-05-10T18:16:46, mobile_phone=null, person_id=5557e08f-b569-47b9-993c-29fb85830724, session_metadata={ip=xxx, user_agent={"OS": "Android", "ip": "xxx", "Vendor": "Google Inc.", "AppName": "Netscape", "Browser": "Chrome", "OSVersion": 9, "Plataform": "Linux
 Thanks for your help!
Hi, we are trying to integrate a web application with the salesforce rest API but we are having some CORS issues.

The domain is white listed in salesforce (currently testing on localhost), and all requests work fine if we send the OAuth token as a query param in the URL like this:
https://test.salesforce.com/id/XXXXXXXX/YYYYYYYY?oauth_token=access_token
But if we try to send the token using the Authorization Header instead of passing it in the URL, like this:
Authorization: Bearer access_token

It fails with a CORS error because the prefligh request to the same URL using the OPTIONS method returns a 403 with error "Missing OAuth token".
This happens because the browser omits the Authorization Header when doing the preflight request, this is actually documented in the CORS spec (https://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0): "for a cross-origin request with preflight … make a preflight request … Exclude user credentials"

Is there any workaround for this?
Thanks for the help =)
 
Hello,
We are setting up a custom liveChat throught the rest API documentation.
--> from here : REST API LiveAgent (https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_understanding_resources.htm)

We are have used the possibility for our agents to upload specific documents and have them correctly integrated using costomEvents
--> from here : Send Custom Events (https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_sendCustomEvent.htm)

Now we are looking into automate this process with the help of Einstein Bots.
We have read the cookbook carefully
--> from here : Einstein Cookbook (https://developer.salesforce.com/docs/atlas.en-us.bot_cookbook.meta/bot_cookbook/bot_cookbook_overview.htm)

But i still cannot figure IF/HOW to have Einstein bots trigger these custom events as they are currently javascript based...
I guess i would need to have Einstein call an Invocable APEX but ... that would require the appropriate APEX commands which i am looking for.

Anyone has information on this ?

thanks very much !
I have a flow wrapped in a lightning component for a global action. 

The flow worked fine in the lightning component but the problem is the flow will run then go back to the start. I want the screen to disppear after the user clicks finish.

hen I added the e.force:closeQuickAction and click the global action the flow screen doesn't really open, but you can see it automatically close to the lower right hand corner of the computer screen. I'm not sure if I need to add something to my code below to only close the screen after the flow finishes but I'm not sure where the issue is with my code. 
 
<aura:component implements="force:appHostable, flexipage:availableForAllPageTypes, flexipage:availableForRecordHome,force:lightningQuickAction"  >

<aura:handler name="init"  value="{!this}" action="{!c.init}" />
<lightning:flow aura:id="flowData" />
    <br/>
    
</aura:component>
 
({
init : function (component) {
// Find the component whose aura:id is "flowData"
var flow = component.find("flowData");
// In that component, start your flow. Reference the flow’s Unique Name.
flow.startFlow("New_IT_Support_Case");
    
    // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
  },
})

 
I am trying to retrive value from more than 2000 records, so in the process i want to fetch the id value of 2000th record and assign it to a variable.Please let me know the syntax.
I'm using the lightning tree component and I'm trying to dynamically select an item after Init through an event and want all parent nodes expanded. I have a separte lighting component that the user selects and item and then an event is passed to my component with the Tree containing the Tree Node Name I want to select. This is all working fine but I can't get the lighting:tree component to work.

The expanded issue:
My java script code works to the point of setting all the expanded=true flags for all parent items of the item I want selected but it never renders the children. I can see the expanded icon changed but none of the children are rendered. If I expand everything in the Init handler it displays the tree correctly but on the event java script to change the selected item it just changes the expanded icon and all text is the same.

The Selection Issue: I'm not sure how to select an Item in the tree or what java script I need to make this happen. Any help would be appreciated.