• Prasanthi B
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 13
    Replies
Hi,

I need to redirect a custom button to opportunity creation page.

    Pagereference optypage = new Pagereference('https:ap1.salesforce.com/006/e?retURL=%2F0062Fo%');
    system.debug('***optypage****'+optypage);
    optypage.setRedirect(true);
    return optypage;

But the page is not redirecting to the edit page of new opportunity. It remains same on the previous page.

When I remove retURL, it wokrs fine. 

Pagereference optypage = new Pagereference('https:ap1.salesforce.com/006/o');

I need to redirect to the edit page of new Opportunity.

Plesse suggest.

Thanks

Hi,

 

I am not able to use the wrapperclass selected property in my visal force checkbox button.

 

Error: Invalid field selected for SObject User

 

<apex:pageBlockTable value="{!results}" var="t" id="theTable">
        <apex:column >
          <apex:inputCheckbox value="{!t.selected}"/>
        </apex:column>

 

public class UserWrapper 
 {   
  
 public User wuser { get; set; }   
 public boolean selected { get; set; }
 public UserWrapper(User u)    
   {        wuser = u; 
            selected = false;    
   } 

 }

 

Please suggest.

 

Thnaks.

 

 

 

Hi,

 

My controller class is having two actions. One is search based on a picklist value. Other one is command button action based on the result of first action.

 

Command button action(second action) is not getting invoked when the first action is occured.

 

Indepently it is working fine. Only the command button action without the first action is working.

 

But these two should be dependent actions.

 

Please advise on the requirement

 

VFCODE:

<apex:page StandardController="User" Extensions="UserData" tabstyle="User" sidebar="false">
  <apex:form >
  <apex:pageBlock title="Select Users" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
<apex:actionRegion >
<apex:outputLabel value="Select Region of the user: " for="viewlist" />
<apex:inputField id="startMode" value="{!User.Region__c}">
<apex:actionsupport event="onchange" action="{!doSearch}" rerender="theTable" />
</apex:inputfield> 
</apex:actionRegion>
           <br></br> 
   <apex:pageBlockTable value="{!results}" var="t" id="theTable">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
          </apex:inputCheckbox>
        </apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>      
  </apex:pageBlockTable>
<!--<apex:inputField value="{!User.ManagerId}" rendered="{!size}"/> -->
<apex:inputField value="{!User.ManagerId}" styleClass="StyleCSS"/>
<apex:actionRegion >
<apex:commandButton value="UpdateManager" Id="Update" action="{!getselected}" styleClass="StyleCSS"/>
</apex:actionRegion>
    </apex:pageblock>    
  </apex:form>
  </apex:page>

  CONTROLLER:

public class UserData {
List<Userwrapper> userList {get;set;} 
PUBLIC String usr{get;set;} 
List<User> results=new List<User>();
public User user;
public ApexPages.StandardController stdCtrl;
public UserData(ApexPages.StandardController controller) 
   { 
     stdCtrl=controller;

   }   
        
         
  public Pagereference doSearch() 
     {
      //results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:User.Region__c];
      User u=(User)stdCtrl.getrecord();
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:u.Region__c];
            system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }
  public List<Userwrapper> XXX()  
   {
     if(userList == null) {
      userList = new List<Userwrapper>();

     for(User u:results)
      {
        userList.add(new Userwrapper(u));
      }
      system.debug('****ADDEDUSERS****'+userlist);
       }
       return userList;

  }
     
   Public PageReference getSelected()
   { 
        User u1=(User)stdCtrl.getrecord();
        system.debug('ENTERED INTO SELECTED');
        List<User> selectedUsers = new List<User>(); 
        for(userwrapper usrwrapper : XXX()) 
        { 
          if(usrwrapper.selected== true) 
          { 
           selectedusers.add(usrwrapper.wuser); 
          }
        }
        system.debug('@@@SELECTEDUSERs@@@:'+selectedusers);  
        return null;
  }
   
  public boolean getsize()
  {
    Integer size=results.size();
     IF(size>0)
      return True;
     Else 
      return false;
    
  } 
  Public Pagereference UpdateManager()
   {
        return null;
   }
     
   public List<User> getResults() 
    {
        return results;
    }
 
 }

 Update manager button action is not working in the page.

 

Please advice.

 

Thanks,

Santhi.

Hi,

 

I have a search button in my visual force page. When a dropdown value is selected and clicked on search button, query will be executed and results are displayed. But for the second time dropdown value is changed and search button is clicked, the result set is not getting changed. Whatever is returned in the first click action is only getting displayed.

 

Can anyone please clarify on this thing.

 

Thanks,

Santhi.

Hi,

 

My requirement is to have one search button in a VF page. And display the search results in a table with a checkbox for each record. Some records need to be selected and only those records have to be updated with some input value given on the same VF page.

 

The problem here is, first search button is working fine and displaying the results. But the update command button action is not getting invoked in the controller class.

 

Please find the code below.

 

This is very critical requorement which needs to be delivered.

 

 

It would be great if anyone could look into it and suggest.

 

VF PAGE:

 

<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
   Select Region of the user:
    
   <apex:inputField id="startMode" value="{!User.Region__c}" />
   <br></br>
      <apex:commandButton action="{!doSearch}" value="Search" rerender="table">               
   </apex:commandButton>
  <br></br> 
  <apex:pageBlockSection >
   <apex:inputField value="{!User.ManagerId}" id="Manager"/>
  </apex:pageBlockSection> 
    
  <apex:pageBlockTable value="{!results}" var="t" id="table">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
          </apex:inputCheckbox>
        </apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>
      
  </apex:pageBlockTable> 
    
  <apex:commandButton action="{!getSelected}" value="UpdateManager" />
  </apex:pageblock>    
  </apex:form>
  </apex:page>

 

CONTROLLER:

 

public class UserData {
List<Userwrapper> userList {get;set;}
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results=new List<User>();
public User user;
  public UserData(ApexPages.StandardController controller)
   {
     this.user= (User)controller.getRecord();
   }
    
  public Pagereference doSearch()
     {
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:User.Region__c];
      system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }
  public List<Userwrapper> XXX() 
  {
     if(userList == null) {
      userList = new List<Userwrapper>();

     for(User u:results)
      {
        userList.add(new Userwrapper(u));
      }
      system.debug('****ADDEDUSERS****'+userlist);
       }
       return userList;

  }
    // This method is called for 'UpdateManager' command button action, which is not getting invoked when clicked on the button . 
   Public PageReference getSelected()
   {
        system.debug('ENTERED INTO SELECTED');
        List<User> selectedUsers = new List<User>();
        for(userwrapper usrwrapper : XXX())
        {
          if(usrwrapper.selected == true)
          {
           selectedusers.add(usrwrapper.wuser);
          }
        }
        system.debug('@@@SELECTEDUSERs@@@:'+selectedusers); 
        return null;
  }
  
   Public Pagereference UpdateManager()
   {
        return null;
   }
      
   public List<User> getResults()
    {
        return results;
    }
 
 }

Hi,

 

I need to pass some records selected using an input checkbox field on a visualforce page to a controller. The list of selected records have to be updated with already selected lookup field value on the same visual force page.

 

Hence, the list of selected records and lookup field value should be passes over to a controller class.

 

Please find below code and suggest if there is an idea.

 

VFCODE:

 

<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
   Select Region of the user:
    
   <apex:inputField id="startMode" value="{!User.Region__c}" />
   <br></br>
      <apex:commandButton action="{!doSearch}" value="Search" >               
   </apex:commandButton>
  <br></br> 
  <apex:pageBlockSection >
   <apex:inputField value="{!User.ManagerId}" id="Check"/>
  </apex:pageBlockSection>       
  <apex:pageBlockTable value="{!results}" var="t">
        <apex:column headerValue="Select">
        <apex:inputCheckbox id="checkedone">
        </apex:inputCheckbox></apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>
      
  </apex:pageBlockTable> 
  <apex:commandButton value="UpdateManager" action="{!UpdateManager}"/>
  </apex:pageblock>    
  </apex:form>
  </apex:page>

 

