• Debendra Ray 8
  • NEWBIE
  • 68 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 47
    Questions
  • 68
    Replies
Hello,
I am using Dataloader CLI to integrate SFDC with SAP - I've build all necessary configration files in keeping with the guidelines published by Salesforce , however, I'm not able to connect to Salesforce end point : https://login.salesforce.com while running the process.bat file from command line.
Please, could you suggest plausible cause of this connectivity issue?

Thanks & Regards,

Debendra 
Hello,

I have an approval process which could be submitted by the Adminstrator , however, SFDC throws an error that No Appproval   Process  exists   when   it is  submitted   by any other   user.

Appreciate if you could please suggest what could have gone wrong in this case.

Regards,

Debendra 
Hi,

Please, could someone provide me a pathway to implement a Running User for VisualForce Dashboards wherein each logged-in user sees the dashboard according to his or her own access level?

This feature is available for Standard Dashboards.

Thanks & Regards,

Debendra Ray
Hi,
I'm getting an Invalid Date Error in a VF Page emanating from the following code :

Date stDate = Date.valueOf((System.currentPageReference().getParameters().get('startDate')));
 Datetime dt = datetime.newInstance(stDate.year(), stDate.month(),stDate.day());
 startDate  = Date.valueOf(dt.format('DD/MM/YYYY'));

Please, could you help me remediate this issue?

Thanks & Regards,

DR
 
I'm trying to copy the attachments from Contact to the Opportunity after Conversion from a Lead - Below is the code, which works only if I manually update the new Account converted from Lead  :

trigger Copy_Attachments_Accts_to_Oppr on Account (after insert,after update) {

    //if (trigger.isAfter && trigger.isInsert) {
        List<Attachment> attachmentsToInsert = new List<Attachment>();
        //List<Attachment> attachmentsToDelete = new List<Attachment>();
        for (Account acc : Trigger.New) { 
        
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Account Id->'+ acc.id);
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Account Parent Lead Id->'+ acc.Account_ID__c);      
            
               List<Opportunity> opprs = [select Id from Opportunity where Account.Id = :acc.id ]; 
               List<Contact> conts = [select Id from Contact where Account.Id = :acc.id ];   
               List<Attachment> accountAttachmentLst = new List<Attachment>();  
               
               for(Contact contact : conts ){
                   accountAttachmentLst.addAll([select name, body, parentid from Attachment where PARENTID = :contact.id]);
                   
               }
                
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Opportunities ->'+opprs );
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Contact Attachment List ->'+accountAttachmentLst );       
          
                for (Attachment a : accountAttachmentLst ) {
                   
                    System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Attachment ->'+a.name);
                    System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Attachment ->'+a.parentid);
                    
                    for(Opportunity opr : opprs ){
                       Attachment att = new Attachment(name = a.name, body = a.body, parentid = opr.id); 
                       System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachments.name ->'+att.name );
                       System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachments.parentid ->'+att.parentid);
                       
                       attachmentsToInsert.add(att);
                       
                    }
                    
                    //Attachment att = new Attachment(name = a.name, body = a.body, parentid = acc.id); 
                   // attachmentsToDelete.add(att);
                }
            
        }
        
        System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachmentsToInsert->'+attachmentsToInsert); 
        //System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachmentsToDelete'+attachmentsToDelete); 
        
        
         if (attachmentsToInsert.size() > 0) {
             insert attachmentsToInsert;
         }

         // Minimize storage requirements by cleaning up attachments
         /*if (attachmentsToDelete.size() > 0) {
             delete attachmentsToDelete;
         }*/
   // }

Any suggestions to circumvent this problem will be much appreciated.

Regards,

Debendra
Please, could you someone suggest a workaround in APEX to figure out number of times users have accessed Reports and Dashboards?

An early reply on this will be much appreciated.

Thanks & Regards,

Debendra Ray
I've three objects: Customer_Visit_Report__c, Action_Point__c , Invitee__c  wherein Action_Point__c , Invitee__c  are child objects for the master Customer_Visit_Report__c. I would like the users to create Action_Point__c , Invitee__c objects much before they create the Customer_Visit_Report__c object. Below is the code, which is not giving me the desired result :

trigger ValidateCVRInvittee_Task_Creation on Customer_Visit_Report__c (after update) {
    
    for (Integer i = 0; i < Trigger.new.size(); i++) {
         try{
           
           
           List<Customer_Visit_Report__c> cvrLst = [select Invitee_Created__c , Actions_Created__c from Customer_Visit_Report__c where id = :Trigger.new[i].id ];
           List<Action_Point__c> cvrActionLst = [select id , name  from Action_Point__c where Customer_Visit_Report__c = :Trigger.new[i].id ]; 
           List<Invitee__c> cvrInviteeLst = [select id , name  from Invitee__c where Customer_Visit_Report__c = :Trigger.new[i].id ]; 
            
           if(cvrActionLst.size() == 0 ){
                 Trigger.new[i].addError('Please create Actions for this Customer Visit Report !');
            }
             
            if(cvrInviteeLst.size() == 0 ){
                 Trigger.new[i].addError('Please create Invitees for this Customer Visit Report !');
            } 
             
             if(cvrInviteeLst.size() > 0 && cvrInviteeLst.size() >0 ){
                 
                 for(Customer_Visit_Report__c cvr :cvrLst ){
                     
                     cvr.Invitee_Created__c = true;
                     cvr.Actions_Created__c = true;
                 
                 }
                 
                  if(RecursiveTriggerHandler.isFirstTime){
                                  RecursiveTriggerHandler.isFirstTime = false; 
                                  update cvrLst;
                   }
                 
                 
             }       
          
                    
         
          }catch(Exception e)
         {
           Trigger.new[i].addError(e.getMessage());
           System.debug('Error : ValidateCVRInvittee_Task_Creation ->'+ e);  
        }
        
    }  
    

}


Any help towards this end will be much appreciated.
Hi,

Please let me know how to use J Query in a VF Page? 

Thanks & Regards,

Debendra
Hi,

Please, could you provide the steps for installation of the Eclipse IDE for Salesforce?

Thanks & Regards,

Debendra 
Hi,
I'm getting following error while trying to run a scheduled job in the Production  :
"common.apex.methods.MessagingStaticMethods$EmailExecutionException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Either the plain text body or html body must be supplied:

This code worked fine in the Sandbox.

Any suggestion towards circumventing this problem will be much appreciated.

Thanks & Regards,

Debendra
 
Hi,

Issue is : == operator is returning false although the operands are same on both sides of the operator  - statement is below:

System.debug('DEBUG:approvalForProposalPricingDeviation::: BEGIN INVOKATION ********quNew.Status---->'+quNew.Status );-- This prints out the value : Pending Approval with RM-West for Pricing Deviation
if(quNew.Status == 'Pending Approval with RM-West for Pricing Deviation'  ){
           
             submitForApproval(quNew);         
  }
System.debug('DEBUG:approvalForProposalPricingDeviation::: END INVOKATION ********quNew.Status---->'+quNew.Status );

Please could someone suggest what's going wrong here in the code snippet?

An early response on this will be much appreciated.

Regards,

Debendra 
        
Hi All,
The javascript in the below code is not getting invoked :
<apex:page standardController="Customer_Visit_Report__c" recordSetVar="Customer_Visit_Report__c" tabStyle="Customer_Visit_Report__c" extensions="cvrController"> 
 <apex:sectionHeader title="Customer Visit Report" subtitle="{!cvr.Name}"/>
 <apex:pageMessages id="pageMessages"/> 

    <script type="text/javascript">

    function validate()
    {
        alert("Test Alert --->");
        if(((document.getElementById('{!$Component.CVRFrm.invt.therepeatINV.Contact}').value == '') && 
           (document.getElementById('{!$Component.CVRFrm.invt.therepeatINV.User}').value == '') )   ||
           (document.getElementById('{!$Component.CVRFrm.invt.therepeatINV.Organisation}').value == '' )
          )
        {
            alert("Please add Invitee Details for the CVR !");
        }
      
        if(
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatAP }').value == '')  ||
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatDP}').value == '')   ||
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatATBT}').value == '') ||
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatAB}').value == '')   ||
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatCD}').value == '')   ||
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatBU}').value == '')   ||
          (document.getElementById('{!$Component.CVRFrm.actPnt.therepeatST}').value == '')  
         ) 
        {
            alert("Please add Action Items for the CVR!");
        }
        else
        {
            Save();
            alert("CVR is created successfully!");
        }
        
        
    }
    
    </script>
    
 <apex:form id="CVRFrm"> 
     
     <apex:pageBlock mode="edit"> 
          <apex:pageBlockButtons >          
            <apex:commandButton value="Save" action="{!save}" onclick="validate()"/> 
            <apex:commandButton value="Cancel" action="{!cancel}"/> 
          </apex:pageBlockButtons>   
         
        <apex:pageBlockSection title="Minutes of Meeting">
            <apex:inputField value="{!cvr.Name}"  required="true"/> 
            <apex:inputField value="{!cvr.Date_of_Visit__c}"  required="true"/> 
            <apex:inputField value="{!cvr.Start_Time__c}"  required="true"/> 
            <apex:inputField value="{!cvr.End_Time__c}"  required="true"/> 
            <apex:inputField value="{!cvr.Discussion_Reference__c}"  required="true"/>  
            <apex:inputField value="{!cvr.Venue__c}"  required="true"/> 
            <apex:inputField value="{!cvr.Type__c}"  required="true"/> 
            <apex:inputField value="{!cvr.Agenda__c}"  required="true"/>
            <apex:inputField value="{!cvr.Account__c}"  required="false"/>  
            <apex:inputField value="{!cvr.Lead__c}"  required="false"/> 
            <apex:inputField value="{!cvr.Opportunity__c}"/>  
         </apex:pageBlockSection>
     </apex:pageBlock> 
     
     <apex:pageBlock mode="edit"> 
         <apex:pageBlockButtons >
                    <apex:commandbutton value="Add Invitee" action="{!AddInvitee}" rerender="invt"/>
                    <apex:commandButton value="Remove Invitee" action="{!DelInvitee}" rerender="invt"/>                                            
          </apex:pageBlockButtons>
           
         <apex:pageBlockSection title="Invitee" id="invt"> 
             <apex:repeat value="{!lstInvitee}" var="inv" id="therepeatINV">
                 <apex:pageMessage summary="Please select either Invitee (Internal) or Invitee (External). Only one can be filled at a time." severity="error" strength="3" /> 
                 <apex:pageMessages />              
                 <apex:inputField value="{!inv.Contact__c}" id="Contact"/>
                 <apex:inputField value="{!inv.User__c}" id="User"/> 
                
                 <!-- <apex:inputField value="{!inv.Invitee_Name__c}"/> -->
                 <apex:inputField value="{!inv.Organization__c}" id="Organisation"/> 
             </apex:repeat>
             
         </apex:pageBlockSection>
   </apex:pageBlock>  
  <!--   
   <apex:pageBlock mode="edit"> 
         <apex:pageBlockButtons >
                    <apex:commandbutton value="Add Agenda" action="{!AddAgenda}" rerender="agend"/>
                    <apex:commandButton value="Remove Agenda" action="{!DelAgenda}" rerender="agend"/>                                            
          </apex:pageBlockButtons>
           
         <apex:pageBlockSection title="Agenda" id="agend"> 
             <apex:repeat value="{!lstAgenda}" var="agd" id="therepeatAG"> 
                    <apex:inputField value="{!agd.Discussion_Topics__c}"/>
             </apex:repeat>
            
         </apex:pageBlockSection> 
        
   </apex:pageBlock>
   
   -->
     
   <apex:pageBlock mode="edit"> 
         <apex:pageBlockButtons >
                    <apex:commandbutton value="Add Action Points" action="{!AddActionPoints}" rerender="actPnt"/>
                    <apex:commandButton value="Remove Action Points" action="{!DelActionPoints}" rerender="actPnt"/>                                            
          </apex:pageBlockButtons>
           
         <apex:pageBlockSection title="Action Points" id="actPnt"> 
             <apex:repeat value="{!lstActionPoint}" var="acPt" id="therepeatAP"> 
                    <apex:inputField value="{!acPt.Discusssion_Point__c}" id="therepeatDP"/>
                    <apex:inputField value="{!acPt.Action_To_Be_Taken__c}" id="therepeatATBT"/>
                    <apex:inputField value="{!acPt.Action_By__c}" id="therepeatAB"/> 
                    <apex:inputField value="{!acPt.Completion_Date__c}" id="therepeatCD"/> 
                    <apex:inputField value="{!acPt.BU__c}" id="therepeatBU"/>                    
                    <apex:inputField value="{!acPt.Status__c}" id="therepeatST"/>  
             </apex:repeat>
             
         </apex:pageBlockSection>
   </apex:pageBlock>   
        
     
 </apex:form> 
    
   
