• MaheemSam
  • NEWBIE
  • 245 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 99
    Questions
  • 87
    Replies
Hi, 
  
Please suggest me how to update all child and grand child when parent account field is updated in account. 

Example: Each account has a parent lookup field of account. 

We created a checkbox called Global in account when this field is updated in account all its assocaited children and grand children "Global Account" checkbox should be checked please suggest me how to add this logic. Similarly when unchecked all childres and grand childrens should get "Global Account" be unchecked. 

Thanks
Sudhir 
Hi, 

  I made pick list required from page layout able to remove none from picklist in classic but in lightning its still showing as none please suggest me how to remove none from picklist in lightninig. 

Thanks
Sudhir
Hi, 

   I want a help in building a condition in process builder to fire only for the first quote in opportunity. Here opportunity and quote (CPQ custom object) there is not direct relation. 

Can you suggest me how to add a logic to fire the process builder only for first quote when it is created. 

Thanks
Maheem
Hi, 

  In excel data is 98.2134% I want to upload this to a custom object Margin guidance which has green which is a percentage filed. 

 I tried to convert this to a number format but the value is getting stored as 0.98 instread of 98.21% 

 Please suggest me how to use which format. 

Thanks
Sudhir
Hi, 
trigger OpportuntiyDelete on Opportunity (Before Delete) {
 
    list<SBQQ__Quote__c> qt = [select id from SBQQ__Quote__c where  SBQQ__Opportunity2__c = :trigger.oldmap.keyset()]; // Here it is always returning 0 even if it has data to return. 
   
   for(opportunity opp: trigger.old){

      opp.adderror('Opportunity record cannot be deleted' + ' '  + qt.size() + ' ' + opp.id + ' ' + cpqid  + ' ' + trigger.oldmap.keyset());

    }
}

This list is returning 0 values even if data existing for opportunity. 

  list<SBQQ__Quote__c> qt = [select id from SBQQ__Quote__c where  SBQQ__Opportunity2__c = :trigger.oldmap.keyset()]; 

SBQQ__Quote__c is not a child object it has a lookup value of opportunity there is a no master child relationship. Please suggest me how to fix. 

Thanks
Sudhir

 
Hi, 
    
    I am trying to implement a delete validation on opportunity object using a trigger but I keep getting Attempt to de-reference a null object error please suggest me what is the issue in this code. 
public static void processOptyDelete(List<Opportunity> newLst){

    List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()];
     for(Opportunity opp: newLst){
       for(SBQQ__Quote__c sqt : cpqqt){
          if(opp.id == sqt.SBQQ__Opportunity2__c){
             opp.addError('Opportunity have Quotes ,so you can not delete this opportunity');
           }
       }  
     } 
 }

Error is coming from line below
List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()];

Please let me know if there are any other way to fix this issue. 

Thanks
Sudhir
Hi, 

  Below formula field is not working on rollup field "number" please suggest me what will be the alternative way for below formula. 
 
AND 
(OR( 
TEXT(ApprovalStatus__c) = 'Pending', 
TEXT(ApprovalStatus__c) = 'Approved' ),
Quote_Lines_Count__c <> PRIORVALUE(Quote_Lines_Count__c),
$User.Id != "005300000011QKX" 
)
Thanks
Sudhir
 
Hi, 
   
   Below is the validation in opportunity when a new lead is converted it keeps firing, We have used NOT(ISNEW()) function but still while creating a new opportunity from lead convertion this validation keeps firiing please suggest how to fix this issue. 
AND(
NOT(ISPICKVAL(Deal_Type__c, "Renewal")),
ISBLANK( TEXT( Operational_Technology_Opportunity__c )),   RecordTypeId  <> "01280000000UNnc",
RecordTypeId  <> "0123000000009UT",
RecordTypeId  <> "0123400000047wC",
NOT(ISPICKVAL(StageName, "Pending Initial Meeting")),  
$User.Id <> "005300000011QKX",
NOT(ISNEW())
)

Thanks
Sudhir
Hi, 

  Is there a way to prepare report based on contract object and associated attachment. 

Thanks
Sudhir
Hi, 

   We have few scheduled dashbboards running on inactive user we want to change to a active user please suggest us know to change. 

Thanks
Maheem
Hi, 

   Is there a way to prepare a report in salesforce with gives notes and attachement for user to download. 

Thanks
 
Hi, 

   Like ISNEW() function is there any methods or way to identify a record a deleted please suggest. 

  I want to avoid users deleting from quotelines when quote is approved or pending 

Thanks
Sudhir
Can we get a prior value in rollup helper? 
Hi, 

  I want to implement a logic in pop-page component, add a checkbox on page when user confirms not to display page it should not display further. How to implement this logic.

Thanks
Sudhir 
Hi, 

  Created a popup using lightning component using CSS am creating style sheets. 

I want to reduce the space between messages please suggest me how to fix


User-added image
Component
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="PopupMessageController">  
    <aura:attribute name="ListOfMessage" type="Popup_Message__c[]" description="displayes list of messages"/>
    <aura:handler name='init' action="{!c.doInit}" value="{!this}" /> 
    <aura:attribute name="isOpen" type="boolean" default="False" />
    
    <aura:if isTrue="{!and(v.isOpen,v.ListOfMessage != null)}"> 
         
    <div class="slds-backdrop" aura:id="Modalbackdrop"></div>         
        <div role="dialog" aria-labelledby="header43" class='pop-up slds-modal' aura:id="popupDiv1">
            <div class="slds-modal__container">
                <div class="slds-modal__pinner">                      
                    <div class="message">	
                        <!-- <p>Sudhir First </p> -->                         
                        <ul>
      					<aura:iteration items="{!v.ListOfMessage}" var="msg">
                            <li type="dice" style="margin: 0;padding: 0.2em;display: inline-block;">{!msg.Message_Text__c}</li>
  						 <hr/>
      					</aura:iteration>
   						</ul>
                     </div>                                           
                    <div class="slds-form-element">
                        <lightning:button variant="success" label="Ok" title="ok" onclick="{!c.close }" class="OKButton button4"/>
                    </div>
                </div>                    
            </div>
            
        </div>   
        <aura:set attribute="else">
             <div> 
            </div> 
        </aura:set>
   </aura:if> 
</aura:component>

Controller
({
    doInit : function(component, event, helper) {
        var action = component.get('c.fetchMessage',true);
        action.setCallback(this, function(response) {
        //store state of response
        var state = response.getState();
        if (state === "SUCCESS") {
         //set response value in ListOfMessage attribute on component.
         component.set('v.ListOfMessage', response.getReturnValue());
         }
       });
        $A.enqueueAction(action); 
        var temperorySession = localStorage.getItem('tempSession');
        if(temperorySession == '1')
        {  
            component.set("v.isOpen", true); //This should be set to false to testing set to true
        }
        else
        {
            component.set("v.isOpen", true);
            var cmpTarget1 = component.find('popupDiv1');
            var cmpBack1 = component.find('Modalbackdrop1');
            $A.util.addClass(cmpTarget1, 'slds-fade-in-open');
            $A.util.addClass(cmpBack1, 'slds-backdrop--open');
            $A.enqueueAction(action); 
        }
        localStorage.setItem('tempSession', '1');
        
    },
    close: function(component, event, helper) {
        component.set("v.isOpen", false);
    }
})

CSS
.THIS.pop-up {
    display: block;
    opacity: 1;
    visibility: visible;
    overflow: auto;
    background-color:#000;
}

.THIS .slds-modal__inner {
    padding: 10px;
    text-align:left;
    overflow-y: scroll;
}

.THIS .slds-modal__pinner {
    background: #fff;
    padding: 10px;
    font-size: 12px; 
    font-weight: bold;
    overflow-y: scroll;
}
.THIS .OKButton{
   -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0px;
  font-family: Arial;
  color: #ffffff;
  font-size: 20px;
  background: #91989c;
  padding: 6px 15px 9px 13px;
  text-decoration: none;
}
.THIS .OKButton:hover {
  background: #5c575c;
  text-decoration: none;
}


Thanks
​​​​​​​
 
Hi, 
 
 In below code popup alert is displayed in home page for first time only when user login 

 Below code is working perfect in lightning in salesforce I want to make it work in mobile app as well please suggest me how to implement this feature. 


  Aura Component:
<aura:component 
               implements="flexipage:availableForAllPageTypes"
                access="global">
    <aura:handler name='init' action="{!c.init}" value="{!this}" />
    <aura:attribute name="isOpen" type="boolean" default="false" />
    <div class="slds-backdrop" aura:id="Modalbackdrop"></div>
    <aura:if isTrue="{!v.isOpen}">
        <div role="dialog" tabindex="-1" aria-labelledby="header43" class='pop-up slds-modal' aura:id="popupDiv1">
            <div class="slds-modal__container">
                <div class="slds-modal__pinner">
                    <div class="message">
                        <p>You logged into salesforce Lightning </p>                    
                    </div>
                    <div class="slds-form-element">
                        <lightning:button variant="success" label="Ok" title="ok" onclick="{! c.close }" />
                        
                    </div>
                </div>
            </div>
        </div>
    </aura:if>
</aura:component>
JS Controller:
({
    init : function(component, event, helper) {
        var temperorySession = localStorage.getItem('tempSession');
        if(temperorySession == '1')
        {  
            component.set("v.isOpen", false);
        }
        else
        {
            component.set("v.isOpen", true);
            var cmpTarget1 = component.find('popupDiv1');
            var cmpBack1 = component.find('Modalbackdrop1');
            $A.util.addClass(cmpTarget1, 'slds-fade-in-open');
            $A.util.addClass(cmpBack1, 'slds-backdrop--open');
        }
        localStorage.setItem('tempSession', '1');
        
    },
    close: function(component, event, helper) {
        component.set("v.isOpen", false);
    }
})

STYLE:
.THIS.pop-up {
    display: block;
    opacity: 1;
    visibility: visible;
}

.THIS .slds-modal__inner {
    background: yellow;
    padding: 20px;
    text-align:left;
}

.THIS .slds-modal__pinner {
    background: #fff;
    padding: 20px;
}


 
Hi,

 In below component <aura:if isTrue="{!v.erpId == null}"> is not retuning please suggest me what might be the issue here. 
 
v.erpid is not returning value from controller in component. 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global"  controller="POTrackerExtLtn">
	<aura:attribute name="act" type="Object"/>
	<aura:attribute name="key" type="String" access="private"/>
    
     <force:recordData aura:id="forceRecord"
                      recordId="{!v.recordId}"
                      targetFields="{!v.act}"
                      fields="accountId,userId,erpId,region,quoteIds"
                      recordUpdated="{!c.handleRecordUpdated}"
                      mode="EDIT" />
    <div class="slds-box slds-theme_info">
        
<aura:if isTrue="{!v.erpId == null}">
	<p>"Oracle ERP disti ID" is not set for this account. Please contact system administrator for more information. </p>
    <aura:set attribute="else">
        <p>PO Tracker is lunched in New window!</p>
    </aura:set>
</aura:if>
        
    </div>
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
</aura:component>

Class. 
public class POTrackerExtLtn{
      
    @AuraEnabled
    public static String getAccessKey(ID recordId){
         ID accountId; 
         ID userId;
         String erpId;
         string region;
         string quoteIds;
         String userarea;
         string commaQuoteIds;    
       list<String> CommastrList = new List<String>();
       
       list<SBQQ__Quote__c> QtAprd = [select id, Quote_ID__c,SBQQ__Opportunity2__r.ownerid,
                                     SBQQ__Opportunity2__r.accountid,SBQQ__Opportunity2__r.account.Oracle_ERP_ID__c,
                                     SBQQ__Opportunity2__r.owner.Area__c,SBQQ__Opportunity2__r.owner.Region_New__c,
                                     SBQQ__Opportunity2__r.API_Session__c,SBQQ__Opportunity2__r.API_Partner_Server_100__c,
                                     SBQQ__Opportunity2__r.Distributor__r.Account__c,
                                     SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c
                                     from SBQQ__Quote__c 
                                     where SBQQ__Opportunity2__c = :recordId and ApprovalStatus__c = 'Approved'];   
    
       for(SBQQ__Quote__c str : QtAprd){
       
           if(str.Quote_ID__c != null){
                CommastrList.add(str.Quote_ID__c);     
            }     
            
            
            accountId = str.SBQQ__Opportunity2__r.Distributor__r.Account__c;
            userId    = str.SBQQ__Opportunity2__r.ownerid;
             
             if(str.SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c != null){
             erpId     = String.valueof(str.SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c);
             }
             
             region    = str.SBQQ__Opportunity2__r.owner.Region_New__c;
             quoteIds  = commaQuoteIds;
        }
    
        commaQuoteIds = String.join(CommastrList,','); //Quote Id in comma separated format. 
        
          system.debug('Debug from POTrackerExtLtn commaQuoteIds ' + commaQuoteIds);
          system.debug('Debug from POTrackerExtLtn accountId ' + accountId );
          system.debug('Debug from POTrackerExtLtn userId    ' + userId );
          system.debug('Debug from POTrackerExtLtn erpId ' + erpId);
          system.debug('Debug from POTrackerExtLtn region    ' + region    );
          system.debug('Debug from POTrackerExtLtn quoteIds  ' + commaQuoteIds );
          
             String input = 'accountId=' + accountId  +
                        '&erpId='+erpId +
                        '&userId='+userinfo.getUserId() +
                        '&region='+region +
                        '&quoteIds='+commaQuoteIds +                        
                        '&timestamp=' + System.currentTimeMillis();
                        
        String key = EncryptionSSOUtils.encryptWithAES128(input);
        system.debug('Key_noendcode_'+key);
        key = EncodingUtil.urlEncode(key,'UTF-8');
        system.debug('Key__endcode__'+key);
        return key; 
        
         

    }
    
}

 
Hi,
  
 In below code it converts list to a comma seprated value problem here it added comma at the end please suggest me how to remove the end comma 
Boolean chkcomma = false;

// a list of string, you wanna display

list<String> QtAprd = new list<string>{'A','B','C','D','E','F'};

// making a single string with comma seprated from above list

String commaSepratedList='';

for(String str : QtAprd)

{
 if (chkcomma)
     
 commaSepratedList += str + ',' ;
  chkcomma = true;
}

system.debug(commaSepratedList);

Thanks
Sudhir
Hi, 

   When user logs in using lightning is there  a way to build a popup page with a message please suggest me how to implement this feature. 

Thanks
Sudhir
Hi, 

  For Class   
public class LeadTriggerUtils {
    
    public static void processLeadOnUpdate(Map<id, Lead> newMap, Map<id, Lead> oldMap) { 
        List<Lead> leadLst = new List<Lead>();
        for (Lead lead : newMap.values()) {
            Lead oldLead = oldMap.get(lead.id);
            if(lead.rvpe__IsDealRegistration__c && lead.rvpe__RVAccount__c != null && lead.rvpe__RVAccount__c != oldLead.rvpe__RVAccount__c) {
        leadLst.add(lead);
            }
        }
        if(!leadLst.isEmpty()) {
      processChangeOwnerAsPartnerAccount(leadLst); 
        }
    }
    
    public static void processLeadOnInsert(List<Lead> newLst) {
      processChangeOwnerAsPartnerAccount(newLst);
    }
    public static void processChangeOwnerAsPartnerAccount(List<Lead> newLst) {
        List<ID> rvAcctIDs = new List<ID>();
        for(Lead lead : newLst) {
            if(lead.rvpe__IsDealRegistration__c && (lead.Global_Region__c == 'EMEA' || lead.Global_Region__c == 'LATAM') && lead.rvpe__RVAccount__c != null) {
                rvAcctIds.add(lead.rvpe__RVAccount__c);
            }
        }
        Map<ID, rvpe__RVAccount__c> rvActMap = new Map<Id, rvpe__RVAccount__c>([select id, rvpe__SFAccount__c, rvpe__SFAccount__r.OwnerId from rvpe__RVAccount__c where id in :rvAcctIDs]);
        for(Lead lead : newLst) {
            rvpe__RVAccount__c rvAct = rvActMap.get(lead.rvpe__RVAccount__c);
            if(rvAct != null && rvAct.rvpe__SFAccount__c != null) {
                lead.OwnerId = rvAct.rvpe__SFAccount__r.OwnerId;
            }
        }
    }
}

Below is the test class it has 90% code coverage. 
@isTest(seealldata = true)
public class LeadTriggerUtilsTest{
    @istest
        public static void leadTest(){
        
          rvpe__RVAccount__c rpv = [select id from rvpe__RVAccount__c where rvpe__SFAccount__c <> null and rvpe__PartnerLevel__c = 'NA Reseller' limit 1];
        
            Lead l1 = new Lead();
            l1.FirstName = 'Pranavan';
            l1.LastName = 'Karthi';
            l1.Email = 'karthi@pranavan.com';
            l1.Company = 'Pranavan';
            l1.country = 'United States';
            l1.rvpe__IsDealRegistration__c = true;
            l1.Global_Region__c = 'EMEA'; 
            l1.rvpe__RVAccount__c = rpv.id;
            
            insert l1;
            
            l1.FirstName = 'Velu';
            
            update l1;
            
       }
       
       public static void leadTest_two(){
       
        Lead l = [select id from lead where rvpe__IsDealRegistration__c  = true and Global_Region__c  <> null and rvpe__RVAccount__c  <> null limit 1];
        
        l.firstname = 'sudhir';
        
        update l;
  
        
       }
}
Only below lines are not covered. 
User-added image
 
When I try to deploy in production it is giving code coverage error.  Please suggest me how to fix. 

Thanks
GMASJ
Hi,

  I am using below code to insert data into a custom object using TxnSecurity.PolicyCondition but its not working please suggest me what is the issue in code. 
public class AccountExportLog implements TxnSecurity.PolicyCondition {

public boolean evaluate(TxnSecurity.Event e) {  

        Integer numberOfRecords = Integer.valueOf(e.data.get('NumberOfRecords'));
        String entityName = String.valueOf(e.data.get('EntityName'));
         
          system.debug('Number of Records ' + numberOfRecords);
           system.debug('EntityName ' + entityName);
             system.debug('entity ' + e);
              system.debug('resource type ' + e.resourceType);
              
             if(e.resourceType == 'Account'){ 
               //SELECT ID,Name FROM Report WHERE NAME = 'TEST_ACCOUNT_EXP'
                  if(entityName == 'Account'){
            
            //list<Report_Download_Log__c> rec = new list<Report_Download_Log__c>();
              
              Report_Download_Log__c rec = new Report_Download_Log__c(API_Type__c = entityName,Download_by__c='00534000009Gu7u',Object_Name__c=entityName,Total_Records__c=numberOfRecords);
              
              //insert rec;
              
               //return true;
             }   
              //Report_Download_Log__c rec = new Report_Download_Log__c( API_Type__c = entityName,Download_by__c='00534000009Gu7u',Object_Name__c=entityName,Total_Records__c=numberOfRecords);
               //insert rec;
          } 
            return false;

    }
    
}


Thanks
Sudhir
 
Hi, 
  
Please suggest me how to update all child and grand child when parent account field is updated in account. 

Example: Each account has a parent lookup field of account. 

We created a checkbox called Global in account when this field is updated in account all its assocaited children and grand children "Global Account" checkbox should be checked please suggest me how to add this logic. Similarly when unchecked all childres and grand childrens should get "Global Account" be unchecked. 

Thanks
Sudhir 
Hi, 
    
    I am trying to implement a delete validation on opportunity object using a trigger but I keep getting Attempt to de-reference a null object error please suggest me what is the issue in this code. 
public static void processOptyDelete(List<Opportunity> newLst){

    List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()];
     for(Opportunity opp: newLst){
       for(SBQQ__Quote__c sqt : cpqqt){
          if(opp.id == sqt.SBQQ__Opportunity2__c){
             opp.addError('Opportunity have Quotes ,so you can not delete this opportunity');
           }
       }  
     } 
 }

Error is coming from line below
List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()];

Please let me know if there are any other way to fix this issue. 

Thanks
Sudhir
Hi, 

   Like ISNEW() function is there any methods or way to identify a record a deleted please suggest. 

  I want to avoid users deleting from quotelines when quote is approved or pending 

Thanks
Sudhir
Hi,

 In below component <aura:if isTrue="{!v.erpId == null}"> is not retuning please suggest me what might be the issue here. 
 
v.erpid is not returning value from controller in component. 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global"  controller="POTrackerExtLtn">
	<aura:attribute name="act" type="Object"/>
	<aura:attribute name="key" type="String" access="private"/>
    
     <force:recordData aura:id="forceRecord"
                      recordId="{!v.recordId}"
                      targetFields="{!v.act}"
                      fields="accountId,userId,erpId,region,quoteIds"
                      recordUpdated="{!c.handleRecordUpdated}"
                      mode="EDIT" />
    <div class="slds-box slds-theme_info">
        
<aura:if isTrue="{!v.erpId == null}">
	<p>"Oracle ERP disti ID" is not set for this account. Please contact system administrator for more information. </p>
    <aura:set attribute="else">
        <p>PO Tracker is lunched in New window!</p>
    </aura:set>
</aura:if>
        
    </div>
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
</aura:component>

Class. 
public class POTrackerExtLtn{
      
    @AuraEnabled
    public static String getAccessKey(ID recordId){
         ID accountId; 
         ID userId;
         String erpId;
         string region;
         string quoteIds;
         String userarea;
         string commaQuoteIds;    
       list<String> CommastrList = new List<String>();
       
       list<SBQQ__Quote__c> QtAprd = [select id, Quote_ID__c,SBQQ__Opportunity2__r.ownerid,
                                     SBQQ__Opportunity2__r.accountid,SBQQ__Opportunity2__r.account.Oracle_ERP_ID__c,
                                     SBQQ__Opportunity2__r.owner.Area__c,SBQQ__Opportunity2__r.owner.Region_New__c,
                                     SBQQ__Opportunity2__r.API_Session__c,SBQQ__Opportunity2__r.API_Partner_Server_100__c,
                                     SBQQ__Opportunity2__r.Distributor__r.Account__c,
                                     SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c
                                     from SBQQ__Quote__c 
                                     where SBQQ__Opportunity2__c = :recordId and ApprovalStatus__c = 'Approved'];   
    
       for(SBQQ__Quote__c str : QtAprd){
       
           if(str.Quote_ID__c != null){
                CommastrList.add(str.Quote_ID__c);     
            }     
            
            
            accountId = str.SBQQ__Opportunity2__r.Distributor__r.Account__c;
            userId    = str.SBQQ__Opportunity2__r.ownerid;
             
             if(str.SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c != null){
             erpId     = String.valueof(str.SBQQ__Opportunity2__r.Distributor__r.Oracle_ERP_disti_ID__c);
             }
             
             region    = str.SBQQ__Opportunity2__r.owner.Region_New__c;
             quoteIds  = commaQuoteIds;
        }
    
        commaQuoteIds = String.join(CommastrList,','); //Quote Id in comma separated format. 
        
          system.debug('Debug from POTrackerExtLtn commaQuoteIds ' + commaQuoteIds);
          system.debug('Debug from POTrackerExtLtn accountId ' + accountId );
          system.debug('Debug from POTrackerExtLtn userId    ' + userId );
          system.debug('Debug from POTrackerExtLtn erpId ' + erpId);
          system.debug('Debug from POTrackerExtLtn region    ' + region    );
          system.debug('Debug from POTrackerExtLtn quoteIds  ' + commaQuoteIds );
          
             String input = 'accountId=' + accountId  +
                        '&erpId='+erpId +
                        '&userId='+userinfo.getUserId() +
                        '&region='+region +
                        '&quoteIds='+commaQuoteIds +                        
                        '&timestamp=' + System.currentTimeMillis();
                        
        String key = EncryptionSSOUtils.encryptWithAES128(input);
        system.debug('Key_noendcode_'+key);
        key = EncodingUtil.urlEncode(key,'UTF-8');
        system.debug('Key__endcode__'+key);
        return key; 
        
         

    }
    
}

 
Hi, 

   When user logs in using lightning is there  a way to build a popup page with a message please suggest me how to implement this feature. 

Thanks
Sudhir
Hi, 

  For Class   
public class LeadTriggerUtils {
    
    public static void processLeadOnUpdate(Map<id, Lead> newMap, Map<id, Lead> oldMap) { 
        List<Lead> leadLst = new List<Lead>();
        for (Lead lead : newMap.values()) {
            Lead oldLead = oldMap.get(lead.id);
            if(lead.rvpe__IsDealRegistration__c && lead.rvpe__RVAccount__c != null && lead.rvpe__RVAccount__c != oldLead.rvpe__RVAccount__c) {
        leadLst.add(lead);
            }
        }
        if(!leadLst.isEmpty()) {
      processChangeOwnerAsPartnerAccount(leadLst); 
        }
    }
    
    public static void processLeadOnInsert(List<Lead> newLst) {
      processChangeOwnerAsPartnerAccount(newLst);
    }
    public static void processChangeOwnerAsPartnerAccount(List<Lead> newLst) {
        List<ID> rvAcctIDs = new List<ID>();
        for(Lead lead : newLst) {
            if(lead.rvpe__IsDealRegistration__c && (lead.Global_Region__c == 'EMEA' || lead.Global_Region__c == 'LATAM') && lead.rvpe__RVAccount__c != null) {
                rvAcctIds.add(lead.rvpe__RVAccount__c);
            }
        }
        Map<ID, rvpe__RVAccount__c> rvActMap = new Map<Id, rvpe__RVAccount__c>([select id, rvpe__SFAccount__c, rvpe__SFAccount__r.OwnerId from rvpe__RVAccount__c where id in :rvAcctIDs]);
        for(Lead lead : newLst) {
            rvpe__RVAccount__c rvAct = rvActMap.get(lead.rvpe__RVAccount__c);
            if(rvAct != null && rvAct.rvpe__SFAccount__c != null) {
                lead.OwnerId = rvAct.rvpe__SFAccount__r.OwnerId;
            }
        }
    }
}

Below is the test class it has 90% code coverage. 
@isTest(seealldata = true)
public class LeadTriggerUtilsTest{
    @istest
        public static void leadTest(){
        
          rvpe__RVAccount__c rpv = [select id from rvpe__RVAccount__c where rvpe__SFAccount__c <> null and rvpe__PartnerLevel__c = 'NA Reseller' limit 1];
        
            Lead l1 = new Lead();
            l1.FirstName = 'Pranavan';
            l1.LastName = 'Karthi';
            l1.Email = 'karthi@pranavan.com';
            l1.Company = 'Pranavan';
            l1.country = 'United States';
            l1.rvpe__IsDealRegistration__c = true;
            l1.Global_Region__c = 'EMEA'; 
            l1.rvpe__RVAccount__c = rpv.id;
            
            insert l1;
            
            l1.FirstName = 'Velu';
            
            update l1;
            
       }
       
       public static void leadTest_two(){
       
        Lead l = [select id from lead where rvpe__IsDealRegistration__c  = true and Global_Region__c  <> null and rvpe__RVAccount__c  <> null limit 1];
        
        l.firstname = 'sudhir';
        
        update l;
  
        
       }
}
Only below lines are not covered. 
User-added image
 
When I try to deploy in production it is giving code coverage error.  Please suggest me how to fix. 

Thanks
GMASJ
Hi, 
 
  I am trying to install below app in my sandbox environment its giving me below error  
This app can't be installed.
There are problems that prevent this package from being installed.
Missing Organization Feature: EnhancedEmail

   https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EouGRUAZ

   Please suggest me how to fix this issue. 

Thanks
Sudhir
Hi, 

  There are two different class  I am trying to get the  code coverage for the below class
public class QuoteLineClaimTriggerUtils {

   public static void processRollupQuoteLine(List<Quote_Line_Claim__c> newLst){

        Set<ID> qIds = new Set<ID> ();
        for(Quote_Line_Claim__c qlc : newLst) {
            system.debug(qlc.CPQ_Quote_Product1__c);
            if(qlc.CPQ_Quote_Product1__c != null)
                qIds.add(qlc.CPQ_Quote_Product1__c);

        }
         system.debug('Quote ID  ' + qIds);
         Map<id, SBQQ__QuoteLine__c> qlMap =  new Map<id, SBQQ__QuoteLine__c>([select id, name, CPQ_Forticare_Quote_ID__c, SBQQ__NetTotal__c,SBQQ__Quantity__c,
                                                                                         SBQQ__Quote__r.SBQQ__Opportunity2__c                                               
                                                                                      from SBQQ__QuoteLine__c 
                                                                                      where id in :qIds and  CPQ_Forticare_Quote_ID__c != null]); 
        List<SBQQ__QuoteLine__c> qlLstUpdate = new List<SBQQ__QuoteLine__c>();
        for(AggregateResult result : [SELECT sum(CPQ_Amount__c) amt, sum(CPQ_Quantity__c) qty, CPQ_Quote_Product1__c 
                                            FROM Quote_Line_Claim__c
                                            where  CPQ_Quote_Product1__c = :qIds
                                            group by CPQ_Quote_Product1__c] ) {
            system.debug('result ' + result);
            SBQQ__QuoteLine__c ql = new SBQQ__QuoteLine__c(id = (String)result.get('CPQ_Quote_Product1__c'));
            system.debug(qlMap);
            if(qlMap.containsKey(ql.id)) {
                ql.CPQ_ClaimedAmountToDate__c = qlMap.get(ql.id).SBQQ__NetTotal__c;
                ql.CPQ_Claimed_Quantity_To_Date__c = qlMap.get(ql.id).SBQQ__Quantity__c;
                system.debug('fully claimed for Coterm or renewal');
              } else {
                ql.CPQ_ClaimedAmountToDate__c = (Decimal)result.get('amt');
                ql.CPQ_Claimed_Quantity_To_Date__c = (Decimal)result.get('qty');
            }
            system.debug(ql);
            qlLstUpdate.add(ql);
        }
       if(!qlLstUpdate.isEmpty()){
            update qlLstUpdate;

            Set<ID> opportunityIds = new Set<ID>();
            for(SBQQ__QuoteLine__c ql : [select id, name, CPQ_Forticare_Quote_ID__c, SBQQ__NetTotal__c,SBQQ__Quantity__c,
                                                                                         SBQQ__Quote__r.SBQQ__Opportunity2__c                                               
                                                                                      from SBQQ__QuoteLine__c 
                                                                                      where id in :qIds]) {
                   opportunityIds.add(ql.SBQQ__Quote__r.SBQQ__Opportunity2__c);
            }
            List<opportunity> optyLstUpdate = new List<opportunity>();
            for(AggregateResult result : [select  sum(Total_Claimed_Amount_to_Date__c) amt, SBQQ__Opportunity2__c from SBQQ__Quote__c  where  SBQQ__Opportunity2__c in :opportunityIds
                                                group by SBQQ__Opportunity2__c] ) {
                system.debug('result ' + result);
                opportunity opp = new opportunity(id = (String)result.get('SBQQ__Opportunity2__c'));
                opp.Oracle_Claimed_Amount__c = (Decimal)result.get('amt');
                system.debug(opp);
                optyLstUpdate.add(opp);
            }
            if(!optyLstUpdate.isEmpty()) {
                update optyLstUpdate;
            }
        }



   }

   public static void processErpClaims(List<Quote_Line_Claim__c> newLst){
   
     Set<String> erpUuniqueIds = new Set<String>();
     Set<String> prdNbrs = new Set<String>();
     Map<String, SBQQ__QuoteLine__c> prdMap = new Map<String, SBQQ__QuoteLine__c>();
     
     for(Quote_Line_Claim__c sc: newLst) {
       erpUuniqueIds.add(sc.CPQ_ERP_Unique_Id__c);
       prdNbrs.add(sc.CPQ_ERP_Quote_Product_Number__c);
     }   
     List<SBQQ__QuoteLine__c> sprPrds = [select id, name, CPQ_Forticare_Quote_ID__c
                                          from SBQQ__QuoteLine__c 
                                          where name in :prdNbrs]; 
     for(SBQQ__QuoteLine__c sPrd : sprPrds) {
            prdMap.put(sPrd.name, sPrd);
        }   
     
       for(Quote_Line_Claim__c sc: newLst) {
            SBQQ__QuoteLine__c sPrd = prdMap.get(sc.CPQ_ERP_Quote_Product_Number__c);
            if(sPrd != null) {
                sc.CPQ_Quote_Product1__c = sPrd.id;
                sc.CPQ_Result__c ='';
            } else {
                sc.CPQ_Result__c ='DEL:Invalid product number';
            }
            system.debug('cliams : '+ sc);
        }
        
    }
     
     
     
   }
  Test Class
@isTest(seealldata=true)
public class QuoteLineClaimTriggerUtilsTest
{  
    public static testMethod void method1(){
        
        Profile profileObj =[select id from Profile where name='System Administrator' limit 1];
        User u = new User(
            FirstName = 'Sudhir',
            LastName = 'Testing Usre',
            Alias = 'tstN',
            Email = 'test11@abc.com',
            Username = 'partne1r11@abc.com',
            CommunityNickname = 'testi11',
            emailencodingkey = 'UTF-8',
            languagelocalekey = 'en_US',
            localesidkey = 'en_US',
            timezonesidkey = 'America/Los_Angeles',
            profileId = profileObj.Id,
            spr_region__c = 'LATAM',
            NFR_User__c  = false,
            SPR_to_Forticare_Linking__c = true
        );
        insert u; 
        
        Distributor__c Dist = [select id from Distributor__c where CPQ_DistributorStatus__c  = true limit 1];
        
        Account Pact = [select id from account where recordtype.name = '.Partner' and Is_In_RV_Portal__c = true and Partner_Status__c = 'Activated' limit 1];
        
        Contact Pcnt = [select id from contact where accountid = :Pact.id  limit 1];    
        
        Account Act = new Account( Name = 'Test Sudhir Ac',Website='www.sudhir.com',Industry='Legal',BillingStreet='894', BillingCity='sunnyvalley', BillingState='CA', 
                                  BillingPostalCode='997',BillingCountry='United States',Customer_Status__c='Current Customer');  
        
        insert Act; 
        
        Contact C = [select id from contact limit 1];
        
        Opportunity opp = new Opportunity(
            AccountId=Act.id,
            StageName='Omit from Forecast',
            Amount = 0,
            Name = 'Test Sudhir',
            CloseDate = Date.today(),
            Market_Segmentation__c = 'Education',
            End_User_Industry__c = 'Education',
            End_Customer_Country__c = 'United States',
            Deal_Type__c='Refresh',
            Primary_Opportunity_Contact__c =  c.id,
            Partner_Initiated__c = 'No',
            Distributor__c = Dist.id,
            Reason_for_Won_Opportunity__c = 'Other'
        );
        
        insert opp;
        
        OpportunityTeamMember oppmem = new OpportunityTeamMember(
            Opportunityid = opp.id,
            OpportunityAccessLevel = 'Read' ,
            TeamMemberRole = 'CAM',
            Userid = u.id ); 
        
        insert oppmem;
        
        SBQQ__Quote__c SQ = new SBQQ__Quote__c(SBQQ__Opportunity2__c = opp.id,
                                               CPQ_Distributor__c = Dist.id,
                                               CPQ_Partner_Account__c = Pact.id,
                                               CPQ_Partner_Contact__c = Pcnt.id
                                               ,SBQQ__Primary__c = true
                                              );
        
        
        insert SQ;
        
        
        PricebookEntry pbe = [ select   Id, IsActive, Name, Pricebook2Id, Product2Id, ProductCode, SystemModstamp, UnitPrice, UseStandardPrice 
                              from PricebookEntry where isactive = true and usestandardprice = true limit 1];
        
        Product2 Prd = [select id from product2 where isactive = true limit 1];
        
        //Product2 PrdCTRM = [select id from product2 where isactive = true and productcode = 'COTERM' limit 1];
        
        SBQQ__QuoteLine__c SQln = new SBQQ__QuoteLine__c(SBQQ__Product__c = Prd.id,
                                                         SBQQ__Quantity__c = 1,
                                                         SBQQ__Quote__c = SQ.id,
                                                         SBQQ__ListPrice__c = 111,
                                                         SBQQ__NetPrice__c = 111,
                                                         CPQ_Reseller_Discount__c = 22,
                                                         Category__c = 'A'
                                                        );
        insert SQln;                                                                                                    
        
      /*  SBQQ__QuoteLine__c SQlnCTRM = new SBQQ__QuoteLine__c(SBQQ__Product__c = PrdCTRM.id, 
                                                             SBQQ__Quantity__c = 1,
                                                             SBQQ__Quote__c = SQ.id,
                                                             SBQQ__ListPrice__c = 111,
                                                             SBQQ__NetPrice__c = 111,
                                                             CPQ_Reseller_Discount__c = 22,
                                                             CPQ_Forticare_Quote_ID__c = 'SUDHIR',
                                                             Category__c = 'B'
                                                            );
        insert SQlnCTRM;    */                                                                                                
        
        
        Quote_Line_Claim__c QLClm = new Quote_Line_Claim__c(CPQ_Quote_Product1__c = SQln.id,
                                                            CPQ_Quantity__c =2,
                                                            CPQ_Claim_Number__c='123',
                                                            CPQ_ERP_PO_or_Claim__c = 'test',
                                                            CPQ_ERP_Quote_Product_Number__c = '342');
                                                           
        
        
        insert QLClm;
        
        
       /* SBQQ__Quote__share SQS = new SBQQ__Quote__share(UserOrGroupId = u.id,
                                                        ParentId = SQ.id,
                                                        AccessLevel  = oppmem.OpportunityAccessLevel
                                                       );
        
        insert SQS; */
        
        //Quote_Category_Metrics__c QCM = new Quote_Category_Metrics__c(Name='a', CPQ_Quote__c=SQ.id,CPQ_Gross_Margin__c = 1,CPQ_List_Price__c =1,CPQ_Disti_Price__c =1);    
        
        //insert QCM;
    }
  
}

I am getting error from 

 Pass/FailFail
Error MessageSystem.LimitException: Too many SOQL queries: 101
Stack TraceClass.CpqQuoteLineTriggerUtils.processQuoteMatrics: line 107, column 1
Trigger.CpqQuoteLineTrigger: line 22, column 1

Below the class where the error is from please suggest me how to fix. 
public class CpqQuoteLineTriggerUtils {

    public static void calcMarigns(List<SBQQ__QuoteLine__c> newLst) {
        Set<Id> product2IDs = new Set<Id>();
        Set<String> bundleSkus = new Set<String>();
        ID pbId = null;
        Map<String, String> bundleSkuMap = new Map<String, String>();
        Map<String, PriceBookEntry> pbeMap = new Map<String, PriceBookEntry>();
        system.debug(newLst);

        for (SBQQ__QuoteLine__c line : newLst) {
            if(pbId == null) {
                pbId = [select SBQQ__PriceBook__c from SBQQ__Quote__c where id = :line.SBQQ__Quote__c].SBQQ__PriceBook__c;
            }
            if(line.CPQ_IS_Dummy_Product_Formula__c == false) {
                product2IDs.add(line.SBQQ__Product__c);
                if(line.CPQ_Product_Code__c != null && line.CPQ_Product_Code__c.contains('-BDL')) {
                    bundleSkus.add(line.CPQ_Product_Code__c);
                }
            }
        }

        for(Bundled_Product_Map__c pmap: [SELECT Id, Bundle_SKU__c, Hardware_OR_Software_SKU__c 
                                                FROM Bundled_Product_Map__c where Bundle_SKU__c in :bundleSkus]) {
            system.debug('pmap.Hardware_OR_Software_SKU__c' + pmap.Hardware_OR_Software_SKU__c);
            system.debug('pmap.Bundle_SKU__c' + pmap.Bundle_SKU__c);                                     
            bundleSkuMap.put(pmap.Bundle_SKU__c, pmap.Hardware_OR_Software_SKU__c); 
        }

        for(PriceBookEntry pbe : [Select id, Product2.COGS__c,Product2.Product_Type__c,Product2.Productcode, UnitPrice,
                                        Product2.Isactive,Product2.CPQ_IS_Dummy_Product__c 
                                    from PriceBookEntry 
                                    where pricebook2.IsStandard = false 
                                        and (Product2Id In :product2IDs or Product2.ProductCode in :bundleSkuMap.values())
                                        and pricebook2ID = :pbId]) {
            pbeMap.put(pbe.Product2.ProductCode, pbe);
            system.debug( pbe.Product2.Isactive + 'cogs== '+ pbe.Product2.COGS__c+  'pbe' + pbe);
        }
        system.debug('pbeMap' + pbeMap);
        for (SBQQ__QuoteLine__c line : newLst) {
            System.debug('line '+ line);
            PriceBookEntry pbe = pbeMap.get(line.CPQ_Product_Code__c);
            if(line.CPQ_IS_Dummy_Product_Formula__c != true && pbe != null) {
                system.debug( 'cogs== '+ pbe.Product2.COGS__c+  'pbe' + pbe);
                system.debug('quoteline'+line);

                Double cogs = pbe.Product2.COGS__c;
                Double listPrice = line.SBQQ__ListPrice__c != null ? line.SBQQ__ListPrice__c : pbe.UnitPrice;
                if(line.CPQ_Product_Code__c.contains('COTERM')) {
                    cogs = listPrice * 0.1;
                }
                Double distiDiscount = ( 1 - (line.CPQ_DistDiscount__c == null ? 0 : line.CPQ_DistDiscount__c) /100);
                Double distiNetUnitPrice = listPrice * distiDiscount;
                Double quantity = line.SBQQ__Quantity__c;
                System.debug('quantity=' + quantity + 'cogs=' + cogs);
                Double grossMargin = (distiNetUnitPrice - cogs) * quantity;

                line.COGS__c = cogs;
                //line.Gross_Margin__c = grossMargin;
                system.debug( 'distiNetUnitPrice=' + distiNetUnitPrice + 'distiDiscount=' + distiDiscount + 'pbe' + pbe);

                Double totalBilling = distiNetUnitPrice * quantity;
                Double cogsBilling = cogs * quantity;
                line.Is_BundleMapping_missing__c = false;
                line.Bundle_Related_HW_Product__c = null;
                if(line.CPQ_Product_Code__c.contains('-BDL') ) {
                     if(bundleSkuMap.containsKey(line.CPQ_Product_Code__c)){
                        String mappingSku = bundleSkuMap.get(line.CPQ_Product_Code__c);
                         system.debug('mappingSku ' + mappingSku); 
                        PriceBookEntry hwProduct = pbeMap.get(mappingSku);
                         system.debug('hwProduct ' + hwProduct );
                         system.debug('hwProduct.Product2.cogs__c' + hwProduct.Product2.cogs__c);
                        cogsBilling = hwProduct.Product2.cogs__c * quantity;
                        Double hwListPice = hwProduct.UnitPrice;                
                        Double hwCogs = hwProduct.Product2.cogs__c;
                        Double hwSalesPrice = (hwListPice * distiDiscount);
                        Double hardwareBilling = hwListPice * distiDiscount * quantity;
                        system.debug('hwListPice =' + hwListPice + ' hwSalesPrice =' + hwSalesPrice );
                        if(hwProduct.Product2.product_Type__c == 'HW' || hwProduct.Product2.product_Type__c == 'Hardware') {
                            line.Bundle_Related_HW_Product__c = hwProduct.Product2Id;
                            line.Hardware_billings_in_amount__c = hardwareBilling;
                            line.Hardware_Gross_Margin_in_amount__c = (hwSalesPrice - hwCogs)* quantity;
                            line.Hardware_Gross_Margin_Percentage__c = 100*(hardwareBilling -cogsBilling )/hardwareBilling; 
                        } 
                    } else {
                        line.Is_BundleMapping_missing__c = true;
                        system.debug( '_log_' + line);
                        //throw new PP_HandleException (p.ProductCode +  ' - this bundle product has not mapped with appropriate Hardware sku mapping, please contain admin with screenshot.' );
                    }
                } else if(pbe.Product2.product_Type__c == 'HW' || pbe.Product2.product_Type__c == 'Hardware') {
                    line.Hardware_billings_in_amount__c = totalBilling;
                    line.Hardware_Gross_Margin_in_amount__c = grossMargin;
                    line.Hardware_Gross_Margin_Percentage__c = 100*(totalBilling -cogsBilling )/totalBilling;
                } else if(pbe.Product2.Product_type__c == 'SW') {
                    line.Software_Billings_in_amount__c = totalBilling;
                } 
            }
        }
    }
    public static void processQuoteMatrics(List<SBQQ__QuoteLine__c> newLst) {
        Set<ID> qIds = new Set<ID> ();
        for(SBQQ__QuoteLine__c ql : newLst) {
            qIds.add(ql.SBQQ__Quote__c);
        }
         system.debug('Quote ID  ' + qIds);
        List<Quote_Category_Metrics__c> insertMatrics = new List<Quote_Category_Metrics__c>();
        for(AggregateResult result : [select Category__c,SBQQ__Quote__c, sum(CPQ_marginDollars__c) a, 
                                            sum(SBQQ__ListTotal__c) b, sum(SBQQ__NetTotal__c) c 
                                        from SBQQ__QuoteLine__c 
                                        where SBQQ__Quote__c  IN :qids and SBQQ__Quote__r.ApprovalStatus__c != 'Approved'  group by Category__c, SBQQ__Quote__c] ) {
            Quote_Category_Metrics__c qc = new Quote_Category_Metrics__c();
            system.debug('Category C ' + (String)result.get('Category__c'));
            system.debug('Category A  ' + (Decimal)result.get('a'));
            system.debug('Category B  ' + (Decimal)result.get('b') );
            system.debug('Category C  ' + (Decimal)result.get('c') );
            qc.Name = (String)result.get('Category__c');
            if(qc.name != null) {
                qc.CPQ_Gross_Margin__c = (Decimal)result.get('a');
                qc.CPQ_List_Price__c = (Decimal)result.get('b');
                qc.CPQ_Disti_Price__c = (Decimal)result.get('c');
                
                qc.CPQ_Quote__c = (String)result.get('SBQQ__Quote__c');
                insertMatrics.add(qc);
            }
        }

        List<Quote_Category_Metrics__c> existingRec = [select id from Quote_Category_Metrics__c where CPQ_Quote__c in :qIds];
        if(!existingRec.isEmpty()) {
            delete existingRec;
        }

        if(!insertMatrics.isEmpty()){
            insert insertMatrics;
        }
    }

Thanks
Sudhir
Hi, 

