function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CHANDRA KANTH KONDURU 10CHANDRA KANTH KONDURU 10 

Code to create Campaign when a New Campaign is created

Hi All,

I need code for the following scenarios. Please help me out.

1.When any new Project(Custom Object) is created, a default Campaign will created by system. (This will allow countryManagers(India,USA, Brazil managers)  to assign a campaign to leads)
2.When a new campaign is created, a series of Campaign tasks will automatically be created by Salesforce and assigned to a user. The specific list of tasks will be conditional on the ‘Campaign Type’ field. 

Default Campaign Tasks that are created when a new Campaign is created:-    
1.CIO Event
2.Digital (Lead Generation)
3.Digital (Brand Awareness) 

Thanks,
Chandu
PratikPratik (Salesforce Developers) 
Hi Chandu,

You can achieve this bt using the Trigger. Trigger can create the record in the system.

You can write the trigger on the Insert event of Project (Custom object), with your ceratin criteria you can create the Campaign. 

Now to create the Campign Task: Write another trigger on Campaign on the inser event of Campaign.  

Thanks,
Pratik
CHANDRA KANTH KONDURU 10CHANDRA KANTH KONDURU 10
Hi Pratik,

Can you please give me the code for 1st scenario.

Here are the details:
Project (Custom Object) 

Some Imp Fields required for writting the trigger:
 Name - Required
Currency - Required
Project_Id__c - Auto number
Campaign__c - Lookup

Regards,
Chandu