0

enter image description hereHow to get the IbProduct.Commercial_Product_Name__c value on the controller class from Vf page.

acontroller class:

public with sharing class IBSearchController3 {
public IB_Product__c IbProduct{get;set;}

public IBSearchController3(ApexPages.StandardController controller) {
    this.IbProduct = (IB_Product__c)controller.getRecord();
}

public PageReference doSearch2() {
    oppId = ApexPages.currentPage().getParameters().get('id');

    Account acc =[ select id from account where id in (select Accountid from opportunity where id =:oppid)];    

    String cProd = '%' +IbProduct.Commercial_Product_Name__c+ '%';

    system.debug(cprod);

    return null;
}

vf page :

<apex:page standardController="Opportunity" extensions="IBSearchController3">
    <apex:form>
        <apex:outputField value="{!Opportunity.Accountid}"/>

        <apex:inputField label="Commercial Product Name" value="{!IbProduct.Commercial_Product_Name__c}"/>
        <apex:commandButton value="Search IB Asset" action="{!doSearch2}"/>
    </apex:form>
</apex:page>
1
  • What is the current behavior? What does that system.debug statement print?
    – metasync
    Commented Sep 24, 2017 at 18:16

1 Answer 1

5
 standardController="Opportunity"

this.IbProduct = (IB_Product__c)controller.getRecord();

The SObject type from the standard controller must match the type of variable you're trying to store the record in.

As near as I can tell, you'll need to change your constructor as follows:

Id oppId;
public IBSearchController3(ApexPages.StandardController controller) {
    this.IbProduct = new IB_Product__c();
    oppId = controller.getId();
}

You'll be able to do your search based on the user's input from there.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .