• Lincoln Karuhanga
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi Folks,

 

I have assigned 4 custom boolean fields to the Contacts and these are for users to update which email they would like to subscribe too, such as Monthly Newsletter, New Courses etc.

 

I am trying to create a page on our force.com site that displays the 4 checkboxes with a save button, so we can attach a link to the bottom of the emails we send for users to update their subscriptions to the emails we send them.

 

Visualforce Page:

 

<apex:page Controller="EmailSubscriptionController">
    <apex:form >
        <apex:messages />
        <br />

        <apex:inputCheckbox id="Brochure_email__c" value="{!contact.Brochure_email__c}"/>Brochure Email<br />
        <apex:commandButton value="Save" action="{!save}"/>


    </apex:form>
</apex:page>

 

Apex Class:

 

public class EmailSubscriptionController {

    public final Contact contact;
    public ID get_id {get;set;}
    public boolean email_brochure {get;set;}

    public EmailSubscriptionController() {
        contact = [SELECT Brochure_email__c  FROM Contact
            WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Contact getContact() {
        return contact;
    }

    public PageReference save() {

        try {
            upsert(contact);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }

        return null;

    }
}

 

The code shows me the force.com page fine, and check's the relevant boxes, but when i click update it gives me the following error message:

 

system.security.NoAccessException: Update access denied for Contact

 

Any ideas on how i can get this working?

 

Many Thanks

 

Dave

 

 

I'm looking for a method that will have a join/implode functionality.

 

I cannot seem to find an equivalent in the docs.  Does one exist in APEX?

 

Thanks