Basically, we have records that are Unassigned. We would like to be able to assign them to an Account. These records are displayed in a related list on the Account page. Of course, a new button is there, but would it be possible to build a button to re-parent the selected Unassigned objects to the currently viewed account?

I'm thinking this will require a custom-button along with a VF page + controller.

  • 1
    Although I normally don't push the SFDC Ajax toolkit, this can be done by modifying the code here - simplysfdc.blogspot.com/2014/04/…
    – cropredy
    Commented Aug 13, 2014 at 21:05
  • How would I obtain which objects to change their parent to? I assume I'm going to need a psuedo-lookup form.
    – Sam
    Commented Aug 13, 2014 at 21:13
  • 1
    Will this be an ongoing problem? If so, a quick VF page launched from the account displaying a list of unassigned records for the user to select would be a good choice...
    – Eric
    Commented Aug 13, 2014 at 21:18
  • That's what I was thinking of doing, was seeing if there was another solution that would be more clean-cut. Thanks.
    – Sam
    Commented Aug 13, 2014 at 21:23
  • 2
    Sam -- I may have misunderstood your requirement - a screen mockup w/ example might help
    – cropredy
    Commented Aug 13, 2014 at 22:41

1 Answer 1


It is possible to do this without custom Apex or a custom controller by creating a new Visualforce page and a custom list button.

You didn't mention if this is a custom object or a standard object so in the example below I use the standard Contact object. You could swap out "Contact" in the Visualforce with the name of a custom object too though.

Below is the Visualforce and instructions for creating the button and adding it to a search layout.


<apex:page standardController="Contact" recordSetVar="Contacts" id="muCt" tabStyle="Contacts__tab" sidebar="false">
    <apex:form id="muform">
        <apex:pageBlock title="Mass-Update Assigned Account" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockSection id="mus1">
                <apex:inputField value="{!Contact.AccountId}" id="account">
                    <apex:actionSupport event="onchange" rerender="muSelectedList"/>
            <apex:pageBlockButtons location="bottom" id="muBtns">
                <apex:commandButton value="Save" action="{!save}" id="btnSav"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="btnCan"/>
        <apex:pageBlock title="Selected Contacts" id="muSelectedList">
            <apex:pageBlockTable value="{!selected}" var="ct" id="mutab">
                <apex:column value="{!ct.name}" id="oppName"/>
                <apex:column value="{!ct.AccountId}" id="accountId"/>

Custom Button:

  1. Navigate to Setup/Customize/Contacts/Buttons, Links, and Actions"
  2. Click the "New button or link" button.
  3. Give your new button a label, name and select "List button" for the display type.
  4. Select "Visualforce Page" for the Content Source.
  5. Select your newly created Visualforce page for the Content.

Add the new button to the Search Layout:

  1. Navigate to Customize/Contact/Search Layouts
  2. Edit the Contacts List View
  3. Add your new button from the list of available buttons

Navigate to your Contacts list and you should see your new button. Select the contacts you want to assign to an account. You then click your new custom list button and you'll be taken to your new Visualforce page where you can specify which account to assign to the contacts. Finally click the Save button to save the changes.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .