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
pitaboypitaboy 

CaseComment Object questions

Hi,

I have a few questions regarding the CaseComment object.

1. How do you make a new CaseComment object public/private using the API 6.0 and C#? Is it using the IsPublished() method call? I've tried using it and the CaseComment object is still created as private. Do I need to create the CaseComment object then use 'update' to make the CaseComment private/public?

2. I know you cannot set/modify the CreatedBy property. However, I need to find a way to track who created the comment (i.e. If it was a self-service user or an internal user.) and I'm not sure how to go about it. As far as I know, the CaseComment object is not customizable, so I assume adding a field/property to the CaseComment is not possible.

Thanks in advance.


CaseComment CommentObject = new CaseComment();

CommentObject.ParentId = CaseId;
CommentObject.CommentBody = Comment.Text;
CommentObject.IsPublished = true;

// Create service object for sforce
SforceService SFService = new SforceService();

// Invoke the login call and save results in LoginResult
LoginResult lResult = SFService.login(usr,pwd);
// Reset the SOAP endpoint to the returned server URL
SFService.Url = lResult.serverUrl;
// Create a new session header
// Add the session ID returned from the login
SFService.SessionHeaderValue = new SessionHeader();
SFService.SessionHeaderValue.sessionId = lResult.sessionId;

sObject[] sObjectArray = new sObject[] {CommentObject};
SaveResult[] saveResults = SFService.create(sObjectArray);
SuperfellSuperfell
you probably need to add

CommentObject.IsPublishedSpecified = true;

otherwise .NET doesn't send that element over the wire.
pitaboypitaboy
Thanks for the reply Simon.

As for my 2nd question, is their any way to find who wrote a comment? Either by creating a new field for the CaseComment or by any another means? Are their plans to allow such things in future API releases?

Thanks
SuperfellSuperfell
Doesn't the createdBy field point to the self service user that created the comment ?
pitaboypitaboy
That's what I was trying to use. However, when I use a Self-service username/password to login before making the create() method call, I get an error: "INVALID_LOGIN: Invalid username or password or locked out." Is this because I'm using a self-service demo username? Or am I missing some permissions somewhere? When I use my sforce developer username/password, I'm able to create the CaseComments but I am always listed as the Creator (which is understandable). How do I get the Self-service user to be the creator of the CaseComment?

// Invoke the login call and save results in LoginResult
LoginResult lr = sfdc.login(usr,pwd);
// Reset the SOAP endpoint to the returned server URL
sfdc.Url = lr.serverUrl;
// Create a new session header
// Add the session ID returned from the login
sfdc.SessionHeaderValue = new SessionHeader();
sfdc.SessionHeaderValue.sessionId = lr.sessionId;
SuperfellSuperfell
SelfService Users can't use the API.

An upcoming feature allows API users to override some of the audit fields for loading data, although i don't know if casecomment is included in the set of objects that'll be supported.
nxdevnxdev

 

#1----------------------------------------------------------------------------------------------------------------
Doesn't the createdBy field point to the self service user that created the comment ?

Cheers
Simon
----------------------------------------------------------------------------------------------------------------

#2----------------------------------------------------------------------------------------------------------------
SelfService Users can't use the API.

An upcoming feature allows API users to override some of the audit fields for loading data, although i don't know if casecomment is included in the set of objects that'll be supported.

Cheers
Simon
----------------------------------------------------------------------------------------------------------------

At the point you were writing Comment #1, what was the suggestion you were thinking?

Is there "ANY" way to make the selfservice user's id to be the createdby of a casecomment?