• AlexRitsonDev
  • NEWBIE
  • 0 Points
  • Member since 2013

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

I need to write a test class for my code before Salesforce will allow us to deploy it.

 

I'm a complete newbie and would greatly appreciate your help.

 

The class is as follows (please also let me know if you can see any basic errors):

 

public with sharing class CreatecontractonOppstageclosewon {
{
Set<Id> accId = new Set<Id>();
List<Opportunity> opplist = new List<Opportunity>();
List<contract> conrtlist = new List<contract>();
for(Opportunity opp : Trigger.new){
if(opp.StageName == 'Closed Won'){
Contract con = new Contract();
if(opp.AccountId != NULL){
con .AccountId = opp.AccountId;
}
con .Status = 'Draft';
con .StartDate = System.Today();
con .ContractTerm = opp.Length_of_project_months__c;
con.X2_RESEARCH_LPA__c = opp.X2_RESEARCH_LPA__c
con.X3_RESEARCH_site_history__c) - opp.X3_RESEARCH_site_history__c)
con.X4_RESEARCH_likely_issues__c = opp.X4_RESEARCH_likely_issues__c
con.X5_RESEARCH_Stakeholders__c - opp.X5_RESEARCH_Stakeholders__c
con.X6_RESEARCH_company_other_projects__c = opp.X6_RESEARCH_company_other_projects__c
con.Client_Code__c = opp.Client_Code__c
con.Council__c = opp.Council__c
con.Date_for_1st_Public_Exhibition__c = opp.Date_for_1st_Public_Exhibition__c
con.Date_for_2nd_Public_Exhibition__c = opp.Date_for_2nd_Public_Exhibition__c
con.Date_to_Call__c = opp.Date_to_Call__c
con.Date_for_Submission__c = opp.Date_for_Submission__c
con.Details_of_Lead__c = opp.Details_of_Lead__c
con.First_Meeting_Report__c = opp.First_Meeting_Report__c
con.IPA_Pitch_Member_1__c = opp.IPA_Pitch_Member_1__c
con.IPA_Pitch_Member_2__c = opp.IPA_Pitch_Member_2__c
con.IPA_Pitch_Member_3__c = opp.IPA_Pitch_Member_3__c
con.Indigo_Email__c = opp.Indigo_Email__c
con.Planning_Committee_Date_Time__c = opp.Planning_Committee_Date_Time__c
con.Previous_contact__c = opp.Previous_contact__c
con.Referersemail__c = opp.Referersemail__c
con.Region__c = opp.Region__c
con.Relevant_Work__c = opp.Relevant_Work__c
con.Sales_Notes__c = opp.Sales_Notes__c
con.Sector__c = opp.Sector__c
con.Is_there_a_URL_where_you_found_this_lead__c = opp.Is_there_a_URL_where_you_found_this_lead__c
conrtlist .add(con );
}
}
if(conrtlist.size() > 0){
insert conrtlist ;
}
}
}

 

And the trigger is as follows:

 

trigger CreatecontractonOppstageclosewon on Opportunity (after insert, after update) {

}

 

Please, please help.  Essentially, what this will do is when we get to the Opportunity Closed/Won stage in Opportunities, a Contract will automatically be created with our custom fields fully copied over.  I know lots of other people wish they could do this, will share anything you give me and what we have created already with the world.

 

Best regards,

 

Alex.

 

 

Someone I met on these boards has kindly helped me write a piece of code that should create a contract from an opportunity, and copy over our custom fields (see below).

 

I am now struggling with the task of getting it deployed into our org.  We have enterprise edition - is there anyone who would be prepared to walk me through what I need to do, stage by stage?

 

Please, please help!

 

 

