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 / February 2007

Tip: Looking for answers? Try searching our database.

How to submit infopath form using custom form code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor - 22 Jan 2007 03:01 GMT
Hi, i have an infopath form that needs to generate an auto-increment invoice
no which i have written a stored procedure to increment the invoice no
everytime the user submits a new form. But i need to put the auto-increment
stored procedure in OnSubmitRequest subroutine so that everytime i click on
Submit, the stored procedure will be called to execute the auto-increment
function. My problem is i don't know the custom form code to submit the form
to sharepoint. I am using VB Script. I have searched for the source code but
very limited and not solving my problem. Can anyone provide the scripts code
in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 31 Jan 2007 02:59 GMT
Isn't Infopath has sample source code in submitting a new form to sharepoint
in VB Script?

If there is, how come there is none reply to the question posted? Or have i
posted to the wrong newsgroup?

> Hi, i have an infopath form that needs to generate an auto-increment invoice
> no which i have written a stored procedure to increment the invoice no
[quoted text clipped - 5 lines]
> very limited and not solving my problem. Can anyone provide the scripts code
> in submitting a form to sharepoint?  Your help is very much appreciated.
S.Y.M. Wong-A-Ton - 31 Jan 2007 05:57 GMT
Download the code sample that comes with this article:
http://blogs.msdn.com/infopath/archive/2006/11/08/submitting-to-this-document-li
brary.aspx


While it does *not* contain a VBScript sample, it shouldn't be too difficult
to convert the JScript sample included to VBScript. The first part of the
script contains code for what you would like to do.

And no, you did not post to the wrong newsgroup; there just aren't that many
VBScript samples online.
---
S.Y.M. Wong-A-Ton

> Isn't Infopath has sample source code in submitting a new form to sharepoint
> in VB Script?
[quoted text clipped - 11 lines]
> > very limited and not solving my problem. Can anyone provide the scripts code
> > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 01 Feb 2007 06:25 GMT
Thanks S.Y.M for being so helpful.

I have followed your instruction to convert Jscript to VBScript to be
applied in my form.

When i run the form, there is an error message prompted " Object required:
strUri"

I have no problem to run the JScript codes in my new form but have this
error using VB Script.

So, i think there must be some syntax error in VB Script.

I will post the script that prompted the error message at the bottom.  The
error encountered at the PopulateLibInfo subroutine for strPath. Please help
me to take a look at what has gone wrong.

Thank you.

Sub XDocument_OnLoad(eventObj)
'Get the Uri of where the form was opened
   strUri = XDocument.Solution.URI
   
   'Populate the fields on the form - keep in mind, this is not necessary -
   'this is simply to see the process in action
   PopulateLibInfo
End Sub

Sub PopulateLibInfo

   'Create IXMLDOMNode objects for each field
   dim xnFormURL
   set xnFormURL =
XDocument.DOM.selectSingleNode("my:myFields/my:strFormURL")
   dim xnLocation
   set xnLocation =
XDocument.DOM.selectSingleNode("my:myFields/my:strLocation")
   dim xnFolderName
   set xnFolderName =
XDocument.DOM.selectSingleNode("my:myFields/my:strFolderName")

   'Create a variable to store the path (URL) to the document library
   dim strPath
   
   'Parse just the path to the document library -
   'this would return something like this: http://server/library            
                  
   strPath = strUri.substring(0, strUri.indexOf("Forms") - 1)
   
   'Now, parse the URL to where the document library resides -
   'this would return something like: http://server or http://server/site
   dim strLoc
   strLoc = strPath.substring(0, strPath.lastIndexOf("/"))

   'Lastly, parse the URL to return just the document library name -
   'in this case,we are looking for the last "/" character
   'knowing that what comes after this is the document library name
   dim strFolder
   strFolder = strPath.substring(strPath.lastIndexOf("/") + 1)

   'Populate the fields on the form – we will use these values
   'in the Submit process
   
   xnFormURL.text = strUri
   xnLocation.text = strLoc
   xnFolderName.text = strFolder
   
