How to get configurable information into infoPath 2007

M

morna

I have some static data that I want to allow the client to configure
for an Infopath 2007 form. The form is published within the MOSS
2007
environment. Where can I put this static (configurable) data so the
form can read it and a user can change it
- in an app.config or in a MOSS 2007 web.config? I have tried both
ways and the C# code behind does not read the data from either
location.

Thanks for your time.
 
M

morna

The answer I came up with is to use an XML file in a known location -
like "C:\FormData\".

I added a function like this:

/// <summary>
/// Set the sharepoint list url from the configuable file c:
\POFormData\ConfigData.xml.
/// </summary>
private void SetURL()
{
try
{
// read SharePoint URL from C:\FormData\ConfigData.xml
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\POFormData\ConfigData.xml");
XmlNodeList elemList =
doc.GetElementsByTagName("ItemListURL");

foreach( XmlNode listNode in elemList)
{
string url = listNode.InnerText;
_URL = url.Trim();
}
}
catch (Exception ex)
{
EventLogHelper.WriteToLog(_EventLogName.ToString(),
"Function: SetURL(), Err: " +
ex.Message,
System.Diagnostics.EventLogEntryType.Error);
}
}

With the ConfigData.xml looking like this:

<configuration>
<ItemListURL>
http://sp2007second/admin/tech/Pages
</ItemListURL>
</configuration>

I was interested in the ItemListURL value, so I set the value here
within my form:

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
// set the PO event log filename

EventLogHelper.CreateEventLog(System.Environment.MachineName,
_EventLogName.ToString());
// set the sharePoint list url
SetURL();
}

And stored the value for use here:

/// <summary>
/// Stores location of form when initially opened
/// </summary>
private object _URL
{
get { return FormState["_URL"]; }
set { FormState["_URL"] = value; }
}

No sure if this is the right way to do it, but it works for me. Hope
this helps someone :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top