RSS

Pass parameter to Infopath 2007 browser forms using Business Data Catalog

30 Apr

Last week, I got an excellent oppurtunity to work with Infopath 2007 and Business Data Catalog(BDC). As per requirement, need to pass employee personal information id to infopath forms. Infopath form should pre-populate data from DB based on PersonalInfoID from Querystring.  Whether i pass a parameter to a form file in InfoPath 2007 or the Web browser, first i need to update the form template’s Loading event. The LoadingEventArgs class of the Loading event provides the InputParameters property. This property gets an IDictionary object, which contains any input parameters that are specified in the URL that is used to start a form file. Next, use the TryGetValue method of the IDictionary object that was returned by the InputParameters property to retrieve a parameter value. Then, use the SetValue method on an XPathNavigator object to set the corresponding node value in the form file. The following example sets the Employee Name box to the value based on PersonalInfoID parameter that was passed in the URL that was used to start the form.  public void FormEvents_Loading(object sender, LoadingEventArgs e) {

string personalInfoId = string.Empty;

try    

e.InputParameters.TryGetValue(“PersonalInfoID”, out personalInfoId);  

} catch (Exception ex) {

personalInfoId = ex.Message.ToString();

} finally {

 …do some db calls…

MainDataSource.CreateNavigator().SelectSingleNode (“/my:myFields/my: Name”, NamespaceManager).SetValue(customerId);

}

Next, I must update the Business Data Catalog metadata file to include a custom action. So I’ve added as follows, which adds a custom action to the existing Employee entity (before the </Entity> end tag) that starts the status report form in the Web browser with a PersonalInfoID parameter.

<Actions>   

    <Action Name=”Status Report” Position=”1″ IsOpenedInNewWindow=”true” Url=      “<i>My MOSS Server</i>/_layouts/formserver.aspx?xsnlocation=       /formservertemplates/statusreport.xsn&      openin=browser&PersonalInfoID={0}”>       

  <ActionParameters>           

                  <ActionParameter Name=”personalInfoID” Index=”0″/>       

    </ActionParameters>   

  </Action>

</Actions>

Now, if I would like to add save location(which user can save the form after submited to DB) as follows 

http://mossserver/Employee Info/HR Response/Credit Response/Check In/_layouts/FormServer.aspx?XsnLocation=http://mossserver/FormServerTemplates/StatusCheck-In.xsn&SaveLocation=http://mossserver/Employee Info/HR Response/Credit Response/Check In /Personal CheckIn&Source=http://mossserver/Employee Info/HR Response/Credit Response/Check In /Pages/default.aspx&DefaultItemOpen=1   – Kindly note that, I’ve long URL which more than675 characters. If we would like to add this URL into our custom action, BDC services turncated longest URL because of MaxLength.Now, how we can resolve this problem? – I got an idea, why don’t to apply URLMapping functionality to this scenario. So finally I’ve added URL Mapping element to Web.Config as follows:       <urlMappings>        

                  <add url=”~/sample.aspx” mappedUrl=”~/_layouts/FormServer.aspx?XsnLocation= /FormServerTemplates/StatusCheck-In.xsn&SaveLocation= /Personal CheckIn&Source= /Pages/default.aspx&DefaultItemOpen=1&Perso nalInfoID={0} ” />     

    </urlMappings> 

Ahrr….Finally, we solved the problem by adding URL mapping. Hatzz off to ASP.NET team J

Also, here’re some pointer really help me to solve this issue.

http://msdn2.microsoft.com/en-us/library/bb406004.aspx 

http://wm.microsoft.com/ms/msdn/office/2007officevisualhowtos/infopathparameters.wmv – Excellent videocast regarding this context 

Advertisements
 
11 Comments

Posted by on April 30, 2007 in Business Data Catalog

 

11 responses to “Pass parameter to Infopath 2007 browser forms using Business Data Catalog

  1. Bill

    May 31, 2007 at 10:42 am

    MSN I NIIPET
    MSN

     
  2. Sunil Joshi

    June 12, 2007 at 5:47 am

    Nice one !!

    I try using the above, but i want to open the infopath form in web-page mode.
    Does the above expirement support it,
    i m getting an error while opening the form …

    please revert back

     
  3. lovedjohnysmith

    June 12, 2007 at 1:12 pm

    Sunil,

    Please have a look at the following URL:-
    http://wm.microsoft.com/ms/msdn/office/2007officevisualhowtos/infopathparameters.wmv

    Regards,
    Johnny

     
  4. Disha

    October 14, 2008 at 7:28 pm

    Hello

    If it is not against ethics, can you please pass me the code or step by step instruction. I am also tryint to do this, but not able to fetch record from BDC datalist to Infpath forms.

    Please help me out
    Disha

     
  5. Maynard

    March 11, 2013 at 2:26 am

    Attractive section of content. I just stumbled upon your site
    and in accession capital to assert that I acquire in fact enjoyed account your blog posts.
    Anyway I’ll be subscribing to your augment and even I achievement you access consistently fast.

     
  6. Lucia

    June 4, 2013 at 9:04 am

    This is very interesting, You are a very skilled blogger. I’ve joined your rss feed and look forward to seeking more of your wonderful post. Also, I’ve shared your
    web site in my social networks!

     
  7. tin Moi

    June 5, 2013 at 8:59 pm

    I constantly emailed this weblog post page to all my contacts, because if like
    to read it afterward my links will too.

     
  8. buy levitra

    June 13, 2013 at 1:58 am

    WOW just what I was looking for. Came here by searching for please click the
    following web site

     
  9. it suport

    June 30, 2013 at 11:26 am

    Thanks in favor of sharing such a nice idea,
    article is good, thats why i have read it fully

     
  10. komandosiaki.pl

    August 2, 2013 at 2:49 am

    Outstanding post, you have pointed out some excellent points , I as well think this s
    a very good website.

     
  11. pain of coccydynia

    August 8, 2013 at 4:41 am

    Very nice post. I just stumbled upon your weblog and wished
    to say that I’ve really enjoyed browsing your blog posts. In any case I’ll
    be subscribing to your feed and I hope you write again very soon!

     

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 )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: