• AlexRitson
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 11
    Replies

I'm a newbie and have, with the help of some very kind people on these boards, assembled some code that should enable us to convert Opportunities to Contracts.  Once this is working, I shall be happy to share this with everyone, as I know that I am not the first person to have needed this functionality.

 

Frustratingly, there is, according to Salesforce, still a missing couple of lines of code somewhere around line 2 - the method.

 

Would very much appreciate help from anyone who can make this work for me.

 

Best regards,

 

Alex.

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 ;
}
}
}

 

Hello,

 

Background:

We are a services based company, and have therefore customised "Contracts" to be a third stage of the CRM process.  Therefore:

Stage 1: Leads.  This is where our Sales team cold-call potential business prospects and arrange meetings.

Stage 2: Opportunities.  This is where our team of experts go to meet a new potential client, after a meeting has been set up in the stage 1 (Leads) section, and with luck, actually sell them the service that our company provides.

Stage 3. Contracts.  This is where we have won a contract at the end of Stage 2 (above) and we wish to use Salesforce to standardise and improve the customer experience.

 

As you will all know, Contacts can be associated with Accounts, Leads and Opportunities.  If you click on a Contact record, you will be able to see which Accounts, Leads and Opportunities they are associated with (for customisation of layout, these are in Page Layout under "Related Lists".)

 

Annoyingly, "Contracts" (our new Stage 3) does not exist on the "Related Lists" section of "Contacts".

 

Can anyone help write us some code that will make "Contracts" show in "Related Lists" of "Contacts" please?

 

Thank you very much in advance,

 

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.

Hi there,

 

I'm putting Salesforce into my company - first time have done this and all is going well.  However, I now need to design the next stage (stage 3) of my process - and I'm not sure which bit of Salesforce is most appropriate to use.  Obviously, it's important I make a good choice, as the decision I make will have implications for years to come.

 

So far, the system I have created is structured as below:

 

Stage 1. LEADS.  A lot of new business comes in this way.  I have essentially made this like an old fashioned salesperson's T card system.  When we have a new lead, including one from an existing customer for a new area of business, it goes into leads, the sales team make the call, and then either kick it into the long grass for a while (i.e. are told to call back later, where a combination of lead status and and workflow rules mean it comes back to the sales team on an appropriate day) or they set up a meeting with the potential client - at which point the Lead is converted to an Opportunity.

 

Stage 2. OPPORTUNITIES. In our company, opportunities are where a potential client with a project (new or existing) has agreed to meet us to hear our pitch for their business.  Again, it's a T-card type system - with workflow rules and Opportunity status creating team meetings to prepare for a pitch, a pitch, and then the necessary follow-up to hopefuly win the business at the end of the process.

 

Stage 3.  This is the bit I need help with.  This is where we want Salesforce to help us create a process for dealing with customers who have allowed us to win their business in stage 2.  These are the most important people in our business.  Obviously, when the lead was converted into an opportunitiy, the customer became registered as an Account.  The people we talk to are registered as Contacts.  But in what part of Salesforce do we create the process that handles the current projects that we have won?  Ideally, there would also be a "convert" button in Opportunities that would take the opportunitiy and turn it into something else which retains all the information about the customer that was recorded earlier in the process.  I've looked at Contracts, but they don't seem like a good place, as there is no way to automatically transfer informaton from an Opportunity which has been won to a Contract.

 

Your thoughts very gratefully considered.  I'm a newbie - this is only my second post - so please be gentle.

 

Best regards,

 

Alex.

Hello,

 

This is my first post here.  I'm putting in Salesforce to my organisation and it has been good so far.  However, there is one feature which is missing, and I really need to find a workaround.

 

During our Opportunitiy stage, we have various meetings.  Some of the people who attend are Salesforce users, most of the people aren't, but their emails are in the system and accessible to the either as contacts or custom email fields.  It is obviously easy to create a workflow rule that emails all the people I want to email when a meeting is arranged, however I want to accompany the email with an ICS attachment that has the meeting time.

 

I'm not a programmer, although I do play with HTML code in my spare time for fun.  As such, I may well ask things that appear a bit dumb - apologies in advance for this.

 

However, I have found the two following bits of code which might make my objective possible, with a bit of tweaking.  If you can give me any help or advice, I shall be most grateful.  I have also realised that I'm noto the only one who wants this goal, so if you can come up with the answer, there will be grateful people around the world.

 

Thanks in advance!

 

Alex.

 

CODE 1:

 

<?php
  $date      = $_GET['date'];  $startTime = $_GET['startTime'];  $endTime   = $_GET['endTime'];  $subject   = $_GET['subject'];  $desc      = $_GET['desc'];  $ical ="BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:". md5(uniqid(mt_rand(),true))."example.com
