• Sarika Patel
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies
Is it possible to add a custom button "Add to Campaign" with the default salesforce functionality on custom object, as I am not able to bring that button in my reports for that custom object?

Hi,

I have a requirement to automate Purchase Order Emails, meaning if an Opportunity is Closed Won, Sales Manager can click on 'Send PO Email' button, and then email template will be previewed by him.

In this case, I was able to generate successfully the template and all, I have one issue, the template comprises instruction for different departments like Support, Training etc. Now if the purchase order is just for training then the field for 'Instructions for Support' should not be populated. As in my template, I have caption:
Support: {!Closing Instructions for Suppport} 
Training: {!Closing Instructions for Training},

So in the above mentioned scenario the email template should have only 
Training: {!Closing Instructions for Training} and not Support: {!Closing Instructions for Suppport}  based on my condition field that the product is for training.

Could anyone please advice?

Thanks
Sarika Patel

Hi,

I have created a custom object for "Contracts" and another custom object called "Contract Applicable Accounts". There is a rollup summary field on Contracts having total count of "Contract Applicable accounts" called Total_Applicable_Accounts__c.

Now I have created a trigger which on update of Contract object, checks all the accounts listed in "Contract Applicable Accounts" object and updates certain fields in an Account Object.

Here it is:

trigger UpdateAccount on Contract__c (before update) {
Contract__c[] Contract = Trigger.new;
try
{
    if(contract[0].Id != null)
    {
        if(contract[0].Total_Applicable_Accounts__c > 0)
        {
       
            List<Applicable_Accounts__c> ApplicableAccounts = [Select Id,Account_Name__c from Applicable_Accounts__c where Contract__c =: contract[0].Id ];
            System.debug(ApplicableAccounts.size());
            if(ApplicableAccounts != null && ApplicableAccounts.size() > 0)
            {
               for(Applicable_Accounts__c appaccount : ApplicableAccounts)
               {
                   if( appaccount.Account_Name__c != null)
                   {
                       Account objaccount = [ Select Name from Account where Id =: appaccount.Account_Name__c];                  
                       if(contract[0].Active__c != null)
                      {
                        objaccount.Active_Hidden__c = contract[0].Active__c;        
                        if(contract[0].Active__c == 'Yes')
                        {
                            if(contract[0].Id != null)
                            {  objaccount.Contract_Hidden__c = contract[0].Id; }    
                           if(contract[0].Contract_Details__c!=null)                       
                           { objaccount.Contract_Details_Hidden__c = contract[0].Contract_Details__c;}
                           if(contract[0].Special_Quoting_Instructions__c!=null)        
                           { objaccount.Special_Quoting_Instructions_Hidden__c = contract[0].Special_Quoting_Instructions__c;}
                           if(contract[0].Special_Report_Links__c!=null)
                           { objaccount.Special_Report_Links_Hidden__c = contract[0].Special_Report_Links__c;}
                            if(contract[0].Contract_Manager__c!=null)
                           { objaccount.Contract_Manager_Hidden__c = contract[0].Contract_Manager__c;  }
                           if(contract[0].Pricebook__c!=null)
                           { objaccount.Pricebook_Hidden__c = contract[0].Pricebook__c;  }                  
                        }
                        else
                        {
                             objaccount.Contract_Hidden__c = null;
                             objaccount.Contract_Manager_Hidden__c = null;
                             objaccount.Contract_Details_Hidden__c =null;
                             objaccount.Special_Quoting_Instructions_Hidden__c=null;
                             objaccount.Special_Report_Links_Hidden__c=null;
                             objaccount.Pricebook_Hidden__c = null;
                             
                        }       
                       update objaccount;
                    }  
               }  }
            }
                
        }
        List<Account> DeletedApplicableAccounts=[ Select Id,Name,Total_Applicable_Accounts_Hidden__c from Account where Contract_Hidden__c =:contract[0].Id and Total_Applicable_Accounts_Hidden__c=0 ];
         System.debug(DeletedApplicableAccounts.size());
          if(DeletedApplicableAccounts != null && DeletedApplicableAccounts.size() > 0)
            {
             for(Account deletedappaccount : DeletedApplicableAccounts)
               {
                if( deletedappaccount.Id != null && deletedappaccount.Total_Applicable_Accounts_Hidden__c == 0 )
                   {
                            deletedappaccount.Active_Hidden__c = 'No';
                            deletedappaccount.Contract_Hidden__c = null;
                            deletedappaccount.Contract_Manager_Hidden__c = null;
                            deletedappaccount.Contract_Details_Hidden__c =null;
                            deletedappaccount.Special_Quoting_Instructions_Hidden__c=null;
                            deletedappaccount.Special_Report_Links_Hidden__c=null;
                            deletedappaccount.Pricebook_Hidden__c = null;
                            
                            update deletedappaccount;
                   }
                }
            }
    }               
    
  
}
 catch(Exception ex)
    {
        System.debug('The following exception has occurred: ' + ex.getMessage());
        contract[0].addError('Exception has occured updating Account on update of Contract object');
    }   

}

