Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2006

Tip: Looking for answers? Try searching our database.

Multi-Picklist from SharePoint List

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robot smiff - 01 Mar 2006 15:44 GMT
Scott Heim has posted here
(http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.infopath&m
id=6e360b1b-55ff-4c50-9cb3-9cd954359fa4&sloc=en-us
)
a working solution to create a multipicker from a list sourced in an access
database.

I'm trying to get it sourced from a SharePoint list.

Do I just need to change his references to "Table1" to "MyList"?

The SharePoint Boolean is "Yes\No"  So I suppose I need to search for values
of "yes" instead of "Tue"

I think I'm having trouble with this line:

objTable1DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:Table1[@Selected =
'True']");

Especially the "d:table1"

Should it read: ../d:MyList[@Selected = 'Yes']");

Thanks!
JK
robot smiff - 01 Mar 2006 16:41 GMT
I think the problem is in the .selectionnamespace object.

The Access solution reads like this:

//Set the SelectionNamespaces property of the Table1 data connection to walk
the DOM

objTable1DOM.setProperty("SelectionNamespaces",       
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' +
'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');

I think the "xmlns:d.."   value needs to be something else.

Anybody can help!

Thanks!

-robot

> Scott Heim has posted here
> (http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.infopath&m
id=6e360b1b-55ff-4c50-9cb3-9cd954359fa4&sloc=en-us
)
[quoted text clipped - 19 lines]
> Thanks!
> JK
S.Y.M. Wong-A-Ton - 02 Mar 2006 12:27 GMT
You might be right on both occasions as to where your problem lies. Try
adding some debugging code to your code to find out what is going on. For
example, add

XDocument.UI.Alert(XDocument.GetDOM("<your_sharepoint_list>").xml);

to your code. This should contain enough information on namespaces and the
"yes/no" issue to solve your problem. If you are still unable to solve it and
the XML is not too long, post the XML.
---
S.Y.M. Wong-A-Ton

> I think the problem is in the .selectionnamespace object.
>
[quoted text clipped - 38 lines]
> > Thanks!
> > JK
robot smiff - 02 Mar 2006 15:27 GMT
I got this to work using thes code below for the buton.

Apparently, the SharePoint data is accessed in the same name space as the
InfoPath data, i.e. ../infopath/2003/dataFormSolution or "xhtml:dfs"

I still need to do two things.

One, I need to blank the target table before I start writing values to it.  
As it is now, everytime I click, the selected values are appended to what
could be a partially filled out list.

Two, I need to be able to filter the SharePoint source.  Our Software
profiles support life cycle and I only want titles with the "current" value
equal to true.

Thanks for helping!

here's the code.

