I try insert data in my custom object from page controller on site, and nothing happened

  • I have public access site, and i want that guest user can register on site.
  • BUT i want saving guest info in custom object.
  • I am trying insert record on button click but nothing happened.

Help please. How its can be implement?

Code method

    public PageReference add(){

    Customer__c customer = new Customer__c(
            Name = 'DAAAAAAA',
            Last_name__c = 'SYKA',
            Username__c = 'BLEAT',
            Email__c = 'SUPER@mail.ru',
            Password__c = 'qwer'

    try {
        insert customer;
    } catch(DmlException e){
        new CookieController().setUs('BAAAAD');

    PageReference page = new PageReference('/index');

    return page;



<apex:commandLink action="{!add}" value="Login"/>
  • are you running in without sharing? – Pranay Jaiswal Jul 4 '16 at 13:18

What I believe is an access issue. In your Debug log add your GuestSite User and try clicking that button with Guest Site User context. The Debug Los will provide the access or code violations if any. Mighthappen you havent provided access to Object for the Guest Site user.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.