+ Start a Discussion
Emmanuel CoronaEmmanuel Corona 

IF Error



I'm working in a trigger with the next sintax


if (opp.stagename=='Ganada' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1&& (opp.FUNCION__c<>'Costumer Care' ||opp.FUNCION__c<>'Direccion MCM') ){
opp.addError('La Oportunidad debe tener al menos una punta.');


But when i test it, i get the error message using a user with Funcion Direccion MCM


So what i'm trying to do is to get the message when the user Funcion is not equal to Costumer or Direccion, whats is wrong? how can i add more than one OR in the if?


Thank you.

Code looks good. Are you sure your user has
opp.FUNCION__c = 'Direccion MCM'

Neha LundNeha Lund

The record which you are testing with has following conditions true as well:


opp.stagename=='Ganada' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1&&


That's why it is returning error.. what condition you want to satisfy ?

Emmanuel CoronaEmmanuel Corona
Greetings Neha!

If the stagename=Ganada, puntasiza=0, es_inactiva!=1 and the Funcion is different from Direccion or Costumer Care then send the error message

That is what i'm trying to get :(

Your code should be 


if (opp.stagename=='Ganada' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1&& (opp.FUNCION__c<>'Costumer Care' && opp.FUNCION__c<>'Direccion MCM') ){
opp.addError('La Oportunidad debe tener al menos una punta.');

Emmanuel CoronaEmmanuel Corona
Greetings Sandeep!

i tried that but it was not working :S

I'm using this:

if (opp.stagename=='Negociar' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1 && opp.Funcion_propietario__c<>'Costumer Care' && opp.Funcion_propietario__c<>'EV-Network-DR' && opp.Funcion_propietario__c<>'Coordinador-DR'){
opp.addError('La Oportunidad debe tener al menos una punta.');

but some times it works and some times no... i don't know if there is a limit

Can you please let me know the scenario when it is not working I mean please put this statement and check value of attributes. 




and let me know values.