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
Sfdc SivaSfdc Siva 

If condition help

Hi All,
Can anyone please help me to create if condition for below
1.If opportunity having Owner role= Partner and then it is getting closed within 30 days after creation and If opportunity contains any partner Relate list then check box is true
2.If opportunity does not having Owner role= Partner and then it is getting closed within 45 days after opportunity creation if opportunity does not contain any partner related lists then check box is true.
And there is an OR condition between these two.

Thanks
 
Jasper WallJasper Wall
Hi Siva,
try like this,
List<Opportunity> opplist=[SELECT role,createddate,checkbox__c,closedDate,(SELECT Id FROM Partner_r) FROM Opportunity];
List<Opportunity> updlist=new List<Opportunity>();
for(Opportunity opp:opplist){
     if(opp.role=='Partner'){
           opp.ClosedDate=opp.createddate+30;
           if(opp.Partner__r!=null){
                 opp.checkbox__c=true;
           }
     }
    if(opp.role!='Partner'){
           opp.ClosedDate=opp.createddate+45;
           if(opp.Partner__r!=null){
                 opp.checkbox__c=true;
           }
     }
    updlist.add(opp);
}
update updlist;

Mark it as the best answer if it helps,

Thanks,
Balayesu

 
Jasper WallJasper Wall
try like this,
for(opportunity opp : [SELECT CategoryName,Id,RecordTypeId,Role_Name__c,createddate,checkbox,closedDate,(SELECT Id FROM OpportunityPartner) FROM Opportunity]){
    if(oppMap.get(opp.id)!=null){
        for(Opportunitysplit opss : oppMap.get(opp.id)){
            if((opp.CategoryName=='Best' || opp.CategoryName=='Agree')&& opp.RecordTypeId== devRecordTypeId && sscmap!=null && sscmap.get(opss.SplitOwnerid)!=null &&(opss.Role_Name__c==' Channel Manager'||opss.Role_Name__c==' Account Manager')&&((sscMap.get(opss.SplitOwnerid).Quota__c!=null&& (sscMap.get(opss.SplitOwnerid).Quota__c/2 <= opss.SplitAmount))|| (sscMap.get(opss.SplitOwnerid).Manager_Quota__c!=null && opss.SplitAmount >=sscMap.get(opss.SplitOwnerid).Manager_Quota__c*25/100))){
                opp.CheckBox=true;
                break ;                
            }else
                opp.CheckBox=false;
        }
        if(opp.Role_Name__c=='Partner'){
           opp.ClosedDate=opp.createddate+30;
           if(opp.OpportunityPartner.size()>0){
                 opp.checkbox=true;
           }
     }
    if(opp.Role_Name__c!='Partner'){
           opp.ClosedDate=opp.createddate+45;
           if(opp.OpportunityPartner.size()==0){
                 opp.checkbox=true;
           }
     }


    }
}


Thanks,
Balayesu