</apex:page>

Please could you help identify the issue.

Regards,
​Debendra
 
Dear All,

I've written the below  trigger to validate the Lead before it's converted to an opportunity :

for (Integer i = 0; i < Trigger.new.size(); i++) {
         try{
                    
                            
                    List<Attachment> leadAttachmentLst = [select name from Attachment where PARENTID = :Trigger.new[i].id] ;
                    List<Customer_Visit_Report__c> cvrLeadLst = [select id from Customer_Visit_Report__c where Lead__c = :Trigger.new[i].id ];
             
             if(cvrLeadLst.size() == 0 ){
                 Trigger.new[i].addError('Please create Customer Visit Report for this Lead!');
             }
             
             if(!(leadAttachmentLst.size() == 2) ){
                 Trigger.new[i].addError('Please attach the PIF & Dossier documents for this Lead!');
             }
             
             for(Attachment attch :leadAttachmentLst){
                 if(!(attch.name.contains('PIF')||attch.name.contains('Dossier') ) ){
                     Trigger.new[i].addError('Please rename the PIF & Dossier documents as : <nameofthefilePIF> , <nameofthefileDossier>!');
                 }                 
             }
         
          }catch(Exception e)
         {
           Trigger.new[i].addError(e.getMessage());
           System.debug('Error : ValidateLeadConversionPrerequisites ->'+ e);  
        }

The issue is while this code works fine , however, this throws these errors again while I'm on the 2nd screen of Lead conversion - Ideally, this trigger should not have thrown these errors when all conditions are already met on the previous screen.

Please could someone provide a clue to circumvent this problem.

Thanks & Regards,

Debendra Ray 
Hi All,

I'm trying to update the owner of the Account and the corresponding Contract for this account, on completion of the approval process for the Contract - In doing so , while the owner of the Account gets updated successfully , however, the moment I try to update the corresponding Contract an error is thrown which shows a recursive call - Please find the code below :
public void autoTransferAgreementToSales(Contract quNew,Contract quOld ){
     
        List<Account> AccountToUpd = new List<Account>();
        List<Contract > ContractToUpd = new List<Contract >();
        AccountToUpd = [Select Id, OwnerId,Approval_Completion_of_Contract__c from Account where Id = :quNew.AccountId ];
        Map<Id,AccountHistory> history = new Map<Id,AccountHistory>();
        for(AccountHistory t : [Select Acct.AccountId,Acct.OldValue, Acct.NewValue, Acct.Field From AccountHistory Acct Where Acct.Field = 'Owner']){
          if(t.NewValue instanceof ID){
             history.put(t.AccountId, t);
             System.debug('Old: '+ t.OldValue +' New: ' +t.NewValue);
          }  
    
        }
        
        System.debug('DEBUG: autoTransferAgreementToSales::AccountToUpd ********'+ AccountToUpd.size() );
        System.debug('DEBUG: autoTransferAgreementToSales::AccountFldHistory ********'+ history.size() );
         
        for(Account acc: AccountToUpd ) {
           acc.Approval_Completion_of_Contract__c = true;
           if(history.containsKey(acc.Id)){
                 String accOwnerId = String.valueOf(history.get(acc.Id).OldValue);
                 System.debug('DEBUG: autoTransferAgreementToSales::accOwnerId ********'+ accOwnerId );
                 acc.OwnerId     = accOwnerId ;
                  ContractToUpd = [Select Id, OwnerId,Approval_Completion_of_Contract__c  from Contract
                                  where Id=:quNew.Id and AccountId = :quNew.AccountId];
                  for(Contract cont: ContractToUpd ) {
                               cont.Approval_Completion_of_Contract__c = true;
                               cont.OwnerId = accOwnerId ;
                               System.debug('DEBUG: autoTransferAgreementToSales::cont.OwnerId********'+ cont.OwnerId);                            
                   }
                 
           }         
                      
        }
        System.debug('DEBUG: autoTransferAgreementToSales::AccountToUpd ********'+ AccountToUpd.size() );          
        if(AccountToUpd.size() > 0)
              update AccountToUpd ;  
        
       
        System.debug('DEBUG: autoTransferAgreementToSales::ContractToUpd ********'+ ContractToUpd.size() );       
        if(ContractToUpd.size() > 0)
              update ContractToUpd ;         
        
     
     }

Error thrown is : Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Update failed. First exception on row 0 with id 8000k00000092CkAAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SubmitForApprovalAgreement: maximum trigger depth exceeded Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck]: []".