 I am writing test class for below class but @future method is not getting covered. Please suggest me how to cover. 
public class CpqQuoteTriggerUtil {

    public static void createQuoteShareFromOpportunity(List<SBQQ__Quote__c> newLst) {
        system.debug('Calling CpqQuoteTriggerUtil.createQuoteShareFromOpportunity' + newLst);
        Map<ID,ID> optyQuoteMap = new Map<ID,ID>();
        List<SBQQ__Quote__share> insertShares = new List<SBQQ__Quote__share>();
        List<SBQQ__Quote__share> currentUserShare = new List<SBQQ__Quote__share>();
        for(SBQQ__Quote__c quote : newLst) {
            if(quote.SBQQ__Opportunity2__c <> null) {
                optyQuoteMap.put(quote.SBQQ__Opportunity2__c, quote.id);
            }
            currentUserShare.add(new SBQQ__Quote__share(UserOrGroupId = userinfo.getUserId(),
                                                ParentId = quote.id,
                                                AccessLevel = 'Edit'));
        }
        //Map<Id, List<SBQQ__Quote__share>> oppToQuoteShareLst = new Map<Id, List<SBQQ__Quote__share>>();
        Boolean notOppOwnerFlg = false;
        Set<Id> userids = new Set<Id>();
        ID OptyOwnerId;
        Id qid;
        //for Opportunity share
        for(OpportunityShare r : [SELECT Id, OpportunityId,Opportunity.ownerid, UserOrGroupId, OpportunityAccessLevel, 
                                            RowCause 
                                            FROM OpportunityShare 
                                            where opportunityid = :optyQuoteMap.keyset() and RowCause in('Rule', 'Team')]) {
            if(userids.isEmpty()) {
                userids.add(r.Opportunity.ownerid);
                OptyOwnerId = r.Opportunity.ownerid;
                qid = optyQuoteMap.get(r.OpportunityId);
            }
            if(!userids.contains(r.UserOrGroupId) ) {
                userids.add(r.UserOrGroupId);
                //insertShares = new List<SBQQ__Quote__share>();
                insertShares.add(new SBQQ__Quote__share(UserOrGroupId = r.UserOrGroupId,
                                                    ParentId = optyQuoteMap.get(r.OpportunityId),
                                                    AccessLevel = r.OpportunityAccessLevel == 'All' ? 'Edit': r.OpportunityAccessLevel));
                if(r.Opportunity.ownerid != userinfo.getUserId()) {
                    notOppOwnerFlg = true;
                }
                system.debug(insertShares);
            }
        }

        //for Default Opportunity Teams // sudhir Test here for 
        for(UserTeamMember r : [SELECT Id,OpportunityAccessLevel,OwnerId,TeamMemberRole,UserId 
                                                FROM UserTeamMember where ownerid   = :OptyOwnerId] ) {
                insertShares.add(new SBQQ__Quote__share(UserOrGroupId = r.UserId,
                                                    ParentId = qid,
                                                    AccessLevel = r.OpportunityAccessLevel));
        }
        system.debug('share from opty :: ' + insertShares);
        if(notOppOwnerFlg) {
            system.debug('for user share creator :: ' + currentUserShare);
            insertShares.addAll(currentUserShare);
        }

        Database.SaveResult[] srList = database.insert(insertShares, false);
        for (Database.SaveResult sr : srList) {
            if (sr.isSuccess()) {
                // Operation was successful, so get the ID of the record that was processed
                System.debug('Successfully inserted account. Account ID: ' + sr.getId());
            }
            else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('The following error has occurred.');                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Account fields that affected this error: ' + err.getFields());
                }
            }
        }

    }
    public static void prepopulateApproverLevelFromOwner(List<SBQQ__Quote__c> newLst) {
        Set<id> opps = new set<id>();
            for(SBQQ__Quote__c quote : newLst) {
            if(quote.SBQQ__Opportunity2__c <> null) {
                opps.add(quote.SBQQ__Opportunity2__c);
            }
        }
        
        Map<id, Opportunity> optyMap = new Map<id, Opportunity>([select id, owner.SPR_Approver_Director_Level__c,owner.SPR_Approver_EVP__c,
                                                owner.SPR_Approver_GVP__c,owner.SPR_Approver_RVP__c,owner.SPR_Approver_GD_Group_Director__c,
                                                 owner.SPR_Approver_RD_Regional_Director__c
                                                 from opportunity where id = :opps]);
        //Approval
        for(SBQQ__Quote__c quote : newLst) {
            if(quote.SBQQ__Opportunity2__c <> null) {
                Opportunity opp = optyMap.get(quote.SBQQ__Opportunity2__c);
                    quote.ownerid = opp.ownerid;
                quote.CPQ_Approver_Director__c = opp.owner.SPR_Approver_Director_Level__c;
                quote.CPQ_Approver_RVP__c = opp.owner.SPR_Approver_RVP__c;
                quote.CPQ_Approver_GVP__c = opp.owner.SPR_Approver_GVP__c;
                quote.CPQ_Approver_EVP__c = opp.owner.SPR_Approver_EVP__c;
                quote.CPQ_Approver_RD_Regional_Director__c = opp.owner.SPR_Approver_RD_Regional_Director__c;
                quote.CPQ_Approver_GD_Group_Director__c = opp.Owner.SPR_Approver_GD_Group_Director__c;
            }
        }
    }

    public static void processQuoteOnBeforeUpdate(Map<Id, SBQQ__Quote__c> newMap, Map<Id, SBQQ__Quote__c> oldMap){
        for(SBQQ__Quote__c q : newMap.values()) {
            SBQQ__Quote__c oldQ = oldMap.get(q.Id);
            system.debug(q.CPQ_Quote_Remaining_Claim_Status__c  + '_'+ q.CPQ_Quote_Product_Count__c + '_'+oldQ.CPQ_Closed__c );
            if(q.CPQ_Quote_Remaining_Claim_Status__c  <= 0 && q.CPQ_Quote_Product_Count__c > 0 && oldQ.CPQ_Closed__c == false) {
                q.CPQ_Closed__c = true;
            } else {
                q.CPQ_Closed__c = false;
            }
            system.debug(q.CPQ_Closed__c +'_');
        }
    }
    
    public static void processQuoteOnAfterUpdate(Map<Id, SBQQ__Quote__c> newMap, Map<Id, SBQQ__Quote__c> oldMap){
        Set<ID> Idset = new Set<ID>();
        for(SBQQ__Quote__c q : newMap.values()) {
            SBQQ__Quote__c oldQ = oldMap.get(q.Id);
            if(q.CPQ_Quote_Remaining_Claim_Status__c  <= 0 && q.CPQ_Quote_Product_Count__c > 0 && q.CPQ_Closed__c == true && oldQ.CPQ_Closed__c == false) {
                Idset.add(q.Id);
            }
        }

        if(!IdSet.isEmpty()) {
            updateOpportuntiy(IdSet);
        }
    }

    @future
    public static void updateOpportuntiy(Set<Id> Idset){
        Set<Id> oppIdSet = new Set<Id>();
        List<Opportunity> oppLst = new List<Opportunity>();
        system.debug(Idset);
        for(SBQQ__Quote__c q : [select id, name, CPQ_Distributor__r.name, SBQQ__Opportunity2__c, SBQQ__Opportunity2__r.stageName                                               
                                                                                      from SBQQ__Quote__c 
                                                                                      where id in :IdSet and 
                                                                                      (CPQ_Distributor__r.name like 'US -%' Or CPQ_Distributor__r.name like 'CAN -%' OR CPQ_Distributor__r.name like 'LAT -%' )] ){
            if(!oppIdSet.contains(q.SBQQ__Opportunity2__c)) {
                oppIdSet.add(q.SBQQ__Opportunity2__c);
                Opportunity opp = new opportunity(id = q.SBQQ__Opportunity2__c);
                if(q.CPQ_Distributor__C != null) { 
                        If((q.CPQ_Distributor__r.name.Startswith('US -') || q.CPQ_Distributor__r.name.Startswith('CAN -'))
                            &&  (q.SBQQ__Opportunity2__r.stageName != 'P.O. Issued,Fortinet can Ship & Invoice' && q.SBQQ__Opportunity2__r.stageName != 'Closed Won - All Products on Leaderboard')) {
                        opp.stageName = 'P.O. Issued,Fortinet can Ship & Invoice';
                        oppLst.add(opp);
                    }  else If (q.CPQ_Distributor__r.name.Startswith('LAT -') 
                            &&  q.SBQQ__Opportunity2__r.stageName != 'Closed Won - All Products on Leaderboard') {
                        opp.stageName = 'Closed Won - All Products on Leaderboard';
                        oppLst.add(opp);
                    }
                }
            }
            system.debug(oppLst);
            if(!oppLst.isEmpty()) {
                update oppLst;
            }
        }
    }
        /*
    public static void lockAfterApproval(List<SBQQ__Quote__c> newQ, List<SBQQ__Quote__c> oldQ) {
    
    SBQQ__Quote__c blankQuote = new SBQQ__Quote__c();
    Schema.SObjectType objType = blankQuote.getSObjectType();
    Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.SBQQ__Quote__c.fields.getMap();
        
            
        
    } 
    
        private static void updateSPRAndCategoryMetrics(List<SBQQ__QuoteLine__c> sprProductList, String sprId) {
    
}*/
}
User-added image

