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
sieb4mesieb4me 

formulla instead of code

Hi,

I wish to remove code and accomplish this on forumullas, is it possible?

 

thanks

 

 

 

 

lstOppty = [Select Id, Name, AccountId,Probability, Amount, Net_License_Revenue__c, Maintenance__c, PS__c, ES__c,
                        Other__c, Total__c, INFA_Forecast_Category__c, DatedConversionRate__c from Opportunity 
where AccountId in : accountIdList
AND StageName IN ('Compliance Prep','Validated','Working','Qualified Suspect','Received','Qualify Opportunity','Discover Needs','Validate Solution','Negotiate','Paperwork to SOG','Negiotiations & Paperwork','Onsite Quote Sent','Lead or Interest Shown','Date selected, funding approved','Quote Sent','Training purchased,sitting in deferred','Date selected, funded, payment not made','Student registered, payment made','Credits being used for training','Course delivered or credits expired','Delivered','Agreement sent','Agreement Signed','Onsite','Awaiting Renewal')
                        AND CloseDate = THIS_QUARTER 
                        AND CloseDate <= NEXT_QUARTER order by AccountId];


//CountOpportunity = lstOppty.size();
Id previousAcctId = null;
SLic = 0;
//Decimal conRate = ?
Integer oppCount = 0;
Integer caseIndex = 0;
for (Opportunity opp: lstOppty){
    String thisAcctId = opp.AccountId;
    if (thisAcctId != previousAcctId) {
        if (previousAcctId != null) {
            // skip past any non matching account id's - should not be any
            while ((caseIndex < lstCase.size()) && (lstCase[caseIndex].AccountId != previousAcctId)) 
                caseIndex++;
            while ((caseIndex < lstCase.size()) && (lstCase[caseIndex].AccountId == previousAcctId)) {
                Case c = lstCase[caseIndex];
                if ((c != null) && (c.Status !=null)) {
                
                c.Sum_License__c = SLic;
                c.Count_Opportunity__c =  oppCount;
                c.Sum_ES__c = SEs;
                c.Sum_Maintenance__c = SMain;
                c.Sum_Other__c = SOth;
                c.Sum_PS__c = SPs;
                c.Sum_Total__c = STot;
                //c.Status = 'Working';
                    cs.add(c);            
                }
                caseIndex++;
            }
        }
        previousAcctId = thisAcctId;
        SLic = 0;
        oppCount = 0;
        
    }
    oppCount++;

    if(opp.DatedConversionRate__c != null && opp.DatedConversionRate__c != 0){
                conRate = 1/opp.DatedConversionRate__c;
            }else{
                conRate=1;
            }
            
            if(opp.Amount != null){
                SLic += opp.Amount*conRate;
            }
            

sieb4mesieb4me

let me clarify actually, all i need is to accoumplish following in formulla, is it possible?

 

                       AND CloseDate = THIS_QUARTER 
                        AND CloseDate <= NEXT_QUARTER order by AccountId];

T-HanT-Han

So you want 2 formula fields to be calculated based on your cndition given?