• madimulia
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hi there, I am very new at writing APEX code. I am trying to write trigger to automatically clone a contract if it expired. So here is the code I currently have and apparently it does not work.

 

 

An expired contract should only be cloned once, and the new contract status will be set to "awaiting payment". Any help on this matter would be greatly appreaciated :)

 

trigger CloneExpiredContract on Contract (after update) {

  // List of the contracts that have been passed into the trigger.
  List<Contract> Contracts = new List<Contract>();
  Set<Id> AccIds = new Set<Id>();  // set of unique associated Account Ids
  Map<Id, Integer> ExpiredContractCnt = new Map<Id, Integer>();  // map of Account Ids and number of Active Contracts
  Map<Id, Integer> AwaitingPaymentContractCnt = new Map<Id, Integer>();  // map of Account Ids and number of Draft Contracts
  
  // Assign new Contract values
  Contracts = Trigger.new;

  // make list of unique Account Ids and build maps
  for (Contract con : Contracts) {
    ExpiredContractCnt.put(con.accountid,0);
    AwaitingPaymentContractCnt.put(con.accountid,0);
    AccIds.add(con.accountid);
  } 
  
  // query Contract table for any expired SLA Contracts linked to Accounts
  //  iterate through results to count up expired Contracts per Account
  for (Contract qra : [select id, accountid from contract where accountid in :ExpiredContractCnt.KeySet() and
    recordtypeid = '0123000000003Tf' and status = 'Expired']) {
    // increment counter in Account map for each Active contract
    integer cnta = ExpiredContractCnt.get(qra.accountid);
    integer cntb = 0;
    ExpiredContractCnt.put(qra.accountid, cnta+1);
    
    //Check to see if contract has been cloned before
    for (Contract qrb : [select id, accountid from contract where accountid in :AwaitingPaymentContractCnt.KeySet() and
    recordtypeid = '0123000000003Tf' and status = 'Awaiting Payment']) {
        // increment counter in Account map for each Draft contract
        cntb = AwaitingPaymentContractCnt.get(qrb.accountid);
        AwaitingPaymentContractCnt.put(qrb.accountid, cntb+1);
    }
    
    if (cntb > 0) {
       qra.clone();
    }
    
  }  
}

The main goal is to notify Account Owner and additional email of a Case. So I set up a new Workflow Rules with criteria "Case Comment: Body not equal to null". The workflow is working fine. Then I also set up a new Email Alert.

 

I did these steps:
http://blogs.salesforce.com/support/2009/06/new-in-summer-09-workflow-email-alerts-for-case-comments.html

 

Here is my current obstacle, I cannot send the email alert to the Case Account Owner and Email Field I created. There is options for both, but Account Owner from the list is basically My Account (logged in account), not the Case Account Owner. And the email field I created does not show up on the list.

 

Any idea? Thanks in advance

Message Edited by madimulia on 09-16-2009 01:44 PM

I'm currently trying to create formula to calculate the Age of a case at certain status. So that we would be able to know how long a case has been in "new", "in-progress", or "Waiting", etc.

 

Is anyone know how to do this? I can only calculate Today()-CreatedDate so far.

Any input is very appreciated. Thanks!:)

My company is still using API version 6.0 and planning to upgrade to the latest one. While generating java files from Enterprise API using Apache Axis2-1.1, I notice that I'm missing com.sforce.soap.enterprise.SforceServiceLocator class. Is this file deprecated in the current API?

 

Also, does anyone have a clue where I can get EnterpriseLoginBean (om.sforce.util.login.EnterpriseLoginBean)? Thanks in advance!

 

Last question, what would be best practices in upgrading API? Do I need to redeploy the whole web app or just need to update the related /WEB-INF/classes?

The main goal is to notify Account Owner and additional email of a Case. So I set up a new Workflow Rules with criteria "Case Comment: Body not equal to null". The workflow is working fine. Then I also set up a new Email Alert.

 

I did these steps:
http://blogs.salesforce.com/support/2009/06/new-in-summer-09-workflow-email-alerts-for-case-comments.html

 

Here is my current obstacle, I cannot send the email alert to the Case Account Owner and Email Field I created. There is options for both, but Account Owner from the list is basically My Account (logged in account), not the Case Account Owner. And the email field I created does not show up on the list.

 

Any idea? Thanks in advance

Message Edited by madimulia on 09-16-2009 01:44 PM

My company is still using API version 6.0 and planning to upgrade to the latest one. While generating java files from Enterprise API using Apache Axis2-1.1, I notice that I'm missing com.sforce.soap.enterprise.SforceServiceLocator class. Is this file deprecated in the current API?

 

Also, does anyone have a clue where I can get EnterpriseLoginBean (om.sforce.util.login.EnterpriseLoginBean)? Thanks in advance!

 

Last question, what would be best practices in upgrading API? Do I need to redeploy the whole web app or just need to update the related /WEB-INF/classes?

I have an email going to the record owner when their record is rejected as part of the Approval process. Is there a way to include the reasons for rejection in the email template.

 

I tried using {!ApprovalRequest.Comments} but it did not work.

I am not sure if answer to my question below is pretty simple and not getting in to my head...

Salesforce allows to use only one communication template for all steps in an approval process. Is there a way to use different templates for different stages.  Basically we wanted to send an email alert to user with whom action is pending next in case of rejection or approval in current level. Right now same email is sent for all events. Please let me know of there is any issue with out setup.

Thanks in anticipation,

  • October 07, 2008
  • Like
  • 0