When is a default view not a default view?

J

jb

I'm stumped on this one...

Developing a form. It had one view. I introduce a second view, and set that
as default view. Works fine when accessed from any machine. Except... On my
machine (where I develop), the original view gets shown first. Believe me, I
have tried everything: resetting, resaving, rebooting, starting from either
"open" or "design" mode ... If I place a debugger statement in MS Script
OnLoad() event and run on my machine, I can see it says the *original* view
is the default, so no wonder. But where's it getting that from: I can see
quite clearly that I have set the new view as default? The only thing I can
think of is a cached copy/saved setting somewhere/somehow?

I have checked I do not have any load rules, user views etc. For now, I have
created a rule in "Form Options" for "Open behaviour" telling it to switch to
the other view, and that gets my by, but what the heck?...
 
A

Andrew Watt [MVP - InfoPath]

Have a look at the Help topic Customize How InfoPath Starts.

There is a /cache ClearAll setting there.

Start InfoPath using that.

It may get rid of your problem.

Andrew Watt
MVP - InfoPath
 
J

jb

Thanks. Tried that, but no difference in behaviour... :(

Any other ideas? How can this be happening?
 
A

Andrew Watt [MVP - InfoPath]

When you are opening the form / form template and get the "old"
version what *exactly* do you do?

For example, are you opening from inside InfoPath? From Windows
Explorer? Are you opening a form template (.xsn) or a form (.xml) ...
etc

Andrew Watt
MVP - InfoPath
 
J

jb

Andrew,

Like I said, believe me, I've tried the lot! Always XSN file. From
Explorer, from InfoPath, Design and Open mode, switching the Default View
between the two views and saving, making sure the last view I looked at is
the one I want to be the default, you name it...

On my machine, my original, non-default view comes up always; on others the
new default comes up first...

I don't actually see how this could be an "old"/"caching" problem --- I was
clutching at straws. I'm developing this all day, and *every other* change I
make is reflected OK, just not the new default view.

Here's the simple facts I can't explain:

* In IP Design mode, I can see the Default View has been set to the *second*
view I designed
* I've tried Exporting Form Files, looked in manifest.xsf, and I can see line:
<xsf:views default="Logon">
which is correct ("Logon" is my second view)
* I'm using MS Script. I break in XDocument::OnLoad() function (can't get
much earlier than that...)
* In debugger, I look at XDocument.ViewInfos(0 and 1).IsDefault. It shows
my original (0, first) View.IsDefault = true ! So given that the behaviour
isn't surprising, but how come it's set like that??? (If I change this value
in debugger so second view is default, then that comes up first.)

I don't have any "User Roles", so it's not to do with that. My "workaround"
is to go into "Form Options" and set a rule on "Open behaviour" to switch to
the correct view, which works, but it's not "right", is it, and eventually
I'll want to use that properly "anyway"...

I know it might sound like I'm just not really setting the Default View to
the other one. But I am, honset, and saving! Plus, it works right on other
machines...
 
A

Andrew Watt [MVP - InfoPath]

Hi,

There is certainly something odd going on. I am also clutching at
straws now. :)

Have you tried saving the form template with a different name? Does
the "wrong" default view still happen on your machine with the
differently named template? (I guess it may)

If that doesn't work ...

Also ... on the copy only ... try Ctrl+A to select all the visible
parts of the view, create a new view and paste the controls into the
newly created view, delete the "old" default view, set the "newly
created" view to being the default.

Any different? Or still the same odd behaviour on your machine?

Andrew Watt
MVP - InfoPath
 
J

jb

Yeah, so basically, "try deleting everything and start again" :) I had come
to this kind of conclusion myself... (Mind you, at least it's not the
standard support answer of "first reformat and reinstall OS" ;-) )

Will do when I have a moment. FWIW, I'll post when I've got something to
say. Thanx for caring...
 
A

Andrew Watt [MVP - InfoPath]

No, not "try deleting everything and start again".

If ... always do it on a copy though :) ... you do what I suggested
the binding stays with the form controls ... at least it has done when
I have done similar things .. so you have minimal work to do to try
it. :)

