function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Padmini S 26Padmini S 26 

Passing Parameter in Apex Controller

I am not able to pass the parameter in Apex Controller. Below is the my Code.

public assigntechniciancontroller(ApexPages.StandardController controller) { 
    accID =  ApexPages.currentPage().getParameters().get('Id');
    skill =  ApexPages.currentPage().getParameters().get('Problem__c');
    system.debug ('@@@@@@@@@@@' +skill);
}

Problem__c is the picklist field on Standard WorkOrder Object. I am getting the null in Problem__c field. Kindly help me on this.

Thanks in Advance.
Best Answer chosen by Padmini S 26
JethaJetha
Please provide workorder id in your page URL after pageName in the form of ?id=[workorder 15/18 digit Id]
 
public class assigntechniciancontroller 
{
	public List<User> uList{get;set;}
    public assigntechniciancontroller(ApexPages.StandardController controller) 
	{
      WorkOrder wc = [SELECT Problem__c FROM WorkOrder WHERE ID =: controller.getId()];
	  
	  uList = [select Name, Skill__C from User WHERE Skill__c =: wc.Problem__c];
	}
}

Please replace your controller with mine and try again and let me know if you face any issue.

All Answers

JethaJetha
Could you please paste your visualforce page content as well. because that would help us, how you are passing parameters.
Padmini S 26Padmini S 26
Thank you for reply. Actually I want to develop visualforce page to display the all Users which User Object Skill__c field value should match with WorkOrder Object Problem__c field value.

VisualForce Page:
=========
<apex:page standardcontroller="WorkOrder" extensions="assigntechniciancontroller" sidebar="false">
    <apex:form >
        <apex:pageBlock > 
          <apex:pageblockTable value="{!uList}" var="cl">
              <apex:column headervalue="Set as Primary">                    
                              <apex:outputPanel id="counter2">
                               <input type="radio" name="sel"  />
                                   <apex:actionsupport action="{!process}" event="onchange" rerender="abc">
                                 <apex:param name="select"  value="{!cl.id}"  assignTo="{!str}"/>
                                   </apex:actionsupport>
                               </apex:outputPanel>
              </apex:column>  
              <apex:column value="{!cl.Name}"/>
                 <apex:column value="{!cl.Skill__c}"/>
    </apex:pageblockTable>
  </apex:pageBlock>
        <apex:commandButton value="Save" action="{!SaveOwner}" disabled="{!flag}" id="abc"/>
    </apex:form>
</apex:page>

Apex Controller:
=========

public class assigntechniciancontroller {

        Private Id accID;
       Public String skill;
      Public string str {get;set;}
     Public Boolean flag {get;set;}
   public List<User> uList{get;set;}
    public assigntechniciancontroller(ApexPages.StandardController controller) {
      accID =  ApexPages.currentPage().getParameters().get('Id');
    skill =  ApexPages.currentPage().getParameters().get('Problem__c');
    system.debug ('@@@@@@@@@@@' +skill);
     if (skill != null)
 
    {
     uList = [select Name, Skill__C from User ];
     
     }
 }

I am not getting skill value in debug. Kinldy help me on this issue.
JethaJetha
Please provide workorder id in your page URL after pageName in the form of ?id=[workorder 15/18 digit Id]
 
public class assigntechniciancontroller 
{
	public List<User> uList{get;set;}
    public assigntechniciancontroller(ApexPages.StandardController controller) 
	{
      WorkOrder wc = [SELECT Problem__c FROM WorkOrder WHERE ID =: controller.getId()];
	  
	  uList = [select Name, Skill__C from User WHERE Skill__c =: wc.Problem__c];
	}
}

Please replace your controller with mine and try again and let me know if you face any issue.
This was selected as the best answer
Padmini S 26Padmini S 26
Thank you Jetha. It is working fine now.
JethaJetha
Nice to see from you that it is working now :) Great