0

SCenario1: whenever i add case comment and leave the make it public checkbox as unchecked, it created as public only. Is there any way to avoid it by configuration? user is a partner user.

Scenario2: i tried below code for vf component. but it seems it doesn't work for e. any sggestions?

public with sharing class CaseCommentsComponentController {

public Id caseId {get; set;}
public cComments[] comments{
    get{
        List<cComments> comments = new List<cComments>();
        for(CaseComment comment : [Select LastModifiedDate, LastModifiedBy.Id, LastModifiedBy.Name, IsPublished, CreatedDate, CreatedBy.Id, CreatedBy.Name, CommentBody From CaseComment c where ParentId = :caseId order by c.LastModifiedDate desc])
        {
            cComments tempcComment = new cComments();
            tempcComment.cComment = comment;

            // Build String to display.
            tempcComment.commentText = '<b>Created By: <a href=\'/' + comment.CreatedBy.Id + '\'>' + comment.CreatedBy.Name + '</a> (' + comment.CreatedDate.format() + ') | ';
            tempcComment.commentText += 'Last Modified By: <a href=\'/' + comment.LastModifiedBy.Id + '\'>' + comment.LastModifiedBy.Name + '</a> (' + comment.LastModifiedDate.format() + ')</b><br>';
            tempcComment.commentText += comment.CommentBody;

            if(comment.IsPublished)
                tempcComment.PublicPrivateAction = 'Make Private';
            else
                tempcComment.PublicPrivateAction = 'Make Public';
            //Add to list
            comments.add(tempcComment);
        }
        return comments;
    }

    set;
}

public PageReference NewComment()
{
    PageReference pr = new PageReference('/00a/e?parent_id='+ caseId + '&retURL=%2F' + caseId);
    pr.setRedirect(true);
    return pr;
}

public PageReference deleteComment()
{
    Id commentId = ApexPages.currentPage().getParameters().get('CommentId_d');

    for(cComments Comment : comments)
    {
        if(Comment.cComment.Id == commentId)
        {
            delete Comment.cComment;
            break;
        }
    }

    PageReference pg = new PageReference('/' + caseId);
    pg.setRedirect(true);
    return pg;
}

public PageReference makePublicPrivate()
{
    Id commentId = ApexPages.currentPage().getParameters().get('CommentId_p');
    for(cComments Comment : comments)
    {
        if(Comment.cComment.Id == commentId)
        {
            Comment.cComment.IsPublished = !Comment.cComment.IsPublished;
            if(Comment.cComment.IsPublished)
                Comment.PublicPrivateAction = 'Make Private';
            else
                Comment.PublicPrivateAction = 'Make Public';

            update Comment.cComment;
            break;
        }
    }
    PageReference pg = new PageReference('/' + caseId);
    pg.setRedirect(true);
    return pg;
}

public class cComments {

    public CaseComment cComment {get; set;}
    public String commentText {get; set;}
    public String PublicPrivateAction {get; set;}
}

}

1 Answer 1

0

You can try updating IsPublished of CaseComment with false. This field is accessible to update using API.

See document https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_casecomment.htm

1
  • Thanks for reply. I am just using standard layout out on community. how could i update this? if i also make it false as default value using WF rule, all comments will be private. i want to create a comment as private when i do not check the 'publish' checkbox only.
    – chandu
    Sep 18, 2019 at 11:24

You must log in to answer this question.

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