trigger CreatecontractonOppstageclosewon on Opportunity (after insert , after update) {
Set<Id> accId = new Set<Id>();
List<Opportunity> opplist = new List<Opportunity>();
List<contract> conrtlist = new List<contract>();
for(Opportunity opp : Trigger.new){
if(opp.StageName == 'Closed Won'){
Contract con = new Contract();
if(opp.AccountId != NULL){
con .AccountId = opp.AccountId;
}
con .Status = 'Draft';
con .StartDate = System.Today();
con .ContractTerm = 6;
con.X2_RESEARCH_LPA__c = opp.X2_RESEARCH_LPA__c
con.X3_RESEARCH_site_history__c) - opp.X3_RESEARCH_site_history__c)
con.X4_RESEARCH_likely_issues__c = opp.X4_RESEARCH_likely_issues__c
con.X5_RESEARCH_Stakeholders__c - opp.X5_RESEARCH_Stakeholders__c
con.X6_RESEARCH_company_other_projects__c = opp.X6_RESEARCH_company_other_projects__c
con.Client_Code__c = opp.Client_Code__c
con.Council__c = opp.Council__c
con.Date_for_1st_Public_Exhibition__c = opp.Date_for_1st_Public_Exhibition__c
con.Date_for_2nd_Public_Exhibition__c = opp.Date_for_2nd_Public_Exhibition__c
con.Date_to_Call__c = opp.Date_to_Call__c
con.Date_for_Submission__c = opp.Date_for_Submission__c
con.Details_of_Lead__c = opp.Details_of_Lead__c
con.First_Meeting_Report__c = opp.First_Meeting_Report__c
con.IPA_Pitch_Member_1__c = opp.IPA_Pitch_Member_1__c
con.IPA_Pitch_Member_2__c = opp.IPA_Pitch_Member_2__c
con.IPA_Pitch_Member_3__c = opp.IPA_Pitch_Member_3__c
con.Indigo_Email__c = opp.Indigo_Email__c
con.Planning_Committee_Date_Time__c = opp.Planning_Committee_Date_Time__c
con.Previous_contact__c = opp.Previous_contact__c
con.Referersemail__c = opp.Referersemail__c
con.Region__c = opp.Region__c
con.Relevant_Work__c = opp.Relevant_Work__c
con.Sales_Notes__c = opp.Sales_Notes__c
con.Sector__c = opp.Sector__c
con.Is_there_a_URL_where_you_found_this_lead__c = opp.Is_there_a_URL_where_you_found_this_lead__c
conrtlist .add(con );
}
}
if(conrtlist.size() > 0){
insert conrtlist ;
}
}

 

 

 

 

I am now, finally, in a position to deploy the code which a kind developer on this board wrote for me a couple of weeks ago.  The hold-up was in getting our organisation upgraded to Enterprise edition, which has now been done.

 

I have downloaded and installed the force.com IDE, but I am a complete newbie and am now absolutely terrified.  What do I need to do to get this code actually installed on our company's Salesforce system?

 

 

I notice thae Salesforce.com have a requirement that 75%, and preferably 100% of the code be covered by automated tests.  I assume I need to find out how to do this?

 

Someone, please help!

 

Best regards,

 

Alex.

ezdhanhussain created an amazing bit of code for me last week which automatically creates a Contract from an Opportunities, as soon as the stage is advanced to Closed Won.  For the benefit of others, as well as those kind people who might help me now, the code is below.

 

I now need to make some small improvements - specifically, to get the code to transfer over some custom fields from each opportunity.

 

The custom fields which we need to transfer over are these:

 

1. RESEARCH People (X1_RESEARCH_People__c)

2. RESEARCH LPA (X2_RESEARCH_LPA__c)

3. RESEARCH site history (X3_RESEARCH_site_history__c)

4. RESEARCH likely issues (X4_RESEARCH_likely_issues__c)

5. RESEARCH Stakeholders (X5_RESEARCH_Stakeholders__c)

6. RESEARCH company other projects (X6_RESEARCH_company_other_projects__c)

Client Code (Client_Code__c)

Council where the scheme is (Council__c)

Date for 1st Public Exhibition (Date_for_1st_Public_Exhibition__c)

Date for 2nd Public Exhibition (Date_for_2nd_Public_Exhibition__c)

Date for Steve to Call (Date_to_Call__c)

Date for Submission (Date_for_Submission__c)

Details of Lead (Details_of_Lead__c)

First Meeting Report (First_Meeting_Report__c)

IPA Pitch Member 1 (IPA_Pitch_Member_1__c)

IPA Pitch Member 2 (IPA_Pitch_Member_2__c)

IPA Pitch Member 3 (IPA_Pitch_Member_3__c)

IPA Source of Lead (Indigo_Email__c)

Planning Committee Date Time (Planning_Committee_Date_Time__c)

Previous contact (Previous_contact__c)

Referer's main email address (Referersemail__c)

Region where the scheme is (Region__c)
Relevant Work (Relevant_Work__c)

Sales Notes (Sales_Notes__c)

Sector of the scheme (Sector__c)

URL where you found this lead (Is_there_a_URL_where_you_found_this_lead__c)

 

The code is:

 

trigger CreatecontractonOppstageclosewon on Opportunity (after insert,after update) {
Set<Id> accId = new Set<Id>();
List<Opportunity> opplist = new List<Opportunity>();
List<contract> conrtlist = new List<contract>();
for(Opportunity opp : Trigger.new){
if(opp.StageName == 'Closed Won'){
System.Debug('Testing');
Contract con = new Contract();
if(opp.AccountId != NULL){
con .AccountId = opp.AccountId;
System.Debug('Test');
}

con .Status = 'Draft';
system.debug('Testing1');
con .StartDate = System.Today();
system.debug('Testing2');
con .ContractTerm = 6;
system.debug('Testing3');
conrtlist .add(con );
}
}
if(conrtlist.size() > 0){
insert conrtlist ;
system.debug('Testing4');
}
}

 

Will greatly appreciate your advice and assistance.  I'm a newbie - didn't know what Salesforce was 10 weeks ago, but making good progress implementing it into the small ish company I'm working with.  Hopefully in a few months I'll be writing me own code and helping other people out on these boards.

 

Thanks in advance,

 

Alex.

I am now, finally, in a position to deploy the code which a kind developer on this board wrote for me a couple of weeks ago.  The hold-up was in getting our organisation upgraded to Enterprise edition, which has now been done.

 

I have downloaded and installed the force.com IDE, but I am a complete newbie and am now absolutely terrified.  What do I need to do to get this code actually installed on our company's Salesforce system?

 

 

I notice thae Salesforce.com have a requirement that 75%, and preferably 100% of the code be covered by automated tests.  I assume I need to find out how to do this?

 

Someone, please help!

 

Best regards,

 

Alex.

Hello,

 

Being a business that provides services, I need a third stage of the Salesforce process for when we have won the contract a the end of the Opportunity phase.  This will be for the period where we have won a contract for some business, and it would be great to have Salesforce workflow etc to ensure that we provide what we promised to provide to our customers.

 

It appears to me that Contracts would be the perfect tool, however there is apparently no way of transferring information such as quotations, sales notes, company names or contacts directly from a Salesforce Opportunity into a Salesforce Contract.

 

The people at Salesforce say this ought to be possible with some fairly simple Apex code, but I don't know where to start.  

 

This was clearly an issue back in 2010 - see http://boards.developerforce.com/t5/General-Development/New-to-Sales-force-Convert-Opportunity-to-Contract/td-p/163183 .Annoyingly, the link to the supposed "answer" no longer works.

 

Please help!

 

Best regards,

 

Alex.

Hello,

 

I'm a new user with a devil of a problem - I need to create a bit of code that wil allow me to send meeting requests to non-Salesforce users that will put my Salesforce meetings in their diaries, Outlook or other.

 

I put full details of my request on the General board, thinking it could be done from within the custom HTML email templates.  I now realise it's more of an Apex issue.  

 

Would you be so kind as to take a look?  The thread is http://boards.developerforce.com/t5/General-Development/sending-an-ICS-Outlook-compatible-calendar-request-with-workflow/td-p/658603.

 

Best regards,

 

Alex.