end sub

> Download the code sample that comes with this article:
> http://blogs.msdn.com/infopath/archive/2006/11/08/submitting-to-this-document-li
brary.aspx

[quoted text clipped - 23 lines]
> > > very limited and not solving my problem. Can anyone provide the scripts code
> > > in submitting a form to sharepoint?  Your help is very much appreciated.
S.Y.M. Wong-A-Ton - 01 Feb 2007 06:49 GMT
You're getting 'Object required' because strUri is not an object, it is just
a string, meaning that it has no methods or properties.

strUri.substring(...)

is not correct VBScript syntax. You need to use the VBScript "Mid" function
instead of "substring" (see
http://msdn2.microsoft.com/en-us/library/wffts6k3.aspx). I haven't analyzed
the code to see what it is actually doing, but it shouldn't be too difficult
to figure out. And before you bump into another error, you must use the
VBScript "InStr" function instead of "indexOf" (see
http://msdn2.microsoft.com/en-us/library/wybb344c.aspx). Do the same for the
code using strPath.

Hope this helps.
---
S.Y.M. Wong-A-Ton

> Thanks S.Y.M for being so helpful.
>
[quoted text clipped - 92 lines]
> > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 02 Feb 2007 02:24 GMT
Good morning S.Y.M. Wong,

      Follow your instruction, i have managed to get the strUri, strPath
and strLocation using Mid and instr functions. Thank you very much!

     Now i have another problem.  My problem is Object doesn't support this
proerty or method. I have checked on my source code and found that the error
came from
    dim fc
          fc=XDocument.DataAdapter("Main submit")

    I think this is once more VBScript syntax error. VBScript should have
another way to create connection. Can you kindly show me? Thank you!

     One more thing is

     I would like to capture the exception during the submission but i
don't know how to do that in VBScript. Please correct my source code below:
     
     try
         fc.submit
         eventObj.returnstatus=true
     catch(ex)
        eventObj.returnstatus=false

 Will this work?  

Thank you.
 
 

> You're getting 'Object required' because strUri is not an object, it is just
> a string, meaning that it has no methods or properties.
[quoted text clipped - 110 lines]
> > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
S.Y.M. Wong-A-Ton - 05 Feb 2007 05:00 GMT
fc=XDocument.DataAdapter("Main submit")

needs to be

Set fc = XDocument.DataAdapters("Main submit")

Notice the extra "s" on "DataAdapters"? As for catching errors, you must use
"On Error Resume Next" just before the line you want to check, and then test
whether  Err.Number <> 0 just after the line you want to check. If Err.Number
<> 0 an error occurred.
---
S.Y.M. Wong-A-Ton

> Good morning S.Y.M. Wong,
>
[quoted text clipped - 141 lines]
> > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 07 Feb 2007 05:37 GMT
Hi, S.Y.M. Wong,
   
Thanks for telling me the mistake i made in setting up the connection. Now,
i managed to establish the connection.

     Thanks also for providing me with the source code to capture the
exception.

     I still face problem in submitting the form. I can get the form
submitted but there is an error prompting my submission failed. However, when
i go to the sharepoint to see, the form is submitted. I put a display of
message in the if err.number<>0, the message displayed.

     What could be the error?

    My Submit function written like this:

Sub XDocument_OnSubmitRequest(eventObj)
' If the submit operation is successful, set
' eventObj.ReturnStatus = True
' Write your code here

'Create string objects for each field we will use to modify the FolderUrl
    dim xnLocation
       xnLocation =
XDocument.DOM.selectSingleNode("my:myFields/my:strLocation").text
    dim xnFolderName
       xnFolderName =
XDocument.DOM.selectSingleNode("my:myFields/my:strFolderName").text

    'Get a reference to the submit data connection
   
    dim fc
   
    set fc=XDocument.DataAdapters("Main submit")
       
    'Modify the Submit connection URL we want to submit to by concatenating the
    'xnLocation and xnFolderName values
    fc.FolderURL = xnLocation + "/" + xnFolderName
    'Execute the submit connection
   
    dim err
   
    on error resume next
   
    fc.Submit
   
    if err.number<>0 then
       msgbox err.Description
       err.clear
    end if  
   
End Sub
   
Can help me to troubleshoot my erorr?

Thank you!

Rgds,
Victor

> fc=XDocument.DataAdapter("Main submit")
>
[quoted text clipped - 154 lines]
> > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 16 Feb 2007 07:58 GMT
To S.Y.M. Wong, wishing you a very Happy & Prosperous Pig Year!

> Hi, S.Y.M. Wong,
>      
[quoted text clipped - 215 lines]
> > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
S.Y.M. Wong-A-Ton - 16 Feb 2007 08:34 GMT
Thank you, Victor. I often get that from people like you, who do not realize
that there are other people in the newsgroup who also need help. I only have
less than 15 hours within a day to work to put bread on my table, and then
help people like yourself for free in the time that I have left.
---
S.Y.M. Wong-A-Ton

> To S.Y.M. Wong, wishing you a very Happy & Prosperous Pig Year!
>
[quoted text clipped - 217 lines]
> > > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 26 Feb 2007 02:54 GMT
OK. Understand your situation now. I can see that you are helping out many
people including myself for free even beyond your working time. Because i
noticed that there was once you replied my query at night around 10 something
pm. So, i could figure that you are doing it after your working time as well.
Thanks. Really appreciate that. So, will you be answering questions that i
post in the future?

> Thank you, Victor. I often get that from people like you, who do not realize
> that there are other people in the newsgroup who also need help. I only have
[quoted text clipped - 224 lines]
> > > > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
S.Y.M. Wong-A-Ton - 26 Feb 2007 08:06 GMT
That's a difficult question to answer, since I do not know whether I will
still be here to answer any questions. I do not have criteria when answering
questions in the group. If I know the answer and have time to answer, I will
answer. If I do not know the answer and have time to answer, I won't answer.
So you see, it is not that clear-cut.
---
S.Y.M. Wong-A-Ton

> OK. Understand your situation now. I can see that you are helping out many
> people including myself for free even beyond your working time. Because i
[quoted text clipped - 231 lines]
> > > > > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 27 Feb 2007 01:18 GMT
Ok. No problem. Can you provide me with some resources or references on
coding Infopath form using Microsoft Toolkit 2003? This is because i find
that Microsoft Toolkit will be quite useful in developing Infopath form and i
would like to explore and learn more on how to use Microsoft Toolkit in
solving Infopath problems.

Thank you.

> That's a difficult question to answer, since I do not know whether I will
> still be here to answer any questions. I do not have criteria when answering
[quoted text clipped - 239 lines]
> > > > > > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
S.Y.M. Wong-A-Ton - 27 Feb 2007 23:27 GMT
As far as I know, there aren't any toolkit specific resources online, but you
can repost your question to see if someone else knows of any resources, since
I am not the only one who provides answers in this newsgroup. :)

Your best bet to learn to program for InfoPath is to go to:
http://blogs.msdn.com/infopath
http://www.infopathdev.com

or to buy a book like "Developing Solutions with InfoPath" from Microsoft
Press. Consulting the InfoPath SDK might help too.
---
S.Y.M. Wong-A-Ton

> Ok. No problem. Can you provide me with some resources or references on
> coding Infopath form using Microsoft Toolkit 2003? This is because i find
[quoted text clipped - 247 lines]
> > > > > > > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
> > > > > > > > > > > > > in submitting a form to sharepoint?  Your help is very much appreciated.
Victor - 28 Feb 2007 01:18 GMT
Thanks a lot. I will repost my question to gather useful information. Thanks
for the helps!

> As far as I know, there aren't any toolkit specific resources online, but you
> can repost your question to see if someone else knows of any resources, since
[quoted text clipped - 259 lines]
> > > > > > > > > > > > > > to sharepoint. I am using VB Script. I have searched for the source code but
> > > > > > > > > > > > > > very limited and not solving my problem. Can anyone provide the scripts code
 
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.