I have a custom setup dialog, which allows the user to select features.
Let's call them:
Feature A
Feature B
Once the user clicks the next button, a new dialog will open depending on what was selected.
My events look like this:
> New Dialog -> &FeatureA = 3 -> DialogA
> New Dialog -> &FeatureB = 3 -> DialogB
Obviously this is simplified, in reality there's OR clauses everywhere.
My question is why, even after changing the event order, only dialog B is ever opened, if both features are selected?
Note the second paragraph of ControlEvent Table:
The exception to note is that each control can publish a most one NewDialog or one SpawnDialog event. If you need to author multiple NewDialog and SpawnDialog control events in this table, also include conditional statements in the Condition fields that ensure at most one event is published. If multiple NewDialog and SpawnDialog control events are selected for the same control, only the event with the largest value in the Ordering column gets published when the control is activated.
You're best off giving mutually exclusive conditions to all NewDialog control events on a given control. Ordering them correctly should work, but this is easy to mess up.
I have my account entity linked to a custom entity called inspections, I only want these inspections to be created for accounts of a certain type. So when it isn't that type I want the left hand navigation to this entity to be hidden away. I've seen some code that says will hide it away, as long as you have the navID of the item.
I've had a crack at hiding it using what i thought could be the ID but it hasn't worked, so I'm wondering if anyone knows how to get this ID, or if there is another way to do this?
The code I'm using to hide the navigation is below:
var navitem = Xrm.Page.ui.navigation.items.get("nav_ts_inspection");
if (navitem != null)
{
navitem.setVisible(false);
}
Load the form
Press F12 to show IE Developer's Toolbar
From here you can use CTRL+F to search for the display name of the item you'd like to hide. This will give you a link that is generated. The Id of this element is what you need to use to show/hide the link.
As an example, you can see results of searching for 'Sub Accounts' on the Account screen for an installation I am working on at the moment. The Id can be seen and is 'navSubAct'
Changes by traversing DOM and manually hide an area is not officially supported.
Luckily if you are on CRM 2011, you can go to
Settings > Customization Or open the solution.
Select the entity > Forms. Inside the Form editor window, open the Form Properties of the entity.
Go to Display Tab and untick "Show navigation items" checkbox.
Finally do not forget to Publish your changes.
Use the relationshipname to hide folder in navigation like this:
If you have folder with the relationship name: ts_inspection
Use this for ID: navts_inspection
So otherwise the same as above, but lose the extra underscore (_) between nav and ts.
var navitem = Xrm.Page.ui.navigation.items.get("navts_inspection");
If you want to hide particular navigation section from the FORM then remove all the links from that section and publish it. That section will not be visible anymore.
If you want to just remove Navigation Pane from FORM, then go to 'Display' tab of form and mark as 'Do Not Show' and then publish it.
I have a repeat control for a domino view which displays the results from a search field.
As you type more characters into the search field the number of items in the list is reduced. If/When the the list only contains a single item I would like to open item automatically, without having to click the link.
Any ideas are appreciated.
Edit: after some very interesting responses, here are some screenshots
I have 3 elements on the page, a searchbar, a repeat control and a form:
When I start typing in the search bar, the repeat is refreshed with every keystroke:
the list is reduced, typing the next character ...
again the list is reduced, only 2 left, typing again....
Only one left, now it would be time to open the document in the form ..... without clicking the link.
I've tried several events on the page, but it seems that I could not find the one that will allow me to "select" the document and display the data in the form.
It seems that it's not as simple as I thought
Since you want to open the link automatically I don't know if I would try to base it on the getRowCount() of the repeat itself. You don't want to even get that far right? you just want to go to the single document.
I would put a function in beforePageLoad event maybe. Not totally sure which event but I'd try that first. Use SSJS and do a lookup that would basically return a collection of what the repeat would show. If the collection count = 1 then get your destination from that entry and do your redirection from there.
That what I would try at least. Interesting scenario!
Now that I see the screenshots this might be easier then you think and I have already implemented something similar on an internal application that I have built. It does rely on the fact that each entry in the list is 100% unique.
First of all you will need to bind the search field to a scoped variable and the onchange/onkeypress event will need to perform a partial refresh of a panel that contains both the list and the document portion of the page.
For the list the link on each item should set the value of the same scoped variable used in the search box and clicking the link should be set to run a partial refresh of the document area.
For the document area you will need two panels, the first panel will only display if there is no matching document and the second panel will only display if there is a matching document, you can do this in the rendered section by writing some ssjs that grabs a handle to the db/view and does a dblookup and returns either true or false if the document exists depending on panel your dealing with.
With this setup, when somebody clicks a link or fills out the searchbox the scoped variable will contain a value, the document panels will then check to see if this is a unique value in the view in the db and update themselves to either display the 'no document' panel or the 'document' panel accordingly.
You could add a evaluation script to the entry of your repeat control which checks the size of your repeat control using the method getRowCount() from the component. If this is 1 you could execute a context.redirectToPage("yourpage.xsp?id=yourid",true) this forces the current page to send a redirect request back to the browser and therefore redirects you to the correct page.
All you need to know is which xpage you need to open and which parameters you should use. But these could be retrieved from the content you are iterating over.
I am trying to work with mouseover on a particular Item in my application by using the following command
{
ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
}
On doing mouseover on a item, two subitems are displayed.
Is there any way to capture the sub items which are part of the Item by doing mouseover with which we can report that our test is pass or fail.
Please suggest.
Additional Information :
If we take example,On the StackOver flow page, If i do mouseover on my name, i get a window where i see activity, privileges, Logout and other stuff. This is really what i was looking for. Is there a way to capture the items displayed on the window on doing mouseover.
I also tried to capture the subitems with the following :
{
text=ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
puts(text.inspect)
}
On doing this "text" value is displayed as 'nil'.
My general tactic for such things is a combination of using IRB and the IE Developer tool, or Firebug.
using IRB, type out (or cut and paste) the watir statement to fire the onmouseover command to the proper element on the page.
Then have the developer tool rescan the DOM (there's a little refresh icon you can click) The use the tool to point to an element to point to one of the items in the stuff exposed by the onmouseover. Using the info from that, you can then figure out how to address those elements to get the text from the proper div, etc.
If I do that here to the info that opens up when I float the mouse over my name I can find out that it is a table of class "profile-recent-summary" Furthermore I can then look at the way the table is made up and see for example that the 'today' reputation value is in the second cell on that row.. The row also has the text 'reputation' in it.. so
browser.table(:class, 'profile-recent-summary').row(:text, /reputation/).cell(:index, 2).flash
Should flash the cell I want (index might be 1 if using firewatir or webdriver) I can then replace the .flash with something else like .text if I want to get the text from that cell (which is actually inside a link that sits in the cell)..
without seeing your code, I would 'inspect' the element that you are trying to verify and when_present (text) assert that its true
The following problem happens on both Safari and Chrome, so probably a WebKit issue.
Page A: a page that requires you to login to see, contains a form that has a type=submit button, with name=submit, and value=a
Page B: some other page
Page C: ask user to login page, contains a form with a type=submit button, with name=submit and value=c
User visits page A, then page B. Then idles and the user's login session times out. User hits back button to go back to page A. Browser redirects user to page C.
On Safari and Chrome, when C is rendered, the form on page C has the type=submit button, name=submit, but value shows up as "a".
If you reload while on page C, "c" appears as the value of the name=submit button.
The same problem appears with type=hidden input fields; when user hits back button, their values are also changed to some other value from some other form. Also, this problem also shows up w/o the redirect, with just submit then back. In this case the previous page renders with incorrect values for hidden and submit CGI variables.
So far the only fix I can come up with is use Javascript to reset the type=hidden and type=submit variable values, after page C loads, to make sure the values are correct. But that's not clean and universally applicable.
Short of WebKit fixing this error, has anyone ran into a better workaround?
Thanks.
After much digging, I found the answer to this. Well, not an answer, but why this happens. I hope this saves other people some time.
Current WebKit based browsers (as of 3/16/2010), e.g. Safari and Chrome, exhibit the following bugs. Perhaps someone can take a look. Thanks.
Bug 1: If a page A has multiple form elements F1 and F2, and the first (in order of appearance in HTML) form, F1, has autocomplete set to "off" (i.e. ), but F2 has autocomplete set to "on" (default behavior), then after navigating away from page A, and then hitting browser back button to go back to page A, F1 and F2 may be auto-completed incorrectly. In particular, if F1 and F2 both have input elements with the same name and type, say N and T (i.e. ), then when navigating back to page A using the back button, F1.N's value will be autocompleted with F2.N's value.
Bug 2: First, browser hits page A, and server returns an HTML page with form elements F1 and F2 (both forms have autocomplete set to on). Then, user navigates away from page A, and subsequently returns to page A using the browser back button. On the second visits to page A, WebKit issues another request for A to the server (this differs from FireFox's behavior, where on back button no addition request is issued to server). If the server returns a different HTML page (e.g. because user session has logged out), with form elements F3 and F4 that are different from F1 and F2, but consisting of input elements with the same name and type, then F3 and F4 will be autocompleted with F1 and F2 input element values, even for input element type hidden and submit.
WORK AROUND
Bug 1: never use autocomplete="off" unless you have this set for ALL the forms on the same HTML page.
Bug 2: case specific, no good generic solution. We found an acceptable work around by including hidden forms to make sure two versions of page A have similar forms; first version has F1, F2, F3, and second one has F1, F2', and F3, where F2' is a hidden version of F2. If we don't include F2', then the second version of page A is F1, and F3, and F3 will be auto-completed with F2's element values, even for hidden and submit elements in F3.
ANALYSIS of WebKit CODE
These two bugs occur in the same part of the code, but can probably be considered as two separate bugs. The code are in WebCore sub-directory of the WebKit code tree.
Bug 1: in Document::formElementsState, input elements that have autocomplete turned ON (checked via HTMLInputElement::saveFormControlState), have their states saved in a vector. However, in HTMLFormControlElementWithState::finishParsingChildren, every form element, regardless if autocomplete is ON or OFF, restores state from the aforementioned vector. This results in bug 1.
Bug 1 Fix: this should be a fairly straight-forward fix - finishParsingChildren should not restore state if element has autocomplete turned OFF.
Disclaimer: I don't develop on Mac. I only use it and we develop a website. I just browse the WebKit code today. Hence, I have not created or tested a patch.
Bug 2. This is much more complex.
I assume that in a design decision unrelated to autocomplete, WebKit is designed to re-fetch page A if user is using the back button to go back in history to page A.
(I'd be interested in hearing about this too)
Fundamentally, WebKit makes the incorrect assumption that the second fetch of page A results in the same HTML, or at least the same set of forms, as the first fetch. If this is not the case, then the autocomplete logic no longer produces the correct/expected behavior.
When WebKit saves state for a page, it calls Document::formElementsState, which simply creates a map of pairs, and puts each input element's name+type and value pair into the map. If two input elements in two separate forms have the same name and type, both the values are saved.
For example, say page A has forms F1 and F2, and F1 has input elements with names a1 and a2, with types t1 and t2, with values v1 and v2 respectively. F2 has input elements with names a3 and a2, with types t1 and t2, and values v3 and v4, respectively. WebKit saves the state of this page as (in JSON notiation)
{ "a1,t1" : [ v1 ], "a2,t2" : [ v2, v4 ], "a3,t1" : [ v3 ] }
If user revisits page A using the browser back button, WebKit will try to autocomplete forms on the new version of page A, fetched from the server, using the above state. If the new version of page A has exactly the same forms as the last, then everything works. If not, then WebKit produces incorrect behavior. For example, assume the second time page A is fetched, server returns just one form F3, and F3 has input elements with names a4 and a2, with types t1 and t2, then F3's a2 element will be populated with v2, saved from the previous page.
(Note: actual logic of storing state and recovering state, as used in the code, are slightly different, but the idea is the same)
This problem manifests itself on websites when user sessions may expire, and after a session expires, hitting page A may produce slightly different HTML. E.g. may give you a "please login" form, or may give you roughly the same content, but in place of a search user data form on top, a login form appears. In these cases, the visible text input element, hidden input element, and submit input elements may all have their values changed by WebKit.
Bug 2 Fix: This is difficult, because WebKit re-fetches page A when user uses the back button. If new version of page A is different from the old version, WebKit cannot easily match a form's state from old version of the page to some form, if it even exists, on the new version. You can't realistically require all forms to have the same DOM id, and even if you do, that's still not entirely correct since DOM ids are required to be unique within a HTML page, but not need to be unique across separate HTML Documents.
The only fix I can think of is this: when you save the state from the first time you visit page A, take a MD5 or SHA1 hash of the page, and store that with the input element state. When you go back to page A, only restore state if the MD5 or SHA1 hash is the same.
I'm not sure, but try to add autocomplete = 'off' to all forms.
<form .... autocomplete = 'off'>
autocomplete="off"
doesn't work for me. I found another workaround, can use text fields, hide these fields using
DIV style="display:none"
and add input_type="text" value="s" fields in the DIV tag
One solution to this is to have it reset the form when the document is loaded
function ready(fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
function resetForm() {
document.forms["myForm"].reset()
}
ready(resetForm)