Andrew Watt
MVP - InfoPath
 
J

jb

Yes, I do realise copy & paste etc. will help me. I didn't mean to be rude.
I just meant, I'll try reconstructing everything a bit at a time to see what
works/fails. Rather than actually figuring what the fault is. No problem.
 
J

jb

Andrew,

Greg posted this to my same question on InfoPathDev.com, and I've replied
there (http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=85), saying I
think not.

Thanks for your interest, guys. I promise, as soon as I have a minute I
really will get "down & dirty" with this one. It's just that I'm doing so
many other IP things at mo., I don't have time yet... !
 
P

Patrick Halstead [InfoPath MVP]

Hi JB,
There was a bug in InfoPath that I discovered that was exactly like what you
describe here and that's why Greg suggested reading the blog entry. It's
possible that you have discovered another bug in InfoPath. You should post
repro instructions so that people from MS can take a look.
Cheers,
Patrick
 
J

jb

Repro instructions: since I'm saying it only happens on my development
machine, shall I attach my computer to the post? :)
 
J

jb

OK, I'm starting to look into this.

Can I *please* have an answer first off to a very simple question: is
"Default View" taken into account when previewing from *design* mode?

In a test, I create a blank form and an extra view, i.e. "View 1" & "View
2". I set "View 2" as the default. I save.

Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up

I have tried every combination of getting into Open/Design mode (from IP,
from Explorer, etc. etc.) and this is always the behaviour. Open mode
respects my default, from design mode does not.

Is this or is this not expected behaviour?

(Having said this, this still doesn't solve my original problem: in that
form, it still doesn't matter what I'm viewing in design mode, or when I
open, it *always* comes up one one (non-default) viw. But let's wait on that
till I get an answer to this part...)
 
J

jb

Hmmmm.... So now I technically have two problems (at least on my machine)
then:

1. Default View is *not* taken into account for me from design mode (as per
repro steps below on brand new IP form, two views, no code, nothing...)

2. On real form, reagrdless design/open mode, Default View *always* ignored
and set to one particular view.

Inexplicable? Related? Why do I begin to feel a "uninstall & reinstall IP"
coming on? ... :)

I'm happy continuing this conversation here or at InfoPathDev.com. Probably
prefer the latter. Except that it's down (again)...

Greg Collins said:
To answer your first question... the default view *IS* taken into account during preview from the designer.

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



OK, I'm starting to look into this.

Can I *please* have an answer first off to a very simple question: is
"Default View" taken into account when previewing from *design* mode?

In a test, I create a blank form and an extra view, i.e. "View 1" & "View
2". I set "View 2" as the default. I save.

Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up

I have tried every combination of getting into Open/Design mode (from IP,
from Explorer, etc. etc.) and this is always the behaviour. Open mode
respects my default, from design mode does not.

Is this or is this not expected behaviour?

(Having said this, this still doesn't solve my original problem: in that
form, it still doesn't matter what I'm viewing in design mode, or when I
open, it *always* comes up one one (non-default) viw. But let's wait on that
till I get an answer to this part...)

jb said:
I'm stumped on this one...

Developing a form. It had one view. I introduce a second view, and set that
as default view. Works fine when accessed from any machine. Except... On my
machine (where I develop), the original view gets shown first. Believe me, I
have tried everything: resetting, resaving, rebooting, starting from either
"open" or "design" mode ... If I place a debugger statement in MS Script
OnLoad() event and run on my machine, I can see it says the *original* view
is the default, so no wonder. But where's it getting that from: I can see
quite clearly that I have set the new view as default? The only thing I can
think of is a cached copy/saved setting somewhere/somehow?

I have checked I do not have any load rules, user views etc. For now, I have
created a rule in "Form Options" for "Open behaviour" telling it to switch to
the other view, and that gets my by, but what the heck?...
 
J

jb

[Posted to InfoPathDev.com too.]

Please be kind enough to try something very simple for me. I feel I'm going
mad! I've now tested from scratch on another PC here, and I do *not* find
that Default View is taken into account from design mode!