DTSTAMP:". gmdate('Ymd').'T'. gmdate('His')."Z
DTSTART:".$date."T".$startTime."00Z
DTEND:".$date."T".$endTime."00Z
SUMMARY:".$subject."
DESCRIPTION:".$desc."
END:VEVENT
END:VCALENDAR";//set correct content-type-header  header('Content-type: text/calendar; charset=utf-8');  header('Content-Disposition: inline; filename=calendar.ics');  echo $ical;exit;?>

CODE NO 2

 

publicvoid Sendmail_With_IcsAttachment()

        {

 

            MailMessage msg = newMailMessage();

            //Now we have to set the value to Mail message properties

 

            //Note Please change it to correct mail-id to use this in your application

            msg.From = newMailAddress("xxxxx@xyz.com", "ABC");

            msg.To.Add(newMailAddress("yyyyy@xyz.com", "BCD"));

            msg.CC.Add(newMailAddress("zzzzz@xyz.com", "DEF"));// it is optional, only if required

            msg.Subject = "Send mail with ICS file as an Attachment";

            msg.Body = "Please Attend the meeting with this schedule";

 

            // Now Contruct the ICS file using string builder

            StringBuilder str = newStringBuilder();

            str.AppendLine("BEGIN:VCALENDAR");

            str.AppendLine("PRODID:-//Schedule a Meeting");

            str.AppendLine("VERSION:2.0");

            str.AppendLine("METHOD:REQUEST");

            str.AppendLine("BEGIN:VEVENT");

            str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+330)));

            str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));

            str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+660)));

            str.AppendLine("LOCATION: " + this.Location);

            str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));

            str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body));

            str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body));

            str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject));

            str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address));

 

            str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));

 

            str.AppendLine("BEGIN:VALARM");

            str.AppendLine("TRIGGER:-PT15M");

            str.AppendLine("ACTION:DISPLAY");

            str.AppendLine("DESCRIPTION:Reminder");

            str.AppendLine("END:VALARM");

            str.AppendLine("END:VEVENT");

            str.AppendLine("END:VCALENDAR");

 

            //Now sending a mail with attachment ICS file.                     

            System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();

            smtpclient.Host = "localhost"; //-------this has to given the Mailserver IP

 

            smtpclient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

 

            System.Net.Mime.ContentType contype = new System.Net.Mime.ContentType("text/calendar");

            contype.Parameters.Add("method", "REQUEST"); 

            contype.Parameters.Add("name", "Meeting.ics");

            AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), contype);

            msg.AlternateViews.Add(avCal);

            smtpclient.Send(msg); 

 

          

        }

 

Hello,

 

Background:

We are a services based company, and have therefore customised "Contracts" to be a third stage of the CRM process.  Therefore:

Stage 1: Leads.  This is where our Sales team cold-call potential business prospects and arrange meetings.

Stage 2: Opportunities.  This is where our team of experts go to meet a new potential client, after a meeting has been set up in the stage 1 (Leads) section, and with luck, actually sell them the service that our company provides.

Stage 3. Contracts.  This is where we have won a contract at the end of Stage 2 (above) and we wish to use Salesforce to standardise and improve the customer experience.

 

As you will all know, Contacts can be associated with Accounts, Leads and Opportunities.  If you click on a Contact record, you will be able to see which Accounts, Leads and Opportunities they are associated with (for customisation of layout, these are in Page Layout under "Related Lists".)

 

Annoyingly, "Contracts" (our new Stage 3) does not exist on the "Related Lists" section of "Contacts".

 

Can anyone help write us some code that will make "Contracts" show in "Related Lists" of "Contacts" please?

 

Thank you very much in advance,

 

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.

I'm a newbie and have, with the help of some very kind people on these boards, assembled some code that should enable us to convert Opportunities to Contracts.  Once this is working, I shall be happy to share this with everyone, as I know that I am not the first person to have needed this functionality.

 

Frustratingly, there is, according to Salesforce, still a missing couple of lines of code somewhere around line 2 - the method.

 

Would very much appreciate help from anyone who can make this work for me.

 

Best regards,

 

Alex.

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 ;
}
}
}

 

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 ;
}
}

 

 

 

 

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.

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.

Hi there,

 

I'm putting Salesforce into my company - first time have done this and all is going well.  However, I now need to design the next stage (stage 3) of my process - and I'm not sure which bit of Salesforce is most appropriate to use.  Obviously, it's important I make a good choice, as the decision I make will have implications for years to come.

 

So far, the system I have created is structured as below:

 

Stage 1. LEADS.  A lot of new business comes in this way.  I have essentially made this like an old fashioned salesperson's T card system.  When we have a new lead, including one from an existing customer for a new area of business, it goes into leads, the sales team make the call, and then either kick it into the long grass for a while (i.e. are told to call back later, where a combination of lead status and and workflow rules mean it comes back to the sales team on an appropriate day) or they set up a meeting with the potential client - at which point the Lead is converted to an Opportunity.

 

