• Célio Xavier
  • NEWBIE
  • 15 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 12
    Replies

I need help please, how do I make a template class for this Json, I've tried several ways but I'm getting the message that the Json is malformed.
 
[
    {
        "tipo": "PECÚLIO POR MORTE - RISCO",
        "beneficiarios": [
            {
                "idade": 60,
                "nascimento": "0000-00-00",
                "parentesco": "PAIS",
                "percentualRateio": 50,
                "cpf": "12312312345",
                "nome": "L***MASC***",
                "id": 3449190,
                "sexo": "FEMININO"
            },
            {
                "idade": 38,
                "nascimento": "0000-01-00",
                "parentesco": "IRMÃO",
                "percentualRateio": 50,
                "cpf": "12312312365",
                "nome": "S***MASC***",
                "id": 3449188,
                "sexo": "MASCULINO"
            }
        ],
        "valorBeneficio": 46100.83,
        "valorPagamento": 79.13,
        "status": "SUSPENSO"
    },
    {
        "tipo": "RENDA MENSAL VITALÍCIA - SOBREVIVENCIA",
        "idadeSaida": 65,
        "beneficiarios": [
            {
                "idade": 38,
                "nascimento": "0000-01-00",
                "parentesco": "IRMÃO",
                "percentualRateio": 50,
                "cpf": "12312312378",
                "nome": "S***MASC***",
                "id": 3449188,
                "sexo": "MASCULINO"
            },
            {
                "idade": 63,
                "nascimento": "0000-07-00",
                "parentesco": "PAIS",
                "percentualRateio": 50,
                "cpf": "12312312378",
                "nome": "L***MASC***",
                "id": 3449190,
                "sexo": "FEMININO"
            }
        ],
        "valorBeneficio": 0,
        "dataSaida": "2053-10-23",
        "valorPagamento": 0,
        "status": "SUSPENSO"
    }
]

My class:
 
public with sharing class ConsultationBeneficiaryModels {
    
    public class JSON2Apex {
	    @AuraEnabled public String tipo;	    
	    @AuraEnabled public Double valorBeneficio;
        public List<Beneficiarios> beneficiarios;
        @AuraEnabled public Double valorPagamento;
        @AuraEnabled public String status;
        @AuraEnabled public Integer idadeSaida;
        @AuraEnabled public String dataSaida;
    }
	public class Beneficiarios {
		@AuraEnabled public Integer idade;
		@AuraEnabled public String nascimento;
		@AuraEnabled public String parentesco;
		@AuraEnabled public Integer percentualRateio;
		@AuraEnabled public String cpf;
		@AuraEnabled public String nome;
		@AuraEnabled public Integer id;
		@AuraEnabled public String sexo;
    }
}

Message error:

FATAL_ERROR System.JSONException: Malformed JSON: Expected '{' at the beginning of object
I need help please, I'm not able to deploy this package, has anyone been through this?
 
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>NotificationTypeConfig</members>
        <name>NotificationTypeConfig</name>
    </types>
    <version>51.0</version>
</Package>
Print
 
I carried out a development that when the email field is changed in Salesforce, a Process Builder is triggered that according to some criteria calls a class that makes a callout to send data to an external service, it is working, but in order to implement it in production I need to deal code 500 that I receive if in case the external service is out, is there any way to prevent the saving of the email field according to the response of the external service request?
 
