I want to create campaign record via script as new button was not there.But when i insert record it says

Line: 1, Column: 20
Field is not writeable: Campaign.Name

Even i am system admin .I have full CRUD access

Campaign newCamp = new Campaign(Name='EMEA Dist-Multi Channel Product/Marketing Info',isActive = true);
insert newcamp;
system.debug('campaign inserted successfully');
  • Name and few other fields are not writeable because those are managed by system directly, like createdDate, lastModifiedDate, CreatedBy etc. So remove Name field. Commented Apr 29, 2021 at 9:42
  • Refer to this thread for more help on the same. Commented Apr 29, 2021 at 10:01
  • if i remove name field then how would i add campaign where name field is required Commented Apr 29, 2021 at 10:05
  • Have you ensured the Marketing user checkbox is checked on the admin profile? Commented Apr 29, 2021 at 10:55
  • no...please tell me how can i verify it...I means where can i find marketing user checkbox Commented Apr 29, 2021 at 12:21

2 Answers 2


I have done a quick repro of the code snippet you provided in my org with the "Marketing user" checkbox enabled and it gives output as

campaign inserted successfully

When disabled, it gives an error

Field is not writeable: Campaign.Name

Click path to enable the Marketing user checkbox: Navigate to setup>Mange Users> Users> select the user and search for "Marketing User " checkbox. Make sure it is checked. enter image description here


Your code is fine, it is a User field that is causing the problem. The User executing the piece of code must have Marketing User enabled in order to perform any database operation other than Read on Campaign records.

When enabled and the user has Read permission on contacts or the Import permission on Leads, and Edit permission on campaigns, the user can create, edit, and delete campaigns, configure advanced campaign setup, and add campaign members and update their statuses with the Data Import Wizard. Available in Professional, Enterprise, Unlimited, and Performance Editions.

If this option isn’t selected, or the user doesn’t have the necessary permissions, the user can only view campaigns and advanced campaign setup, edit the Campaign History for a single lead or contact, and run campaign reports.

As per User Fields.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .