+ Start a Discussion
Abhishek Singh 88Abhishek Singh 88 

populate some field on visualforce page after clicking on command link button

Hi Developers.
i have a custom button link called "new incident" after clicking on link i am redirected to another vf page.the screen shot is belowUser-added image
After clicking on new incident i am redirectin to below page:
User-added image
I want to populate client id field with current user,and bussiness unit as PHS:
Plz help me out.
thanks in advance.
Magesh Mani YadavMagesh Mani Yadav
Hi Abhishek,

In your VF Controller constructor add below lines
API name of ClientID = UserInfo.getUserId();
API name of BussinessUnit = 'PHS';
Abhishek Singh 88Abhishek Singh 88
Hi Magesh:
Thanks for your reply.But how it will populate that paticular page,if i update it in constructor.
Magesh Mani YadavMagesh Mani Yadav
Can you provide me the code of that VF controller?
swati_sehrawatswati_sehrawat
Hello Abhishek,

When you will do something like this below inside your constructor:

objectName__c.ClientIDfieldName__c = UserInfo.getUserId();
objectName__c.BussinessUnitfieldName__c = 'PHS';

When page is loaded, constructor is the first thing that gets invoke so it will automatically take values for these two fields from the constructor and would pe populated in the page.

 
Abhishek Singh 88Abhishek Singh 88
thanks swati.
i will check it.it looks perfect.
Abhishek Singh 88Abhishek Singh 88
Hi Swati,
i am facing this error.
 Expression cannot be assigned at line -1 column -1
<apex:page controller="HSDSearchController_Malla">

 
swati_sehrawatswati_sehrawat
Can you share your complete code of page and class.
Abhishek Singh 88Abhishek Singh 88
page
public with sharing class HSDSearchController_Malla 
 {
     
     
            public HSDSearchController_Malla()
                 {
                     contactBlock = false;
                      siteLst=new List<Site__c>();
                      custLst=new List<Account>();
                      clientLst=new List<Client__c>();
                      showcontacts=false;
                      BMCServiceDesk__Incident__c.BMCServiceDesk__clientId__c=UserInfo.getUserId();
                      BMCServiceDesk__Incident__c.Business_Unit__c='PHS';
                      }
 
                   
                       public PageReference newIncidentLink()
                           {     
                                 
                              
                               PageReference pageRef = new PageReference('/apex/BMCServiceDesk__RemedyforceConsole?record_id=&objectName=Incident__c');
         
                                pageRef.setRedirect(true);
                                return pageRef;
                       }

Page:
<apex:page controller="HSDSearchController_Malla">
 
   
          <!-------------------incidents records of customer------------>
          <apex:pageBlock title="Incidents" rendered="{!showIncidents}">
             <apex:commandlink action="{!newIncidentLink}" target="_balank" >
          <apex:commandButton value="New Incident" id="newIncident"/><br />
           </apex:commandlink>
              <div style="overflow: scroll;height: 200px;">
                  <apex:pageBlockTable value="{!accincidentLst}" var="acinci">
                  <apex:column >
                  <apex:pageblockTable value="{!acinci.Incidents__r}" var="inci">
                   <apex:column headerValue="Incident #">
            <apex:outputLink value="https://bmcservicedesk.cs15.visual.force.com/apex/BMCServiceDesk__RemedyforceConsole?record_id={!inci.id}&objectName=Incident__c" target="_blank">{!inci.Name}</apex:outputLink>
                   </apex:column>
                    <apex:column headerValue="Name">                    
                     <apex:outputField value="{!inci.Name}"/>
                 </apex:column> 
                  <apex:column headerValue="ShortDescription">                    
                     <apex:outputField value="{!inci.BMCServiceDesk__shortDescription__c}"/>
                 </apex:column> 
                   <apex:column headerValue="Phs Category">                    
                     <apex:outputField value="{!inci.PHS_Category__c}"/>
                 </apex:column> 
                <apex:column headerValue="Phs SubCategory">                    
                     <apex:outputField value="{!inci.PHS_Sub_Category__c}"/>
                 </apex:column>
                <apex:column headerValue="Status">                    
                     <apex:outputField value="{!inci.BMCServiceDesk__FKStatus__c}"/>
                 </apex:column>
                  </apex:pageblockTable>
                  </apex:column>
                  </apex:pageBlockTable>
                 </div>
          </apex:pageBlock>
      
 </apex:form>
</apex:page>

 
Abhishek Singh 88Abhishek Singh 88
Some part i have erased
swati_sehrawatswati_sehrawat
Am sorry but I can't see anywhere you are using client ID or bussiness unit field in the code that you have shared.