You need to sign in to do that
Don't have an account?
Henrique Ortiz
Trigger to class 3
Hello everyone,
I need to convert this trigger into a class and them call it in a trigger in another object.
Can someone help me?
Also, I created 3 lists for validation of the records in this object, I know that is not the best way of doing, so what is the bets of way?
this 3 lists:cont_social, cont_loca, rg_cpf
I need to convert this trigger into a class and them call it in a trigger in another object.
Can someone help me?
Also, I created 3 lists for validation of the records in this object, I know that is not the best way of doing, so what is the bets of way?
this 3 lists:cont_social, cont_loca, rg_cpf
trigger Unidade_Status on Campus__c (before update) { for (Campus__C a :trigger.new) { list <Integrante_equipe__c> integrantes = new list<Integrante_equipe__c>(); integrantes = [SELECT ID FROM INTEGRANTE_EQUIPE__c WHERE INTEGRANTE_EQUIPE__c.POLO__C = :a.Id AND integrante_equipe__c.funcao__C = 'Sócio' AND integrante_equipe__c.cpf__C != null]; list <Documentos_Parceiro__c> cont_social = new list <Documentos_Parceiro__c>(); cont_social = [SELECT ID FROM Documentos_Parceiro__c WHERE Documentos_Parceiro__c.Unidade__c =: a.Id AND Recordtype.name = 'Contrato Social']; list <Documentos_Parceiro__c> cont_loca = new list <Documentos_Parceiro__c>(); cont_loca = [SELECT ID FROM Documentos_Parceiro__c WHERE Documentos_Parceiro__c.Unidade__c =: a.Id AND Recordtype.name = 'Contrato de Locação']; list <Documentos_Parceiro__c> rg_cpf = new list <Documentos_Parceiro__c>(); rg_cpf = [SELECT ID FROM Documentos_Parceiro__c WHERE Documentos_Parceiro__c.Unidade__c =: a.Id AND Recordtype.name = 'RG/CPF Sócios']; if(a.City__C != null && a.State__C != null && a.Email__c != null && a.Work_Phone__c != null) { if(a.LastActivityDate != null) { if(a.CNPJ__c != null && a.Razao_social_c__C != null && a.Street_Address__c != null && a.House_Number__c != null && a.Bairro__c != null && a.Zip_Code__c != null ) { if (!integrantes.isEmpty()) { if(cont_social.size() > 0 && cont_loca.size() > 0 && rg_cpf.size() > 0){ a.Status_parceria__c = 'Em Análise'; } Else { a.Status_parceria__c = 'Pré-Cadastro'; } } Else { a.Status_parceria__c = 'Pré-Cadastro'; } } Else { a.Status_parceria__c = 'Negociação'; } } Else { a.Status_parceria__c = 'Lead'; } } Else { a.Status_parceria__c =''; } } }
Check the following code that may help you to resolve your problem.
Note- Code is not compiled.
<!-------------Trigger-------------------->
--
Thanks,
Prashant