• Qui Tran
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I have created a dynamic soql in controller but while using it with IN operator its not showing the query properly....
<apex:page controller="dynamicsoql">
    <apex:form>
        <apex:pageBlock >
            <apex:pageBlockSection id="pbs">
                <apex:outputText>{!idinlist}</apex:outputText>
                <apex:inputTextarea value="{!query}" />
            </apex:pageBlockSection>
            <apex:commandButton action="{!showid}" value="showid" reRender="pbs"/>
            <apex:commandButton action="{!showquery}" value="showquery" reRender="pbs"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
.........................................................................
public class dynamicsoql {
    public list<j__c> recordid { get; set; }
    public string singleid{get;set;}
    public list<string> idinlist{get;set;}
    public string query {get;set;}
    public dynamicsoql()
    {
     recordid=[select id from j__c];
     idinlist=new list<string>();
    }
    public void showid()
    {
        for(j__c j: recordid)
        {
            singleid='\''+string.valueOf(j.id)+'\'';
            idinlist.add(singleid);
        }
    }
    public void showquery()
    {
        query ='select name from j__c where id in '+  idinlist ;
    }
}

In my controller their is a dynamic soql query----

(((((((((((query ='select name from j__c where id in '+  idinlist ;))))))))))))))))

in this query ""idinlist"" is a list of id's. If in the list their are only 10 id then its fine and the query is printed in the vf page in this form
select name from j__c where id in ('a019000000FRJDkAAP', 'a019000000FRJDzAAP', 'a019000000FRJEdAAP', 'a019000000FRJEeAAP', 'a019000000FRJFCAA5', 'a019000000FRJFDAA5', 'a019000000FRJFEAA5', 'a019000000FRJFFAA5', 'a019000000FRJFlAAP', 'a019000000FRJGSAA5')

but if  ""idinlist"" has more then 10 id's then its query is printed in this form

select name from j__c where id in ('a019000000FRJDkAAP', 'a019000000FRJDzAAP', 'a019000000FRJEdAAP', 'a019000000FRJEeAAP', 'a019000000FRJFCAA5', 'a019000000FRJFDAA5', 'a019000000FRJFEAA5', 'a019000000FRJFFAA5', 'a019000000FRJFlAAP', 'a019000000FRJGSAA5',...)

means after 10th id it's just showing '''...''' and no id. i had printed the query in vf page system debug every where it's the same.
and because of that my query is not working. Please help.