InfoPath: Filter SharePoint List with condition

Connection to return SharePoint List in XML


Code Behind of InfoPath

public void FormEvents_Loading(object sender, LoadingEventArgs e)
    // Write your code here.

private void SetCompaniesOptions()

    FileQueryConnection q = (FileQueryConnection)this.DataConnections["XML SharePoint Company List"];
    q.FileLocation = q.FileLocation + "&FilterField1=Tag&FilterValue1=" +GetFilterValue();
    //XPathNavigator mainNav = this.CreateNavigator();
    //mainNav.SelectSingleNode("//my:PaymentRequest/my:Requestor/my:Company", NamespaceManager).SetValue(q.FileLocation);

private string GetFilterValue()
    XPathNavigator nav = this.CreateNavigator();
    string filterValue = (string)nav.SelectSingleNode("/my:PaymentRequest/my:Configuration/my:CompanyOption", this.NamespaceManager).ValueAs(typeof(string));
    return filterValue;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s