Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a Finder method defined on an External Content type (created with Visual Studio). Whan That method receives a parameter. So the method is something like ReadList(string partnerName). I have FilterDescriptor associated with this parameter so the parameter gets populated when I use Entity Picker dialog.

But When I use CAML Query to get items (using SharePoint Client Object Model) I can't get to call the ReadList method with a parameter. An example of my CAML Query is

<View>
    <Method Name='ReadList'/>
    <Query>
        <Where>
            <Contains>
                    <FieldRef Name='Name'/>
                    <Value Type='Text'>{0}</Value>
            </Contains>
        </Where>
    </Query>
    <ViewFields>
    <FieldRef Name='Name'/>
    <FieldRef Name='Id'/>
    <FieldRef Name='BdcIdentity'/>                        
    </ViewFields>
</View>

Setting breakpoint on my BCS assembly I see that indeed ReadList method is called, but parameter is empty. Is it possible to pass the parameter to the method as well?

share|improve this question
    
I have a question on above post. that is, in the filter you specified the values as {0} <Value Type='Text'>{0}</Value> So here how we can send a dynamic value in the place of {0} My requirement is to filter the data based on query string value Please answer my question, thanks in advance. –  user7719 Apr 5 '12 at 7:31
    
Hey, @Vasu. It's quite simple. If you're doing this in C# and you have a page, then you can do it very simple. You just put the query above in the String.Format. An example would be String.Format(@"<View><Method Name=...", Request.QueryString["PartnerName"]);. If you're doing it in JavaScript, you need to make a function for querystring (you can find one on my blog (search for qs). Next you put the CAML query in a variable (for example var query = "<View><Method Name=...";' and next you do a query = query.replace(/\{0\}/g, qs("partner"));` –  Gomiunik Apr 7 '12 at 18:34

1 Answer 1

up vote 6 down vote accepted

Got it!

<View>
    <Method Name='ReadList'>
        <Filter Name='PartnerName' Value='{0}'/>
    </Method>
    <Query>
        <Where>
            <Contains>
                    <FieldRef Name='Name'/>
                    <Value Type='Text'>{0}</Value>
            </Contains>
        </Where>
    </Query>
    <ViewFields>
    <FieldRef Name='Name'/>
    <FieldRef Name='Id'/>
    <FieldRef Name='BdcIdentity'/>                        
    </ViewFields>
</View>

Be sure to replace the filter Name attribute value with your own FilterDescriptor name as defined in BCS model and Value attribute with your own value.

share|improve this answer
    
Brilliant stuff, this is exactly what I've been looking for all day! –  Infotekka Aug 11 '12 at 0:16
    
Hi, can you explain me what filter type did you use? –  Fobos Apr 19 '13 at 15:06
1  
I've used FilterDescriptor of type Comparison –  Gomiunik Apr 22 '13 at 10:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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