function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Delinda TinkeyDelinda Tinkey 

Editing User Record in VisualForce Page

I'm new to VisualForce and would like to use a VisualForce page on a VisualForce tab to allow the current running user to update a field on their user record. The code I have (below) displays everything correctly but does not update the running user's record when saved. What am I missing?

Bonus points if anyone can tell me how to refresh just the enhanced list div on the page every 10 seconds and not the entire page.

Thanks!


<apex:page standardController="User">
<apex:form >
<apex:pageBlock title="My Queue Status" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="1">
<apex:inputField value="{!user.Assignment_Group_Active__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<div>
<apex:enhancedList height="550" listid="00B40000006uQHB"/>
</div>
<script type="text/javascript"> isListLoaded(); function isListLoaded(){ setTimeout("location.reload(true);",10000); }
</script>
</apex:page>
 
Best Answer chosen by Delinda Tinkey
Himanshu ParasharHimanshu Parashar
Hi Delinda,

Code is seems to working for me. Make sure you are are passing current user id in url.

regarding your bonus point: You can use action poller function to call controller side method and at return you can rerender specific part of your page.


Here is the ref page.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionPoller.htm
 
<apex:page standardController="User" extension="exampleCon">
<apex:form >
<apex:pageBlock title="My Queue Status" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="1">
<apex:inputField value="{!user.Assignment_Group_Active__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<div>
<apex:outputpanel id="renderpanel">
<apex:enhancedList height="550" listid="00B40000006uQHB"/>
<apex:outputpanel>
</div>
<script type="text/javascript"> isListLoaded(); function isListLoaded(){ setTimeout("location.reload(true);",10000); }
</script>
<apex:actionPoller action="{!updateagain}" reRender="renderpanel" interval="10"/>
</apex:page>

here is the controller for the same
 
public class exampleCon {
    Integer count = 0;
			
    public PageReference updateagain() {
        count++;
        return null;
    }
}




Thanks,
Himanshu
Salesforce Certified Developer, Administrator, Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

All Answers

Himanshu ParasharHimanshu Parashar
Hi Delinda,

Code is seems to working for me. Make sure you are are passing current user id in url.

regarding your bonus point: You can use action poller function to call controller side method and at return you can rerender specific part of your page.


Here is the ref page.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionPoller.htm
 
<apex:page standardController="User" extension="exampleCon">
<apex:form >
<apex:pageBlock title="My Queue Status" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="1">
<apex:inputField value="{!user.Assignment_Group_Active__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<div>
<apex:outputpanel id="renderpanel">
<apex:enhancedList height="550" listid="00B40000006uQHB"/>
<apex:outputpanel>
</div>
<script type="text/javascript"> isListLoaded(); function isListLoaded(){ setTimeout("location.reload(true);",10000); }
</script>
<apex:actionPoller action="{!updateagain}" reRender="renderpanel" interval="10"/>
</apex:page>

here is the controller for the same
 
public class exampleCon {
    Integer count = 0;
			
    public PageReference updateagain() {
        count++;
        return null;
    }
}




Thanks,
Himanshu
Salesforce Certified Developer, Administrator, Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
This was selected as the best answer
buyan thyagarajanbuyan thyagarajan
Hi Delinda,
 Himanshu solution should solve the problem for you. If you run into issues, shoot me an email to talk on next Tuesday or Wednesday between 2 to 4 and i can call you and help you to trouble shoot it..
Thanks
Buyan
Delinda TinkeyDelinda Tinkey
Thank you Himanshu, I was hoping to use the page on a VF tab, in which case there would be no ID from a URL. However, I ended up making a custom link in the sidebar for this purpose. Once the ID was in place, a validation rule was preventing the user object from updating.

I still have to test your code for the auto-refresh, but assume it will work (especialy if Buyan thinks it will). Thanks again!