I have a RestResource class which when accepts a POST request, i want to insert or update a checkbox field in a custom object. Here is the code:

@RestResource(urlMapping='/**some string**/*')
global class ClassName{
    global static String acceptConsent(String patientId) {
        ConsentTable__c cTable = new ConsentTable__c(PatientId__c = patientId, SmsConsent__c = true);
        if (Schema.sObjectType.ConsentTable__c.fields.PatientId__c.isCreateable() && Schema.sObjectType.ConsentTable__c.fields.SmsConsent__c.isCreateable()) {
             insert cTable;

The problem here I have is that, insertion is not happening, because even though Schema.sObjectType.ConsentTable__c.fields.PatientId__c.isCreateable() returns true, Schema.sObjectType.ConsentTable__c.fields.SmsConsent__c.isCreateable() returns false. Result is same if I check with the isUpdateable() method also. PatientId__c is a text field and SmsConsent__c is a checkbox field. Thats the only difference between these fields. There are no other differences. I have enabled all the permissions for the ConsentTable__c object in the Public Access Settings of the site and also added the class to the Enabled Apex Class Access. So, what could be the problem here? Even though I can insert or update a text field, why cannot I do the same for a checkbox field?

  • I've edited the tags here to be a bit more useful to others (I hope). Seems to me that the heart of this question is about permissions and sites. – Derek F Jul 21 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.