I created a site where the guest users can edit their personal information. the operation should be on the Account object.so I created a extentsion submit which will save the edited info by a user. It worked fine in the developer mode when I put that page in sites it's not updating the information on the lead record. when I went to public access settings and checked there are no modify permission for accounts on sites. how can I achieve this task through sites? I want to update the record not insert the record.  public Without Sharing class ExtensionExample{     public String currentRecordId {get;set;}     public String parameterValue {get;set;}     List&lt;Account&gt; accRecords = new List&lt;Account&gt;();     public Account acc{get;set;}     public string accountName;     public id accID;      public ExtensionExample(ApexPages.StandardController controller) {         currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');         acc = [select id ,name, AccountNumber, Type, Industry from Account where id =: currentRecordId ];         parameterValue = ApexPages.CurrentPage().getparameters().get('nameParam');     }     public void  doSubmit() {         accountName = acc.name;         accID = acc.id;         accRecords.add(new Account(id= accID, name=accountName));         update accRecords;      } }   // vf page   &lt;apex:page standardController="Account" extensions="ExtensionExample"&gt;     &lt;apex:form &gt;         &lt;apex:pageBlock &gt;             &lt;apex:pageBlockSection title="Current account record Id is : {!currentRecordId}" collapsible="false"&gt;                 &lt;apex:InputField value="{!acc.name}"/&gt;                 &lt;apex:InputField value="{!acc.AccountNumber}"/&gt;                 &lt;apex:outputField value="{!acc.Type}"/&gt;                 &lt;apex:outputField value="{!acc.Industry}"/&gt;             &lt;/apex:pageBlockSection&gt;                &lt;apex:commandButton value="Submit" action="{!doSubmit}"/&gt;          &lt;/apex:pageBlock&gt;     &lt;/apex:form&gt; &lt;/apex:page&gt;
67165
I have a client who wants external users to submit data via a Sites VF page and update Opportunity records.  Of course the Sites profile doesn't have permissions to update standard objects.  Also, the client does not want to purchase portal licenses for these external users.  I am considering two workarounds and am wondering if they are possible:  1 -- Write some Apex webservices and call them from the Sites page Visualforce controller.  Is it even possible to call your own webservices from a controller?  I presume the webservices would be running in system context?   2 -- Have the Sites page create a custom object record instead, and then write a trigger to update the opp record using the custom object.  Will the trigger be running in the system context and be able to update the opp?  Thanks David
14052
What I am trying to do is to set a date in my date field and also update the object. I am using the class below to do so which works just fine in my sanbox but in production I am getting this error:      System.LimitException: Too many query rows: 50001   public with sharing class updateObject{     public  List&lt;NRProducts__c&gt;  values;     public PageReference updateObject() {         values=[SELECT Refreshed_Date__c FROM NRProducts__c ];         for (NRProducts__c s :values){            s.Refreshed_Date__c =Date.today();          }          update values;         return null;                       }     }   VF Page:  &lt;apex:page showheader="false" controller="updateObject" sidebar="false"&gt; &lt;apex:form&gt;  &lt;apex:commandButton action="{!updateObject}" value="Update"/&gt; &lt;/apex:form&gt; &lt;/apex:page&gt;
104633
I'm trying to edit the hosts file (C:\Windows\System32\drivers\etc\hosts), because I want to setup a local redirect for my website (like I've always done in XP). However, I can't save the changes!  I have taken ownership, I have allowed my account full access and have tweaked every other setting I can think of. Every time I edit and save it, "Access is denied" pops up.  How do I get past this?
28036
I'd like to create a lead via apex and set it's address. I've read that Address is a compound field and that it is totally read only unless via SOAP/REST API. Looking at the docs, I could only find getter methods - nothing to set a value.  How do I go about setting an address via apex?  Thank you!
854
I am trying to copy the value of user selected Status value into the standard salesforce required Company field. Now, when I try to save the record on the object since I am not entering any value in the Company field, the record is not being saved. How do I solve this kind of issue? Any leads appreciated  trigger CopyStatusToTitle on Lead (before insert, after insert) {      List&lt;Lead&gt; leadList = new List&lt;Lead&gt;();     if(Trigger.isInsert){         if(Trigger.isBefore){             //process before insert               for(Lead l : trigger.New){                 l.Company = l.Status;              }          }else if(Trigger.isAfter){             //process after insert          }       } }
116203
I am working on a scenario where record created by users with permission set 'A' should be visible to users with permission set 'B'. On googling I came across apex sharing of a record programmatically. However the one thing I could not understand is the usage of rowCause and the difference of using rowcause manual and custom rowcause. I don't see what difference does it make if one uses custom rowcause (using sharing reason) instead of manual rowcause.
101869
I have one recordtype named 'India' in both Account and Contact Objects.My requirement is whenever i create a new account record of type 'India' a new contact record of type 'India' should be created automatically.  i tried with the following code:  trigger AccRecTypeTrigger on Account (before insert) {     List&lt;RecordType&gt; recType = [select id,name from RecordType where sobjectType = 'Account' and isActive = true];    Map&lt;String,Id&gt; m = new Map&lt;String,Id&gt;();    for(RecordType r : recType){      m.put(r.name,r.id);    }     List&lt;Contact&gt; conlst = new List&lt;Contact&gt;();    for(Account a : trigger.new){        a.recordTypeId = m.get('India');        Contact con = new Contact();        con.accountId = a.id;        con.recordTypeId = a.recordTypeId;        con.recordType.name = a.recordType.name;         conlst.add(con);       }    insert conlst; }   But i am getting following error when i try to save     Apex trigger AccRecTypeTrigger caused an unexpected exception, contact   your administrator: AccRecTypeTrigger: execution of BeforeInsert   caused by: System.NullPointerException: Attempt to de-reference a null   object: Trigger.AccRecTypeTrigger: line 14, column 1   Please help me how to achieve this......
65649
Here's the use case. When a lead is converted to an Opportunity, I want to automatically share the opportunity with the previous owner of the lead. This is needed because upon conversion, the opportunity ownership is granted to someone else but the original lead owner needs ongoing access to the opportunity.  So:   A partner submits/creates a lead and is the lead owner Lead is converted to opportunity and internal sales person gains ownership Original partner needs to have view/edit access on this opportunity   I know you can use Apex Managed Sharing to share a custom object, but I'm hitting a wall trying to do this with an opportunity since the fields in OpportunityShare are not writable. The following won't even compile as a result:  List&lt;OpportunityShare&gt; oppShares = new List&lt;OpportunityShare&gt;(); for(Id i : oppIds) {    OpportunityShare os = new OpportunityShare(OpportunityId = i);    os.OpportunityId = i; // *** ERROR - not writable ***    os.OpportunityAccessLevel = 'Read/Write';    os.UserOrGroupId = oppIdToLead.get(i).OwnerId;    os.RowCause = 'Manual Sharing';    oppShares.add(os); }  Database.SaveResult[] result = Database.insert(oppShares, false);
3956
Im creating a community user from an Apex code. When our internal users (non-admins) run the code they are getting following error. (This was working fine when we test the feature in sandbox)     SObjectException: Field is not writeable: User.ProfileId   The code is       //Grab Community User Profile     Profile p = [Select Id, Name from Profile where Name = :COMMUNITY_PROFILE LIMIT 1];       User PortalUser = new User();          PortalUser.UserName = Con.Email+'-POC';         PortalUser.ContactId = Con.Id;         PortalUser.ProfileId = p.id;         PortalUser.Email = Con.Email;         PortalUser.EmailEncodingKey = 'UTF-8';         PortalUser.FirstName = Con.FirstName;         PortalUser.LastName = Con.LastName;         PortalUser.TimeZoneSidKey = 'America/Los_Angeles';         PortalUser.LocaleSidKey = 'en_US';         PortalUser.LanguageLocaleKey = 'en_US';          if (Con.LastName.length() &gt;= 8){             PortalUser.Alias = Con.LastName.substring(0, 7);             }else{             PortalUser.Alias = Con.LastName;         }             SObjToInsert.add(PortalUser);
116089
I have created a Vf page from which i need to fetch the value of new owner and need to save the value in property defined in controller:  Following is my vf page code:  &lt;apex:pageBlockSection&gt;     &lt;apex:InputField label="user" value="{!a.ownerid}"/&gt; &lt;/apex:pageBlockSection&gt;   here a is object of opportunity  Controller code:  used one property to store the value:  public string ownername {get;set;}   Note: user will input the value through lookup field.  Any suggestions on this?
115263
I was so excited about the Spring '14  as a way to present data visualizations on a public site, and now it looks like that's not possible.  I created a page that looks basically like the release notes sample:  &lt;apex:page &gt;     &lt;analytics:reportChart reportId="00OW0000000Spru"&gt;&lt;/analytics:reportChart&gt; &lt;/apex:page&gt;   I tested it inside the authenticated environment, where it works fine, then added it to a Site. There, I get the error: To view the report chart, you need both the Run Reports permission and access to the report's folder. But, Run Reports is not a permission I can grant to the Site Guest User.  Anybody have any ideas for a workaround? Or is it not going to be possible to show report charts on a public site?
63548
If a user clicks 'Edit' on an opportunity which he isn't allowed to edit, the "Insufficient Privileges" page directly appears. This is good. If a user clicks 'Edit' on a custom object (which has an edit override that points to a visualforce page), he first sees the form without problems, and the "Insufficient Privileges" page only appears when he tries to save it. This behaviour is misleading for the users, because they think they can manipulate the data and put effort into it, and only afterwards they realize that this wasn't possible after all.  An idea was to check at page load if the user has edit permissions and otherwise redirect him to the "Insufficient Privileges" page.  Might there be another way? Thanks!
68495
I am getting this error:     SObject row was retrieved via SOQL without querying the requested   field: Contact.Account   Controller:  public class WrapperAccountCtrl {      public List&lt;Account&gt; acclist{get;set;}     public List&lt;Contact&gt; conlist{get;set;}      public List&lt;MyWrapper&gt; wap{get;set;}      public WrapperAccountCtrl()      {         acclist=[Select id,name from Account];          conlist=[Select id,name,AccountID  from contact where AccountID IN:acclist];          system.debug('Size----'+conlist.size());           wap=new List&lt;MyWrapper&gt;();           for(integer i=0;i&lt;acclist.size();i++)          {              wap.add(new MyWrapper(conlist,acclist[i]));          }     }      public class MyWrapper     {          public Account accn{get;set;}          public List&lt;Contact&gt;conrec{get;set;}          public MyWrapper(List&lt;Contact&gt; con,Account acc)         {             accn=acc;             conrec=con;             }     } }   VF Page:  &lt;apex:page controller="WrapperAccountCtrl" sidebar="false"&gt;       &lt;apex:form &gt;          &lt;apex:pageBlock &gt;              &lt;apex:pageBlockTable value="{!conlist}" var="c"&gt;                  &lt;apex:column value="{!c.account.Name}"/&gt;              &lt;/apex:pageBlockTable&gt;          &lt;/apex:pageBlock&gt;      &lt;/apex:form&gt;  &lt;/apex:page&gt;
63726
We want to move a large number of customer portal users (users who self-register via a pre-existing Contact record) from one "User License" type to another. But I note that in the User edit page the "User License" field is not editable (whereas it is for other license types) and in any case as thousands of users are involved we would like to automate the process.  Can this be done via an Apex script? Or can this be done via a Salesforce support request?
116377
I'm trying to populate the Contact lookup when a User creates a new related list object from the Contact page.  I am storing the Contact parameter in a Custom Setting so it can be changed when deploying to Production.  For some reason, whenever I try to bind this custom setting to the URL I get a leading '#' and none of the bindings work correctly.  This is despite using the URLENCODE function in the Visualforce  So when I put this (contactParameterId is != null)  &lt;apex:outputLink value="/{!relList.keyPrefixObject}/e?{!IF(relList.contactParameterId != null, 'CF{!URLENCODE(relList.contactParameterId)}={!URLENCODE(contact.Id)}&amp;', '')}retURL=/{!contact.Id}&amp;saveURL=/{!contact.Id}"&gt;&lt;/apex:outputLink&gt;   I get the URL      {URLENCODE(relList.contactParameterId)}={!URLENCODE(contact.Id)}&amp;retURL=/003U000000PL9LNIA1&amp;saveURL=/003U000000PL9LNIA1   What am I doing wrong?
57540
I'm trying to update an account list and I need to get the Ids when the update fails.  I use the getId() method but for accounts which fail I get null.  It's an update so my account already has an Id.  Is it normal ? If it is, how can I get the Ids list of non-updated accounts ?  Here is my code :  List&lt;Account&gt; accountsList = [select Id from Account];  for(Account a : accountsList) {     a.Name = 'Test', }  List&lt;Database.SaveResult&gt; res = Database.update(accountsList, false);  for (Database.SaveResult s : res) {     if (!s.isSuccess()) {         system.debug(s.getId()); // I get null here      }  }
6074
Here's what I am trying to do:  1) User creates record A.  2) Time-based workflow sends an email to the Record A creator based on a date field in the record.  3) The email template has a URL link.  4) The URL links to a Visualforce page that is basically a form with fields to be filled out (this Visualforce page is in a managed package) and a save button that creates a new User record.  5) When the User clicks the URL link in the email, the Visualforce page opens in a new window.  6) I would like to pass the values of the fields in record A to pre-fill the Visualforce page fields.   Here's my link:  &lt;a href="https://cs19.visual.force.com/apex/CloneThisUser?Desktop=true&amp;Id={!Pending_User__c.User_to_CloneId__c}&amp;formGroupInputSmall={!Pending_User__c.First_Name__c}   And here's the code from the relevant section of the Visualforce page:  &lt;div class="form-group form-group-sm"&gt;       &lt;!-- &lt;apex:outputLabel styleClass="col-sm-2 control-label" for="formGroupInputSmall"&gt;First Name&lt;/apex:outputLabel&gt; --&gt;       &lt;div class="col-xm-11 col-sm-12"&gt;           &lt;apex:inputField html-placeholder="First Name" styleClass="form-control FirstNameInput"  value="{!u.FirstName}" id="formGroupInputSmall"/&gt;       &lt;/div&gt;     &lt;/div&gt;   I have only included the first field I would like to pass the parameter to, in order to keep this post simple.   The link passes the User_to_Clone_Id__c just fine but does not fill in the "First Name" field with the value of the First_Name__c .  What am I doing incorrectly? Thanks.