Above code is not covered. 

Below is the test class writter it is having only 67% code coverage
@isTest(seealldata=true)
public class CpqQuoteTriggerUtilTest
{  
    public static testMethod void method1(){
        
        Profile profileObj =[select id from Profile where name='System Administrator' limit 1];
        User u = new User(
            FirstName = 'Sudhir',
            LastName = 'Testing Usre',
            Alias = 'tstN',
            Email = 'test11@abc.com',
            Username = 'partne1r11@abc.com',
            CommunityNickname = 'testi11',
            emailencodingkey = 'UTF-8',
            languagelocalekey = 'en_US',
            localesidkey = 'en_US',
            timezonesidkey = 'America/Los_Angeles',
            profileId = profileObj.Id,
            spr_region__c = 'LATAM',
            NFR_User__c  = false,
            SPR_to_Forticare_Linking__c = true
        );
        insert u;
        
        Distributor__c Dist = [select id from Distributor__c where CPQ_DistributorStatus__c  = true limit 1];
        
        Account Pact = [select id from account where recordtype.name = '.Partner' and Is_In_RV_Portal__c = true and Partner_Status__c = 'Activated' limit 1];
        
        Contact Pcnt = [select id from contact where accountid = :Pact.id  limit 1];    
        
        Account Act = new Account( Name = 'Test Sudhir Ac',Website='www.sudhir.com',Industry='Legal',BillingStreet='894', BillingCity='sunnyvalley', BillingState='CA', 
                                  BillingPostalCode='997',BillingCountry='United States',Customer_Status__c='Current Customer');  
        
        insert Act; 
        
        Contact C = [select id from contact limit 1];
        
        Opportunity opp = new Opportunity(
            AccountId=Act.id,
            StageName='Omit from Forecast',
            Amount = 0,
            Name = 'Test Sudhir',
            CloseDate = Date.today(),
            Market_Segmentation__c = 'Education',
            End_User_Industry__c = 'Education',
            End_Customer_Country__c = 'United States',
            Deal_Type__c='Refresh',
            Primary_Opportunity_Contact__c =  c.id,
            Distributor__c = Dist.id
        );
        
        insert opp;
        
        OpportunityTeamMember oppmem = new OpportunityTeamMember(
            Opportunityid = opp.id,
            OpportunityAccessLevel = 'Read' ,
            TeamMemberRole = 'CAM',
            Userid = u.id ); 
        
        
        insert oppmem;
        
        
        
        SBQQ__Quote__c SQ = new SBQQ__Quote__c(SBQQ__Opportunity2__c = opp.id,
                                               CPQ_Distributor__c = Dist.id,
                                               CPQ_Partner_Account__c = Pact.id,
                                               CPQ_Partner_Contact__c = Pcnt.id
                                              );
        
        
        insert SQ;
        
        
        
        SBQQ__Quote__share SQS = new SBQQ__Quote__share(UserOrGroupId = u.id,
                                                        ParentId = SQ.id,
                                                        AccessLevel  = oppmem.OpportunityAccessLevel
                                                       );
        
        insert SQS;
        
        
        
        opp.stageName = 'P.O. Issued,Fortinet can Ship & Invoice';
        opp.Partner_Initiated__c = 'No';
        
        update opp;
        
    }
    
 
    
}

 
Hi, 

  We have a approval process in account. we have a requirement to include rejected comments in email template. we have a visualforce template and we need to include the comment Please suggest how to include. 

Thanks
Sudhir
Hi, 

  Created below validation in opportunity both are same tried different approach both are not working not sure what is the issue Please suggest. 
AND( 
TEXT(Account.Account_Status__c) = 'Pending', 
OR( 
TEXT(StageName) ='1 - Closed Won', 
TEXT(StageName) = 'Closed - Renewed', 
TEXT(StageName) = 'Booked', 
TEXT(StageName) = 'De-booked' ) )
 
AND(
 ISPICKVAL(Account.Account_Status__c,'Pending'), 
OR(
ISPICKVAL(StageName,'1 - Closed Won'),
ISPICKVAL(StageName,'Closed - Renewed'),
ISPICKVAL(StageName,'Booked'),
ISPICKVAL(StageName,'De-booked')  ) )
Thanks
Sudhir
 
Hi, 

   Please suggest me how to create a lookup were user can select multiple records at a time. I have a requirement to select more than one account record and save Please suggest me 

Thanks
​Sudhir
Hi, 

 Below is the code which is working and has 94% code coverage in sandbox. When I try to deply the changeset to production. Please suggest me to fix this issue
 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityApprovelMatrixTrigger: execution of AfterInsert caused by: System.StringException: Invalid id: Test Sudhir Ac External entry point Trigger.OpportunityApprovelMatrixTrigger: line 22, column 1: [] 
Stack Trace: Class.OpportunityTriggerUtilsTest.OpportunityLineItemTriggerUtils_test1: line 44, column 1


System.DmlException: Update failed. First exception on row 0 with id 0063400001AcWEMAA3; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityApprovelMatrixTrigger: execution of AfterUpdate caused by: System.StringException: Invalid id: Test Sudhir Ac External entry point Class.OpportunityTriggerUtils.processOptySharingOppTeamUpdate: line 127, column 1 Trigger.OpportunityApprovelMatrixTrigger: line 27, column 1: [] 
Stack Trace: Class.OpportunityTriggerUtilsTest.OpportunityLineItemTriggerUtils_test2: line 80, column 1
 
  Trigger
