-3

Missing return statement required return type: List

Illegal assignment from System.PageReference to String

Illegal conversion from String to List

Variable does not exist: cCaseId

public class CaseExpCsvCtrl {

  public static boolean lPermissaoExportar { get; set; }
  public List<SelectOption> lTiposApresentacao { get; set; }
  private static final String PERFIS_HABILITADOS = '(BI_BR_Administrador_de_Vendas, BI_BR_Carteira, BI_BR_Ferramentas_Comerciais)';
  private static Mensagem_erro__c mensagem { get; set; }

  @AuraEnabled 
  //public static List<Map<String, String>> retornaOpcoesTipoCaso(){
  public static String retornaOpcoesTipoCaso(){
    List<Map<String, String>> options = new List<Map<String, String>>();
    options.add(new map<String, String>{ 'value' => CaseMethods.RT_CASE_MIGR_CLIENTE, 'name' => 'Atribuição de Atendimento' });
    //options.add(new SelectOption(CaseMethods.RT_CASE_COLIGACAO, 'Coligação e Descoligação'));
    return JSON.serialize(options);
  }

    /*@AuraEnabled
    public static  preSet()
  {
    //Set<Id> lIdPerfisHabilitados = ( new Map<Id, Profile>([SELECT Id FROM Profile WHERE Name = :PERFIS_HABILITADOS])).keySet().clone();
    //if (lIdPerfisHabilitados.contains(UserInfo.getProfileId())) return;
    //setMensagem('Você não possui acesso!');
    //lPermissaoExportar = true;
  }*/

  @AuraEnabled  
  public static List<String> botaoExportar(Date lInicio, Date lFim, boolean lAtualizar, String lCsvGerado, String lFltStatusCaso, String lFltTipoCaso, Integer NUM_ATCC, Integer lSysSoqlLimit){
      NUM_ATCC = 40;
      List<String> lretorno = new List<String>();

    if (lInicio == null || lFim == null || lInicio > lFim)
    {
      String cMensagem = (mensagem.VF_importar_erro_data__c != null) ? mensagem.VF_importar_erro_data__c : 'Data não preenchida ou Data de inicio maior que a data fim!';
      setMensagem(cMensagem);
      return;
    }
    boolean cLimiteEstourado = true;
    String query = 'SELECT COUNT() FROM Case ';
    String cWhere = ' WHERE RecordTypeId = \'' + lFltTipoCaso + '\'';
    if (lFltStatusCaso != 'Todos') cWhere += ' AND Status = \'' + lFltStatusCaso + '\'';
    if (lInicio != null) cWhere += ' AND CreatedDate > ' + lInicio.year() + '-' + string.valueof(lInicio.month()+100).right(2) + '-' + string.valueof(lInicio.day()+100).right(2) + 'T00:00:00Z AND CreatedDate < ' + lFim.year() + '-' + string.valueof(lFim.month()+100).right(2) + '-' + string.valueof(lFim.day()+100).right(2) + 'T23:59:59Z';
    Integer cCaseCount = Database.countQuery(query + cWhere);
    if (cCaseCount < lSysSoqlLimit)
    {
      query = 'SELECT Id, Solicitante__r.Modelo_de_atuacao__c, Razao_Social_Cli__r.BI_CAM_Codigo_del_cliente__c, CPF_CNPJ__c, Acao_carteira__c, Razao_Social_Cli__r.Codigo_Grupo__c, Modelo_de_atuacao__c   FROM Case ';
      Set<String> lCodGrupo = new Set<String>(), lCodCli = new Set<String>(), lCpfCnpj = new Set<String>(), lModeloDeAtuacao = new Set<String>();
      List<Case> lCasos = Database.query(query + cWhere);
      for (Case cCaso : lCasos)
      {
        if (cCaso.Acao_carteira__c == 'Cód. Cliente')
        {
          if (cCaso.Razao_Social_Cli__r.BI_CAM_Codigo_del_cliente__c != null && !lCodCli.contains(cCaso.Razao_Social_Cli__r.BI_CAM_Codigo_del_cliente__c))
            lCodCli.add(cCaso.Razao_Social_Cli__r.BI_CAM_Codigo_del_cliente__c);
        }
        else if (cCaso.Acao_carteira__c == 'CNPJ/CPF')
        {
          if (cCaso.CPF_CNPJ__c != null && !lCpfCnpj.contains(cCaso.CPF_CNPJ__c))
            lCpfCnpj.add(cCaso.CPF_CNPJ__c);
        }
        else
        {
          if (cCaso.Razao_Social_Cli__r.Codigo_Grupo__c != null && !lCodGrupo.contains(cCaso.Razao_Social_Cli__r.Codigo_Grupo__c))
            lCodGrupo.add(cCaso.Razao_Social_Cli__r.Codigo_Grupo__c);
        }
        if (!lModeloDeAtuacao.contains(cCaso.Solicitante__r.Modelo_de_atuacao__c)) lModeloDeAtuacao.add(cCaso.Solicitante__r.Modelo_de_atuacao__c);
      }
      Integer cAcc = [SELECT count() FROM Account WHERE Codigo_Grupo__c = :lCodGrupo OR BI_CAM_Codigo_del_cliente__c = :lCodCli OR BI_No_Identificador_fiscal__c = :lCpfCnpj];
      if ((cCaseCount + (cAcc * NUM_ATCC)) < lSysSoqlLimit) cLimiteEstourado = false;
    }


    if (!cLimiteEstourado)
    {
      PageReference pg = Page.CaseCsv;
      pg.getParameters().put('Inicio', EncodingUtil.urlEncode( String.valueOf(lInicio), 'UTF-8'));
      pg.getParameters().put('Fim', EncodingUtil.urlEncode( String.valueOf(lFim), 'UTF-8'));
      pg.getParameters().put('Status', EncodingUtil.urlEncode(lFltStatusCaso , 'UTF-8'));
      pg.getParameters().put('Tipo', EncodingUtil.urlEncode(lFltTipoCaso , 'UTF-8'));
      String cMensagem = (mensagem.Relatorio_Sendo_Gerado__c != null) ? mensagem.Relatorio_Sendo_Gerado__c : 'Dados sendo gerados, aguarde alguns instantes!';
      setMensagem(cMensagem, ApexPages.Severity.CONFIRM);
      lAtualizar = true;
      lCsvGerado = pg;
      return cMensagem;
    }

    String cMensagem = (mensagem.VF_importar_erro_limite__c != null) ? mensagem.VF_importar_erro_limite__c : 'Relatório muito extenso, por favor melhore os critérios selecionados!';
    setMensagem(cMensagem);

      return lretorno;
  }

