• Athi
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hi all,
I am new to VF coding ...I would like to Rerender AllAccounts in a Account. Idea is to change all account owner by using custom button.  I have Controller extension which query all account. But I could rerender the list from controller extension. How do i do that? thanks in advance

VF page invoked by custom list button:
<apex:page standardController="Account"
    recordSetVar="Accounts"
    extensions="AccountSelectAllRec"
   showHeader="false"
    id="muopp"
>
    <apex:form id="muform">
                <apex:pageBlock title="Account Owner Mass-Update" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockSection id="mus1">
                <apex:inputField value="{!Account.Ownerid}" id="stagename">
                    <apex:actionSupport event="onchange" rerender="{!AccountSelectAllRec}"/>
                </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:form>
</apex:page>
I dont want to select account. I have to update all account respecting user security. I wrote controller extension to query all account.
My controller extension.
 
public with sharing class AccountSelectAllRec {
private final Account acct; 
    // The constructor passes in the standard controller defined

    // in the markup below

    public AccountSelectAllRec(ApexPages.StandardSetController controller) {

        this.acct = (Account)controller.getRecord();

    }   
    public ApexPages.StandardSetController accountRecords {

        get {

            if(accountRecords == null) {
                           accountRecords = new ApexPages.StandardSetController(

                    Database.getQueryLocator([SELECT OwnerId FROM Account ]));

            }
            return accountRecords;

        }

        private set;
    }
    public List<Account> getAccountSelectAllRec() {
         return (List<Account>) accountRecords.getRecords();
    } 
}


When I change the code  rerender="{muselectedlist}"  to rerender="{!AccountSelectAllRec}" Code fails. Please helppppppppp......
  • May 08, 2017
  • Like
  • 0
How to mass update a field all records in a specific view (Eg.  Records in All Accounts or My Accounts)
  • May 04, 2017
  • Like
  • 0
I am searching all blog to death but with no solution.
Requirement:
Mass update or Calculate All records in list view using Custom button. I tried two ways
1. Embedded Visualforce page with flow 
2. visualforce page with StandardController
Multiselect in custom button allows me to select records in give page. Say, In "AllAccounts" view has 500records. I can only process first page(Upto 200records) by using above method. 
Is there anyway to process all the records in a given view by using custom list button? code below

<apex:page standardController="Contact" recordSetVar="Contacts" id="updateOwnerPage"> <apex:form > <apex:sectionheader title="Change Owner for Contacts"/> <apex:pageblock mode="edit"> <apex:pagemessages /> <apex:pageblocksection title="Change" columns="1"> <apex:pageblocksectionitem > <apex:outputlabel for="owner">New Owner</apex:outputlabel> <apex:inputfield id="owner" value="{!Contact.OwnerId}"/> </apex:pageblocksectionitem> </apex:pageblocksection> <apex:variable var="call" value="{!0}" /> <apex:repeat value="{!Selected}" var="con"> <apex:pageblocksection title="Selected Contacts" columns="1"> <apex:pageblocktable value="{!con}" var="j" > <apex:column > <apex:facet name="header">Contact Name</apex:facet> <apex:outputlink value="{!URLFOR($Action.Contact.View, j.id)}"> {!j.FirstName} {!j.LastName}</apex:outputlink> </apex:column> <apex:column > <apex:facet name="header">Account Name</apex:facet> <apex:outputlink value="{!URLFOR($Action.Account.View, j.Account.id)}"> {!j.Account.Name}</apex:outputlink> </apex:column> <apex:column > <apex:facet name="header">Current Owner</apex:facet> {!j.Owner.Name} </apex:column> </apex:pageblocktable> </apex:pageblocksection> <apex:variable var="call" value="{!call+1}"/> </apex:repeat> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr height="5"> <td width="35%" class="outsideround_head" align="right"> Total Contacts Returned:&nbsp; </td> <td width="8%" class="outside_round_head_value"> <apex:outputText value="{!call}"/> </td> </tr> </table> <apex:pageblockbuttons location="bottom"> <apex:commandbutton value="Save" action="{!save}"/> <apex:commandbutton value="Cancel" action="{!cancel}"/> </apex:pageblockbuttons> </apex:pageblock> </apex:form> </apex:page>
 
  • May 04, 2017
  • Like
  • 0
I have performed a fast lookup and retrieved a list of objects. I need to make a decision based on the number of records returned - can I do this with a formula instead of having to use a loop to count the records?
HI All
I want to add change owner button on account list view page but shows this error.
Null reference exception
public class AccountController1 
{
    public Account accounts{get;set;}
    

    private ApexPages.StandardSetController standardController;
    public AccountController1(ApexPages.StandardController controller) {

    }

    public AccountController1(ApexPages.StandardSetController standardController)
    {
        this.standardController = standardController;
        List<Account> selectedAccounts = (List<Account>) standardController.getSelected();
        for(Account selectedAccount : selectedAccounts)
        {
            //if(selectedAccount.ownerid== null) 
                selectedAccount.ownerid = selectedAccount.ownerid;
            //else if(selectedAccount.ownerid == 'Low')
            System.debug('selectownerid>>>'+selectedAccount.ownerid);
           //  System.debug('selectownerid>>>'+selectedAccount.ownerid);
            //    selectedAccount.ownerid = 'Medium';
           /// else if(selectedAccount.ownerid == 'Medium')
            //    selectedAccount.ownerid = 'High';
        }       
    }

    
    
    public PageReference updateAccount()
    {       
        //update accounts;
        return standardController.save();
        // Call StandardSetController 'save' method to update (optional, you can use your own DML)
        //return null;   
    }
}


vd page

<apex:page standardController="Account" extensions="AccountController1">
    <apex:form >
        <apex:pageblock >
            <apex:pageblockbuttons >
                <apex:commandButton action="{!updateAccount}" value="Save"/>
            </apex:pageblockbuttons>
            <apex:pageblockSection >
                <apex:inputField value="{!accounts.OwnerId}"/>
            </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
please help me
 

I'm looking for an alternative to passing selected records from a List View via the URL.  Here is how I'm currently doing it, but I'm running into IE URL limits when more than 100 records are selected.  This is a custom List view button executing JavaScript.

 

var ids = {!GETRECORDIDS( $ObjectType.Account )};

if(ids.length < 1 ) {
alert('Please select at least one Account.')
}
else {
// window.open('/apex/Quick_Email?rec='+ids.join(',')+'&retURL=001/o');
window.location='/apex/Quick_Email?rec='+ids.join(',')+'&retURL=001/o';
}

 

What other methods could I implement?

 

  • August 15, 2011
  • Like
  • 0

When you check the top box on a page with Multi-Record Selection, it selects/deselects only the records currently displayed on the page.  So if there are 50 records in the view but only 25 records per page, it only affects the 25.

 

How would I go about implementing a "Select All" link or button?

Hello... In a StandardController extention I would like to guery fields from records selected in a related list view. So, if the user selects 3 records in the custom object I would like to retrieve their Ids and then perfrom a query based on that List. The List command in red fails with :  ' Illegal assignment from LIST:SObject to LIST:SOBJECT:' I've tried different variations of the List with ctl.getSelected but have quite got it right.

 

How do I structure the List so I can retrieve the selected Ids? Perhaps using List isn't the best way to hold the Ids so I am certainly open for suggestions on how to use 'getSelected'

 

Regards,

 

The Extension controller looks like this:

 

 

Public class ConAE {
      private final Asset_Entitlement__c ae;
      ApexPages.StandardSetController ctl = null;
      public ConAE(ApexPages.StandardSetController controller) {
           if ( ctl == null )
            {
               ctl = controller;
              
               List<Asset_Entitlement__c> aeId = ctl.getSelected();  //ERROR HERE
               System.debug('aeId is: ' +aeId);
              List<Asset_Entitlement__c> ae = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id = :ctl.getSelected()];// This is probably incorrect too
               System.debug('*******************m ae is:' + ae);
            }
           
           
          
      }