Any help to resolve this recussion isssue will be much appreciated.

Thanks & Regards,

Debendra Ray
Dear All,
I've a typical situation on hand - There is frequent change of ownership of opportunities in our Org between Sales & Solutions team and it's imprative for us to track the last time Sales Team had changed the ownership of the opportunity to the Solutions Team.
Appreciate, if someone could please suggest a solution for this problem through a Trigger - A Skeletal apex code to achieve the same would be much appreciated.

Thanks & Regards,
Debendra

 
Hi All,
I would like to send SMS to all Approvers through a Worklfow Outbound Message Action in an Approval Processss - Please let me know the options available to acheive the same.

Thanks.
Regards,
Debendra
 
Dear All,
Please could someone provide help on the below issue :

I'm facing this issue despite the fact that , I have uncheck the option "Strictly enforce picklist values" on the dependent field. Following is the  code which throws this error in PRODUCTION Org , however the passes the testing in SANDBOX :
@istest(SeeAllData=true)  private class TestEmailAlertsForQoute {             static testmethod void test() {                            Test.startTest();             Account acc = new Account(name='acc1');           insert acc;                   Opportunity oppr = new Opportunity();           oppr.AccountId = acc.ID;           oppr.Annual_Contract_Value_ACV__c = 111;           oppr.BU__c = 'MJ';           oppr.CloseDate = Date.today();           oppr.Contract_Opportunity_Estimate_CoE__c = 111;           oppr.Total_Contract_Value_TCV__c = 111;            oppr.Name = 'SubmitforQuoteApproval';            oppr.StageName = 'Prospecting';             oppr.Date_on_Opportunity_Prospecting_Stage__c = Date.today();           insert oppr;                      oppr.Region__c ='North';           oppr.Responsible_Sales_Rep__c ='Siddharth Bhatia';           update oppr;                                         Quote quot1 = new Quote ();           quot1.Name = 'TestPropForSandbox2016-10';            quot1.Status ='Draft';           quot1.OpportunityId = oppr.id ;           insert quot1;                                  quot1.Status = 'Acceptance by Client';            update quot1 ;                       Test.stopTest();          }           }

