• Sri 7
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
global class ZuoraProductRatePlanChargeHandlerBatch implements Database.Batchable<sObject>
{    
    global Database.QueryLocator start(Database.BatchableContext BC){
        String Query ='SELECT Id, Rate_Plan_Charge__c, Rate_Plan_Charge__r.Invoice_Display_Name__c,Subscription_Product_Charge__c,Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c,Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.id,Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c FROM SPG_Product_User__c WHERE Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__c != null'; 
        return database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext Bc, List<SPG_Product_User__c> puList){        
        map<id, Zuora__SubscriptionRatePlan__c> mapValues = new Map<Id, Zuora__SubscriptionRatePlan__c>();
        for(SPG_Product_User__c pu:puList){
            if(pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c != null &&  pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c == pu.Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c){
            
            }else if(pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c == null || (pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c != null &&  pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c != pu.Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c))
            {
                if (!mapValues.containsKey(pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__c)){
                    Zuora__SubscriptionRatePlan__c tempSRP = new Zuora__SubscriptionRatePlan__c();
                        tempSRP.Id=pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.id;                    
                        tempSRP.PRPC_Invoice_Display_Name__c = pu.Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c != null ? pu.Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c : pu.Rate_Plan_Charge__r.Invoice_Display_Name__c;
                        mapValues.put(tempSRP.Id,tempSRP);
                } 
                else {
                        mapValues.get(pu.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__c).PRPC_Invoice_Display_Name__c = pu.Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c != null ? pu.Subscription_Product_Charge__r.PRPC_Invoice_Display_Name__c : pu.Rate_Plan_Charge__r.Invoice_Display_Name__c;
                }
            }
        } 
        if(mapValues.size() >0 ){
            update mapValues.values();
            
        }        
    }
    global void finish(Database.BatchableContext BC){        
    }
}


Thanks in Advance
 
  • December 02, 2018
  • Like
  • 0
global class ZuoraProductRatePlanChargeHandlerBatch implements Database.Batchable<sObject>
{    
    global Database.QueryLocator start(Database.BatchableContext BC){
        system.debug('ProductRatePlanCharge');        
        String query = 'select id,Invoice_Display_Name__c,(select id,Name,Subscription_Product_Charge__c,Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__c,Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c from Product_Users__r where Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c!=null) from zqu__ProductRatePlanCharge__c where Invoice_Display_Name__c!=null';
        return database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext Bc, List<zqu__ProductRatePlanCharge__c> prpcList){
        Set<Zuora__SubscriptionRatePlan__c> srplist = new Set<Zuora__SubscriptionRatePlan__c>();
        for(zqu__ProductRatePlanCharge__c each:prpcList){
            if(each.Product_Users__r !=null){
                List<SPG_Product_User__c> tempUsers = each.Product_Users__r;
                for(SPG_Product_User__c eachUser:tempUsers){
                    if(eachUser.Subscription_Product_Charge__c!=null){
                        if(eachUser.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__c!=null){
                            if(each.Invoice_Display_Name__c!=eachUser.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__r.PRPC_Invoice_Display_Name__c){
                                Zuora__SubscriptionRatePlan__c tempSRP = new Zuora__SubscriptionRatePlan__c();
                                tempSRP.Id=eachUser.Subscription_Product_Charge__r.Zuora__SubscriptionRatePlan__c;
                                tempSRP.PRPC_Invoice_Display_Name__c = each.Invoice_Display_Name__c;
                                srplist.add(tempSRP);
                            }                         
                        }
                    }                    
                }
            }            
        }
        if(srplist.size() >0 ){
            List<Zuora__SubscriptionRatePlan__c> tempList = new List<Zuora__SubscriptionRatePlan__c>();
            tempList.addAll(srplist);
            update tempList;
        }        
    }
    global void finish(Database.BatchableContext BC){        
    }
}
  • November 30, 2018
  • Like
  • 0
here it is class:

