Group:  Other Microsoft Office Products ยป microsoft.public.infopath
Thread: Hide/Show Button based on Online/Offline status

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Hide/Show Button based on Online/Offline status
"jackcroww[ at ]gmail.com" <jackcroww[ at ]gmail.com> 14.07.2006 18:37:45
I have a form that my users want to be able to use while offline. I
have set up the form so that I have two buttons at the bottom of the
form, one of which submits the form via email [EmailSubmit], and the
other submits the form directly to a Sharepoint site [WebSubmit].

I know that I can determine the Online/Offline state in the OnLoad
event with Application.MachineOnlineState:

<code>
function XDocument::OnLoad(eventObj)
{
if (Application.MachineOnlineState)
XDocument.UI.Alert("Online");
else
XDocument.UI.Alert("Offline");
}
</code>

But, there is where I'm stuck with two problems.

1. As far as I can tell, the Application.MachineOnlineState only
determines if the user is on a network. Ideally, I'd like my test to
look for my specific Sharepoint site and verify it is available.

2. I seem to have found that one can't access the form elements
programmatically, so it there a way to get my Online/Offline test
result available to the Conditional Formatting capability?

Thanks in advance for any help.

Jack

Re: Hide/Show Button based on Online/Offline status
"jackcroww[ at ]gmail.com" <jackcroww[ at ]gmail.com> 18.07.2006 13:35:17
jackcroww[ at ]gmail.com wrote:
[Quoted Text]
> I have a form that my users want to be able to use while offline. I
> have set up the form so that I have two buttons at the bottom of the
> form, one of which submits the form via email [EmailSubmit], and the
> other submits the form directly to a Sharepoint site [WebSubmit].
>
> I know that I can determine the Online/Offline state in the OnLoad
> event with Application.MachineOnlineState:
>
> <code>
> function XDocument::OnLoad(eventObj)
> {
> if (Application.MachineOnlineState)
> XDocument.UI.Alert("Online");
> else
> XDocument.UI.Alert("Offline");
> }
> </code>
>
> But, there is where I'm stuck with two problems.
>
> 1. As far as I can tell, the Application.MachineOnlineState only
> determines if the user is on a network. Ideally, I'd like my test to
> look for my specific Sharepoint site and verify it is available.
>
> 2. I seem to have found that one can't access the form elements
> programmatically, so it there a way to get my Online/Offline test
> result available to the Conditional Formatting capability?
>
> Thanks in advance for any help.
>
> Jack

Solved it:

Added this code to script.js

<code>
function IsServerAvailable()
{
if (Application.IsDestinationReachable("http://mmci-gd103sp1"))
return true;
else
return false;
}
</code>

Then added these Conditional Formatting expressions to the appropriate
buttons:

WebSubmit: [xdExtension:IsServerAvailable() = false] : Hide this
control
EmailSubmit: [xdExtension:IsServerAvailable()] : Hide this control

Hope this helps anyone else with this problem.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net