function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sruthiforcesruthiforce 

need validation rule

Question:

Type <> Support Site Admin, License request

How to use <> in this case Type is Picklist

 ISPICKVAL(Type,<> 'Support Site Admin'), ISPICKVAL(Type,<> 'License Request'))

 

error: <>

PremanathPremanath

Hi, 

 

  You can try like this may be you can reach,

 

trigger BillingAddPopulateOnCustomAddress on Account (before insert, before update) {
list<Country__c> ct = [select name,ISO2__c from Country__c];
//Country__c obj = new Country__c();
set<String> set1=new set<String>();
for(Integer i=0;i<ct.size();i++){
set1.add(ct[i].Name);
}
for(Account acct : Trigger.new){
if((acct.OS_Address_1__c==null && acct.OS_City__c==null && acct.OS_State__c==null && acct.D_B_Country__c==null && acct.D_B_Postal_Code__c==null) &&
( acct.BillingStreet !=null || acct.BillingCity !=null || acct.BillingState !=null || acct.BillingPostalCode !=null || acct.BillingCountry !=null )) {
//Moving Billing Address to CustomAddress
acct.OS_Address_1__c = acct.BillingStreet;
acct.OS_City__c = acct.BillingCity;
acct.OS_State__c = acct.BillingState;
acct.OS_Postal_Code__c = acct.BillingPostalCode;
//obj.name = acct.BillingCountry;

if(set1.contains(acct.BillingCountry)) {
acct.D_B_Country__c = acct.BillingCountry;
acct.ISO_Country_Code__c = obj.ISO2__c; 
}
else acct.D_B_Country__c = ' ';
}

}
}

 

otherwise 

What type of error your getting..

Explain clearly

 

Regards

Prem

sruthiforcesruthiforce

Type <> Support Site Admin, License request

Type is a picklist


how to use <> not equal in this case

 

ISPICKVAL(Type, 'Support Site Admin'), ISPICKVAL(Type, 'License Request'))

 

PremanathPremanath

There we commented the obj na so we get error...

 

Try this code

 

 


trigger BillingAddPopulateOnCustomAddress on Account (before insert, before update) {
    list<Country__c> ct = [select name,ISO2__c from Country__c];
    //Country__c obj = new Country__c();
    Map<String,String> map1=new Map<String,String>();
    for(Integer i=0;i<ct.size();i++){
        map1.put(ct[i].Name,ct[i].ISO2__c);
    }
    for(Account acct : Trigger.new){
        if((acct.OS_Address_1__c==null && acct.OS_City__c==null && acct.OS_State__c==null && acct.D_B_Country__c==null && acct.D_B_Postal_Code__c==null) &&
        ( acct.BillingStreet !=null || acct.BillingCity !=null || acct.BillingState !=null || acct.BillingPostalCode !=null || acct.BillingCountry !=null )) {
        //Moving Billing Address to CustomAddress
        acct.OS_Address_1__c = acct.BillingStreet;
        acct.OS_City__c = acct.BillingCity;
        acct.OS_State__c = acct.BillingState;
        acct.OS_Postal_Code__c = acct.BillingPostalCode;
        //obj.name = acct.BillingCountry;
        
        if(map1.containsKey(acct.BillingCountry)) {
            acct.D_B_Country__c = acct.BillingCountry;
            acct.ISO_Country_Code__c = map1.get(acct.BillingCountry);
        }
        else acct.D_B_Country__c = ' ';
        }
        
    }
}

 

 

Regards

Prem

sruthiforcesruthiforce

 thanks

PremanathPremanath

Why because your writing code in If Condition na

 

if(set1.contains(acct.BillingCountry)) {
acct.D_B_Country__c = acct.BillingCountry;
acct.ISO_Country_Code__c = obj.ISO2__c; // Compile Error: Variable does not exist: obj.ISO2__c at line 25 column 28
}
else acct.D_B_Country__c = ' ';
}

 

So  From query whatever your entering qrery for Getting record .. That record may be not there

 

 

Use System.Debug(); on Every step. Later you came to know about that easily..

 

like this

 

System.Debug('==============='+map1.get(acct.BillingCountry));

 

   if(map1.containsKey(acct.BillingCountry)) {
            acct.D_B_Country__c = acct.BillingCountry;
            acct.ISO_Country_Code__c = map1.get(acct.BillingCountry);
        }
        else acct.D_B_Country__c = ' ';
        }

 

-----

Actually this is your requirement Right? So you have to take care of this na.. How can i understood which records you have?

 

Regards

Prem