Any help resolving the error : System.DmlException: Update failed. First exception on row 0 with id 0066F00000jPi87QAC; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Siddharth Bhatia: [Responsible_Sales_Rep__c]
Stack Trace: Class.TestEmailAlertsForQoute.test: line 24, column 1

Regards,

Debendra
September 27, 2016
 
Hi All,
I'm getting the following error while inserting quote in a test class :
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, List has no rows for assignment to SObject: []
Please find the test class appended herewith :
@istest(SeeAllData=true)  private class TestSubmitforQuoteApproval {             static testmethod void test() {        Test.startTest();                   //Account acc = [select Id from Account limit 1];                   Opportunity oppr = new Opportunity();           //oppr.AccountId = acc.ID;           oppr.Annual_Contract_Value_ACV__c = 111;           oppr.BU__c = 'MJ';           oppr.CloseDate = Date.today();           oppr.Contract_Opportunity_Estimate_CoE__c = 111;           oppr.Total_Contract_Value_TCV__c = 111;            oppr.Name = 'SubmitforQuoteApproval';            oppr.StageName = 'Prospecting';             oppr.Date_on_Opportunity_Prospecting_Stage__c = Date.today();             //oppr.UpdatedForReminderToApprover__c = Date.today();           insert oppr;                      Quote quot = new Quote ();           quot.Name = 'TestPropForSandbox2016-1';            //quot.Status ='Draft';           quot.OpportunityId = oppr.id ;           insert quot;
}
}

Any help towards resolving this issue will be much appreciated

Thanks & Rgards,

Debendra Ray
Dear All,
Please could you help me circumvent the following error , which I'm getting while trying to Approve at a certain stage in the workflow :
Validation Errors While Saving Record(s) There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []".

There are triggers and workflow rules associated with this workflow as well.
An early response on this will be much appreciated.

Thanks very much.

Debendra Ray
 
Dear All,

Please could you suggest how to increase the code coverage of a Trigger code to 75% to make it deployable.

An early response on this will be much appreciated.

Thanks.

Regards,

Debendra Ray
Dear All,

I'm not able to open the Log in the Developer Console - The options on the File Menu of the Developer Console : Open Log , Open Raw Log & Download Log are disabled.

