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
evodanhevodanh 

How to create a campaign

I'm using Free trial for developer.
I want to create a campaign by using Salesforce API v9.0
//
Sforce.Campaign campaign = new Sforce.Campaign();
campaign.Name = campaignName;
campaign.StartDate = startTime;
campaign.EndDate = endTime;
campaign.Type = "Other";
campaign.Status = "Planned";
campaign.BudgetedCost = (double)budget;
campaign.ActualCost = (double)cost;
Sforce.SaveResult[] results = null;
Sforce.Campaign[] campaigns =
new Sforce.Campaign[] { campaign };
results = Binding.create(campaigns);
//


After I run this codes, a new campaign that is created in Salesforce. However, StartDate, EndDate, BudgetCost, ActualCost of this campaign is null or no-value!

Please help me to solve my problem! Thanks.
mojeebahmedmojeebahmed
Hi evodanh,

    Have you tried to debug the code? I think you should debug the code and see what are the values of startTime, endTime, Budget and Cost etc variables. Please also provide the complete function or code you are using to create a new campaign so that it is clear where the values for the above variable are coming from.
SuperfellSuperfell
THis is a .NETism, it maps nullable for value types to an additional specified flag, as well as setting the value, you need to set the specified flag a swell, so you need to add
campaign.StartDateSpecified = true;
evodanhevodanh
Thanks for your help.