1

Visualforce Page:

<apex:page showHeader="false" sidebar="False" controller="textInputsCon">
    <apex:form >
      Input Text1 <apex:inputText value="{!inputText1}"/><br/>   
      <apex:selectList id="inputText3" value="{!inputText3}" size="1">
            <apex:selectOption itemValue="Quote_number_new__c" itemLabel="Quote Number"/>
            <apex:selectOption itemValue="From1__c" itemLabel="from"/>
             <apex:selectOption itemValue="Null" itemLabel="None"/>
        </apex:selectList> <br/>
            Input Text2 <apex:inputText value="{!inputText2}"/><br/>
      <apex:selectList id="inputText4" value="{!inputText4}" size="1">
            <apex:selectOption itemValue="Quote_number_new__c" itemLabel="Quote Number"/>
                 <apex:selectOption itemValue="From1__c" itemLabel="from"/>
            <apex:selectOption itemValue="From1__c" itemLabel="None"/>
        </apex:selectList>        
      <apex:selectList id="operator" value="{!operator}" size="1"><br/>
            <apex:selectOption itemValue="=" itemLabel="Equal"/>
            <apex:selectOption itemValue="!=" itemLabel="Not equal to"/>
            <apex:selectOption itemValue="<=" itemLabel="Less than"/>
        </apex:selectList> 
        <apex:commandButton value="list" action="{!showlist}"/>
         <apex:pageBlock >
            <apex:pageBlockTable value="{!quo}" var="q">
                <apex:column value="{!q.Quote_Number_New__c}"/>
                 <apex:column value="{!q.From1__c}"/>
            </apex:pageBlockTable>               
        </apex:pageBlock>
    </apex:form>
    </apex:page>

Controller:

    public with sharing class textInputsCon {
 public String inputText1{get;set;} // input text1 value  from vf
 public String inputText2{get;set;} // input text2 value  from vf  
  public String inputText3{get;set;} // input text1 value  from vf
 public String inputText4{get;set;}
 Public string operator{get;set;}
 public list<Quote__c> quo{get;set;}       //this is will hold data to be displayed on page 
// string query1='select id from  Quote_line_item__c  ';
 string query='select id,from1__c,Quote_number_new__c,(select id from  Quote_line_item__r) from  quote__c ';
 public void showlist(){ //do not return anything
     if(inputText1<>''){
     query += 'WHERE ' + inputText3 + ' ' + operator + ' : inputText1' ;  } 
      if(inputText2<>''){
     query +=' and  '+ inputText4 + ' ' + operator + ' : inputText2';    }   
     quo = database.query(query);

}
}

Error:

System.QueryException: Didn't understand relationship 'Quote_line_item_r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '_r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

string query='select id,from1__c,Quote_number_new__c,(select id from  Quote_line_item__r) from  quote__c ';
  • What's the Relationship Name if you look at the detail object? Is it Quote_Line_Items? – bigassforce Feb 6 '14 at 6:10
  • Quote_line_item__c is child object of Quote__c – Teja Feb 6 '14 at 6:13
  • change Quote_line_item__r to Quote_line_item__c...cause u r not putting any where clause....see my query (select id,name,(select id from contacts) from account) – Sunny Feb 6 '14 at 6:33
  • check the same with custom object then you can see the __r – Teja Feb 6 '14 at 6:34
  • 1
    To get name of a relationship got to Force.com IDE and open schema. Open Quote object and in nested folder named Child Relationships check Quote Line Item object. Use SOQL in Query Result area as starting point of building your SOQL for VF page. I assume you should use Quote_line_items__r instead of Quote_line_item__r (letter 's' is missing after word 'item'). I figured it out by myself not so long time ago. – Andrii Muzychuk Feb 6 '14 at 9:30
1

Ok lets try to solve this :)

First of all: as I understand there should be 3 SObjects in 1 table? As so we need to know what fields you want to use(from each object)? In that case you have to create wrapper class to unified those objects. Also in that case you will have to use more queries.

Please provide me with info about my questions :)

Advice :

Change this :

<apex:selectList id="operator" value="{!operator}" size="1"><br/>
        <apex:selectOption itemValue="=" itemLabel="Equal"/>
        <apex:selectOption itemValue="!=" itemLabel="Not equal to"/>
        <apex:selectOption itemValue="<=" itemLabel="Less than"/>
    </apex:selectList> 

It is better to use list of option in your controller.

Page:

<apex:selectList value="{!SomeObejet.somePicklist}" label="somePicklist" size="1">
    <apex:selectOptions value="{!someOptions}"/>
</apex:selectList>

Controller:

public SelectOption[] getSomeOptions() {
    SelectOption[] options = new SelectOption[] {};

    options.add(new SelectOption('', '--None--'));
    options.add(new SelectOption(String Value, String displied text);
    /** Other options **/
    return options;
}

http://wiki.developerforce.com/page/Wrapper_Class

Wrapper class is just way to convert one type object in other type that contains some orginal values. I think you should create something like that

class Wrapper{
    /** here declare some fields you want show in wrapper **/
    public Wrapper(/**  as input values get this object you wanted use**/){
        /** here assign input object fields to wrapper class values **/
    }      
}

You will need 3 constructors - one for each object.

  • For Quote_line_item__c fields client__c – Teja Feb 6 '14 at 8:18
  • I dont get you .what u r saying with that select option – Teja Feb 6 '14 at 8:26
  • i got it .but this operator value also i am taking from user input – Teja Feb 6 '14 at 8:45
  • Can you answer my questions? Can you create wrapper class by yourself? Do you have any other questions? This method will return values from controller to the page, where user can set it – Artur Kępczyński Feb 6 '14 at 8:47
  • still now i haven't used any where .but i will try .it would be better that you can send me a small piece of code – Teja Feb 6 '14 at 8:50
0

To show related list with custom controller , you can use below method :

<apex:page controller="RelatedListWithCustomController">
    <apex:detail relatedList="false"/>
    <apex:relatedList subject="{!account}" list="Contacts"/>

</apex:page>

public class RelatedListWithCustomController {
    public Account account{get;set;}

    public RelatedListWithCustomController () {
        account = [Select id from Account where id =: ApexPages.CurrentPage().getParameters().get('id')];
    }

}

Regarding the exception, it seems that you are using a wrong relationship name. I think it would be "Quote_line_items__r"

  • it is quote_line_item__c only api name.Do you see my program in the above it doesn't suit my requirement. – Teja Feb 6 '14 at 6:39
0

Easiest way to figure out what the relationship is:

Go into Eclipse -> Open up your schema -> Find the parent object and expand it -> Expand child relationships -> select a single field in that child relationship -> Look at the relationship name in The query results:

(browser)

browser

(query result)

query 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.