  @AuraEnabled
  public static Id botaoCancelar(){

    Id ldevRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('/' + cCaseId.getKeyPrefix() + '/o').getRecordTypeId();

      return ldevRecordTypeId;
  }

  @AuraEnabled
  public static String setMensagem(String msgInfo){
    String mensangem = setMensagem(msgInfo, ApexPages.Severity.INFO);

      return null;

  }
  @AuraEnabled  
  public static String setMensagem(String msgInfo, ApexPages.Severity aSeverity){

    ApexPages.Message msg = new ApexPages.Message(aSeverity, msgInfo);
    ApexPages.addMessage(msg);

      return null;

  }


}
  • Please format your code..first..:) – Ayub May 10 '18 at 19:50
  • Did you get line numbers for any of these compile errors? Because indicating specifically which lines throw the errors would vastly improve this question. – Adrian Larson May 10 '18 at 19:58
  • 2
    The errors are very specific particularly when combined with the line numbers. I suggest you should work out the solutions yourself - Google and read - as this will help you learn more about programming. – Keith C May 10 '18 at 20:04
1

It looks like you tried to port Visualforce directly to Lightning. This is not as straightforward as it seems. First, you need to change your message delivery mechanism:

@AuraEnabled  
public static void setMensagem(String msgInfo, ApexPages.Severity aSeverity){
  throw new AuraHandledException(msgInfo);
}

Now, to address the errors.

Missing return statement required return type: List

if (lInicio == null || lFim == null || lInicio > lFim)
{
  ...
  return;

It's not legal to use return with a missing or invalid data type at any point in a function. You would instead want to return null; if you wanted to return early without data. However, in this case, it's not necessary, because we changed the error reporting system to a thrown exception; no return is necessary because the method will not return.

Illegal assignment from System.PageReference to String

lCsvGerado = pg;

You can't assign a PageReference to a String. Instead, you need the URL:

lCsvGerado = pg.getUrl();

Illegal conversion from String to List

You tried to assign a string to a list. I can't seem to find it without line numbers, but it should be trivial to figure out what's wrong if you had a line number.

Variable does not exist: cCaseId

The variable does not exist. It is never defined. You may have accidentally deleted the declaration from elsewhere in your code. I don't have any way to identify how to fix this without knowing the intent of this variable. In fact, that entire line is entirely questionable, since it seems like it wouldn't do what you think it does. You'll need to puzzle that one out yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.