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
SaaniaSaania 

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY : Entity type cannot be inserted: Campaign

Hi,

I am getting the error specified as the subject when i create a Campaign in VC#. There is no issue of access rights in this case for sure, since I am the System Administrator.

The code is pretty simple. I just create a Campaign object, and call binding.create method with the campaign object as an sObject array. The binding is correct, because I am using it to query the Campaign object earlier as well, that returns correct results

Thanks,
SaaniaSaania
I am still waiting for help on this one. I am facing similar issue with Campaign Member Status object as well. Does SF prevent users from creating Campaigns or CampaignMemberStatus objects via VC#?

The code used to create MemberStatus
Code:
CampaignMemberStatus memberstatus = new CampaignMemberStatus();
List<sObject> status = new List<sObject>();

memberstatus.CampaignId = CampaignID;
memberstatus.Label = "Open";
                    
status.Add(memberstatus);

sObject[] statusToAdd = (sObject[])status.ToArray();

StatusId = createSFObject(statusToAdd);

The createSFObject function:
Code:
private static string createSFObject(sObject[] objToAdd)
        {
            string ID = null;
            //create new opportunities
            try
            {

                //create the object(s) by sending the array to the web service
                SaveResult[] sr = binding.create(objToAdd);
                for (int j = 0; j < sr.Length; j++)
                {
                    if (sr[j].success)
                    {
                        tw.WriteLine("An Object was created with an id of: "
                            + sr[j].id);

                        ID = sr[j].id;
                    }
                    else
                    {
                        //there were errors during the create call, go through the errors
                        //array and write them to the screen
                        for (int i = 0; i < sr[j].errors.Length; i++)
                        {
                            //get the next error
                            Error err = sr[j].errors[i];
                            tw.WriteLine("Errors were found on item " + j.ToString());
                            tw.WriteLine("Error code is: " + err.statusCode.ToString());
                            tw.WriteLine("Error message: " + err.message);
                        }
                    }
                }


            }
            catch (Exception ex)
            {
                tw.WriteLine("\nFailed to create Object, error message was: \n"
                           + ex.Message);


            }

            return ID;
        }

 

And the Error I am getting in the else part of the above funtion(not in the catch part), so the binding is fine ... there are some access issues for sure!!
 
Code:
Errors were found on item 0
Error code is: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
Error message: entity type cannot be inserted: Campaign Member Status

Would definately appreciate a quick response, if someone knows the answer.

Thanks,
 


MarconyMarcony
Try to use "marketing user" setting in your develop salesforce account. It gets CREATE permission for Campaing records.
 
My english is nightmarish... sorry.
 
SaaniaSaania
Thanks Marcony, havent given it a try ... but why shouldnt it work for me? I am a System Administrator :).
SaaniaSaania
Got it (with help from SF Premier Support :) ), the Marketing User privileges were not set for the profile I was using to create Campaigns, even though the Profile was System Administrator, the setting had to be done for individual user.
 Thanks for the suggestion Marcony.