Any help towards resolution of this issue will be much appreciated.

Thanks.

Regards,

Debendra Ray
 
Hello,

I have an approval process which could be submitted by the Adminstrator , however, SFDC throws an error that No Appproval   Process  exists   when   it is  submitted   by any other   user.

Appreciate if you could please suggest what could have gone wrong in this case.

Regards,

Debendra 
Hi,

Please, could someone provide me a pathway to implement a Running User for VisualForce Dashboards wherein each logged-in user sees the dashboard according to his or her own access level?

This feature is available for Standard Dashboards.

Thanks & Regards,

Debendra Ray
I'm trying to copy the attachments from Contact to the Opportunity after Conversion from a Lead - Below is the code, which works only if I manually update the new Account converted from Lead  :

trigger Copy_Attachments_Accts_to_Oppr on Account (after insert,after update) {

    //if (trigger.isAfter && trigger.isInsert) {
        List<Attachment> attachmentsToInsert = new List<Attachment>();
        //List<Attachment> attachmentsToDelete = new List<Attachment>();
        for (Account acc : Trigger.New) { 
        
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Account Id->'+ acc.id);
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Account Parent Lead Id->'+ acc.Account_ID__c);      
            
               List<Opportunity> opprs = [select Id from Opportunity where Account.Id = :acc.id ]; 
               List<Contact> conts = [select Id from Contact where Account.Id = :acc.id ];   
               List<Attachment> accountAttachmentLst = new List<Attachment>();  
               
               for(Contact contact : conts ){
                   accountAttachmentLst.addAll([select name, body, parentid from Attachment where PARENTID = :contact.id]);
                   
               }
                
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Opportunities ->'+opprs );
               System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Contact Attachment List ->'+accountAttachmentLst );       
          
                for (Attachment a : accountAttachmentLst ) {
                   
                    System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Attachment ->'+a.name);
                    System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: Attachment ->'+a.parentid);
                    
                    for(Opportunity opr : opprs ){
                       Attachment att = new Attachment(name = a.name, body = a.body, parentid = opr.id); 
                       System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachments.name ->'+att.name );
                       System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachments.parentid ->'+att.parentid);
                       
                       attachmentsToInsert.add(att);
                       
                    }
                    
                    //Attachment att = new Attachment(name = a.name, body = a.body, parentid = acc.id); 
                   // attachmentsToDelete.add(att);
                }
            
        }
        
        System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachmentsToInsert->'+attachmentsToInsert); 
        //System.debug('DEBUG: Copy_Attachments_Accts_to_Oppr:: attachmentsToDelete'+attachmentsToDelete); 
        
        
         if (attachmentsToInsert.size() > 0) {
             insert attachmentsToInsert;
         }

         // Minimize storage requirements by cleaning up attachments
         /*if (attachmentsToDelete.size() > 0) {
             delete attachmentsToDelete;
         }*/
   // }

Any suggestions to circumvent this problem will be much appreciated.

Regards,

Debendra
Hi,

Please let me know how to use J Query in a VF Page? 

Thanks & Regards,

Debendra
Hi,

Please, could you provide the steps for installation of the Eclipse IDE for Salesforce?

Thanks & Regards,

Debendra 
Hi All,

I'm trying to update the owner of the Account and the corresponding Contract for this account, on completion of the approval process for the Contract - In doing so , while the owner of the Account gets updated successfully , however, the moment I try to update the corresponding Contract an error is thrown which shows a recursive call - Please find the code below :
public void autoTransferAgreementToSales(Contract quNew,Contract quOld ){
     
        List<Account> AccountToUpd = new List<Account>();
        List<Contract > ContractToUpd = new List<Contract >();
        AccountToUpd = [Select Id, OwnerId,Approval_Completion_of_Contract__c from Account where Id = :quNew.AccountId ];
        Map<Id,AccountHistory> history = new Map<Id,AccountHistory>();
        for(AccountHistory t : [Select Acct.AccountId,Acct.OldValue, Acct.NewValue, Acct.Field From AccountHistory Acct Where Acct.Field = 'Owner']){
          if(t.NewValue instanceof ID){
             history.put(t.AccountId, t);
             System.debug('Old: '+ t.OldValue +' New: ' +t.NewValue);
          }  
    
        }
        
        System.debug('DEBUG: autoTransferAgreementToSales::AccountToUpd ********'+ AccountToUpd.size() );
        System.debug('DEBUG: autoTransferAgreementToSales::AccountFldHistory ********'+ history.size() );
         
        for(Account acc: AccountToUpd ) {
           acc.Approval_Completion_of_Contract__c = true;
           if(history.containsKey(acc.Id)){
                 String accOwnerId = String.valueOf(history.get(acc.Id).OldValue);
                 System.debug('DEBUG: autoTransferAgreementToSales::accOwnerId ********'+ accOwnerId );
                 acc.OwnerId     = accOwnerId ;
                  ContractToUpd = [Select Id, OwnerId,Approval_Completion_of_Contract__c  from Contract
                                  where Id=:quNew.Id and AccountId = :quNew.AccountId];
                  for(Contract cont: ContractToUpd ) {
                               cont.Approval_Completion_of_Contract__c = true;
                               cont.OwnerId = accOwnerId ;
                               System.debug('DEBUG: autoTransferAgreementToSales::cont.OwnerId********'+ cont.OwnerId);                            
                   }
                 
           }         
                      
        }
        System.debug('DEBUG: autoTransferAgreementToSales::AccountToUpd ********'+ AccountToUpd.size() );          
        if(AccountToUpd.size() > 0)
              update AccountToUpd ;  
        
       
        System.debug('DEBUG: autoTransferAgreementToSales::ContractToUpd ********'+ ContractToUpd.size() );       
        if(ContractToUpd.size() > 0)
              update ContractToUpd ;         
        
     
     }

Error thrown is : Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Update failed. First exception on row 0 with id 8000k00000092CkAAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SubmitForApprovalAgreement: maximum trigger depth exceeded Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck] Contract trigger event AfterUpdate for [8000k00000092Ck]: []".

Any help to resolve this recussion isssue will be much appreciated.

Thanks & Regards,

Debendra Ray
Dear All,
I've a typical situation on hand - There is frequent change of ownership of opportunities in our Org between Sales & Solutions team and it's imprative for us to track the last time Sales Team had changed the ownership of the opportunity to the Solutions Team.
Appreciate, if someone could please suggest a solution for this problem through a Trigger - A Skeletal apex code to achieve the same would be much appreciated.

Thanks & Regards,
Debendra

 
Dear All,
Please could someone provide help on the below issue :

I'm facing this issue despite the fact that , I have uncheck the option "Strictly enforce picklist values" on the dependent field. Following is the  code which throws this error in PRODUCTION Org , however the passes the testing in SANDBOX :
@istest(SeeAllData=true)  private class TestEmailAlertsForQoute {             static testmethod void test() {                            Test.startTest();             Account acc = new Account(name='acc1');           insert acc;                   Opportunity oppr = new Opportunity();           oppr.AccountId = acc.ID;           oppr.Annual_Contract_Value_ACV__c = 111;           oppr.BU__c = 'MJ';           oppr.CloseDate = Date.today();           oppr.Contract_Opportunity_Estimate_CoE__c = 111;           oppr.Total_Contract_Value_TCV__c = 111;            oppr.Name = 'SubmitforQuoteApproval';            oppr.StageName = 'Prospecting';             oppr.Date_on_Opportunity_Prospecting_Stage__c = Date.today();           insert oppr;                      oppr.Region__c ='North';           oppr.Responsible_Sales_Rep__c ='Siddharth Bhatia';           update oppr;                                         Quote quot1 = new Quote ();           quot1.Name = 'TestPropForSandbox2016-10';            quot1.Status ='Draft';           quot1.OpportunityId = oppr.id ;           insert quot1;                                  quot1.Status = 'Acceptance by Client';            update quot1 ;                       Test.stopTest();          }           }

Any help resolving the error : System.DmlException: Update failed. First exception on row 0 with id 0066F00000jPi87QAC; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Siddharth Bhatia: [Responsible_Sales_Rep__c]
Stack Trace: Class.TestEmailAlertsForQoute.test: line 24, column 1

Regards,

Debendra
September 27, 2016
 

HI All ,

 

I am facing a issue reagrding the field update from apex.

 

System.DmlException: Update failed. First exception on row 0 with id 800c00000001DvXAAU; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Status: bad value for restricted picklist field: Active: [Status]

 

I have provide all the permissions for the field. but still facing the above issue.

 

Please help!!!..

 

Thanks

Shailu

 

  • July 26, 2013
  • Like
  • 0