0

I recieve the following error

Call to create the salesforceobject Campaign failed! Object reference not set to an instance of an object

When i try to execute the following code

set @cost=FormatNumber(22,"D") 
set @EventID = CreateSalesforceObject('Campaign',20,'IsActive','True','Name',
        'test544','Description','test','Type',
        'HQEvent','Category__c','','StartDate','2020-02-03','EndDate','2020-02-03','Status','Draft',
         'EventCapacity__c',
         '1','LocationType__c','Store','LocationName__c','Delhi',
         'StoreCode__c','607','Address1__c','Delhi','Address2__c','Delhi',
         'ZipCode__c','600107','City__c','Delhi',
         'State__c','chennai','Country__c','india','Brand__c','Intel','ActualCost',@cost)

    Output(Concat('test',@cost))

The error occurs only when i add the field "Actual cost" its a decimal field in the campaign object, i tried with different formats but still same error.

Can any one help me why this particular field causes this error. .

2
  • The second parameter of CreateSalesforceObject should be the number of columns used in the function. I've counted them, the actual number is 20 and not 23. Change that and test it again.. Feb 6, 2020 at 9:54
  • Actually i have been trying with other such fields also , that is why 23 is there. But irrespective of it i have actully tried with 20 still same error.
    – Manoj
    Feb 6, 2020 at 10:38

1 Answer 1

0

The way you're doing this, I believe it's treating the @cost as text when it attempts to retrieve it in your EventID variable. Regardless, I was able to get this to work a few different ways below. You shouldn't need to use the format number for the cost field in Salesforce.

    set @cost= 22
set @EventID = CreateSalesforceObject('Campaign',20,'IsActive','True','Name',
        'test544','Description','test','Type',
        'HQEvent','Category__c','','StartDate','2020-02-03','EndDate','2020-02-03','Status','Draft',
         'EventCapacity__c',
         '1','LocationType__c','Store','LocationName__c','Delhi',
         'StoreCode__c','607','Address1__c','Delhi','Address2__c','Delhi',
         'ZipCode__c','600107','City__c','Delhi',
     'State__c','chennai','Country__c','india','Brand__c','Intel','ActualCost',@cost)

Or you can just use the number directly in the CreateSalesforceObject function:

set @EventID = CreateSalesforceObject('Campaign',20,'IsActive','True','Name',
        'test544','Description','test','Type',
        'HQEvent','Category__c','','StartDate','2020-02-03','EndDate','2020-02-03','Status','Draft',
         'EventCapacity__c',
         '1','LocationType__c','Store','LocationName__c','Delhi',
         'StoreCode__c','607','Address1__c','Delhi','Address2__c','Delhi',
         'ZipCode__c','600107','City__c','Delhi',
     'State__c','chennai','Country__c','india','Brand__c','Intel','ActualCost',22)

You must log in to answer this question.

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