CONTROLLER:

 

public class UserData {
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results=new List<User>();

public User user;
String Regionid;
String Region;
  public UserData(ApexPages.StandardController controller)
   {
     this.user= (User)controller.getRecord();
   }
    
  public Pagereference doSearch()
     {
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c  =:User.Region__c];
     
      system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }

 

public List<User> getResults()
    {
        return results;
    }
     
     
   Public Pagereference UpdateManager()
   {
    for(User sluser: selectedusers)
    {
       

     //Update the all the selected users with the  manager id highlighted in the VF page.

 

    }
    return null;
   }
       
    
 }

 

 

 

 

I need to pass a selected picklist value to my controller class and based on that value, a query needs to be created. Then the resulting values have to be displayed in a table.

 

Please find my VF and Controller code and suggest.

 

Thankyou.

 

VF CODE:

 

<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
   Select Region of the user:
   <apex:selectList id="u" value="{!usr}" size="1" title="Users">
   <apex:selectOptions value="{!usrs}"></apex:selectOptions>
   </apex:selectList>
   <apex:pageBlockButtons >  
<apex:commandButton value="GO" action="{!doSearch}">            
    </apex:commandButton>
    </apex:pageBlockButtons>
    <apex:pageBlockTable value="{!Results}" var="names">
    </apex:pageBlockTable>
   <br></br>             
  
  </apex:pageblock>
  </apex:form>   
  </apex:page>

 

 

 

CONTROLLER:

 

public class UserData {
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results;
List<Id> userlist=new List<Id>();

   public UserData(ApexPages.StandardController controller)
   { 
    }
  
   public List<selectOption> getusrs()
  {
    List<selectOption> options = new List<selectOption>(); 
    options.add(new selectOption('', '- None -'));   
    FOR (User users : [SELECT Id,Region__c FROM User Order By Region__c Asc]) 
    {   
      options.add(new selectOption(users.Id, users.Region__c));
     }    
       return options; 
  } 
  
 
   public Pagereference doSearch()
     {

      //selected picklist value must be passed to this query.
       results = (List<User>)[select Name from User Where Id=:???????????];
       system.debug('USERSLISTFOR REGION$$$$'+results);
       return null;
     }
      
   public List<User> getResults()
    {
        return results;
    }
 
 }

We have setup an approval process for opportunity. Whenever an opportunity is changed to the back stage, it should go for manager's approval. In normal scenario, it is working fine.But the problem is that if the record is rejected for the first time, next time the same record is sent for approval. Then the manager is not able to approve the request. An error message is displayed as below. In the trigger, we are making the Stage field set back to the old value only as below.

 

if(a[i].Status__c=='Rejected')
         {
         a[i].StageName = b[i].StageName;
         System.debug('StageName@@@'+a[i].StageName);

 

Please suggest why this field is getting null value?


 

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Required fields are missing: [Stage]".

 

Hi,

I need to redirect a custom button to opportunity creation page.

    Pagereference optypage = new Pagereference('https:ap1.salesforce.com/006/e?retURL=%2F0062Fo%');
    system.debug('***optypage****'+optypage);
    optypage.setRedirect(true);
    return optypage;

But the page is not redirecting to the edit page of new opportunity. It remains same on the previous page.

When I remove retURL, it wokrs fine. 

Pagereference optypage = new Pagereference('https:ap1.salesforce.com/006/o');

I need to redirect to the edit page of new Opportunity.

Plesse suggest.

Thanks

Hi,

 

I am not able to use the wrapperclass selected property in my visal force checkbox button.

 

Error: Invalid field selected for SObject User

 

<apex:pageBlockTable value="{!results}" var="t" id="theTable">
        <apex:column >
          <apex:inputCheckbox value="{!t.selected}"/>
        </apex:column>

 

public class UserWrapper 
 {   
  
 public User wuser { get; set; }   
 public boolean selected { get; set; }
 public UserWrapper(User u)    
   {        wuser = u; 
            selected = false;    
   } 

 }

 

Please suggest.

 

Thnaks.

 

 

 

Hi,

 

My controller class is having two actions. One is search based on a picklist value. Other one is command button action based on the result of first action.

 

Command button action(second action) is not getting invoked when the first action is occured.

 

Indepently it is working fine. Only the command button action without the first action is working.

 

But these two should be dependent actions.

 

Please advise on the requirement

 

VFCODE:

<apex:page StandardController="User" Extensions="UserData" tabstyle="User" sidebar="false">
  <apex:form >
  <apex:pageBlock title="Select Users" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
<apex:actionRegion >
<apex:outputLabel value="Select Region of the user: " for="viewlist" />
<apex:inputField id="startMode" value="{!User.Region__c}">
<apex:actionsupport event="onchange" action="{!doSearch}" rerender="theTable" />
</apex:inputfield> 
</apex:actionRegion>
           <br></br> 
   <apex:pageBlockTable value="{!results}" var="t" id="theTable">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
          </apex:inputCheckbox>
        </apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>      
  </apex:pageBlockTable>
<!--<apex:inputField value="{!User.ManagerId}" rendered="{!size}"/> -->
<apex:inputField value="{!User.ManagerId}" styleClass="StyleCSS"/>
<apex:actionRegion >
<apex:commandButton value="UpdateManager" Id="Update" action="{!getselected}" styleClass="StyleCSS"/>
</apex:actionRegion>
    </apex:pageblock>    
  </apex:form>
  </apex:page>

  CONTROLLER:

public class UserData {
List<Userwrapper> userList {get;set;} 
PUBLIC String usr{get;set;} 
List<User> results=new List<User>();
public User user;
public ApexPages.StandardController stdCtrl;
public UserData(ApexPages.StandardController controller) 
   { 
     stdCtrl=controller;

   }   
        
         
  public Pagereference doSearch() 
     {
      //results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:User.Region__c];
      User u=(User)stdCtrl.getrecord();
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:u.Region__c];
            system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }
  public List<Userwrapper> XXX()  
   {
     if(userList == null) {
      userList = new List<Userwrapper>();

     for(User u:results)
      {
        userList.add(new Userwrapper(u));
      }
      system.debug('****ADDEDUSERS****'+userlist);
       }
       return userList;

  }
     
   Public PageReference getSelected()
   { 
        User u1=(User)stdCtrl.getrecord();
        system.debug('ENTERED INTO SELECTED');
        List<User> selectedUsers = new List<User>(); 
        for(userwrapper usrwrapper : XXX()) 
        { 
          if(usrwrapper.selected== true) 
          { 
           selectedusers.add(usrwrapper.wuser); 
          }
        }
        system.debug('@@@SELECTEDUSERs@@@:'+selectedusers);  
        return null;
  }
   
  public boolean getsize()
  {
    Integer size=results.size();
     IF(size>0)
      return True;
     Else 
      return false;
    
  } 
  Public Pagereference UpdateManager()
   {
        return null;
   }
     
   public List<User> getResults() 
    {
        return results;
    }
 
 }

 Update manager button action is not working in the page.

 

Please advice.

 

Thanks,

Santhi.

Hi,

 

I have a search button in my visual force page. When a dropdown value is selected and clicked on search button, query will be executed and results are displayed. But for the second time dropdown value is changed and search button is clicked, the result set is not getting changed. Whatever is returned in the first click action is only getting displayed.

 

Can anyone please clarify on this thing.

 

Thanks,

Santhi.

Hi,

 

I need to pass some records selected using an input checkbox field on a visualforce page to a controller. The list of selected records have to be updated with already selected lookup field value on the same visual force page.

 

Hence, the list of selected records and lookup field value should be passes over to a controller class.

 

Please find below code and suggest if there is an idea.

 

VFCODE:

 

