You need to sign in to do that
Don't have an account?
IJW
Newbie Seeks Help: How to Deploy New Lead Trigger
Hi all,
I want to deplot the below code onto the Lead Trigger, I've got he force.com IDE, and the class but I can't figure out how to deploy it.
I think it is because I haven't tested with code coverage, but I can't figure out how to do that either. Can you help?
trigger LeadConversionPrimaryContact on Lead (after update) { if (Trigger.new.size() == 1) { if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) { // Get the new oppcontactrole record if (Trigger.new[0].ConvertedOpportunityId != null && Trigger.new[0].ConvertedContactId != null) { OpportunityContactRole ocr = [select Id,IsPrimary from OpportunityContactRole where OpportunityId = :Trigger.new[0].ConvertedOpportunityId and ContactId = :Trigger.new[0].ConvertedContactId]; ocr.IsPrimary = true; update ocr; } } } }
Thanks,
IJW
How to deploy with UI:
Log in to production.
Create a sandbox, if necessary (Setup > Data Management > Sandboxes).
Link the sandbox for change sets (Setup > Deploy > Deployment Connections).
Log in to sandbox.
Create the trigger (Setup > Customize > Leads > Triggers).
Create the test class (Setup > Develop > Apex Classes).
Create an outbound change set (Setup > Deploy > Outbound Change Sets).
Add the class and trigger to the change set, and upload.
Login to production.
View the inbound change set (Setup > Deploy > Inbound Change Sets).
Install the change set.
How to deploy with Force.com IDE:
Create the test class against your production organization.
Populate the code for the test class.
Create the trigger against your production organization.
Populate the code for the trigger.
As you save in the IDE, changes are (by default) automatically sent to the server. You could also highlight both files in the Project Explorer, right-click, and choose Force.com > Save to server.
All Answers
Yes, you need code coverage of at least 1% (for triggers). Looks like this should be easy:
Ok great - seeing the test class, I kind of 'get' how it "covers" the code.
I can't figure out how to deploy using the Force.com IDE, so would it be easier in the SFDC UI?
Do you know of any good tutorials for this part of the exercise?
Thanks,
IJW
How to deploy with UI:
Log in to production.
Create a sandbox, if necessary (Setup > Data Management > Sandboxes).
Link the sandbox for change sets (Setup > Deploy > Deployment Connections).
Log in to sandbox.
Create the trigger (Setup > Customize > Leads > Triggers).
Create the test class (Setup > Develop > Apex Classes).
Create an outbound change set (Setup > Deploy > Outbound Change Sets).
Add the class and trigger to the change set, and upload.
Login to production.
View the inbound change set (Setup > Deploy > Inbound Change Sets).
Install the change set.
How to deploy with Force.com IDE:
Create the test class against your production organization.
Populate the code for the test class.
Create the trigger against your production organization.
Populate the code for the trigger.
As you save in the IDE, changes are (by default) automatically sent to the server. You could also highlight both files in the Project Explorer, right-click, and choose Force.com > Save to server.
This was perfect!
Thank you!