public class ChangeEmailAPI {
    public static HttpResponse CallChangeEmailAPI(String Email, String Inscription_Number) {
        Integer Inscription_Number_Int = integer.valueOf(Inscription_Number);
        if(Email == null){Email = '';}
        System.debug('E-mail: ' + Email + ' / ' + 'Matrícula: ' + Inscription_Number_Int); 
        Http http = new Http(); 
        HttpRequest request = new HttpRequest(); 
        request.setEndpoint('https://test.company.com.br/crm/atendimentos'); 
        request.setMethod('PUT'); 
        request.setHeader('Content-Type', 'application/json'); 
        request.setHeader('x-api-key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); 
        request.setHeader('canalOperacao', '14'); 
        
            JSONGenerator gen = JSON.createGenerator(true); 
            gen.writeStartObject(); 
                gen.writeNumberField('idCanalSolicitacao', 14); // Channel 14 - Salesforce
                gen.writeNumberField('idUsuario', 65200); //User Test Salesforce
                gen.writeNumberField('numeroMatricula', Inscription_Number_Int); 
	            gen.writeStringField('email', Email); 
                gen.writeNumberField('idUsoEmail', 3); //3 - E-mail for sending communications and services *Mock Brasilprev // 4 - E-mail for Billing
            gen.writeEndObject(); 

        String Jsons = gen.getAsString(); 
        System.debug(Jsons);         
        request.setBody(Jsons); 
        try{ 
            HttpResponse response = http.send(request); 
            request.setTimeout(20000);           
            System.debug(response.getStatusCode()); 
            System.debug(response);          
            System.debug('Alteração de e-mail processada no legado com sucesso.'); 
            return response; 
        }catch(System.CalloutException e){
            System.debug('Erro - Serviço de Ateração de e-mail: ' + e);                       
        }  
        return null; 
    }
}

 
I carried out a development that when the email field is changed in Salesforce, a Process Builder is triggered that according to some criteria calls a class that makes a callout to send data to an external service, it is working, but in order to implement it in production I need to deal code 500 that I receive if in case the external service is out, is there any way to prevent the saving of the email field according to the response of the external service request?
Hello,

I need help please, how do I prevent the case from being created in the first condition?
 
public Case generateLog(AccountHistory event) {

               if(OldValue_c.equals(NewValue_c)){ //Help                      
                    Case log = new Case();                        
        			return log;

    			}else{   
                     Case log = new Case();
                         log.RecordTypeId     = recordTypePrevention;
                         log.AccountId        = event.AccountId;           
                         log.Origin           = 'Phone';           
                     return log;
		}
}

 

I need help please, how do I make a template class for this Json, I've tried several ways but I'm getting the message that the Json is malformed.
 
[
    {
        "tipo": "PECÚLIO POR MORTE - RISCO",
        "beneficiarios": [
            {
                "idade": 60,
                "nascimento": "0000-00-00",
                "parentesco": "PAIS",
                "percentualRateio": 50,
                "cpf": "12312312345",
                "nome": "L***MASC***",
                "id": 3449190,
                "sexo": "FEMININO"
            },
            {
                "idade": 38,
                "nascimento": "0000-01-00",
                "parentesco": "IRMÃO",
                "percentualRateio": 50,
                "cpf": "12312312365",
                "nome": "S***MASC***",
                "id": 3449188,
                "sexo": "MASCULINO"
            }
        ],
        "valorBeneficio": 46100.83,
        "valorPagamento": 79.13,
        "status": "SUSPENSO"
    },
    {
        "tipo": "RENDA MENSAL VITALÍCIA - SOBREVIVENCIA",
        "idadeSaida": 65,
        "beneficiarios": [
            {
                "idade": 38,
                "nascimento": "0000-01-00",
                "parentesco": "IRMÃO",
                "percentualRateio": 50,
                "cpf": "12312312378",
                "nome": "S***MASC***",
                "id": 3449188,
                "sexo": "MASCULINO"
            },
            {
                "idade": 63,
                "nascimento": "0000-07-00",
                "parentesco": "PAIS",
                "percentualRateio": 50,
                "cpf": "12312312378",
                "nome": "L***MASC***",
                "id": 3449190,
                "sexo": "FEMININO"
            }
        ],
        "valorBeneficio": 0,
        "dataSaida": "2053-10-23",
        "valorPagamento": 0,
        "status": "SUSPENSO"
    }
]

My class:
 
public with sharing class ConsultationBeneficiaryModels {
    
    public class JSON2Apex {
	    @AuraEnabled public String tipo;	    
	    @AuraEnabled public Double valorBeneficio;
        public List<Beneficiarios> beneficiarios;
        @AuraEnabled public Double valorPagamento;
        @AuraEnabled public String status;
        @AuraEnabled public Integer idadeSaida;
        @AuraEnabled public String dataSaida;
    }
	public class Beneficiarios {
		@AuraEnabled public Integer idade;
		@AuraEnabled public String nascimento;
		@AuraEnabled public String parentesco;
		@AuraEnabled public Integer percentualRateio;
		@AuraEnabled public String cpf;
		@AuraEnabled public String nome;
		@AuraEnabled public Integer id;
		@AuraEnabled public String sexo;
    }
}

Message error:

FATAL_ERROR System.JSONException: Malformed JSON: Expected '{' at the beginning of object
I carried out a development that when the email field is changed in Salesforce, a Process Builder is triggered that according to some criteria calls a class that makes a callout to send data to an external service, it is working, but in order to implement it in production I need to deal code 500 that I receive if in case the external service is out, is there any way to prevent the saving of the email field according to the response of the external service request?
 
public class ChangeEmailAPI {
    public static HttpResponse CallChangeEmailAPI(String Email, String Inscription_Number) {
        Integer Inscription_Number_Int = integer.valueOf(Inscription_Number);
        if(Email == null){Email = '';}
        System.debug('E-mail: ' + Email + ' / ' + 'Matrícula: ' + Inscription_Number_Int); 
        Http http = new Http(); 
        HttpRequest request = new HttpRequest(); 
        request.setEndpoint('https://test.company.com.br/crm/atendimentos'); 
        request.setMethod('PUT'); 
        request.setHeader('Content-Type', 'application/json'); 
        request.setHeader('x-api-key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); 
        request.setHeader('canalOperacao', '14'); 
        
            JSONGenerator gen = JSON.createGenerator(true); 
            gen.writeStartObject(); 
                gen.writeNumberField('idCanalSolicitacao', 14); // Channel 14 - Salesforce
                gen.writeNumberField('idUsuario', 65200); //User Test Salesforce
                gen.writeNumberField('numeroMatricula', Inscription_Number_Int); 
	            gen.writeStringField('email', Email); 
                gen.writeNumberField('idUsoEmail', 3); //3 - E-mail for sending communications and services *Mock Brasilprev // 4 - E-mail for Billing
            gen.writeEndObject(); 

        String Jsons = gen.getAsString(); 
        System.debug(Jsons);         
        request.setBody(Jsons); 
        try{ 
            HttpResponse response = http.send(request); 
            request.setTimeout(20000);           
            System.debug(response.getStatusCode()); 
            System.debug(response);          
            System.debug('Alteração de e-mail processada no legado com sucesso.'); 
            return response; 
        }catch(System.CalloutException e){
            System.debug('Erro - Serviço de Ateração de e-mail: ' + e);                       
        }  
        return null; 
    }
}

 
Hi All,

I am facing challenge in retreieving lightning email templates folder in vscode. I am aware that in order to retrieve classic email templates folder package.xml is like this:
<types>
        <members>foldername</members>
        <members>foldername/templatename</members>
        <name>EmailTemplate</name>
</types>

When I use this package.xml for lightning email templates folder, I am able to retrieve the templates but the folder throws error:
=== WARNING: The following metadata isn’t in your org. If it’s not new, someone deleted it from the org.
Entity of type 'EmailTemplate' named 'foldername' cannot be found

The difference b/w lightning email template folder and classic email template folder is type:

For classic folder it is Email but for lightning it is coming as EmailTemplate
Hello, I have a Scheduled Trigger on a custom object. I want the flow to only run on records that were created after yesterday's Date/Time. To do this, I created a Date/Time variable that grabs today's date, then I created a formula that takes the variable and subtracts 1, to make it yesterday. Then I go to the start object and put in the conditions "CreatedDate Greater Than or Equal (Yesterday's Date)". However, no matter what I put in for yesterday's date (my formula, date/time straight from the global flow value, etc.) it doesn't accept my field. It either gives me a "We don't recognize that value. Make sure it's a valid date/time value in this format: M/d/yyyy h:mm a" or error that says "The Start element can’t have a record filter condition that references a resource or element. Remove the condition that contains the unsupported value “$Flow.CurrentDateTime” or replace it with a literal value." How do I work around this so that I can get my flow to only run on records that were greated yesterday?

Thank you!
Hello,

I need help please, how do I prevent the case from being created in the first condition?
 
public Case generateLog(AccountHistory event) {

               if(OldValue_c.equals(NewValue_c)){ //Help                      
                    Case log = new Case();                        
        			return log;

    			}else{   
                     Case log = new Case();
                         log.RecordTypeId     = recordTypePrevention;
                         log.AccountId        = event.AccountId;           
                         log.Origin           = 'Phone';           
                     return log;
		}
}

 
Hello,

I have below error when deploying a process builder with the email alert
You must specify a verified Org Wide Email Address for this sender type

what canbe the workaround ?
  • November 28, 2018
  • Like
  • 0
school__c -->customObject
studentjoinage =system.today() - createddate; //its formula field which riturn number.
I written the batchclass,in that   if(sch.studentjoinage__c==30) then send an email.
test.starttest
   mybatchcls mb=new mybatchcls();
   database.execute();
test.stoptest;
i get 40% codecoverage, in that start method ,finish methods r coverd but in execute method after if condition which means
messaging.singleemailmessage not coverd bcoze formula field.
i need help here to cover formula field.   
Hello,

I am trying to complete the challenge for the Use Org & Session Cache module on Salesforce Trailhead. Here are the instructions:

In this challenge, you’ll write an Apex class that writes and reads a bus schedule from the org cache. Your method for reading the cache has to handle cache misses.
  • Create a partition called BusSchedule with 0 MB for the size of org cache and session cache. The 0 MB allocation enables you to test cache misses.
  • Create a public Apex class called BusScheduleCache.
  • Add this variable to the class: private Cache.OrgPartition part;
  • In the constructor, create a new instance of Cache.OrgPartition by passing it the partition name (local.BusSchedule). Assign this object to the class variable (part).
  • Add two public methods. a. The first method, putSchedule(), returns void and takes these parameters: String busLine, Time[] schedule. b. The second method, getSchedule(), returns a bus schedule as a time array (Time[]) and takes this parameter: String busLine.
  • Implement the putSchedule() method so that it stores the passed-in values in the org cache by using the partition class variable (part).
  • Implement the getSchedule() method so that it returns the schedule for the specified bus line by using the partition class variable (part).
  • Add logic to the getSchedule() method to handle cache misses. If null is returned for the cached value, getSchedule() should return the following default schedule as a Time array with two Time objects: one Time object value of 8am and another of 5pm. Use the Apex Time.newInstance() method to create the Time objects.
Here is my current code:
 
public class BusScheduleCache {   
    // Get partition
    private Cache.OrgPartition part;
    String partitionName = 'local.BusSchedule';
    
