How to disable submissions with a rule or code

S

Scott L. Heim [MSFT]

Hi,

We may need to get more information from you because you did not indicate
what you wanted the "test" to be (i.e. user role, field data, etc.)
However, here is a quick code example to test if a specific field is blank:

** NOTE: This would be done from the click event of a button:

Dim objField
Set objField = XDocument.DOM.selectSingleNode("//my:myFields/my:field1")

If objField.text = "" Then
XDocument.UI.Alert "Field1 must be filled in!"
Else
XDocument.Submit
End If

Let us know if you need more assistance!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

woolfm

Scott,

Thanks for your prompt reply.

I would like the "test" to be a user role. If a certain user role, then
submission is disabled.
 
S

Scott L. Heim [MSFT]

Hi,

You should be able to achieve what you need by doing the following:

- Modify your submit button to use "Rules"
- When you add a new Rule, you can set a condition and one of the
conditions is a "test" for the user Role
- If the user is in the specific Role, then you can execute an "Action" and
that action would be to perform the submit.

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

woolfm

Thanks again, Scott,

When I test this, a user that is not in the selected role can still submit.
Even if I don't allow submit on the menu and hide the submit button.
When a user queries the data, they can change a value in the returned data.
When they close the form, it asks them if they want to submit.

I want to be able to prevent a certain user role from submitting any new
data or changing any existing data.
 
W

woolfm

Scott,

I managed to do what I wanted by adding Conditional Formatting to each
control in the Data Entry section of my form that look at the User Role and
make the control Read Only. This was pretty tedious, since that section of
the form had many controls, but it worked.

If I knew more about programming InfoPath, I probably could have added a
rule on opening the form that looped through the controls and made them read
only.
 

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