Need help with solution/idea for form

M

mcampbell

We have a form called a "Person-Centered Support Plan Form". It has a series
of questions for a person to answer to figure out how to create a support
plan for a consumer. Within the form, there are 3 sections that captures
data in a repeating table and the other two sections are repeating tables
within repeating sections. This form is filled out the first time a consumer
is met with and thereafter every anniversary date of that first meeting. A
case manager will take the information in these 3 particular sections and
create 90 Day Narratives which is will be a new form. Once the
"Person-Centered Support Plan Form" is created and signed off on it cannot be
changed or modified. So a new form called the "90 Day Narrative" is created
from existing data in the "Support Plan Form". The 90 Day Narrative is used
to gauge progress that a consumer is making and has fields setup so that they
can write narratives and progress the consumer is making and any changes that
might need to be made in the support plan.

Now to the question. Is there a way to take those 3 sections in the
"Person-Centered Support Plan" for a consumer and have that information to be
automatically extracted and populated into a new form - the "90 Day Narrative
Form" so that the case manager to can add/update/modify/change the 90 Day
Narrative Form?
 
J

Josiah Smith

We are using some code I found to do the same thing (I'm slightly smarter
than a gorilla and kludged this together from at least two other individuals
instructions/examples, and added some safety measures myself). I'll walk you
through it, but it is for the InfoPath 2003 Object Model, accessing
SharePoint 2003, in JScript (I'm hoping I can convert this to C# in the 2k7
Managed Object Model shortly).

This should work for you with the obvious data source changes. It is also
possible to take stuff from a particular selected row in a repeating table,
or even from a repeating table within a repeating section, if you have
repeating data. Then you could have fun programatically creating nodes in a
matching repeating table from the secondary form's scripting file, and
possibly devise some way to pass indexes or row numbers along with your data.

function buttonOpen::OnClick(eventObj)
{
//the name of the file you will be opening
var newFileName =
XDocument.DOM.selectSingleNode("/my:SupportPlan/my:SecondaryFileName").text;

//for better data manipulation, grab the URI (form must have already been
saved/submitted) and append additional text onto it
//var currentFileName = XDocument.Uri

//paths to where your xsn and form library is for your secondary form
var newXsnPath = "http://server/NewForm/Forms/template.xsn";
var newDocUrl = "http://server/NewForm/" + newFileName + ".xml";
//alternatively with Uri Data "...Form/" + currentFileName + "90 Day
Narrative.xml";

//Create an xmlhttpobject
var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");

//test for existence of secondary form
oXmlHttp.Open("HEAD", newDocUrl, false);
oXmlHttp.Send();

//the following could be a switch statement
//you could use a switch statement and regular expressions to cover all
possible status codes
//catches the http 500 series status codes
if(oXmlHttp.Status == 500 || ... == 501 || ... == 502)
{
XDocument.UI.Alert("error in connection; try again or call a network
administrator.");
return;
}
//this is what will happen when if there is no version of the secondary form
else if(oXmlHttp.Status == 404)
{
var newForm = Application.XDocuments.NewFromSolution(newXsnPath);

//fill in your necessary elements in the newly opened form
newForm.DOM.selectSingleNode("/my:90DayNarative/my:90DayFileName").text =
XDocument.DOM.selectSingleNode("/my:SupportPlan/my:SecondaryFileName").text;
//or
newForm.DOM.selectSingleNode("/my:90DayNarrative/my:90DayFileName").text
= currentFileName + "90 Day Narrative.xml";
}
//this is what will happen if there is already a form created
else
{
var newForm = Application.XDocuments.Open(newDocUrl);

//fill in new elements or fill in new and overwrite old elements with old
data

Application.XDocuments(newDocUrl).DOM.selectSingleNode("/my:90DayNarrative/my:updatedInfo").text
=
XDocument.DOM.selectSingleNode(/my:SupportPlan/my:InfoToUpdate90DayFileWith").text;
}

}
 
J

Josiah Smith

I should tell you that this is for simple string data. We've had to turn
dates into string in the data source in order to pass them over, and I don't
know how to pass date, dateTime, or base64 data between forms (the base64
passing would be incredibly helpful...)

HTH,
Josiah Smith
 

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