public void geterp(string nicpn){
        // local variables
            String Accountcode; 
            Quote__c quoteWithAccountCode;
            Quote__c  langaugetranslation;
            string PartNic;
            string PartDescription ;
            string PartStock;
            string PartDescriptionUK;
            string PartClientPNREF;
            //Capturing Quote id

                    getRes1.GetInfoResult= soap.GetInfo(nicpn,'6f50456b91ef8ec5123e9c9600380ed5');
                }catch(Exception e){ 
            String XMLString;
                 XMLString = getRes1.GetInfoResult;
          //Getting the values from xml String
              Dom.Document doc = new Dom.Document();
                dom.XmlNode node=doc.getRootElement();
                //Condition to check the responce without error 
                if(node.getChildElements()[0].getName() != 'ERROR'){
                    PartDescription=  node.getChildElement('DESCRIPTION',null).getText();
                    PartStock= node.getChildElement('STOCK',null).getText();
                    //Iterating the child elements
                     for(dom.XmlNode child:node.getChildElements()){
                        if(child.getName() =='CLIENTPNS'){
                        //iterating the grand child elements
                            for(dom.XmlNode gchild:child.getChildElements()){
                                if(gchild .getName() == 'CLIENTPN'){
                                    //Iterating the grand grand child elements
                                    for(dom.XmlNode ggchild:gchild.getChildElements()){
                                        if(ggchild .getName() == 'CLIENTPNREF'){
                                    }//End of for loop
                                }//End of if
                            }//End of for loop
                        }//End of if
                    }//End of for loop
                 }//End of if condition
             }//End of if
        }//End of method

    public quoteController(){
             Quote_line_item__c acc= new Quote_line_item__c();

Visualforce page :

<apex:column headerValue="Nic P/N"><apex:inputField value="{!a.Name}" id="Name" style="width:110px"  StyleClass="AutoPin"  /><br/>
        <apex:commandlink Value="Fetch details" action="{!geterp}" rerender="wtable">
                       <apex:param assignTo="{!nicpn}" value="{!a.Name}" Name="parentname777"/>

I am passing the input value nicpn to get the details from ERP. I am retrieving partclient, partdescription and partstock.

I want to pass the values to the controller. How can I pass the values to controller.

I want to equate nicpn to acc.Name and I want to equate the value related value to related field


quoteController Compile Error: Initial term of field expression must be a concrete SObject: void


geterp doesn't return a value, so you can't geterp(acc.Name).PartDescription. You can't just arbitrarily refer to any local function variable from outside that function. Most likely, you'll probably want to return a class that encapsulates all this data, or, if that's the only parameter you need, just return that one value. For example, you might do this:

public class LookupResult {
    public String PartNic, PartDescription, ...;
public LookupResult geterp(String nicpn) {
    LookupResult result = new LookupResult();
    // process xml here, assign values to result variable, omitted for brevity
    return result;

However, this will also affect this function's ability to be an action method, because action methods must return nothing (void) or a reference to a new page (ApexPages.PageReference). It's not a big deal, as you'll just have to move that logic to a different function.

Depending on exactly what you want to do, you'll probably want to make a LookupResult class member you can refer to, or a list thereof if you want to be able to show multiple results.

  • 4 split seconds :) – Boris Bachovski Jul 3 '15 at 11:21
  • 3
    Great minds think alike. We can't help it. – sfdcfox Jul 3 '15 at 11:23

Your geterp method is void which means it doesn't return anything, but you're trying to reference variables inside the method.

Easiest way would be to create a wrapper class for all your required fields that you want to return to the caller method. So modify your geterp method and change it's return type, as well as create a wrapper class:

public class ERPResult
    public String PartClientPNREF;
    public String PartDescription;
    public String Partstock;
    // any other fields that you need to reference later

public ERPResult geterp(string nicpn)
    // your exising code here

    // add this at the bottom
    ERPResult result = new ERPResult ();
    result.PartClientPNREF = PartClientPNREF;
    result.PartDescription = PartDescription;
    result.Partstock = Partstock;

    return result;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.