[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1384
  • Last Modified:

VB Code For InfoPath Form

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
AnthonyKRo
Asked:
AnthonyKRo
  • 11
  • 10
1 Solution
 
melli111SharePoint Administrator / DeveloperCommented:
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
 
melli111SharePoint Administrator / DeveloperCommented:
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
 
AnthonyKRoAuthor Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
melli111SharePoint Administrator / DeveloperCommented:
Ohhh, In your add data connection I think you selected XML file.... select "WebService" instead, then click next and enter the url
0
 
AnthonyKRoAuthor Commented:
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
 
melli111SharePoint Administrator / DeveloperCommented:
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
 
AnthonyKRoAuthor Commented:
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
 
melli111SharePoint Administrator / DeveloperCommented:
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
 
AnthonyKRoAuthor Commented:
What would the fqdn of the https://servername/_vti_bin/UserProfileService.asmx be

not sure where to find this
0
 
melli111SharePoint Administrator / DeveloperCommented:
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
 
AnthonyKRoAuthor Commented:
Just clarifying we should be using the same server name as in the data connection.

So
https://sameserverasdataconnection.domainofhostsite.com
0
 
melli111SharePoint Administrator / DeveloperCommented:
Yes, it should be that same server name
0
 
AnthonyKRoAuthor Commented:
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
 
melli111SharePoint Administrator / DeveloperCommented:
That's possible - if it's not approved or doesn't have the appropriate trust level it will block out certain data connections
0
 
AnthonyKRoAuthor Commented:
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
 
melli111SharePoint Administrator / DeveloperCommented:
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
 
AnthonyKRoAuthor Commented:
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
 
melli111SharePoint Administrator / DeveloperCommented:
Something is definitely not right there ----- how did you manage to get the form to the right spot (what were your steps)?
0
 
AnthonyKRoAuthor Commented:
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
 
AnthonyKRoAuthor Commented:
Thank You for sticking with this post for so long. If I ever need infopath/sharepoint help your number 1 on my list.
0
 
melli111SharePoint Administrator / DeveloperCommented:
Glad I could help  :)  Happy InfoPath-ing!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 11
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now