Very simple steps:

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Select "Preview Form" (either from toolbar, or from "File" menu)

What do you see? I see "View 2"! You can see from "Views" pane that "View
1" is default. You can swap which is default as much as you like; but I
always get whichever one I am looking at in design mode up first. Don't you?
Same on another PC.

If you then save the file, I find the same whenever I reopen the file for
design. If I open it for fill out, the default view *does* come up.

I'd like this sorted before I tackle the "real" problem, which seems to be
worse...


jb said:
Hmmmm.... So now I technically have two problems (at least on my machine)
then:

1. Default View is *not* taken into account for me from design mode (as per
repro steps below on brand new IP form, two views, no code, nothing...)

2. On real form, reagrdless design/open mode, Default View *always* ignored
and set to one particular view.

Inexplicable? Related? Why do I begin to feel a "uninstall & reinstall IP"
coming on? ... :)

I'm happy continuing this conversation here or at InfoPathDev.com. Probably
prefer the latter. Except that it's down (again)...

Greg Collins said:
To answer your first question... the default view *IS* taken into account during preview from the designer.

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



OK, I'm starting to look into this.

Can I *please* have an answer first off to a very simple question: is
"Default View" taken into account when previewing from *design* mode?

In a test, I create a blank form and an extra view, i.e. "View 1" & "View
2". I set "View 2" as the default. I save.

Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up

I have tried every combination of getting into Open/Design mode (from IP,
from Explorer, etc. etc.) and this is always the behaviour. Open mode
respects my default, from design mode does not.

Is this or is this not expected behaviour?

(Having said this, this still doesn't solve my original problem: in that
form, it still doesn't matter what I'm viewing in design mode, or when I
open, it *always* comes up one one (non-default) viw. But let's wait on that
till I get an answer to this part...)

jb said:
I'm stumped on this one...

Developing a form. It had one view. I introduce a second view, and set that
as default view. Works fine when accessed from any machine. Except... On my
machine (where I develop), the original view gets shown first. Believe me, I
have tried everything: resetting, resaving, rebooting, starting from either
"open" or "design" mode ... If I place a debugger statement in MS Script
OnLoad() event and run on my machine, I can see it says the *original* view
is the default, so no wonder. But where's it getting that from: I can see
quite clearly that I have set the new view as default? The only thing I can
think of is a cached copy/saved setting somewhere/somehow?

I have checked I do not have any load rules, user views etc. For now, I have
created a rule in "Form Options" for "Open behaviour" telling it to switch to
the other view, and that gets my by, but what the heck?...
 
J

jb

Greg,

You're mistaken. I absolutely do *not* want to set a default value in
OnLoad() code. Neither in this example, nor in my "live" problem. The whole
point is is I don't want any code at all at this point. Nor rules; nothing.
I know what you say here works, of course.

I am just asking: in design mode I pick which view is the default one,
right? I do that via the View Properties. Now you said:Remember, no code/rules. Just the View Properties setting for whichever view
is set as the Default.

So can we try again, please:

In Design mode, with no code/rules/roles, which of the following is intended
behaviour when you *preview*:

1. The view which is marked as the default comes up first (i.e. just like it
will be at runtime when filling out form); or
2. The view you happen to be looking at in the designer will come up first
(i.e. *not* the same as filling out form; the Default View property is simply
ignored)

(BTW, if it is 2., I do not find that documented *anywhere*.)

I need this clarified *before* I can tackle my "live" behaviour, in which I
am claiming the Default View --- as set by the Properties in the designer ---
for a particular form is being ignored in every and all cases.

Greg Collins said:
Your steps do not account for what you are wanting to do... namely set a default value in the OnLoad code.

If you do not FORCE a default view, then yes, InfoPath will preview using the CURRENT view. This is the expected behavior.

It sounds like you are wanting to always force Vew 1 to show up first. Let's modify your steps a bit... I tested this before replying to you last time...

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Choose Programming | On Load Event from the Tools menu.
8. In the OnLoad event handler, type 'XDocument.ViewInfos("View 1").IsDefault = true;'
9. Save your form code and close the script editor.
10. Select "Preview Form" (either from toolbar, or from "File" menu);


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