<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
   Select Region of the user:
    
   <apex:inputField id="startMode" value="{!User.Region__c}" />
   <br></br>
      <apex:commandButton action="{!doSearch}" value="Search" >               
   </apex:commandButton>
  <br></br> 
  <apex:pageBlockSection >
   <apex:inputField value="{!User.ManagerId}" id="Check"/>
  </apex:pageBlockSection>       
  <apex:pageBlockTable value="{!results}" var="t">
        <apex:column headerValue="Select">
        <apex:inputCheckbox id="checkedone">
        </apex:inputCheckbox></apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>
      
  </apex:pageBlockTable> 
  <apex:commandButton value="UpdateManager" action="{!UpdateManager}"/>
  </apex:pageblock>    
  </apex:form>
  </apex:page>

 

CONTROLLER:

 

public class UserData {
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results=new List<User>();

public User user;
String Regionid;
String Region;
  public UserData(ApexPages.StandardController controller)
   {
     this.user= (User)controller.getRecord();
   }
    
  public Pagereference doSearch()
     {
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c  =:User.Region__c];
     
      system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }

 

public List<User> getResults()
    {
        return results;
    }
     
     
   Public Pagereference UpdateManager()
   {
    for(User sluser: selectedusers)
    {
       

     //Update the all the selected users with the  manager id highlighted in the VF page.

 

    }
    return null;
   }
       
    
 }

 

 

 

 

I need to pass a selected picklist value to my controller class and based on that value, a query needs to be created. Then the resulting values have to be displayed in a table.

 

Please find my VF and Controller code and suggest.

 

Thankyou.

 

VF CODE:

 

<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
   Select Region of the user:
   <apex:selectList id="u" value="{!usr}" size="1" title="Users">
   <apex:selectOptions value="{!usrs}"></apex:selectOptions>
   </apex:selectList>
   <apex:pageBlockButtons >  
<apex:commandButton value="GO" action="{!doSearch}">            
    </apex:commandButton>
    </apex:pageBlockButtons>
    <apex:pageBlockTable value="{!Results}" var="names">
    </apex:pageBlockTable>
   <br></br>             
  
  </apex:pageblock>
  </apex:form>   
  </apex:page>

 

 

 

CONTROLLER:

 

public class UserData {
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results;
List<Id> userlist=new List<Id>();

   public UserData(ApexPages.StandardController controller)
   { 
    }
  
   public List<selectOption> getusrs()
  {
    List<selectOption> options = new List<selectOption>(); 
    options.add(new selectOption('', '- None -'));   
    FOR (User users : [SELECT Id,Region__c FROM User Order By Region__c Asc]) 
    {   
      options.add(new selectOption(users.Id, users.Region__c));
     }    
       return options; 
  } 
  
 
   public Pagereference doSearch()
     {

      //selected picklist value must be passed to this query.
       results = (List<User>)[select Name from User Where Id=:???????????];
       system.debug('USERSLISTFOR REGION$$$$'+results);
       return null;
     }
      
   public List<User> getResults()
    {
        return results;
    }
 
 }

I need to export a report as a CSV to an FTP site or email it on a daily or weekly basis.

 

I have a Report.  I need to get the report out of Salesforce somehow into CSV format.

 

Ideally, this would be scheduled.


I'm a developer so I can do developer stuff.  However, I don't know APEX and I don't know VisualForce.  I can get someone to do that stuff if we need to.


Thanks!

  • July 26, 2011
  • Like
  • 2

Hi,

 I want to pass the picklist values from visualforce page to the controller. I am using custom setting object.

The situation is that on the basis of the picklist value selected the depended picklist values need to be displayed. Both the picklists are the fields of the custom settings object. The rest of the logic is working fine when the selected picklist option is hardcoded. The only glitche is that data is not getting passed to the controller

The following is the line of code I am using for this:

 

System.debug('selectedMatCatValue..............'+selectedMatCatValue);
      selectedMatCatValue = system.currentPageReference().getParameters().get('selmatcatvalueref');
Please someone provide help in this case