Alternative to UI.Alert

B

BethA

I have an InfoPath form that looks up some data in a database - that's all
done in managed code behind the form. Sometimes it takes a few seconds, so I
have a UI.Alert come up to tell the user the data is being looked up, and
then another to say it's finished.

This is not ideal because I would rather not have the user have to click on
the OK button to clear the Alert and let the code continue. In Excel, I use
Application.StatusBar to give the user the status of what my macro is doing.
Is there such a thing I can do in InfoPath?

Thanks,
Beth A.
 
G

Greg Collins [InfoPath MVP]

Create a secondary .xml file with a status field in it. Place the status field in the view, and then instead of using Alert, just update the value of the status field, which will then display inline in the form.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have an InfoPath form that looks up some data in a database - that's all
done in managed code behind the form. Sometimes it takes a few seconds, so I
have a UI.Alert come up to tell the user the data is being looked up, and
then another to say it's finished.

This is not ideal because I would rather not have the user have to click on
the OK button to clear the Alert and let the code continue. In Excel, I use
Application.StatusBar to give the user the status of what my macro is doing.
Is there such a thing I can do in InfoPath?

Thanks,
Beth A.
 
B

BethA

Thanks Greg - this was really helpful, and like most good ideas, obvious once
I read it! I put the field right into my schema rather than create a
secondary one.

The only problem is that I'm using managed code in the OnAfterChange event
and it doesn't update the fields immediately on the form. Anyway to get it to
update immediately. I tried to make a rule to do it, hoping that the rule
would occur first. It doesn't seem to work though. I want the status field to
be blank after the data has been retrieved from the secondary data source.

Thanks,
Beth A.
 
G

Greg Collins [InfoPath MVP]

Yes, you are running into the issue where the view field is not refreshed until the function exits.

There is a function that forces the view to update [ XDocument.View.ForceUpdate(); ]... but I don't recall having a whole lot of luck with it in situations like this either. Give it a try though and see if it helps.

The problem, as I mentioned, is not that the field is not being updated, but that the view is not being refreshed--at least not until the function exits.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Thanks Greg - this was really helpful, and like most good ideas, obvious once
I read it! I put the field right into my schema rather than create a
secondary one.

The only problem is that I'm using managed code in the OnAfterChange event
and it doesn't update the fields immediately on the form. Anyway to get it to
update immediately. I tried to make a rule to do it, hoping that the rule
would occur first. It doesn't seem to work though. I want the status field to
be blank after the data has been retrieved from the secondary data source.

Thanks,
Beth A.
 
B

BethA

I've been trying to get the ForceUpdate method to work, but it's not doing
anything. Will this work better if I go with the secondary datasource XML
file and query from there? I didn't want to full around with all the extra
machinery (especially figuring out how to access the secondary datasource in
code), but I will if I have to.

Thanks,
Beth A.

Greg Collins said:
Yes, you are running into the issue where the view field is not refreshed until the function exits.

There is a function that forces the view to update [ XDocument.View.ForceUpdate(); ]... but I don't recall having a whole lot of luck with it in situations like this either. Give it a try though and see if it helps.

The problem, as I mentioned, is not that the field is not being updated, but that the view is not being refreshed--at least not until the function exits.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Thanks Greg - this was really helpful, and like most good ideas, obvious once
I read it! I put the field right into my schema rather than create a
secondary one.

The only problem is that I'm using managed code in the OnAfterChange event
and it doesn't update the fields immediately on the form. Anyway to get it to
update immediately. I tried to make a rule to do it, hoping that the rule
would occur first. It doesn't seem to work though. I want the status field to
be blank after the data has been retrieved from the secondary data source.

Thanks,
Beth A.

Greg Collins said:
Create a secondary .xml file with a status field in it. Place the status field in the view, and then instead of using Alert, just update the value of the status field, which will then display inline in the form.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have an InfoPath form that looks up some data in a database - that's all
done in managed code behind the form. Sometimes it takes a few seconds, so I
have a UI.Alert come up to tell the user the data is being looked up, and
then another to say it's finished.

This is not ideal because I would rather not have the user have to click on
the OK button to clear the Alert and let the code continue. In Excel, I use
Application.StatusBar to give the user the status of what my macro is doing.
Is there such a thing I can do in InfoPath?

Thanks,
Beth A.
 
G

Greg Collins [InfoPath MVP]

As I said, I never had any luck with that either. It is completely a timing issue. The secondary data source will make no difference in this case. I don't think I've ever figured out how to make it work.

One thing that might work (never tried it) is to have a custom task pane, and to do your messages in there. This probably doesn't have the same refresh issues that the main view has.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I've been trying to get the ForceUpdate method to work, but it's not doing
anything. Will this work better if I go with the secondary datasource XML
file and query from there? I didn't want to full around with all the extra
machinery (especially figuring out how to access the secondary datasource in
code), but I will if I have to.

Thanks,
Beth A.

Greg Collins said:
Yes, you are running into the issue where the view field is not refreshed until the function exits.

There is a function that forces the view to update [ XDocument.View.ForceUpdate(); ]... but I don't recall having a whole lot of luck with it in situations like this either. Give it a try though and see if it helps.

The problem, as I mentioned, is not that the field is not being updated, but that the view is not being refreshed--at least not until the function exits.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Thanks Greg - this was really helpful, and like most good ideas, obvious once
I read it! I put the field right into my schema rather than create a
secondary one.

The only problem is that I'm using managed code in the OnAfterChange event
and it doesn't update the fields immediately on the form. Anyway to get it to
update immediately. I tried to make a rule to do it, hoping that the rule
would occur first. It doesn't seem to work though. I want the status field to
be blank after the data has been retrieved from the secondary data source.

Thanks,
Beth A.

Greg Collins said:
Create a secondary .xml file with a status field in it. Place the status field in the view, and then instead of using Alert, just update the value of the status field, which will then display inline in the form.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have an InfoPath form that looks up some data in a database - that's all
done in managed code behind the form. Sometimes it takes a few seconds, so I
have a UI.Alert come up to tell the user the data is being looked up, and
then another to say it's finished.

This is not ideal because I would rather not have the user have to click on
the OK button to clear the Alert and let the code continue. In Excel, I use
Application.StatusBar to give the user the status of what my macro is doing.
Is there such a thing I can do in InfoPath?

Thanks,
Beth A.
 
B

BethA

Thank you Greg - I got this to work with the custom task pane. I did it very
simplisticly - made an HTML file with my message in Word, set it the task
pane as invisible in the OnSwitchViews event handler. Then in my
OnAfterChange handler, I make the custom task pane visible before running my
"getdata" procedure, then invisible again at the end.

That was quick way to do it - I would have to think harder if I wanted more
than one message coming up, or other features of the custom task pane.

Beth A.
 
G

Greg Collins [InfoPath MVP]

Perhaps not the most elegant solution, but I'm happy to hear that you got it working!

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Thank you Greg - I got this to work with the custom task pane. I did it very
simplisticly - made an HTML file with my message in Word, set it the task
pane as invisible in the OnSwitchViews event handler. Then in my
OnAfterChange handler, I make the custom task pane visible before running my
"getdata" procedure, then invisible again at the end.

That was quick way to do it - I would have to think harder if I wanted more
than one message coming up, or other features of the custom task pane.

Beth A.
 

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