[Posted to InfoPathDev.com too.]

Please be kind enough to try something very simple for me. I feel I'm going
mad! I've now tested from scratch on another PC here, and I do *not* find
that Default View is taken into account from design mode!

Very simple steps:

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Select "Preview Form" (either from toolbar, or from "File" menu)

What do you see? I see "View 2"! You can see from "Views" pane that "View
1" is default. You can swap which is default as much as you like; but I
always get whichever one I am looking at in design mode up first. Don't you?
Same on another PC.

If you then save the file, I find the same whenever I reopen the file for
design. If I open it for fill out, the default view *does* come up.

I'd like this sorted before I tackle the "real" problem, which seems to be
worse...


jb said:
Hmmmm.... So now I technically have two problems (at least on my machine)
then:

1. Default View is *not* taken into account for me from design mode (as per
repro steps below on brand new IP form, two views, no code, nothing...)

2. On real form, reagrdless design/open mode, Default View *always* ignored
and set to one particular view.

Inexplicable? Related? Why do I begin to feel a "uninstall & reinstall IP"
coming on? ... :)

I'm happy continuing this conversation here or at InfoPathDev.com. Probably
prefer the latter. Except that it's down (again)...

Greg Collins said:
To answer your first question... the default view *IS* taken into account during preview from the designer.

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



OK, I'm starting to look into this.

Can I *please* have an answer first off to a very simple question: is
"Default View" taken into account when previewing from *design* mode?

In a test, I create a blank form and an extra view, i.e. "View 1" & "View
2". I set "View 2" as the default. I save.

Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up

I have tried every combination of getting into Open/Design mode (from IP,
from Explorer, etc. etc.) and this is always the behaviour. Open mode
respects my default, from design mode does not.

Is this or is this not expected behaviour?

(Having said this, this still doesn't solve my original problem: in that
form, it still doesn't matter what I'm viewing in design mode, or when I
open, it *always* comes up one one (non-default) viw. But let's wait on that
till I get an answer to this part...)

:

I'm stumped on this one...

Developing a form. It had one view. I introduce a second view, and set that
as default view. Works fine when accessed from any machine. Except... On my
machine (where I develop), the original view gets shown first. Believe me, I
have tried everything: resetting, resaving, rebooting, starting from either
"open" or "design" mode ... If I place a debugger statement in MS Script
OnLoad() event and run on my machine, I can see it says the *original* view
is the default, so no wonder. But where's it getting that from: I can see
quite clearly that I have set the new view as default? The only thing I can
think of is a cached copy/saved setting somewhere/somehow?

I have checked I do not have any load rules, user views etc. For now, I have
created a rule in "Form Options" for "Open behaviour" telling it to switch to
the other view, and that gets my by, but what the heck?...
 
J

jb

OK, at least we're on the same page now!

I have a "login" page which needs to come first. That's why the designer
behaviour doesn't happen to suit. Not a problem. But a couple observations
then:

1. This behaviour should be documented somewhere --- it's confusing when
it's never mentioned.

2. I don't use user roles yet, but I will. Now, where does that stand with
previewing from Design mode? I have read all the stuff. I think one has to
implement view switching for roles explicitly in code (OnLoad() ?), so maybe
you'll see that falls out OK (coz code works). But then I get confused by
this extract from MS IP documentation:

<QUOTE>
If you click Preview Form on the Standard toolbar (or use the Preview Form
Default command on the File menu) to preview your form, you'll see the view
that's associated with the default user role in the preview window,
regardless of your own role assignment. To preview other user roles, use the
Preview Form With User Role command instead.
</QUOTE>
But, left to itself (no code, and you do the Preview not by role), you
won't: you'll see (what you call) the CURRENT view? I guess maybe this
assumes code?? Dunno...

Meanwhile, next week I'll reinvestigate my "problem" form in the light of
this clarified behaviour. There, I'm still claiming with no code/rules it
just will not respect my Default View, never mind Design mode or not. I'm
tired! Have a nice weekend; thanks for all your help. :)


Greg Collins said:
Yes, I think we have been misunderstanding what you want. When I said that the default view *IS* taken into account... I was referring to the code in the OnLoad event hander, which is what I understood you were using.

Since you are stating that you are not using any view switching code/rules/etc., then what I stated in my previous post is what you should expect, namely:

"If you do not FORCE a default view, then yes, InfoPath will preview using the CURRENT view. This is the expected behavior."

It has been this way since V1. Believe it or not, this is a convenience to the form developer. When you are developing a form, you are usually working in a particular view. When you preview from the designer, you usually want to test the view you were just working on. Being forced to always "switch" back to the view you just worked on is not convenient.

I understand that in your particular situation you feel opposite to this, that it is instead an inconvenience. If this is a problem, then temporarily add an open rule to always switch to the view that you specify as the default view, and then remember to pull that open rule back out before you publish your form to others.

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



Greg,

You're mistaken. I absolutely do *not* want to set a default value in
OnLoad() code. Neither in this example, nor in my "live" problem. The whole
point is is I don't want any code at all at this point. Nor rules; nothing.
I know what you say here works, of course.

I am just asking: in design mode I pick which view is the default one,
right? I do that via the View Properties. Now you said:Remember, no code/rules. Just the View Properties setting for whichever view
is set as the Default.

So can we try again, please:

In Design mode, with no code/rules/roles, which of the following is intended
behaviour when you *preview*:

1. The view which is marked as the default comes up first (i.e. just like it
will be at runtime when filling out form); or
2. The view you happen to be looking at in the designer will come up first
(i.e. *not* the same as filling out form; the Default View property is simply
ignored)

(BTW, if it is 2., I do not find that documented *anywhere*.)

I need this clarified *before* I can tackle my "live" behaviour, in which I
am claiming the Default View --- as set by the Properties in the designer ---
for a particular form is being ignored in every and all cases.

Greg Collins said:
Your steps do not account for what you are wanting to do... namely set a default value in the OnLoad code.

If you do not FORCE a default view, then yes, InfoPath will preview using the CURRENT view. This is the expected behavior.

It sounds like you are wanting to always force Vew 1 to show up first. Let's modify your steps a bit... I tested this before replying to you last time...

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Choose Programming | On Load Event from the Tools menu.
8. In the OnLoad event handler, type 'XDocument.ViewInfos("View 1").IsDefault = true;'
9. Save your form code and close the script editor.
10. Select "Preview Form" (either from toolbar, or from "File" menu);


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



[Posted to InfoPathDev.com too.]

Please be kind enough to try something very simple for me. I feel I'm going
mad! I've now tested from scratch on another PC here, and I do *not* find
that Default View is taken into account from design mode!

Very simple steps:

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Select "Preview Form" (either from toolbar, or from "File" menu)

What do you see? I see "View 2"! You can see from "Views" pane that "View
1" is default. You can swap which is default as much as you like; but I
always get whichever one I am looking at in design mode up first. Don't you?
Same on another PC.

If you then save the file, I find the same whenever I reopen the file for
design. If I open it for fill out, the default view *does* come up.

I'd like this sorted before I tackle the "real" problem, which seems to be
worse...


jb said:
Hmmmm.... So now I technically have two problems (at least on my machine)
then:

1. Default View is *not* taken into account for me from design mode (as per
repro steps below on brand new IP form, two views, no code, nothing...)

2. On real form, reagrdless design/open mode, Default View *always* ignored
and set to one particular view.

Inexplicable? Related? Why do I begin to feel a "uninstall & reinstall IP"
coming on? ... :)

I'm happy continuing this conversation here or at InfoPathDev.com. Probably
prefer the latter. Except that it's down (again)...

:

To answer your first question... the default view *IS* taken into account during preview from the designer.

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



OK, I'm starting to look into this.

Can I *please* have an answer first off to a very simple question: is
"Default View" taken into account when previewing from *design* mode?

In a test, I create a blank form and an extra view, i.e. "View 1" & "View
2". I set "View 2" as the default. I save.

Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up

I have tried every combination of getting into Open/Design mode (from IP,
from Explorer, etc. etc.) and this is always the behaviour. Open mode
respects my default, from design mode does not.

Is this or is this not expected behaviour?

(Having said this, this still doesn't solve my original problem: in that
form, it still doesn't matter what I'm viewing in design mode, or when I
open, it *always* comes up one one (non-default) viw. But let's wait on that
till I get an answer to this part...)

:

I'm stumped on this one...

Developing a form. It had one view. I introduce a second view, and set that
as default view. Works fine when accessed from any machine. Except... On my
machine (where I develop), the original view gets shown first. Believe me, I
have tried everything: resetting, resaving, rebooting, starting from either
"open" or "design" mode ... If I place a debugger statement in MS Script
OnLoad() event and run on my machine, I can see it says the *original* view
is the default, so no wonder. But where's it getting that from: I can see
quite clearly that I have set the new view as default? The only thing I can
think of is a cached copy/saved setting somewhere/somehow?

I have checked I do not have any load rules, user views etc. For now, I have
created a rule in "Form Options" for "Open behaviour" telling it to switch to
the other view, and that gets my by, but what the heck?...
 
J

jb

OK, after exhaustive investigation, what we seem to have here is an IP bug(?).

The Question:
=============

When is a Default View not a Default View?


The Answer:
===========

A Default View is not a Default View when another view has "queryView"
property....


The Problem:
============

I have an IP .XSN file. One particular view inside it --- the very fisrt
view I designed originally --- is determined to be the default and come up
first, no matter what I set as the actual default view. This happens whether
running from Open or Design/Preview mode. (Forget anything about different
behaviour on different machines.) Note that I am *not* using any
script/code/rules/roles (deliberately).

I can delete *everything* from all the views, all the data connections
(except main), rename all the views, change the default etc. etc. and still
that view comes up first. The *only* thing which works is delete the view
completely and recreate it. Then all is well from then on.

You/Microsoft can have the XSN if you want, but see below, 'coz I don't
think it's necessary.


The Reason:
===========

Exported the Form Files and started looking/playing (coz I'm sad, and this
has been bugging me). In manifest.xsf, found this line:
<xsf:property name="queryView" type="string" value="yes"></xsf:property>
inside
<xsf:file name="view1.xsl">
<xsf:fileProperties>
...
for the offending view. Didn't find this in other XSNs which work. Deleted
the "queryView" property line. From then on, all worked fine! And, I
couldn't see any difference in behaviour anywhere...


The Solution:
=============

* What is "queryView" all about? What does it do/supposed to do?
* When/how/why did it get in there? (I only edited properly inside IP, SP-1.)
* Am I safe to delete it to get back proper behaviour?
* The only way I can delete it is via export to files & reimport; I can't
seem to get at it from inside IP?
* Is this a bug?

I'm dying to know now, coz I've spent so long...

Greg Collins said:
First off, if you are going to use roles, and there will be specific views for those roles, then you should definitely be using open rules to set the view based on the user role. DO NOT LEAVE THIS TO CHANCE! Force the user to the correct view.

The Preview with user role will only assign the role for the preview. If you want that role to have a particular view, you must set the view using open rules or the OnLoad event handler.

I'm not sure why you don't want to use rules or code to set the view. The default view is for basic forms. You are creating a more advanced form -- you should probably use open rules to set the correct view.

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



OK, at least we're on the same page now!

I have a "login" page which needs to come first. That's why the designer
behaviour doesn't happen to suit. Not a problem. But a couple observations
then:

1. This behaviour should be documented somewhere --- it's confusing when
it's never mentioned.

2. I don't use user roles yet, but I will. Now, where does that stand with
previewing from Design mode? I have read all the stuff. I think one has to
implement view switching for roles explicitly in code (OnLoad() ?), so maybe
you'll see that falls out OK (coz code works). But then I get confused by
this extract from MS IP documentation:

<QUOTE>
If you click Preview Form on the Standard toolbar (or use the Preview Form
Default command on the File menu) to preview your form, you'll see the view
that's associated with the default user role in the preview window,
regardless of your own role assignment. To preview other user roles, use the
Preview Form With User Role command instead.
</QUOTE>
But, left to itself (no code, and you do the Preview not by role), you
won't: you'll see (what you call) the CURRENT view? I guess maybe this
assumes code?? Dunno...

Meanwhile, next week I'll reinvestigate my "problem" form in the light of
this clarified behaviour. There, I'm still claiming with no code/rules it
just will not respect my Default View, never mind Design mode or not. I'm
tired! Have a nice weekend; thanks for all your help. :)


Greg Collins said:
Yes, I think we have been misunderstanding what you want. When I said that the default view *IS* taken into account... I was referring to the code in the OnLoad event hander, which is what I understood you were using.

Since you are stating that you are not using any view switching code/rules/etc., then what I stated in my previous post is what you should expect, namely:

"If you do not FORCE a default view, then yes, InfoPath will preview using the CURRENT view. This is the expected behavior."

It has been this way since V1. Believe it or not, this is a convenience to the form developer. When you are developing a form, you are usually working in a particular view. When you preview from the designer, you usually want to test the view you were just working on. Being forced to always "switch" back to the view you just worked on is not convenient.

I understand that in your particular situation you feel opposite to this, that it is instead an inconvenience. If this is a problem, then temporarily add an open rule to always switch to the view that you specify as the default view, and then remember to pull that open rule back out before you publish your form to others.

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



Greg,

You're mistaken. I absolutely do *not* want to set a default value in
OnLoad() code. Neither in this example, nor in my "live" problem. The whole
point is is I don't want any code at all at this point. Nor rules; nothing.
I know what you say here works, of course.

I am just asking: in design mode I pick which view is the default one,
right? I do that via the View Properties. Now you said:
To answer your first question... the default view *IS* taken into account during preview from the designer. whereas I had said
Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up
Remember, no code/rules. Just the View Properties setting for whichever view
is set as the Default.

So can we try again, please:

In Design mode, with no code/rules/roles, which of the following is intended
behaviour when you *preview*:

1. The view which is marked as the default comes up first (i.e. just like it
will be at runtime when filling out form); or
2. The view you happen to be looking at in the designer will come up first
(i.e. *not* the same as filling out form; the Default View property is simply
ignored)

(BTW, if it is 2., I do not find that documented *anywhere*.)

I need this clarified *before* I can tackle my "live" behaviour, in which I
am claiming the Default View --- as set by the Properties in the designer ---
for a particular form is being ignored in every and all cases.

Greg Collins said:
Your steps do not account for what you are wanting to do... namely set a default value in the OnLoad code.

If you do not FORCE a default view, then yes, InfoPath will preview using the CURRENT view. This is the expected behavior.

It sounds like you are wanting to always force Vew 1 to show up first. Let's modify your steps a bit... I tested this before replying to you last time...

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Choose Programming | On Load Event from the Tools menu.
8. In the OnLoad event handler, type 'XDocument.ViewInfos("View 1").IsDefault = true;'
9. Save your form code and close the script editor.
10. Select "Preview Form" (either from toolbar, or from "File" menu);


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



[Posted to InfoPathDev.com too.]

Please be kind enough to try something very simple for me. I feel I'm going
mad! I've now tested from scratch on another PC here, and I do *not* find
that Default View is taken into account from design mode!

Very simple steps:

1. Start IP
2. "Design a form"
3. "New blank form"
4. You're looking at "View 1". Type "View 1" onto it.
5. "Views"; "Add a new view". Name "View 2"
6. You're looking at "View 2". Type "View 2" onto it.
7. Select "Preview Form" (either from toolbar, or from "File" menu)

What do you see? I see "View 2"! You can see from "Views" pane that "View
1" is default. You can swap which is default as much as you like; but I
always get whichever one I am looking at in design mode up first. Don't you?
Same on another PC.