function CTRL14_5::OnClick(eventObj)
{

//Get a reference to the Table1 data connection
var objTable1DOM = XDocument.GetDOM("SoftwareProfiles");

   
//Set the SelectionNamespaces property of the Table1 data connection to walk
the DOM
objTable1DOM.setProperty("SelectionNamespaces",    
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' +
'xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
     
//Get the selected items
var objSelectedItems =
objTable1DOM.selectNodes("//dfs:myFields/dfs:dataFields/dfs:SoftwareProfiles[@Selected = 'true']");
     
//Loop through the selected items
    for(i=0;i<=objSelectedItems.length -1;i++)
{
//See if the first record in the destination Repeating Table is blank
if(XDocument.DOM.selectSingleNode("//my:group12/my:group13/my:field46").text
== "")
{XDocument.DOM.selectSingleNode("//my:group12/my:group13/my:field46").text =
objSelectedItems(i).attributes(0).text;
}
else
{
//Add a new row   
XDocument.View.ExecuteAction("xCollection::insert", "group13_20");
//Get a reference to that new row
var objNewItem =
XDocument.DOM.selectSingleNode("//my:group12/my:group13[last()]/my:field46");
//Set the text of the field
objNewItem.text = objSelectedItems(i).attributes(0).text;
}
}
}

> You might be right on both occasions as to where your problem lies. Try
> adding some debugging code to your code to find out what is going on. For
[quoted text clipped - 50 lines]
> > > Thanks!
> > > JK
S.Y.M. Wong-A-Ton - 02 Mar 2006 15:27 GMT
1. Loop through all the child nodes under the group and use removeChild to
remove the node from the documentElement (see
http://www.topxml.com/xml_dom/removechild.asp#P4568_107927)

2. When adding the items to the group (after having cleared all nodes from
the group), add a check that says only add the node to the group if "current"
is true.

---
S.Y.M. Wong-A-Ton

> I got this to work using thes code below for the buton.
>
[quoted text clipped - 108 lines]
> > > > Thanks!
> > > > JK
robot smiff - 02 Mar 2006 15:29 GMT
hey!  That's great!  Thanks for the help.

I may have not been clear.  I need to filter the "Source" list.  My list of
software profiles in SharePoint include some that are current and some that
are not.  I only want the current ones in my source list, the one with the
check boxes.

Thanks again!
JK

> 1. Loop through all the child nodes under the group and use removeChild to
> remove the node from the documentElement (see
[quoted text clipped - 119 lines]
> > > > > Thanks!
> > > > > JK
S.Y.M. Wong-A-Ton - 02 Mar 2006 21:11 GMT
I'm not sure that I get you. How can you recognize whether a software profile
is current or not? Are you saving an indicator field on the software profile?
And do you want to filter in SharePoint or in InfoPath?
---
S.Y.M. Wong-A-Ton

> hey!  That's great!  Thanks for the help.
>
[quoted text clipped - 129 lines]
> > > > > > Thanks!
> > > > > > JK
robot smiff - 02 Mar 2006 21:28 GMT
Thanks for the help...

First, the "current" attribute is set in SharePoint in a list called
SoftwareProfiles using a SharePoint checkbox.

When my InfoPath form opens, it gathers the items in the list into a
repeating table.  I need it only to gather the items where Current is
checked.  I don't want my users to be able to pick a software title that's
not current.

Second, I'm not quite getting the loop through code to delete all the nodes.
I get the code from your source that goes:

Set objXMLDOMElement = objDOMDocument.documentElement.firstChild

Set objRemovedElement =
objDOMDocument.documentElement.removeChild(objXMLDOMElement)

But I'm having trouble objDOMDocument.  This repeating table is in my form's
main data source.  I'm not sure how to get all the nodes in the group to loop
through and delete them.

Thanks again!
JK

> I'm not sure that I get you. How can you recognize whether a software profile
> is current or not? Are you saving an indicator field on the software profile?
[quoted text clipped - 135 lines]
> > > > > > > Thanks!
> > > > > > > JK
S.Y.M. Wong-A-Ton - 02 Mar 2006 22:00 GMT
Since the repeating table is in your Main data source, you can use the
"Filter Data..." option on the properties dialog box for the repeating table
to filter on "current".

You cannot use the code posted on www.topxml.com without modifying it to
suit your needs. "objDOMDocument" would be equivalent to the repeating group
node in your case (dfs:SoftwareProfiles I'm guessing). You need to build a
while loop checking whether hasChildNodes() on the group returns true. If it
does, retrieve the firstChild node on the group and then remove it from the
group. For information on the "while" statement in JScript, check out the
JScript reference at http://www.micrsoft.com/scripting

You could also use ExecuteAction with a "remove" action to delete a row in
the repeating table in pretty much the same way you used ExecuteAction to
"insert" a row.

---
S.Y.M. Wong-A-Ton

> Thanks for the help...
>
[quoted text clipped - 160 lines]
> > > > > > > > Thanks!
> > > > > > > > JK
S.Y.M. Wong-A-Ton - 02 Mar 2006 22:13 GMT
Additional info: You can use XDocument.View.SelectNodes (see
http://blogs.msdn.com/infopath/archive/2004/04/07/109189.aspx) to select all
the nodes in the repeating table, and then call ExecuteAction with a "remove"
to delete all the rows.
---
S.Y.M. Wong-A-Ton

> Thanks for the help...
>
[quoted text clipped - 160 lines]
> > > > > > > > Thanks!
> > > > > > > > JK
_bizon - 23 Mar 2006 22:54 GMT
InfoPath gets only what SharePoint list has in its' default view...
So the simplest approach is to create in WSS a view called current, make it
default  and filter it there (careful with the item limit - you'll get just
the first 100 if this is the setting in the SharePoint view)...

Signature

Liviu

> Thanks for the help...
>
[quoted text clipped - 160 lines]
> > > > > > > > Thanks!
> > > > > > > > JK
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.