You need to sign in to do that
Don't have an account?
bristolbluebear
Custom Button to change Account owner and Contact owner
Hello
I have been directed here for some help from Answers
I am looking for help creating a button that sits in the list view of both Accounts and Contacts that allows me to change owner on both objects simultaneously regardless of the object list view I in.
I have been advised I need to write a VF page but I'm afraid I am not a developer.
Can anyone help or who use such a function? Appreciate in advance.
Marc
I have been directed here for some help from Answers
I am looking for help creating a button that sits in the list view of both Accounts and Contacts that allows me to change owner on both objects simultaneously regardless of the object list view I in.
I have been advised I need to write a VF page but I'm afraid I am not a developer.
Can anyone help or who use such a function? Appreciate in advance.
Marc
You probably entered the full code in the VF page .Please use the below code for your visulaforce page.
You will need the extension class 'testing'' you can refer it starting from line no 24 from my previous reply.
Please reply if you need anything else.
All Answers
Step-1: Setup--> Build--> Customize--> Accounts --> Buttons, Links, and Actions.
Once you land on this page, click on "New Button or Link" button to see a page like below.
Choose the list button to create a list button under Accounts.
Note: Repeat the same steps for contact by navigating to;
Setup--> Build--> Customize--> Contacts --> Buttons, Links, and Actions.
Step-2: Once the button is created, add it to the List view using the below link;
Setup--> Build--> Customize--> Accounts --> Search Layouts.
In the above page, click on "Edit" link next to "Accounts List View" and add the button which you created in Step-1 above.
Step-3: Once the button is added, put your logic in a visualforce page and update the owner of the account and contact records using the VF page.
Hope the solution helps, or else let me know. Thanks.
You can use the below code for your VF page .'SF Issue-Fixer' has already given the steps to use it as a List button.
Please confirm if you find this helpful.
Thanks!!!
many thanks for taking the time to do this
I am creating the VF page but its throwing up an error:
Error: AccountOwnerChangeButton line 23, column 1: Content is not allowed in trailing section
Error: Content is not allowed in trailing section.
many thanks in advance
You probably entered the full code in the VF page .Please use the below code for your visulaforce page.
You will need the extension class 'testing'' you can refer it starting from line no 24 from my previous reply.
Please reply if you need anything else.
<apex:page standardController="Account"
recordSetVar="Accounts"
extensions="selectedSizeWorkaround"
showHeader="false"
id="muopp"
>
<apex:form id="muform">
<!-- <apex:pageMessage summary="Selected Collection Size: {!mySelectedSize}"
severity="info"
id="mupms"
/>
<apex:pageMessage summary="Record Set Size: {!myRecordsSize}"
severity="info"
id="mupmr"
/> -->
<apex:pageBlock title="Account Owner Change" mode="edit" id="mub1">
<apex:pageMessages />
<apex:pageBlockSection id="mus1">
<apex:inputField value="{!Account.ownerid}" id="Owner">
<apex:actionSupport event="onchange" rerender="muselectedlist"/>
</apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom" id="mubut">
<apex:commandButton value="Save" action="{!save}" id="butsav"/>
<apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock title="Selected Accounts" id="muselectedlist">
<apex:pageBlockTable value="{!selected}" var="opp" id="mutab">
<apex:column value="{!opp.name}" id="AccountName"/>
<apex:column value="{!opp.Ownerid}" id="OwnerName"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
===================================
public class selectedSizeWorkaround {
ApexPages.StandardSetController setCon;
public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
setCon = controller;
}
public integer getMySelectedSize() {
return setCon.getSelected().size();
}
public integer getMyRecordsSize() {
return setCon.getRecords().size();
}
}
How we have to do ??
Here is my Code...
public class ownerassigning {
public User u {get;set;}
public User u2 {get;set;}
public List<Account> acc {get;set;}
public List<Account> acc1 {get;set;}
public void getData(){
u = [Select Id From User where Firstname = 'XYZ'];
acc1 = [Select Id,Name,Rating,Industry,Ownerid from Account where ownerid=:u.id];
u2 = [Select Id From User where Firstname = 'ABC'];
for(Account a :acc1){
a.ownerid=u2.id;
acc.add(a);
}
update acc;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<apex:page controller="ownerassigning">
<!-- <apex:page standardcontroller="Account" extensions="ownerassigning"> -->
<apex:form >
<apex:pageBlock title="Account">
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column headerValue="Account Name">
<apex:outputField value="{!a.Name}" />
</apex:column>
<apex:column headerValue="Account Owner">
<apex:outputField value="{!a.OwnerId}" />
</apex:column>
<apex:column headerValue="Rating">
<apex:outputField value="{!a.rating}" />
</apex:column>
<apex:column headerValue="Industry">
<apex:outputField value="{!a.Industry}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks if anyone can solve it!!
Anyone Please Help me out in this....