Solved

VB Code For InfoPath Form

Posted on 2011-03-03
21
1,326 Views
Last Modified: 2013-12-26
Hello, I am an intern looking for a way to have a Infopath form hosted on a Sharepoint site manage who is allowed to see completed forms. The forms will be stored in a location with more secure permissions than the template. But I need a way for the individual who filled out the form to see his completed form in the event he/she needed to update it.

I am currently trying to use code in Infopath to find the current user and load said information from the site into the form. The whole idea behind this is to store information that is only visible, from user side, by the user who entered it to protect any sensitive data.

I'm not 100% positive on the code to find current user, and if I did would it be possible to use that variable field as a trigger for rules in the form.
0
Comment
Question by:AnthonyKRo
  • 11
  • 10
21 Comments
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Hi, how I do this is I create a view in the sharepoint form library called "My Forms" or something like that.  Make it the default view.  Apply a filter of   "where created by is equal to [Me]".  Now for your other view with all of the forms you can click site actions > edit page > modify shared web part  and apply audience targeting to restrict this view to a specific group.
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Oh also, on the part of how you want to store user information in the form you can use sharepoint's userprofileservice as a secondary data connection to get this information.  See this link here:

http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

(no code required)
0
 

Author Comment

by:AnthonyKRo
Comment Utility
Thank you,

I seem to be having a little trouble setting up the connection though, after entering the "http://ServerName/_vti_bin/UserProfileService.asmx" instead of continuing  to the next steps I recieve an error stating,
"InfoPath cannot find or cannot access the specified web service description."
Upon expanding the details,
"The site is not a valid XML file.
Not enough storage is available to process this command."
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Ohhh, In your add data connection I think you selected XML file.... select "WebService" instead, then click next and enter the url
0
 

Author Comment

by:AnthonyKRo
Comment Utility
Using InfoPath 2010, after choosing to add a connection I am given choices between:

SOAP Web service
SharePoint library or list
Database(MS SQL Server only)
XML Document

I chose the web service and entered the  "http://ServerName/_vti_bin/UserProfileService.asmx" but still recieved error.
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Interesting - I have seen this error where your webservice is running using the incorrect asp.net version.  You can check this by going to the server that hosts your sharepoint site > start > run > inetmgr > Expand websites, find your sharepoint site, then you should see the _vti_bin. Right click it and go to properties.  You can change the asp.net version in there to 2.0
0
 

Author Comment

by:AnthonyKRo
Comment Utility
I figured out what was wrong with the data connection, I believe due to the fact that the SharePoint site being used is a secure intranet site it was stopping the regular http. After changing it to "https://ServerName/_vti_bin/UserProfileService.asmx" it allowed me to setup the connection.

I set up a read only text box to display current user that I'm planning to use to set up rules to load any data for the form already stored in the database. Unfortunately after I setup the text box properties, according to the article you pointed me to, I received an error on preview.

"The SOAP response indicates that an error occurred on the server:

The User Profile Manager object could not be loaded. ---> Value cannot be null.
Parameter name: serverContext"

Could this be from running a preview out of InfoPath instead of uploading it to the site first?

0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
I haven't seen this error before so I researched it.  Looks like you need to modify your Alternate Access Mappings in Central Admin (which makes complete sense to me).  

I gathered that from this post here:  http://www.codebureau.com/blog/2010/02/18/RetrievingUserInformationInInfoPathWithoutCodeOneSolutionToValueCannotBeNullParameterNameServerContext.aspx

Here's the Microsoft link on applying your Alternate Access Mappings:  http://technet.microsoft.com/en-us/library/cc263208(office.12).aspx
0
 

Author Comment

by:AnthonyKRo
Comment Utility
What would the fqdn of the https://servername/_vti_bin/UserProfileService.asmx be

not sure where to find this
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
That would be your https://  url for your site.  Most of the time they are something like this:

https://server.domain.com

(configure that url in the AAM)
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:AnthonyKRo
Comment Utility
Just clarifying we should be using the same server name as in the data connection.

So
https://sameserverasdataconnection.domainofhostsite.com
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Yes, it should be that same server name
0
 

Author Comment

by:AnthonyKRo
Comment Utility
We added an internal url with the context: https://servername.domain.com , to the intranet zone seeing how it is an intranet site and are still recieving the error.

The form is uploaded but has not been approved to allow it to open in the browser could this be causing a problem. Or is there something else we need to do with the internal url.
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
That's possible - if it's not approved or doesn't have the appropriate trust level it will block out certain data connections
0
 

Author Comment

by:AnthonyKRo
Comment Utility
Hello, the guy who normally handles form approval and activation is out of town. We've managed to figure out how to get the form approved and uploaded but can't seem to get it to appear in the sight. Checking site collection features its reported as activated but is not appearing on the site.
0
 
LVL 15

Accepted Solution

by:
melli111 earned 500 total points
Comment Utility
Hi, It should be activated as a "content type".  Go to the library you want the form to be on > settings > form library settings > advanced settings.  Select to allow management of content types and click "ok".  Now under the settings options you'll see a content type section.  Add a new content type > find the name of your form in the available content type list and add it to your library & click ok.  Then you can manage the new button default within this same section to remove the original "form" content type so that when your users click "new" it will open this newly published form.
0
 

Author Comment

by:AnthonyKRo
Comment Utility
Managed to fiugre out how to get the form to the right spot but upon moving it, it shows up as a word doc
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Something is definitely not right there ----- how did you manage to get the form to the right spot (what were your steps)?
0
 

Author Comment

by:AnthonyKRo
Comment Utility
Was trying t ocopy the template into the site we wanted it to appear in, followed your instructions and got it to appear correctly. Thank You
0
 

Author Closing Comment

by:AnthonyKRo
Comment Utility
Thank You for sticking with this post for so long. If I ever need infopath/sharepoint help your number 1 on my list.
0
 
LVL 15

Expert Comment

by:melli111
Comment Utility
Glad I could help  :)  Happy InfoPath-ing!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now