Hi all,
I have an InfoPath form that is being submitted to a SharePoint form library. After the form has been submitted, I would like to retrieve the ID field from the form library and store it in the form's data source. I can do this in many different ways, but so far nothing I've tried is working.
I have set up a secondary data connection to the form library and set it to have only one column, namely the ID field.
So when I try something like:
DataConnection SubmitConnection = this.DataConnections["Submit to Form Library"];
SubmitConnection.Execute();
if(NewStatus == "New") {
//query for Form ID, set ChangeRequestNumber to FormID, and resubmit
DataConnection QueryConnection = this.DataConnections["ChangeManagementID"];
QueryConnection.Execute();
string RFCID = xnMyForm.SelectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Request_For_Change/@ID", ns).Value;
xnMyForm.SelectSingleNode("/my:ChangeRequest/my:HeaderInfo/my:ChangeRequestNumber", ns)
.SetValue(RFCID);
SubmitConnection.Execute();
}
I get the object reference not set to an instance of an object error.
Alternately, since this particular form will be opened and closed about 10 times during it's life and I just want to get the information there EVENTUALLY, I tried setting the form options -> open rules to set a field to a value, and set my ChangeManagementID field equal to @ID from the secondary datasource. That does not work either, but I don't get an error either.
Any suggestions? I have considered trying to hack this on the first submit by trying to calculate max(id) + 1, but that does not seem like a good solution. I could also maintain my own ID field in the form library and populate with max(id) + 1, but that's far from the best solution either. What I really want here is the actual sharepoint form library id, but I'm having a hard time finding it.
Thanks so much for any help!
Tim