public class ZuoraProductRatePlanChargeTriggerHandler{

public static void UpdatePRPCIDNLineitems(map<Id,zqu__ProductRatePlanCharge__c> mapPRPC){

    Map<Id,Id> mapInvName = new Map<Id,Id>();
    List<Zuora__SubscriptionRatePlan__c> lstSub = new List<Zuora__SubscriptionRatePlan__c>();
       
    for(SPG_Product_User__c lstpc:[select id,Subscription__c,Rate_Plan_Charge__c from SPG_Product_User__c where Rate_Plan_Charge__c IN :mapPRPC.keyset() AND Subscription__c != Null])
    {
            mapInvName.put(lstpc.Subscription__c,lstpc.Rate_Plan_Charge__c);
    }
    
    for(Zuora__SubscriptionRatePlan__c lstsrp : [select id,PRPC_Invoice_Display_Name__c,Zuora__Subscription__c from Zuora__SubscriptionRatePlan__c where Zuora__Subscription__c IN :mapInvName.keyset()])
    {   
        Id IdVal =mapInvName.get(lstsrp.Zuora__Subscription__c);
        lstsrp.PRPC_Invoice_Display_Name__c = mapPRPC.get(IdVal).Invoice_Display_Name__c;
        
        lstSub.add(lstsrp);
    }     
                
   if(lstSub.size()>0)
        update lstSub ;   
    
 } 

}

Trigger:
trigger TriggerToUpdatePRPCInvoiceDisplayName on zqu__ProductRatePlanCharge__c(after insert, after update) 
{   
    if(Trigger.isAfter)
    {
        // Added this line as part of US#1168855
        if ((Trigger.isInsert || Trigger.isUpdate)&& (Test.isRunningTest() ||SPG_checkRecursive.runOnce()) ){
            ZuoraProductRatePlanChargeTriggerHandler.UpdatePRPCIDNLineitems(trigger.newmap);
        }
    }
    
}
  • November 15, 2018
  • Like
  • 0
    public static void iqId(List<Account> iqList){
        
        for(Account eachAccount: iqList){
            if(eachAccount.IQ_ID__c!=null){
                system.debug('IQ_ID__c');
                if(!eachAccount.Sales_Ops__c){
                    
                    eachAccount.C_Name__c=eachAccount.Ultimate_Parent__c;
                    eachAccount.H_ID__c=eachAccount.Ultimate_Parent_Id__c;
                } else {
                    if (eachAccount.ParentId != null){
                        Map<string,string> ultimateDetails = getultimate(eachAccount.ParentId);
                        List<string> ultimateId = new List<string>();
                        ultimateId.addAll(ultimateDetails.keyset());
                        eachAccount.C_Name__c=ultimateDetails.values()[0];
                        eachAccount.H_ID__c=ultimateId[0];
                    }
                }
            }
        }
    }
    public static Map<string, String> getultimate(string parentAccount){
        boolean isSFDCUltimate = true;
        Map<string, string> ultimateParent = new Map<string, string>();
        while(isSFDCUltimate){
            Account temp = [select Id, Name, ParentId, IQ_ID__c from Account Where Id=:parentAccount];
            if (temp.ParentId==null){
                ultimateParent.put(temp.IQ_ID__c, temp.Name);
                break;
            }else {
                parentAccount=temp.ParentId;
            }
        }
        return ultimateParent;
    }
  • July 27, 2018
  • Like
  • 0
Scenario 1: The ‘C Name Lookup’, field has the ability to reflect itself if it is at the top of the Hierarchy. 
Given there's an Salesforce account with a 'CI company ID'
and 'CI company id' is equal to the 'CaI Ultimate parent Company ID'
When 'CaI Ultimate parent Company ID' is created or modified and 'Override C Name' is not checked
Then the ‘C Name Lookup’ field should be the 'Account' itself.
  • June 26, 2018
  • Like
  • 0
here it is class:

