Reply
Regular Visitor
me.murali
Posts: 1
0

system.security.NoAccessException: Update access denied for Contact

hi there,

i have created a site in salesforce. I have a visual force page and controller. See below for my code

 

when i go to the site from the internet , i see the contact info  and when hit save i get the "Update access denied for Contact   "  error. If you look at my controller, i am not saving or updating anything.

 

I would like to be able to update the contact info from the page I created.

 

Any help appriciated.

 

 

 

<apex:page controller="testpublic" showHeader="false">
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>

<script type="text/javascript" src="/js/functions.js"></script>
<script type="text/javascript" src="/soap/ajax/22.0/connection.js"></script>

<apex:form >
<apex:pagemessages ></apex:pagemessages>
<table width="330px">

        <tr>
            <td width="200px"> <apex:outputLabel value="First Name:" for="txtname" style="font-size:12px" /></td>
            <td width="130px">
             <!-- <input type="text" value="{!contact.FirstName}" id="fname" style="font-size:12px" /> -->
             <apex:inputText id="FirstName" value="{!contact.Name}"/>
             </td>
         </tr>
        <tr>
            <td width="200px"> <apex:outputLabel value="Last Name :" for="txtname" style="font-size:12px" /></td>
            <td width="130px">
           <!--  <input type="text" value="{!contact.LastName}" id="lname" style="font-size:12px" /> -->
             <apex:inputText id="LastName" value="{!contact.Name}"/>
             </td>
         </tr>
        <tr>                   
            <td width="200px"> <apex:outputLabel value="Email:" for="txtemail" style="font-size:12px" /></td>
            <td width="130px">
            <!-- <input type="text"  value="{!contact.Email}"  id="email" style="font-size:12px" /> -->
             <apex:inputText id="Email" value="{!contact.Email}"/>
            </td>
         </tr>
         <tr>                   
            <td width="200px"> <apex:outputLabel value="Phone:" for="txtphone" style="font-size:12px" /></td>
            <td width="130px">
           <!--  <input type="text" value="{!contact.Phone}"  id="phone" style="font-size:12px" /> -->
             <apex:inputText id="Phone" value="{!contact.Phone}"/>
            </td>

         </tr>
                
         <tr><td>
         <apex:commandButton value="Submit"  action="{!save}" />
         </td></tr>           
</table>
</apex:form>
 </apex:page>

 

Controller code

---------------------------

global class testpublic
{
    public Contact contact
    {
    get{
    if(contact == null)contact= new Contact();
    return contact;
    }
    set;
    }

    public testpublic()
    {
    contact= [select Id,Name,Email,Phone,Company__c from Contact where Email= 'my.email@bluehost.com'];
    }
    public PageReference save()
    {
    
        try
        {
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info, 'Nothing to save'));
        }
        catch(Exception ex)
        {
           String mess=  ex.getMessage()+' Line # '+ex.getLineNumber().format();
        }
        return null;
    }
}

 

 

Thanks

Murai

 

Super Contributor
Rahul Sharma
Posts: 846
0

Re: system.security.NoAccessException: Update access denied for Contact

me.murali,

Try rerendering apex:pageMessage on click of save button using rerender attribute.

- Rahul