-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
7Replies
hi.. how i can got 75% code coverge in following apex class.currently i m able to cover only 68 % any body can help me
here is my apex class
and here is my current test class
public class wrapperexample2 { public wrapperexample2(ApexPages.StandardSetController controller) { } public List<Schema.contact> SList{get;set;} //this line was not cover in test class List<wrapper> WList=New List<wrapper>(); public List<wrapper> getLstwrapperstring() //this line was not cover in test class { slist=[SELECT Account_name__c,Name,Phone,Title,Email FROM Contact WHERE AccountId =:ApexPages.CurrentPage().GetParameters().Get('id')]; //this line was not cover in test class for(Integer i=0 ;i<SList.size();i++){ //this line was not cover in test class WList.add(New wrapper(SList[i].name,SList[i].Account_name__c,SList[i].phone,SList[i].Title,SList[i].Email)); //this line was not cover in test class } return WList; //this line was not cover in test class } public class wrapper { public string cid{get;set;} public string cName{get;set;} public string cPhone{get;set;} public string cTitle{get;set;} public string cEmail{get;set;} public wrapper(string cName,string cid,string cPhone,string cTitle,string cEmail) { this.cid=cid; this.cName=cName; this.cPhone=cPhone; this.cTitle=cTitle; this.cEmail=cEmail; } } }
and here is my current test class
@isTest public class contact_pdf_test { static testMethod void data1(){ List<contact> acc = new List<contact>(); contact a = New contact(); a.firstName = 'mycontact'; a.lastName = 'mycontact'; a.phone='124365'; a.Title='Customer'; a.Email ='test@gmail.com'; acc.add(a); insert acc; ApexPages.StandardSetController sac = new ApexPages.StandardSetController (acc); wrapperexample2 aop = new wrapperexample2(sac); test.startTest(); PageReference myVfPage = Page.contact_pdf; Test.setCurrentPage(myVfPage); String mycontact; String cid; String cPhone; String cTitle; String cEmail; wrapperexample2.wrapper sacc = new wrapperexample2.wrapper(mycontact,cid,cPhone,cTitle,cEmail); test.stopTest(); } }
-
- sachitanand kumar
- July 28, 2017
- Like
- 0
- Continue reading or reply
hello can anybody help me to write Test class for this Trigger. i m not able to get 75 code coverage at salesforce
here is my trigger.
trigger autoupdate on Account (before update,before insert) { Integer lista; for(AggregateResult listcount :[SELECT max(customer_no__c) FROM Account]){ Decimal sumAmount = (Decimal) listcount.get('expr0'); lista =sumAmount.intValue(); } for(account count : trigger.new){ if(count.Type =='Customer' && count.customer_no__c == null) { count.customer_no__c = lista +1 ; } } }
-
- sachitanand kumar
- June 26, 2017
- Like
- 0
- Continue reading or reply
when i deploy test class in Inbound Change Sets i got error Invalid type: OpportunityOwnerUpdate at line 16 column 42 in my test code and I don't understand why and how to fix. Below is my test code:
- @isTest
- public class OpportunityOwnerUpdate_test {
- static testMethod void data1(){
- List<Opportunity> Opportunitys = new List<Opportunity>();
- Opportunity a = New Opportunity();
- a.Name = 'myOpportunity';
- a.StageName='Stage 1 - Expressed Interest';
- a.CloseDate=date.today();
- Opportunitys.add(a);
- insert Opportunitys;
- ApexPages.StandardSetController sac = new ApexPages.StandardSetController (Opportunitys);
- sac.setSelected([SELECT Id, OwnerId FROM Opportunity LIMIT 2]);
- OpportunityOwnerUpdate aop = new OpportunityOwnerUpdate(sac);
- aop.isSelected = true;
- aop.updateOpportunity();
- }
- static testMethod void data2(){
- List<Opportunity> Opportunitys = new List<Opportunity>();
- Opportunity a = New Opportunity();
- a.Name = 'myOpportunity';
- a.StageName='Stage 1 - Expressed Interest';
- a.CloseDate=date.today();
- Opportunitys.add(a);
- insert Opportunitys;
- ApexPages.StandardSetController sac = new ApexPages.StandardSetController (Opportunitys);
- OpportunityOwnerUpdate aop = new OpportunityOwnerUpdate(sac);
- aop.isSelected = false;
- }
- }
-
- sachitanand kumar
- May 02, 2017
- Like
- 0
- Continue reading or reply
Hi All, I write a class for vf page for display duplicate lead in vf page.i got the Error: leaddup Compile Error: Illegal assignment from List<AggregateResult> to List<Lead> . i m basically admin so i can't understand about error any help appreciated
This is class
-------------------------------------------------------------------------
public class leaddup {
public List<lead>ac{get;set;}
public leaddup(){
ac =[SELECT name,email FROM lead ];
}
public void getbyname(){
ac=[SELECT name,count(Id) FROM lead GROUP BY name HAVING count(Id)>1];
}
public void getbyemail(){
ac=[SELECT email,count(Id) FROM lead GROUP BY email HAVING count(Id)>1];
}
}
--------------------------------------------------
This is vf
---------------------------------------------------------------------
<apex:page controller="leaddup">
<apex:form >
<apex:pageblock title="Duplicate lead">
<apex:pageBlockButtons >
<apex:commandButton value="based on name" action="{!getbyname}"/>
<apex:commandButton value="based on email" action="{!getbyemail}"/>
</apex:pageBlockButtons>
<apex:PageBlockTable value="{!ac}" var="a">
<apex:Column value="{!a.Name}"/>
<apex:Column value="{!a.email}"/>
</apex:PageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
-------------------------------------------------------------------------
public class leaddup {
public List<lead>ac{get;set;}
public leaddup(){
ac =[SELECT name,email FROM lead ];
}
public void getbyname(){
ac=[SELECT name,count(Id) FROM lead GROUP BY name HAVING count(Id)>1];
}
public void getbyemail(){
ac=[SELECT email,count(Id) FROM lead GROUP BY email HAVING count(Id)>1];
}
}
--------------------------------------------------
This is vf
---------------------------------------------------------------------
<apex:page controller="leaddup">
<apex:form >
<apex:pageblock title="Duplicate lead">
<apex:pageBlockButtons >
<apex:commandButton value="based on name" action="{!getbyname}"/>
<apex:commandButton value="based on email" action="{!getbyemail}"/>
</apex:pageBlockButtons>
<apex:PageBlockTable value="{!ac}" var="a">
<apex:Column value="{!a.Name}"/>
<apex:Column value="{!a.email}"/>
</apex:PageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
-
- sachitanand kumar
- April 27, 2017
- Like
- 0
- Continue reading or reply
Hi, I m new at salesforce. Anybody help me to write Test class for this apex class.
public class AccountOwnerUpdate{
public Boolean isSelected{get;set;}
public Account accounts{get;set;}
public List<Account> selectedAccounts{get;set;}
// public Boolean sendEmail{get;set;}
public AccountOwnerUpdate(ApexPages.StandardSetController standardController)
{
if(standardController.getSelected().size() == 0){
isSelected = false;
ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.ERROR,'No Account Selected');
ApexPages.addMessage(msg);
}else{
isSelected = true;
selectedAccounts= [SELECT id,name,ownerid from Account where id=:standardController.getSelected()];
accounts = selectedAccounts[0];
// accounts.ownerid = null;
}
}
public PageReference updateAccount()
{
for(Account a: selectedAccounts){
a.ownerid = accounts.ownerid;
}
update selectedAccounts;
return new Pagereference('/001/o');
}
}
public Boolean isSelected{get;set;}
public Account accounts{get;set;}
public List<Account> selectedAccounts{get;set;}
// public Boolean sendEmail{get;set;}
public AccountOwnerUpdate(ApexPages.StandardSetController standardController)
{
if(standardController.getSelected().size() == 0){
isSelected = false;
ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.ERROR,'No Account Selected');
ApexPages.addMessage(msg);
}else{
isSelected = true;
selectedAccounts= [SELECT id,name,ownerid from Account where id=:standardController.getSelected()];
accounts = selectedAccounts[0];
// accounts.ownerid = null;
}
}
public PageReference updateAccount()
{
for(Account a: selectedAccounts){
a.ownerid = accounts.ownerid;
}
update selectedAccounts;
return new Pagereference('/001/o');
}
}
-
- sachitanand kumar
- April 25, 2017
- Like
- 0
- Continue reading or reply
hello can anybody help me to write Test class for this Trigger. i m new at salesforce
trigger opportunitytocontactstageupdate on Opportunity (after insert, after update) {
if(Trigger.isafter){
List<contact> thisContact1=new List<contact>();
set<id> thisContact=new set<id>();
map<id,id> oppContactMap = new map<id,id>();
map<id,contact> ContactMap = new map<id,contact>();
List<OpportunityContactRole> oppContact = [SELECT id,OpportunityID,ContactId FROM OpportunityContactRole WHERE OpportunityID = :trigger.newmap.keyset() ];
if(oppContact.size()>0){
for(OpportunityContactRole oppContacObj : oppContact){
oppContactMap.put(oppContacObj.OpportunityId,oppContacObj.ContactId);
thisContact.add(oppContacObj.Contactid);
}
for(Contact conObj :[Select Name,opportunityStageName__c from Contact Where id IN :thisContact] ){
ContactMap.put(conObj.id,conObj);
}
for(opportunity oppObj : trigger.new){
ContactMap.get(oppContactMap.get(oppObj.id)).opportunityStageName__c = oppObj.StageName;
thisContact1.add(contactMap.get(oppContactMap.get(oppObj.id)));
}
update thisContact1;
}
}
}
if(Trigger.isafter){
List<contact> thisContact1=new List<contact>();
set<id> thisContact=new set<id>();
map<id,id> oppContactMap = new map<id,id>();
map<id,contact> ContactMap = new map<id,contact>();
List<OpportunityContactRole> oppContact = [SELECT id,OpportunityID,ContactId FROM OpportunityContactRole WHERE OpportunityID = :trigger.newmap.keyset() ];
if(oppContact.size()>0){
for(OpportunityContactRole oppContacObj : oppContact){
oppContactMap.put(oppContacObj.OpportunityId,oppContacObj.ContactId);
thisContact.add(oppContacObj.Contactid);
}
for(Contact conObj :[Select Name,opportunityStageName__c from Contact Where id IN :thisContact] ){
ContactMap.put(conObj.id,conObj);
}
for(opportunity oppObj : trigger.new){
ContactMap.get(oppContactMap.get(oppObj.id)).opportunityStageName__c = oppObj.StageName;
thisContact1.add(contactMap.get(oppContactMap.get(oppObj.id)));
}
update thisContact1;
}
}
}
-
- sachitanand kumar
- March 24, 2017
- Like
- 0
- Continue reading or reply
how to write test class for standard controller extension for the below code??? Please help me.... i am new at salesforce
Here is my apex class.
public class AccountOwnerUpdate{
public Boolean isSelected{get;set;}
public Account accounts{get;set;}
public List<Account> selectedAccounts{get;set;}
// public Boolean sendEmail{get;set;}
public AccountOwnerUpdate(ApexPages.StandardSetController standardController)
{
if(standardController.getSelected().size() == 0){
isSelected = false;
ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.ERROR,'No Account Selected');
ApexPages.addMessage(msg);
}else{
isSelected = true;
selectedAccounts= [SELECT id,name,ownerid from Account where id=:standardController.getSelected()];
accounts = selectedAccounts[0];
// accounts.ownerid = null;
}
}
public PageReference updateAccount()
{
for(Account a: selectedAccounts){
a.ownerid = accounts.ownerid;
}
update selectedAccounts;
return new Pagereference('/001/o');
}
}
Here is my visual force page code.
<apex:page standardController="Account" recordsetvar="Account" tabStyle="Account" extensions="AccountOwnerUpdate">
<apex:pagemessages />
<script>
function myFunction() {
alert("Are you sure?");
}
</script>
<apex:form rendered="{!isSelected}">
<apex:sectionHeader subtitle="Change Owner" title="Account Edit" description="This screen allows you to transfer ownership of a Account to another user. When you transfer ownership of a Account, the new owner will own:
<br/>• all notes and attachments recorded for the current owner
<br/>• all open activities (tasks and events) owned by the current owner
<br/>
<br/>Note that completed activities and open activities owned by other users will not be transferred."/>
<apex:pageblock mode="Edit" title="Account Edit">
<apex:pageblockSection title="Select New Owner">
<apex:inputField value="{!accounts.OwnerId}"/>
</apex:pageblockSection>
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!updateAccount}" rendered="{!$User.Email == 'raj.sharma@theeclgroup.com'}"/>
<apex:actionRegion >
<apex:commandButton value="Cancel" onclick="myFunction()" action="{!cancel}"/>
</apex:actionRegion>
</apex:pageblockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
public class AccountOwnerUpdate{
public Boolean isSelected{get;set;}
public Account accounts{get;set;}
public List<Account> selectedAccounts{get;set;}
// public Boolean sendEmail{get;set;}
public AccountOwnerUpdate(ApexPages.StandardSetController standardController)
{
if(standardController.getSelected().size() == 0){
isSelected = false;
ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.ERROR,'No Account Selected');
ApexPages.addMessage(msg);
}else{
isSelected = true;
selectedAccounts= [SELECT id,name,ownerid from Account where id=:standardController.getSelected()];
accounts = selectedAccounts[0];
// accounts.ownerid = null;
}
}
public PageReference updateAccount()
{
for(Account a: selectedAccounts){
a.ownerid = accounts.ownerid;
}
update selectedAccounts;
return new Pagereference('/001/o');
}
}
Here is my visual force page code.
<apex:page standardController="Account" recordsetvar="Account" tabStyle="Account" extensions="AccountOwnerUpdate">
<apex:pagemessages />
<script>
function myFunction() {
alert("Are you sure?");
}
</script>
<apex:form rendered="{!isSelected}">
<apex:sectionHeader subtitle="Change Owner" title="Account Edit" description="This screen allows you to transfer ownership of a Account to another user. When you transfer ownership of a Account, the new owner will own:
<br/>• all notes and attachments recorded for the current owner
<br/>• all open activities (tasks and events) owned by the current owner
<br/>
<br/>Note that completed activities and open activities owned by other users will not be transferred."/>
<apex:pageblock mode="Edit" title="Account Edit">
<apex:pageblockSection title="Select New Owner">
<apex:inputField value="{!accounts.OwnerId}"/>
</apex:pageblockSection>
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!updateAccount}" rendered="{!$User.Email == 'raj.sharma@theeclgroup.com'}"/>
<apex:actionRegion >
<apex:commandButton value="Cancel" onclick="myFunction()" action="{!cancel}"/>
</apex:actionRegion>
</apex:pageblockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
-
- sachitanand kumar
- March 09, 2017
- Like
- 0
- Continue reading or reply
send alert email when case owner change..
when i change the case owner and when new case owner not do any activity on the case within 4 hour than send a alert email to the admin and new case owner
-
- sachitanand kumar
- November 14, 2016
- Like
- 0
- Continue reading or reply
How to write test class for this lead trigger
Hello everyone, plz tell me how to write the test class for this trigger listed below.
trigger trigMapFields on Lead (before update) {
Map<Id,String> leadStatus = new Map<Id,String>();
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead.channel__c);
}
}
List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :leadStatus.keySet()];
for ( Contact c : conContacts) {
c.channel__c= leadStatus.get(c.Id);
}
update conContacts;
}
trigger trigMapFields on Lead (before update) {
Map<Id,String> leadStatus = new Map<Id,String>();
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead.channel__c);
}
}
List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :leadStatus.keySet()];
for ( Contact c : conContacts) {
c.channel__c= leadStatus.get(c.Id);
}
update conContacts;
}
-
- sachitanand kumar
- October 16, 2016
- Like
- 0
- Continue reading or reply
hi.. how i can got 75% code coverge in following apex class.currently i m able to cover only 68 % any body can help me
here is my apex class
and here is my current test class
public class wrapperexample2 { public wrapperexample2(ApexPages.StandardSetController controller) { } public List<Schema.contact> SList{get;set;} //this line was not cover in test class List<wrapper> WList=New List<wrapper>(); public List<wrapper> getLstwrapperstring() //this line was not cover in test class { slist=[SELECT Account_name__c,Name,Phone,Title,Email FROM Contact WHERE AccountId =:ApexPages.CurrentPage().GetParameters().Get('id')]; //this line was not cover in test class for(Integer i=0 ;i<SList.size();i++){ //this line was not cover in test class WList.add(New wrapper(SList[i].name,SList[i].Account_name__c,SList[i].phone,SList[i].Title,SList[i].Email)); //this line was not cover in test class } return WList; //this line was not cover in test class } public class wrapper { public string cid{get;set;} public string cName{get;set;} public string cPhone{get;set;} public string cTitle{get;set;} public string cEmail{get;set;} public wrapper(string cName,string cid,string cPhone,string cTitle,string cEmail) { this.cid=cid; this.cName=cName; this.cPhone=cPhone; this.cTitle=cTitle; this.cEmail=cEmail; } } }
and here is my current test class
@isTest public class contact_pdf_test { static testMethod void data1(){ List<contact> acc = new List<contact>(); contact a = New contact(); a.firstName = 'mycontact'; a.lastName = 'mycontact'; a.phone='124365'; a.Title='Customer'; a.Email ='test@gmail.com'; acc.add(a); insert acc; ApexPages.StandardSetController sac = new ApexPages.StandardSetController (acc); wrapperexample2 aop = new wrapperexample2(sac); test.startTest(); PageReference myVfPage = Page.contact_pdf; Test.setCurrentPage(myVfPage); String mycontact; String cid; String cPhone; String cTitle; String cEmail; wrapperexample2.wrapper sacc = new wrapperexample2.wrapper(mycontact,cid,cPhone,cTitle,cEmail); test.stopTest(); } }
- sachitanand kumar
- July 28, 2017
- Like
- 0
- Continue reading or reply
hello can anybody help me to write Test class for this Trigger. i m not able to get 75 code coverage at salesforce
here is my trigger.
trigger autoupdate on Account (before update,before insert) { Integer lista; for(AggregateResult listcount :[SELECT max(customer_no__c) FROM Account]){ Decimal sumAmount = (Decimal) listcount.get('expr0'); lista =sumAmount.intValue(); } for(account count : trigger.new){ if(count.Type =='Customer' && count.customer_no__c == null) { count.customer_no__c = lista +1 ; } } }
- sachitanand kumar
- June 26, 2017
- Like
- 0
- Continue reading or reply
hello can anybody help me to write Test class for this Trigger. i m new at salesforce
trigger opportunitytocontactstageupdate on Opportunity (after insert, after update) {
if(Trigger.isafter){
List<contact> thisContact1=new List<contact>();
set<id> thisContact=new set<id>();
map<id,id> oppContactMap = new map<id,id>();
map<id,contact> ContactMap = new map<id,contact>();
List<OpportunityContactRole> oppContact = [SELECT id,OpportunityID,ContactId FROM OpportunityContactRole WHERE OpportunityID = :trigger.newmap.keyset() ];
if(oppContact.size()>0){
for(OpportunityContactRole oppContacObj : oppContact){
oppContactMap.put(oppContacObj.OpportunityId,oppContacObj.ContactId);
thisContact.add(oppContacObj.Contactid);
}
for(Contact conObj :[Select Name,opportunityStageName__c from Contact Where id IN :thisContact] ){
ContactMap.put(conObj.id,conObj);
}
for(opportunity oppObj : trigger.new){
ContactMap.get(oppContactMap.get(oppObj.id)).opportunityStageName__c = oppObj.StageName;
thisContact1.add(contactMap.get(oppContactMap.get(oppObj.id)));
}
update thisContact1;
}
}
}
if(Trigger.isafter){
List<contact> thisContact1=new List<contact>();
set<id> thisContact=new set<id>();
map<id,id> oppContactMap = new map<id,id>();
map<id,contact> ContactMap = new map<id,contact>();
List<OpportunityContactRole> oppContact = [SELECT id,OpportunityID,ContactId FROM OpportunityContactRole WHERE OpportunityID = :trigger.newmap.keyset() ];
if(oppContact.size()>0){
for(OpportunityContactRole oppContacObj : oppContact){
oppContactMap.put(oppContacObj.OpportunityId,oppContacObj.ContactId);
thisContact.add(oppContacObj.Contactid);
}
for(Contact conObj :[Select Name,opportunityStageName__c from Contact Where id IN :thisContact] ){
ContactMap.put(conObj.id,conObj);
}
for(opportunity oppObj : trigger.new){
ContactMap.get(oppContactMap.get(oppObj.id)).opportunityStageName__c = oppObj.StageName;
thisContact1.add(contactMap.get(oppContactMap.get(oppObj.id)));
}
update thisContact1;
}
}
}
- sachitanand kumar
- March 24, 2017
- Like
- 0
- Continue reading or reply
how to write test class for standard controller extension for the below code??? Please help me.... i am new at salesforce
Here is my apex class.
public class AccountOwnerUpdate{
public Boolean isSelected{get;set;}
public Account accounts{get;set;}
public List<Account> selectedAccounts{get;set;}
// public Boolean sendEmail{get;set;}
public AccountOwnerUpdate(ApexPages.StandardSetController standardController)
{
if(standardController.getSelected().size() == 0){
isSelected = false;
ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.ERROR,'No Account Selected');
ApexPages.addMessage(msg);
}else{
isSelected = true;
selectedAccounts= [SELECT id,name,ownerid from Account where id=:standardController.getSelected()];
accounts = selectedAccounts[0];
// accounts.ownerid = null;
}
}
public PageReference updateAccount()
{
for(Account a: selectedAccounts){
a.ownerid = accounts.ownerid;
}
update selectedAccounts;
return new Pagereference('/001/o');
}
}
Here is my visual force page code.
<apex:page standardController="Account" recordsetvar="Account" tabStyle="Account" extensions="AccountOwnerUpdate">
<apex:pagemessages />
<script>
function myFunction() {
alert("Are you sure?");
}
</script>
<apex:form rendered="{!isSelected}">
<apex:sectionHeader subtitle="Change Owner" title="Account Edit" description="This screen allows you to transfer ownership of a Account to another user. When you transfer ownership of a Account, the new owner will own:
<br/>• all notes and attachments recorded for the current owner
<br/>• all open activities (tasks and events) owned by the current owner
<br/>
<br/>Note that completed activities and open activities owned by other users will not be transferred."/>
<apex:pageblock mode="Edit" title="Account Edit">
<apex:pageblockSection title="Select New Owner">
<apex:inputField value="{!accounts.OwnerId}"/>
</apex:pageblockSection>
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!updateAccount}" rendered="{!$User.Email == 'raj.sharma@theeclgroup.com'}"/>
<apex:actionRegion >
<apex:commandButton value="Cancel" onclick="myFunction()" action="{!cancel}"/>
</apex:actionRegion>
</apex:pageblockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
public class AccountOwnerUpdate{
public Boolean isSelected{get;set;}
public Account accounts{get;set;}
public List<Account> selectedAccounts{get;set;}
// public Boolean sendEmail{get;set;}
public AccountOwnerUpdate(ApexPages.StandardSetController standardController)
{
if(standardController.getSelected().size() == 0){
isSelected = false;
ApexPages.Message msg = new ApexPages.message(ApexPages.Severity.ERROR,'No Account Selected');
ApexPages.addMessage(msg);
}else{
isSelected = true;
selectedAccounts= [SELECT id,name,ownerid from Account where id=:standardController.getSelected()];
accounts = selectedAccounts[0];
// accounts.ownerid = null;
}
}
public PageReference updateAccount()
{
for(Account a: selectedAccounts){
a.ownerid = accounts.ownerid;
}
update selectedAccounts;
return new Pagereference('/001/o');
}
}
Here is my visual force page code.
<apex:page standardController="Account" recordsetvar="Account" tabStyle="Account" extensions="AccountOwnerUpdate">
<apex:pagemessages />
<script>
function myFunction() {
alert("Are you sure?");
}
</script>
<apex:form rendered="{!isSelected}">
<apex:sectionHeader subtitle="Change Owner" title="Account Edit" description="This screen allows you to transfer ownership of a Account to another user. When you transfer ownership of a Account, the new owner will own:
<br/>• all notes and attachments recorded for the current owner
<br/>• all open activities (tasks and events) owned by the current owner
<br/>
<br/>Note that completed activities and open activities owned by other users will not be transferred."/>
<apex:pageblock mode="Edit" title="Account Edit">
<apex:pageblockSection title="Select New Owner">
<apex:inputField value="{!accounts.OwnerId}"/>
</apex:pageblockSection>
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!updateAccount}" rendered="{!$User.Email == 'raj.sharma@theeclgroup.com'}"/>
<apex:actionRegion >
<apex:commandButton value="Cancel" onclick="myFunction()" action="{!cancel}"/>
</apex:actionRegion>
</apex:pageblockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
- sachitanand kumar
- March 09, 2017
- Like
- 0
- Continue reading or reply