InfoPath: Filter SharePoint List with condition

Connection to return SharePoint List in XML

http://servername/eform/_vti_bin/owssvr.dll?cmd=Display&List={5D9A6878-D6EE-4B00-AF03-95F6A2361777}}&XMLDATA=TRUE

Code Behind of InfoPath

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

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);
    q.Execute();
}

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;
}

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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