Stage 2. OPPORTUNITIES. In our company, opportunities are where a potential client with a project (new or existing) has agreed to meet us to hear our pitch for their business.  Again, it's a T-card type system - with workflow rules and Opportunity status creating team meetings to prepare for a pitch, a pitch, and then the necessary follow-up to hopefuly win the business at the end of the process.

 

Stage 3.  This is the bit I need help with.  This is where we want Salesforce to help us create a process for dealing with customers who have allowed us to win their business in stage 2.  These are the most important people in our business.  Obviously, when the lead was converted into an opportunitiy, the customer became registered as an Account.  The people we talk to are registered as Contacts.  But in what part of Salesforce do we create the process that handles the current projects that we have won?  Ideally, there would also be a "convert" button in Opportunities that would take the opportunitiy and turn it into something else which retains all the information about the customer that was recorded earlier in the process.  I've looked at Contracts, but they don't seem like a good place, as there is no way to automatically transfer informaton from an Opportunity which has been won to a Contract.

 

Your thoughts very gratefully considered.  I'm a newbie - this is only my second post - so please be gentle.

 

Best regards,

 

Alex.

Hello,

 

This is my first post here.  I'm putting in Salesforce to my organisation and it has been good so far.  However, there is one feature which is missing, and I really need to find a workaround.

 

During our Opportunitiy stage, we have various meetings.  Some of the people who attend are Salesforce users, most of the people aren't, but their emails are in the system and accessible to the either as contacts or custom email fields.  It is obviously easy to create a workflow rule that emails all the people I want to email when a meeting is arranged, however I want to accompany the email with an ICS attachment that has the meeting time.

 

I'm not a programmer, although I do play with HTML code in my spare time for fun.  As such, I may well ask things that appear a bit dumb - apologies in advance for this.

 

However, I have found the two following bits of code which might make my objective possible, with a bit of tweaking.  If you can give me any help or advice, I shall be most grateful.  I have also realised that I'm noto the only one who wants this goal, so if you can come up with the answer, there will be grateful people around the world.

 

Thanks in advance!

 

Alex.

 

CODE 1:

 

<?php
  $date      = $_GET['date'];  $startTime = $_GET['startTime'];  $endTime   = $_GET['endTime'];  $subject   = $_GET['subject'];  $desc      = $_GET['desc'];  $ical ="BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:". md5(uniqid(mt_rand(),true))."example.com
DTSTAMP:". gmdate('Ymd').'T'. gmdate('His')."Z
DTSTART:".$date."T".$startTime."00Z
DTEND:".$date."T".$endTime."00Z
SUMMARY:".$subject."
DESCRIPTION:".$desc."
END:VEVENT
END:VCALENDAR";//set correct content-type-header  header('Content-type: text/calendar; charset=utf-8');  header('Content-Disposition: inline; filename=calendar.ics');  echo $ical;exit;?>

CODE NO 2

 

publicvoid Sendmail_With_IcsAttachment()

        {

 

            MailMessage msg = newMailMessage();

            //Now we have to set the value to Mail message properties

 

            //Note Please change it to correct mail-id to use this in your application

            msg.From = newMailAddress("xxxxx@xyz.com", "ABC");

            msg.To.Add(newMailAddress("yyyyy@xyz.com", "BCD"));

            msg.CC.Add(newMailAddress("zzzzz@xyz.com", "DEF"));// it is optional, only if required

            msg.Subject = "Send mail with ICS file as an Attachment";

            msg.Body = "Please Attend the meeting with this schedule";

 

            // Now Contruct the ICS file using string builder

            StringBuilder str = newStringBuilder();

            str.AppendLine("BEGIN:VCALENDAR");

            str.AppendLine("PRODID:-//Schedule a Meeting");

            str.AppendLine("VERSION:2.0");

            str.AppendLine("METHOD:REQUEST");

            str.AppendLine("BEGIN:VEVENT");

            str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+330)));

            str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));

            str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+660)));

            str.AppendLine("LOCATION: " + this.Location);

            str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));

            str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body));

            str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body));

            str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject));

            str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address));

 

            str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));

 

            str.AppendLine("BEGIN:VALARM");

            str.AppendLine("TRIGGER:-PT15M");

            str.AppendLine("ACTION:DISPLAY");

            str.AppendLine("DESCRIPTION:Reminder");

            str.AppendLine("END:VALARM");

            str.AppendLine("END:VEVENT");

            str.AppendLine("END:VCALENDAR");

 

            //Now sending a mail with attachment ICS file.                     

            System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();

            smtpclient.Host = "localhost"; //-------this has to given the Mailserver IP

 

            smtpclient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

 

            System.Net.Mime.ContentType contype = new System.Net.Mime.ContentType("text/calendar");

            contype.Parameters.Add("method", "REQUEST"); 

            contype.Parameters.Add("name", "Meeting.ics");

            AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), contype);

            msg.AlternateViews.Add(avCal);

            smtpclient.Send(msg); 

 

          

        }