4

I am new using salesforce and I already created my case, and now I need to create comments from customer and customerSupport(both), but when I try to specify that in soap API like this:

https://xxxx/services/data/v39.0/sobjects/CaseComment

{
"CommentBody": "test",
"IsPublished": true,
"ParentId": "{xxx}",
"CreatedById": "{xxxxx}"                                        
}

The answer of the service is:

[
{
    "message": "Unable to create/update fields: CreatedById. Please check the security settings of this field and verify that it is read/write for your profile or permission set.",
    "errorCode": "INVALID_FIELD_FOR_INSERT_UPDATE",
    "fields": [
        "CreatedById"
    ]
}                                                                     
]

Maybe "CreatedById" is not a field correct to know who created the comment before, Can you help with this? I want to know where and how I can to define a case comment owner in some way

1 Answer 1

6

You have to enable Create Audit Fields permissions from the SF UI to set createdById and CreatedDate

Set Audit Fields upon Record Creation - Allow the user to set audit fields (like "Created By" or "Last Modified By") when you create a record via API importing tools like Data Loader.

Src: https://help.salesforce.com/articleView?id=000213290&type=1

If you are using a System - Admin profile you have to create a permission set with Create Audit Fields mentioned in the below docs

Create a Permission Set

  1. Go to Setup | Manage Users | Permission Sets.
  2. Click New.
  3. Enter Permission Set information such as 'Label' and 'Description'.
  4. Optionally, specify a 'User license' to restrict this Permission Set to Users with specific licenses
  5. Click Save.
  6. On the next page, Go to System Permissions.
  7. Click Edit.
  8. Find 'Set Audit Fields upon Record Creation' and check the box for it. Note: If you do not see this option it's likely that 'Set Audit Fields upon Record Creation' and 'Update Records with Inactive Owners' is not currently enabled.
  9. Click Save.

Assign the Permission Set

  1. Go to Setup | Manage Users | Permission Sets.
  2. Select the Permission Set for the 'Audit Fields.'
  3. Click Manage Assignments.
  4. Click Add Assignments.
  5. Select the User to whom you want to assign the 'Permission Set.'
  6. Click Assign.
  7. Click Done.

Src: https://help.salesforce.com/articleView?id=000232909&type=1&language=en_US

You must log in to answer this question.

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