The logic of this trigger is working fine, but during execution its giving me the error of "Too many SOQL queries". Could anyone please let me know where am I going wrong?

Thanks,

Sarika Patel

Hi,

I have a requirement in which I have to select a field from Pickllist, once selected I have to add an amount in textbox and save. To serve this purpose, I created a related list.

Now the problem, is I want that related list to be filled, meaning I want to keep it mandatory as soon as the opportunity is created. I cannot place the related list at the time of creation, since it is a standard page. 
Hence, I am fine with an pop-up or message saying that you need to fill the values in the related list, once my opportunity is created.

Thanks,
Sarika 
Hi,

I want to add a validation rule, to check an email should be sent, if it has some attachment in it, if not then it should not be sent.

If not validation rule then is there any other possibility to check if the email has an attachment or not?

Is it possible?
Thanks
Hi,

I have a trigger that helps me to generate an email for sending the quote. The only problem is its not able to attache a quote PDF.
Here is the sample code:

  List<Quote> quotes = [Select Id,ContactId,OpportunityId,(Select Id,Name from QuoteDocuments order by LastModifiedDate desc limit 1) from Quote where Primary__c = true and OpportunityId in: oppIdsToProcess];     
       
        for(Opportunity opp : Trigger.new)
        {
            if(opp.Probability == 100)
            {
                string attachId = '';
              
                for(Quote q : quotes)
                {
                    if(q.OpportunityId == opp.Id)
                    {
                    
                        if(q.QuoteDocuments.size()>0)
                       {
                         
                        attachId = q.QuoteDocuments[0].Id;
                        }
                        
                    }
                }


So I am able to go till q.QuoteDocuments.size but since the size is zero, its not able to get the doc_id. Could anyone please help? I am new to this.

Hi,

I have created a custom object for "Contracts" and another custom object called "Contract Applicable Accounts". There is a rollup summary field on Contracts having total count of "Contract Applicable accounts" called Total_Applicable_Accounts__c.

Now I have created a trigger which on update of Contract object, checks all the accounts listed in "Contract Applicable Accounts" object and updates certain fields in an Account Object.

Here it is:

trigger UpdateAccount on Contract__c (before update) {
Contract__c[] Contract = Trigger.new;
try
{
    if(contract[0].Id != null)
    {
        if(contract[0].Total_Applicable_Accounts__c > 0)
        {
       
            List<Applicable_Accounts__c> ApplicableAccounts = [Select Id,Account_Name__c from Applicable_Accounts__c where Contract__c =: contract[0].Id ];
            System.debug(ApplicableAccounts.size());
            if(ApplicableAccounts != null && ApplicableAccounts.size() > 0)
            {
               for(Applicable_Accounts__c appaccount : ApplicableAccounts)
               {
                   if( appaccount.Account_Name__c != null)
                   {
                       Account objaccount = [ Select Name from Account where Id =: appaccount.Account_Name__c];                  
                       if(contract[0].Active__c != null)
                      {
                        objaccount.Active_Hidden__c = contract[0].Active__c;        
                        if(contract[0].Active__c == 'Yes')
                        {
                            if(contract[0].Id != null)
                            {  objaccount.Contract_Hidden__c = contract[0].Id; }    
                           if(contract[0].Contract_Details__c!=null)                       
                           { objaccount.Contract_Details_Hidden__c = contract[0].Contract_Details__c;}
                           if(contract[0].Special_Quoting_Instructions__c!=null)        
                           { objaccount.Special_Quoting_Instructions_Hidden__c = contract[0].Special_Quoting_Instructions__c;}
                           if(contract[0].Special_Report_Links__c!=null)
                           { objaccount.Special_Report_Links_Hidden__c = contract[0].Special_Report_Links__c;}
                            if(contract[0].Contract_Manager__c!=null)
                           { objaccount.Contract_Manager_Hidden__c = contract[0].Contract_Manager__c;  }
                           if(contract[0].Pricebook__c!=null)
                           { objaccount.Pricebook_Hidden__c = contract[0].Pricebook__c;  }                  
                        }
                        else
                        {
                             objaccount.Contract_Hidden__c = null;
                             objaccount.Contract_Manager_Hidden__c = null;
                             objaccount.Contract_Details_Hidden__c =null;
                             objaccount.Special_Quoting_Instructions_Hidden__c=null;
                             objaccount.Special_Report_Links_Hidden__c=null;
                             objaccount.Pricebook_Hidden__c = null;
                             
                        }       
                       update objaccount;
                    }  
               }  }
            }
                
        }
        List<Account> DeletedApplicableAccounts=[ Select Id,Name,Total_Applicable_Accounts_Hidden__c from Account where Contract_Hidden__c =:contract[0].Id and Total_Applicable_Accounts_Hidden__c=0 ];
         System.debug(DeletedApplicableAccounts.size());
          if(DeletedApplicableAccounts != null && DeletedApplicableAccounts.size() > 0)
            {
             for(Account deletedappaccount : DeletedApplicableAccounts)
               {
                if( deletedappaccount.Id != null && deletedappaccount.Total_Applicable_Accounts_Hidden__c == 0 )
                   {
                            deletedappaccount.Active_Hidden__c = 'No';
                            deletedappaccount.Contract_Hidden__c = null;
                            deletedappaccount.Contract_Manager_Hidden__c = null;
                            deletedappaccount.Contract_Details_Hidden__c =null;
                            deletedappaccount.Special_Quoting_Instructions_Hidden__c=null;
                            deletedappaccount.Special_Report_Links_Hidden__c=null;
                            deletedappaccount.Pricebook_Hidden__c = null;
                            
                            update deletedappaccount;
                   }
                }
            }
    }               
    
  
}
 catch(Exception ex)
    {
        System.debug('The following exception has occurred: ' + ex.getMessage());
        contract[0].addError('Exception has occured updating Account on update of Contract object');
    }   

}

The logic of this trigger is working fine, but during execution its giving me the error of "Too many SOQL queries". Could anyone please let me know where am I going wrong?

Thanks,

Sarika Patel

Hi,

I have a requirement in which I have to select a field from Pickllist, once selected I have to add an amount in textbox and save. To serve this purpose, I created a related list.

Now the problem, is I want that related list to be filled, meaning I want to keep it mandatory as soon as the opportunity is created. I cannot place the related list at the time of creation, since it is a standard page. 
Hence, I am fine with an pop-up or message saying that you need to fill the values in the related list, once my opportunity is created.

Thanks,
Sarika 

Has anyone created any sort of code that could recognize whether a quote has a PDF created in the related list?