• vasu sfdc_21
  • NEWBIE
  • 20 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
Hi Folks,

I'm stuck in below requirement.Getting error because of process builder and validation rule and it's not working. Can we do by apex class and trigger with custom lable or what is the best way. please help me out ..

Task:  
System automation to prevent early stage opportunities with unrealistic, near term close dates. 

Ask:
For early stage pipeline opportunities, automatically push the close date to align to ‘healthy’ pipeline metrics:  

30% - Expressed Interest >45d, 
20% - Solution Identified >60d; 
10% - Discovery >75d; 
1% - New >90d

Autoclose:
Last modified Date >60 days
Stage Duration >120 days 

If a user tries to save an opportunity that violates these guidelines, display a message that lists the close date expectations and directs them to contact sales ops if an override is needed. 


Thanks !!
 
Hi All,

Can someone help me with Trigger test class for the below trigger?

Trigger SubscriptionTrigger on SBQQ__Subscription__c (After Insert,After update){

            Map<Id,Set<String>> contractIdVsProductGrp    = new Map<Id,Set<String>>();        
            Set<Id> contractIdset                         = new Set<Id>();
            List<Contract> lstUpdateContracts               = new List<Contract>();

            for(SBQQ__Subscription__c sub:Trigger.New){
            ContractIdset.add(sub.SBQQ__Contract__c);    //fetcting Contract ids - lookup to SBQQ__Subscription__c object
            }
    
            //fetching all subscription records(Product groups names) related to contracts

        for(SBQQ__Subscription__c sb : [Select Id,SBQQ__Contract__c,SBQQ__Product__c,SBQQ__Product__r.Product_Group__c from SBQQ__Subscription__c where SBQQ__Contract__c in :contractIdset])
        {
        
            if(contractIdVsProductGrp.containsKey(sb.SBQQ__Contract__c)){
            
                contractIdVsProductGrp.get(sb.SBQQ__Contract__c).add(sb.SBQQ__Product__r.Product_Group__C);
            }
            else{
                contractIdVsProductGrp.put(sb.SBQQ__Contract__c, new Set<String>{sb.SBQQ__Product__r.Product_Group__C});
            }
        }
    

    
    //Subscriptions parent (contract) needs to update with Product groups name
    for(Id contId:contractIdset){
        Contract parentContract = new Contract(Id = contId);
        String prdGrps = '';
        if(!contractIdVsProductGrp.isEmpty() && contractIdVsProductGrp.containsKey(contId)){
            for(String prdGrpStr : contractIdVsProductGrp.get(contId)){
                if(prdGrps == ''){
                    prdGrps = prdGrpStr;
                }
                else{
                    prdGrps += ','+prdGrpStr;
                }
            }
            parentContract.Product_Group__C = prdGrps;
            lstUpdateContracts.add(parentContract);
        }//if close
    }//for loop close
    

    //update contracts
                if(lstUpdateContracts.size() > 0){
                    update lstUpdateContracts;
          }

    }
 
Hi Folks,

Please help me out below trigger

After creating opportunity then on Contract  for Product Group is not getting populated  when contract has been created in salesforce.


Product_Group__c picklist values are below 
Chrome - CFM License
GAME
Google Cloud Identity
ISV - AODocs
 
Hi Folk,

Trying to write  a soql query on opportunity for Opportunity Status value but getting error bacause value not coming.

Please help me out  soql query for opportunity status value.
How can we wrtite Opportunity status field in the result. 

Any
Open
Closed
Colsed One


 
Hi Folks,

Please help me out below trigger

After creating opportunity then on Contract  for Product Group is not getting populated  when contract has been created in salesforce.


Product_Group__c picklist values are below 
Chrome - CFM License
GAME
Google Cloud Identity
ISV - AODocs
 
Hi Folk,

Trying to write  a soql query on opportunity for Opportunity Status value but getting error bacause value not coming.

Please help me out  soql query for opportunity status value.
How can we wrtite Opportunity status field in the result. 

Any
Open
Closed
Colsed One


 
Hi there,

I got the feeling that I'm almost there. My test class shows a disappointing 0% coverage. What am I doing wrong?

This is my trigger (works in my sandbox, aside from an unintended modulation to my corporate currency <- solved with custom formula field):
trigger TotalAmountTrigger on Account (after insert, after update, after delete, after undelete)
{
    Set<Id> accountIds = new Set<Id>();
    for(Account c: Trigger.isDelete? Trigger.old : Trigger.new){
        if(c.GroupName__c  != null)                                                     
        {
            accountIds.add(c.GroupName__c );
        }
    }  
    List<CustomerGroups__c> accList = new List<CustomerGroups__c>();
    for(AggregateResult currentAggResult:[SELECT GroupName__c  accId, SUM(Customer_Loan_Amount__c ) sumAmt FROM Account  WHERE GroupName__c  in:accountIds GROUP BY GroupName__c ])
    {
        CustomerGroups__c acc = new CustomerGroups__c();
        acc.Id = (Id)currentAggResult.get('accId');
        acc.Customer_Group_OLB__c = (decimal)currentAggResult.get('sumAmt');
        accList.add(acc);
        accountIds.remove((Id)currentAggResult.get('accId'));
    }
   
    for(Id currAccId : accountIds)
    {
        CustomerGroups__c acc = new CustomerGroups__c();
        acc.Id = currAccId;
        acc.Customer_Group_OLB__c = null;
        accList.add(acc);
    }
    update accList;
}

This is my (under performing) test class:
 
@isTest
public class TestTrigger1 
{
    static testMethod void testMethod1() 
    {
         CustomerGroups__c p = new CustomerGroups__c ();
       	p.Name='testgroup';
        insert p;
        
        Account c = new Account(GroupName__c = p.id);
		c.Name='CustomerTest';
        c.Date_of_Sale__c=date.today();
        c.Invoice_No__c='123';
        c.GroupName__c='Rotterdam Group';
        c.CurrencyIsoCode ='ZAR';
		insert c;
       
        Opportunity g = new Opportunity (AccountId = c.id);
        g.Name='OpptyTest';
        g.CloseDate=date.today();
        g.CurrencyIsoCode ='ZAR';
        g.StageName='Closed Won';
        insert g;
        
        OpportunityLineItem b = new OpportunityLineItem (OpportunityId = g.id);
        b.Owed_so_far__c=100;
        b.Paid_so_far__c=5;
     	b.Quantity=1;
        b.TotalPrice=1000;
        insert b;
        
        Product2 f = new Product2 (Id = b.id);
        f.Name='ACE1 R1,080  9Month Credit';
        f.CurrencyIsoCode='ZAR';
        insert f;
        
    }
}

The help so far has already been awesome, thanks again you all!

Thijs
 
HI
I got the error in the Trigger Test Class.The error is Selected job is not yet complete in Apex Test Execution.


Thanks&Regards
Ranga