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
The new LearnerThe new Learner 

not able to create record of casecomment

Hi Experts,

I am getting below error for the case comment. can anyone help me please. Error: SObject type CaseComment is not supported by this unit of work. 
below is the code. can anyone help me how to fix this issue.

 
public void registerNew(SObject record, Schema.sObjectField relatedToParentField, SObject relatedToParentRecord)
    {
        if(record.Id != null)
            throw new UnitOfWorkException('Only new records can be registered as new');
        String sObjectType = record.getSObjectType().getDescribe().getName();
        if(!m_newListByType.containsKey(sObjectType))
            throw new UnitOfWorkException(String.format('SObject type {0} is not supported by this unit of work', new String[] { sObjectType }));
        m_newListByType.get(sObjectType).add(record);
        if(relatedToParentRecord!=null && relatedToParentField!=null)
            registerRelationship(record, relatedToParentField, relatedToParentRecord);
    }

 
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

Can you please let me know,what are you trying to achieve using the above code.Generally,we get the above error when we are trying to define the Sobject incorrectly.So,please check that part where you are trying to access the CaseComment Object.

reference:https://developer.salesforce.com/forums/?id=906F0000000D6ruIAC

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
The new LearnerThe new Learner
HI Shirisha,

Below error is coming , i dont know why can anyou help me please

"statusCode" : "500",     "messages" : [ "Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set." ]   } } 
ShirishaShirisha (Salesforce Developers) 
Hi Aditya,

Can you please check for the field level security on the Profile level with which you are trying to create the record.

This is the lack of the permission which is missing on the profile level.

Warm Regards,
Shirisha Pathuri