If you then save the file, I find the same whenever I reopen the file for
design. If I open it for fill out, the default view *does* come up.

I'd like this sorted before I tackle the "real" problem, which seems to be
worse...


:

Hmmmm.... So now I technically have two problems (at least on my machine)
then:

1. Default View is *not* taken into account for me from design mode (as per
repro steps below on brand new IP form, two views, no code, nothing...)

2. On real form, reagrdless design/open mode, Default View *always* ignored
and set to one particular view.

Inexplicable? Related? Why do I begin to feel a "uninstall & reinstall IP"
coming on? ... :)

I'm happy continuing this conversation here or at InfoPathDev.com. Probably
prefer the latter. Except that it's down (again)...

:

To answer your first question... the default view *IS* taken into account during preview from the designer.

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



OK, I'm starting to look into this.

Can I *please* have an answer first off to a very simple question: is
"Default View" taken into account when previewing from *design* mode?

In a test, I create a blank form and an extra view, i.e. "View 1" & "View
2". I set "View 2" as the default. I save.

Now, I find:
* if I "Open" form to fill out, "View 2" comes up
* if I "Design" form and preview, then whatever view I am looking at in
design mode comes up

I have tried every combination of getting into Open/Design mode (from IP,
from Explorer, etc. etc.) and this is always the behaviour. Open mode
respects my default, from design mode does not.

Is this or is this not expected behaviour?

(Having said this, this still doesn't solve my original problem: in that
form, it still doesn't matter what I'm viewing in design mode, or when I
open, it *always* comes up one one (non-default) viw. But let's wait on that
till I get an answer to this part...)

:

I'm stumped on this one...

Developing a form. It had one view. I introduce a second view, and set that
as default view. Works fine when accessed from any machine. Except... On my
machine (where I develop), the original view gets shown first. Believe me, I
have tried everything: resetting, resaving, rebooting, starting from either
"open" or "design" mode ... If I place a debugger statement in MS Script
OnLoad() event and run on my machine, I can see it says the *original* view
is the default, so no wonder. But where's it getting that from: I can see
quite clearly that I have set the new view as default? The only thing I can
think of is a cached copy/saved setting somewhere/somehow?

I have checked I do not have any load rules, user views etc. For now, I have
created a rule in "Form Options" for "Open behaviour" telling it to switch to
the other view, and that gets my by, but what the heck?...
 
J

jb

OK, after exhaustive investigation, what we seem to have here is an IP bug(?).

The Question:
=============

When is a Default View not a Default View?


The Answer:
===========

A Default View is not a Default View when another view has "queryView"
property....


The Problem:
============

I have an IP .XSN file. One particular view inside it --- the very fisrt
view I designed originally --- is determined to be the default and come up
first, no matter what I set as the actual default view. This happens whether
running from Open or Design/Preview mode. (Forget anything about different
behaviour on different machines.) Note that I am *not* using any
script/code/rules/roles (deliberately).

I can delete *everything* from all the views, all the data connections
(except main), rename all the views, change the default etc. etc. and still
that view comes up first. The *only* thing which works is delete the view
completely and recreate it. Then all is well from then on.

You/Microsoft can have the XSN if you want, but see below, 'coz I don't
think it's necessary.


The Reason:
===========

Exported the Form Files and started looking/playing (coz I'm sad, and this
has been bugging me). In manifest.xsf, found this line:
<xsf:property name="queryView" type="string" value="yes"></xsf:property>
inside
<xsf:file name="view1.xsl">
<xsf:fileProperties>
...
for the offending view. Didn't find this in other XSNs which work. Deleted
the "queryView" property line. From then on, all worked fine! And, I
couldn't see any difference in behaviour anywhere...


The Solution:
=============

* What is "queryView" all about? What does it do/supposed to do?
* When/how/why did it get in there? (I only edited properly inside IP, SP-1.)
* Am I safe to delete it to get back proper behaviour?
* The only way I can delete it is via export to files & reimport; I can't
seem to get at it from inside IP?
* Is this a bug?

I'm dying to know now, coz I've spent so long...
 

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