trigger OpportunityApprovelMatrixTrigger on Opportunity (before insert, before update, after insert, after Update) {
      if(Trigger.isAfter) {
        if(Trigger.isInsert) {
            OpportunityTriggerUtils.processOptySharingOppTeam(Trigger.new); 
        }

        if(Trigger.isUpdate) {                            
            OpportunityTriggerUtils.processOptySharingOppTeamUpdate(Trigger.newMap, Trigger.oldMap);
        }
   }

  Class 
public class OpportunityTriggerUtils {

   public static void processOptySharingOppTeamUpdate(Map<id, Opportunity> newMap, Map<id, Opportunity> oldMap) {   //Karthi - you have to call this method from trigger, which is not called anywhere now.
        List<Opportunity> optyLst = new List<Opportunity>();
        for(Opportunity newRec : newMap.values()){
            Opportunity oldRec = oldMap.get(newRec.id);
            if(newRec.AccountID != oldRec.AccountID || newRec.Partner_Account__c != oldRec.Partner_Account__c)
                optyLst.add(newRec);
        }
        if(!optyLst.isEmpty())    
            processOptySharingOppTeam(optyLst);   
    }
    
    public static void processOptySharingOppTeam(List<Opportunity> newLst) { 
        List<id> OpptIds = new List<id>();
        list<OpportunityTeamMember> Otmlst = new List<OpportunityTeamMember>();
        Set<id> actIdset = new Set<id>(); 
        Set<id> paractIdset = new Set<id>(); 
        String memRolename = 'Global Account Shared Owner'; 
        
        for(Opportunity opp : newLst) {
            OpptIds.add(opp.id); 
        }
        
        list<Opportunity> Oplst = [select id,name,account.Top_Parent_Account__c,partner_account__r.Top_Parent_Account__c
                                    from opportunity where id in :OpptIds];
        
        for(Opportunity Op : Oplst){  
            actIdset.add(Op.account.Top_Parent_Account__c);
            paractIdset.add(Op.partner_account__r.Top_Parent_Account__c);                                                     
        }  
        
        list<Opportunity_Sharing__c> actOplst = new list<Opportunity_Sharing__c>([select id, Account_Names__c, Key_Text__c, Partner_Account_Names__c,
                                                                                  User__c,Access_Level__c,Global_Account_Rep__c,Top_Account_ID__r.id, Top_Partner_Account_ID__r.id,
                                                                                  User__r.name
                                                                                  from Opportunity_Sharing__c
                                                                                  where 
                                                                                  Top_Account_ID__r.id <> NULL and
                                                                                  Top_Account_ID__r.id in :actIdset and
                                                                                  User__c <> null and
                                                                                  Access_Level__c <> null
                                                                                 ]);  
        
        list<Opportunity_Sharing__c> paractOplst = new list<Opportunity_Sharing__c>([select id, Account_Names__c, Key_Text__c, Partner_Account_Names__c,
                                                                                     User__c,Access_Level__c,Global_Account_Rep__c,Top_Account_ID__r.id, Top_Partner_Account_ID__r.id,
                                                                                     User__r.name
                                                                                     from Opportunity_Sharing__c
                                                                                     Where Top_Partner_Account_ID__r.id <> null and 
                                                                                     Top_Partner_Account_ID__r.id in :paractIdset and
                                                                                     User__c <> null and
                                                                                     Access_Level__c <> null]);
        for(Opportunity Ops : Oplst){
            //Account 
            for(Opportunity_Sharing__c rec : actOplst){
                if(Ops.account.Top_Parent_Account__c == rec.Top_Account_ID__r.id){
                    system.debug('Opportunity Name: ' + ops.name + '  ' +  ops.id + '  ' +'Opportunity Sharing: ' + + rec.User__r.name);      
                    if(rec.User__c <> null && rec.Access_Level__c <> null){                      
                        OpportunityTeamMember otm = new OpportunityTeamMember(OpportunityId = ops.id,UserId=rec.User__c,OpportunityAccessLevel=rec.Access_Level__c
                                                                              ,TeamMemberRole= memRolename );  
                        Otmlst.add(otm);           
                    }
                    
                }
            }  
            //Partner Account 
            for(Opportunity_Sharing__c rec : paractOplst){
                if(Ops.partner_account__r.Top_Parent_Account__c == rec.Top_Partner_Account_ID__r.id){
                    system.debug('Opportunity Name: ' + ops.name + '  ' +  ops.id + '  ' +'Opportunity Sharing: ' + + rec.User__r.name);    
                    if(rec.User__c <> null && rec.Access_Level__c <> null){                      
                        OpportunityTeamMember otm = new OpportunityTeamMember(OpportunityId = ops.id,UserId=rec.User__c,OpportunityAccessLevel=rec.Access_Level__c
                                                                              ,TeamMemberRole= memRolename ); 
                        Otmlst.add(otm);           
                    }            
                }
            }  
        }
        
        if(!Otmlst.Isempty()){ 
            upsert Otmlst; 
        }  
        
    }   
 
}

Test Class
@isTest(seealldata=true)
public class OpportunityTriggerUtilsTest
{


 public static testMethod void OpportunityLineItemTriggerUtils_test1(){
  
   Account Act = new Account( Name = 'Test Sudhir Ac',Website='www.sudhir.com',Industry='Legal',BillingStreet='894', BillingCity='sunnyvalley', BillingState='CA', 
                             BillingPostalCode='997',BillingCountry='United States',Customer_Status__c='Current Customer');  

  insert Act; 
   
   Account Pact = [select id from account where recordtype.name = '.Partner' limit 1];
   
   User usr = [select id from user where id = '00580000004geN2' limit 1]; 
  
  Opportunity_Sharing__c ops = new Opportunity_Sharing__c (
          Key_Text__c = 'GMASJ',
          Top_Account_ID__c = Act.id,
          Top_Partner_Account_ID__c  = Pact.id,
          User__c = usr.id,
          Access_Level__c   = 'Edit',
          Global_Account_Rep__c = 'CAM' 
          );
          
  insert ops;        
 
  Contact C = [select id from contact limit 1];
      
  Opportunity opp = new Opportunity(
             AccountId=Ops.Top_Account_ID__c,
             StageName='Omit from Forecast',
             Amount = 999,
             Name = 'Test Sudhir',
             CloseDate = Date.today(),
             Market_Segmentation__c = 'Education',
             End_User_Industry__c = 'Education',
             End_Customer_Country__c = 'United States',
             Deal_Type__c='Refresh',
             Primary_Opportunity_Contact__c =  c.id,
             Partner_Account__c = ops.Top_Partner_Account_ID__c
             );
             
       insert opp;    
       
  Opportunity_Sharing__c ops1 = [select Top_Account_ID__c from Opportunity_Sharing__c where Top_Account_ID__c <> NULL limit 1];
  
  opp.accountid = ops1.Top_Account_ID__c;
  
  update opp;
          
 
  }

 public static testMethod void OpportunityLineItemTriggerUtils_test2(){
 
   Account Act = new Account( Name = 'Test Sudhir Ac',Website='www.sudhir.com',Industry='Legal',BillingStreet='894', BillingCity='sunnyvalley', BillingState='CA', 
                             BillingPostalCode='997',BillingCountry='United States',Customer_Status__c='Current Customer');  

  insert Act; 
    
   opportunity opp = [select id,accountid, Partner_Account__c from opportunity where closedate > today limit 1];
   
   //Opportunity_Sharing__c ops1 = [select Top_Account_ID__c from Opportunity_Sharing__c where Top_Account_ID__c <> NULL limit 1];
   
   User usr = [select id from user where id = '00580000004geN2' limit 1]; 
   
   Opportunity_Sharing__c ops = new Opportunity_Sharing__c (
          Key_Text__c = 'GMASJ',
          Top_Account_ID__c = Act.id,
          User__c = usr.id,
          Access_Level__c   = 'Edit',
          Global_Account_Rep__c = 'CAM' 
          );
          
    insert ops;  
  
   opp.accountid = ops.Top_Account_ID__c;
   
   update opp;
   
  
 }
 
 
   public static testmethod void testautolead()
{
 Lead lead=new Lead(LastName='Doe',FirstName='John',Company='Test',Status='Inquiry',country='United States');

insert lead;                

 
}

}


 
Hi, 

  In below method I am using two for loops inside which is a nested for loop. Code is working as expected but the only issue I see is that this might hit into performance issue when there are bulk operation Please suggest me any alternative way to overcome this issue in the code. 
public static void processOptySharingOppTeam(List<Opportunity> newLst) {
     list<id> OpptIds = new list<id>();
     list<OpportunityTeamMember> Otmlst = new list<OpportunityTeamMember>();
 
     for(Opportunity opp : newLst) {
       OpptIds.add(opp.id); 
      }

  for(Opportunity Op : [select id,name,account.Ultimate_Account__c,partner_account__r.Ultimate_Account__c
                        from opportunity where id in :OpptIds]) {  
            system.debug('Opportunity Name ' + Op.name + '   ' + Op.id);
            
        // Account                             
    for(Opportunity_Sharing__c Ops : [select id, Account_Names__c, Key_Text__c, Partner_Account_Names__c,
                                          User__c,Access_Level__c,Global_Account_Rep__c,Top_Account_ID__r.id, Top_Partner_Account_ID__r.id,
                                          User__r.name
                                          from Opportunity_Sharing__c
                                          where   
                                          Top_Account_ID__r.id <> NULL AND
                                          Top_Account_ID__r.id = :op.account.Ultimate_Account__c]){
                                         
                                
     
               if(Ops.User__c <> null && Ops.Access_Level__c <> null){
                  system.debug('Opportunity Sharing ' + Ops.User__r.name); 
                OpportunityTeamMember otm = new OpportunityTeamMember(OpportunityId = op.id,UserId=Ops.User__c,OpportunityAccessLevel=Ops.Access_Level__c
                                                                              ,TeamMemberRole='Global Account Shared Owner'  ); 
              Otmlst.add(otm);           
             }
         }
      
      // Partner Account                        
      for(Opportunity_Sharing__c Ops : [select id, Account_Names__c, Key_Text__c, Partner_Account_Names__c,
                                            User__c,Access_Level__c,Global_Account_Rep__c,Top_Account_ID__r.id, Top_Partner_Account_ID__r.id,
                                            User__r.name
                                     from Opportunity_Sharing__c
                                     where
                                     Top_Partner_Account_ID__r.id <> NULL AND 
                                     Top_Partner_Account_ID__r.id = :op.partner_account__r.Ultimate_Account__c]){
                                         
                                
     
              if(Ops.User__c <> null && Ops.Access_Level__c <> null){
                 system.debug('Opportunity Sharing ' + Ops.User__r.name); 
               OpportunityTeamMember otm = new OpportunityTeamMember(OpportunityId = op.id,UserId=Ops.User__c,OpportunityAccessLevel=Ops.Access_Level__c
                                                                              ,TeamMemberRole='Global Account Shared Owner'  ); 
              Otmlst.add(otm);           
            }
         }                    
         
      if(!Otmlst.Isempty()){ 
        upsert Otmlst; 
      }        
    }
  }

Thanks
Sudhir
Hi, 

   We have a field called Gross_Margin__c I have to new create a formula field which should be visible on a condition 

    If Opportunity.ownerid == createdid  
      displace Gross_Margin__c
   else 
      Blank
   
  if anyother user logs in they should be able to view Gross_Margin__c  only for opportunity owner based on the condition it must be visible. 
  
 please let me know how to add this logic in formula field. 

Thanks
Sudhir
Hi, 

   Please suggest me how to convert mass lead into account there are more than 1000+ leads which needs to be converted into account please suggest me a way in code. 

Thanks
Sudhir