I have several fields with 'Cannot be blank' selected in the properties. I am
using Visual Studio, InfoPath SP1 and have a published fully trusted
template. I have a Save button using XDocument.SaveAs that saves the XML file
where I tell it to. How can I force the users to have to complete all
required fields before being able to save?
Add rules to your save button which checks the required fields and displays a dialog box if they are not filled out. Stop the remaining rules from processing if you had to display a dialog box.
If you are using code, you can either perform these checks in code and display a dialog box with thisXDocument.UI.Alert("message"); or you can use the rules from above and set some flag in a secondary data source which the code will check before processing the save.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
I have several fields with 'Cannot be blank' selected in the properties. I am
using Visual Studio, InfoPath SP1 and have a published fully trusted
template. I have a Save button using XDocument.SaveAs that saves the XML file
where I tell it to. How can I force the users to have to complete all
required fields before being able to save?
cwrightAGL - 18 Sep 2004 00:25 GMT
Buttons do not seem to have rules for required fields like text fields. I
didn't see it as an available action under Properties/Rule/Add Action. Am I
missing anything?
I wrote some VB.NET code. It is working well. Here is my code:
If thisXDocument.DOM.selectSingleNode("/my:myFields/my:location_code").text
= "" Or thisXDocument.DOM.selectSingleNode("/my:myFields/my:address").text =
"" Or thisXDocument.DOM.selectSingleNode("/my:myFields/my:tkn_by").text = ""
Or thisXDocument.DOM.selectSingleNode("/my:myFields/my:assigned_to").text =
"" Or thisXDocument.DOM.selectSingleNode("/my:myFields/my:date_taken").text
= "" Then thisXDocument.UI.Alert("Please fill out all required fields in
blue.") End If
Thanks.
Catherine
Catherine.
> Add rules to your save button which checks the required fields and displays a dialog box if they are not filled out. Stop the remaining rules from processing if you had to display a dialog box.
>
[quoted text clipped - 5 lines]
> where I tell it to. How can I force the users to have to complete all
> required fields before being able to save?