public class ZuoraProductRatePlanChargeTriggerHandler{

public static void UpdatePRPCIDNLineitems(map<Id,zqu__ProductRatePlanCharge__c> mapPRPC){

    Map<Id,Id> mapInvName = new Map<Id,Id>();
    List<Zuora__SubscriptionRatePlan__c> lstSub = new List<Zuora__SubscriptionRatePlan__c>();
       
    for(SPG_Product_User__c lstpc:[select id,Subscription__c,Rate_Plan_Charge__c from SPG_Product_User__c where Rate_Plan_Charge__c IN :mapPRPC.keyset() AND Subscription__c != Null])
    {
            mapInvName.put(lstpc.Subscription__c,lstpc.Rate_Plan_Charge__c);
    }
    
    for(Zuora__SubscriptionRatePlan__c lstsrp : [select id,PRPC_Invoice_Display_Name__c,Zuora__Subscription__c from Zuora__SubscriptionRatePlan__c where Zuora__Subscription__c IN :mapInvName.keyset()])
    {   
        Id IdVal =mapInvName.get(lstsrp.Zuora__Subscription__c);
        lstsrp.PRPC_Invoice_Display_Name__c = mapPRPC.get(IdVal).Invoice_Display_Name__c;
        
        lstSub.add(lstsrp);
    }     
                
   if(lstSub.size()>0)
        update lstSub ;   
    
 } 

}

Trigger:
trigger TriggerToUpdatePRPCInvoiceDisplayName on zqu__ProductRatePlanCharge__c(after insert, after update) 
{   
    if(Trigger.isAfter)
    {
        // Added this line as part of US#1168855
        if ((Trigger.isInsert || Trigger.isUpdate)&& (Test.isRunningTest() ||SPG_checkRecursive.runOnce()) ){
            ZuoraProductRatePlanChargeTriggerHandler.UpdatePRPCIDNLineitems(trigger.newmap);
        }
    }
    
}
  • November 15, 2018
  • Like
  • 0
    public static void iqId(List<Account> iqList){
        
        for(Account eachAccount: iqList){
            if(eachAccount.IQ_ID__c!=null){
                system.debug('IQ_ID__c');
                if(!eachAccount.Sales_Ops__c){
                    
                    eachAccount.C_Name__c=eachAccount.Ultimate_Parent__c;
                    eachAccount.H_ID__c=eachAccount.Ultimate_Parent_Id__c;
                } else {
                    if (eachAccount.ParentId != null){
                        Map<string,string> ultimateDetails = getultimate(eachAccount.ParentId);
                        List<string> ultimateId = new List<string>();
                        ultimateId.addAll(ultimateDetails.keyset());
                        eachAccount.C_Name__c=ultimateDetails.values()[0];
                        eachAccount.H_ID__c=ultimateId[0];
                    }
                }
            }
        }
    }
    public static Map<string, String> getultimate(string parentAccount){
        boolean isSFDCUltimate = true;
        Map<string, string> ultimateParent = new Map<string, string>();
        while(isSFDCUltimate){
            Account temp = [select Id, Name, ParentId, IQ_ID__c from Account Where Id=:parentAccount];
            if (temp.ParentId==null){
                ultimateParent.put(temp.IQ_ID__c, temp.Name);
                break;
            }else {
                parentAccount=temp.ParentId;
            }
        }
        return ultimateParent;
    }
  • July 27, 2018
  • Like
  • 0
Scenario 1: The ‘C Name Lookup’, field has the ability to reflect itself if it is at the top of the Hierarchy. 
Given there's an Salesforce account with a 'CI company ID'
and 'CI company id' is equal to the 'CaI Ultimate parent Company ID'
When 'CaI Ultimate parent Company ID' is created or modified and 'Override C Name' is not checked
Then the ‘C Name Lookup’ field should be the 'Account' itself.
  • June 26, 2018
  • Like
  • 0