    public BusScheduleCache(String partitionName) {
		Cache.OrgPartition newpart = Cache.Org.getPartition(partitionName);
        part = newpart;
    }
    
    public static void putSchedule(String busLine, Time[] schedule) {
        Cache.Org.put(busline, schedule);
    }
        
    public static Time[] getSchedule(String busLine) {
        Time[] schedule;
        
        // Get a cached value
		Object obj = Cache.Org.get(busLine);
		// Cast return value to a specific data type
		Time t2 = (Time)obj;
        if (t2 != null) {
        	schedule.add(t2);
        }
        else {
            Time t3 = Time.newInstance(8,0,0,0);
            schedule.add(t3);
            Time t4 = Time.newInstance(17,0,0,0);
            schedule.add(t4);
        }        
        return schedule;
    }  
      
}



Here is the error I am receiving:

Challenge Not yet complete... here's what's wrong: 
The Apex Class BusScheduleCache is not properly implemented. Please follow the requirements and ensure everything is setup correctly

Can someone please help?
Hi,


   I have batch apex with http call out. functinality working good. I need to run test case for that batch apex code coverage 100% but test case failed in following line
    "HTTPResponse res = http.send(con); " (con  refers to http request). and the error is
"You have uncommitted work pending. Please commit or rollback before calling out"

please can any one help me out from this issue..

I have written the following code and I am getting the error  "You have uncommitted work pending. Please commit or rollback before calling out". I am new to salesforce, so am unable to understand what the error is for. Kindly help

 

 

authSuccessBool=false;
        String token = ApexPages.currentPage().getParameters().get('oauth_token');
        System.debug('CompleteAuth Token===================================='+ApexPages.currentPage().getParameters().get('oauth_token'));
        if(token!=null)
        {
            String verifier = ApexPages.currentPage().getParameters().get('oauth_verifier');
            System.debug('CompleteAuth Verifier================================================='+ApexPages.currentPage().getParameters().get('oauth_verifier'));
            OAuth oa = new OAuth();
            authSuccess = oa.completeAuthorization(token,verifier);
              
            if(authSuccess!=null||authSuccess!=' ')
            {
                authSuccessBool=true;
            }
            this.message = oa.message;
        }
        else {
            message = 'Invalid request. Missing parameter oauth_token';
        }
        
        
         //--------------------------------------------------------
            Http h = new Http();
            HttpRequest req = new HttpRequest();
            HttpResponse  res = new HttpResponse();
            String endpoint='https://docs.google.com/feeds/download/documents/Export?id=1ok94msdl7FDfo51R9cCSVqdRY6yRVO16byfv-GpvDOs&exportFormat=html';
            req.setMethod('GET');
            req.setEndpoint(endpoint);
            res=h.send(req);
            System.debug('====================='+res.getBody());
         //--------------------------------------------------------
        
        return null;
    }

I'm frequently getting the error "System.CalloutException: Read timed out" on an HTTP Service (RESTful) call I am making from an Apex class.

It doesn't appear to be a proxy/firewall issue as I *am* able to get a response.   I think I just have a slow server on the other end.

Is there any way to increase the timeout period on this call to ensure that the web service has time to respond?

Thanks!