Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Client Side Scripting - Changing the default view of related entit

1 view
Skip to first unread message

Strojin@discussions.microsoft.com Andrej Strojin

unread,
Sep 3, 2007, 10:26:01 AM9/3/07
to
I found an grat article about Changing the default view of related entities.
It is posted on http://www.stunnware.com/crm2/topic.aspx?id=JS11, where is is
writen about possiblities to change the default view of a related entity.
From there I tried to reconfigure the code that would changed the default
filter for Contracts that are on Entity account.

I tried to change the area code to areaContracts, but i does not work (:

I would also like to change the filter for Invoices, orders and Quotes to
default view as "All".

Here is the code:

/**************************************************************
* Change the default view of a view selection combo box
**************************************************************/
SetDefaultView = function(viewCombo, viewName) {

/* If the view has already been set, we don't need to do it again. */
if (viewCombo.value != viewName) {

/* Set the new view */
viewCombo.value = viewName;

/* Call FireOnChange to run the code in the appropriate HTML control.
* Without this call, only the selection in the combo box changes,
* but not the content of the grid */
viewCombo.FireOnChange();
}
}

/**************************************************************
* Event handler. Called whenever the ready state of the
* areaActivityHistoryFrame changes.
**************************************************************/
areaContracts_OnReadyStateChange = function() {

/* Waiting until the frame has finished loading */
if (this.readyState == "complete") {

/* This is the frame we're interested in */
var frame = document.frames("areaContracts");

/* And this is the view combo box */
var viewCombo = frame.document.getElementById("actualend");

/* The view combo box uses a style sheet that references a HTML
* control. We have to wait until the htc file is loaded,
* otherwise the call to FireOnChange in the SetDefaultView
* method will fail. */
if (viewCombo.readyState == "complete") {

/* If the control already has finished loading, we can
* directly set the new view. */
SetDefaultView(viewCombo, "All");
}

else {
/* Otherwise we have to register another event handler
* waiting until all of the include files used by the
* combo box are loaded as well. */
viewCombo.onreadystatechange = function() {
if (this.readyState == "complete") {
SetDefaultView(this, "All");
}
}
}
}
}

/* Load the history area. The loadArea function is defined in the CRM
* server files */
loadArea('areaActivityHistory');

/* Immediately switch back to the main form. The previous line is needed
* to initialize the history frame. This line switches back immediately,
* so you see the main application form while the history frame is loaded
* in the background. As the whole entity form is still loading, you
* shouldn't see any flicker on your screen. */
loadArea('areaForm');

/* We have to wait until the the history frame was completely loaded, so
/* we register a new event handler, calling the code above. */
document.frames("areaContracts").document.onreadystatechange =
areaContracts_OnReadyStateChange;

Does anyone have any idea about the solution that would work.

Thanks

Andrej

Peter Hale

unread,
Sep 4, 2007, 3:40:52 AM9/4/07
to
Keep trying and check you have done all the changes correctly


"Andrej Strojin" <Andrej Str...@discussions.microsoft.com> wrote in message
news:7CC283AB-CCB2-47A1...@microsoft.com...

Andrej Strojin

unread,
Sep 4, 2007, 5:20:06 AM9/4/07
to
Peter Thanks

I had done it. The corect code is:


/**************************************************************
* Change the default view of a view selection combo box
**************************************************************/
SetDefaultView = function(viewCombo, viewName) {

/* If the view has already been set, we don't need to do it again. */
if (viewCombo.value != viewName) {

/* Set the new view */
viewCombo.value = viewName;

/* Call FireOnChange to run the code in the appropriate HTML control.
* Without this call, only the selection in the combo box changes,
* but not the content of the grid */
viewCombo.FireOnChange();
}
}

/**************************************************************
* Event handler. Called whenever the ready state of the
* areaActivityHistoryFrame changes.
**************************************************************/

areaContractsFrame_OnReadyStateChange = function() {

/* Waiting until the frame has finished loading */
if (this.readyState == "complete") {

/* This is the frame we're interested in */

var frame = document.frames("areaContractsFrame");

/* And this is the view combo box */

var viewCombo = frame.document.getElementById("statecode");

/* The view combo box uses a style sheet that references a HTML
* control. We have to wait until the htc file is loaded,
* otherwise the call to FireOnChange in the SetDefaultView
* method will fail. */
if (viewCombo.readyState == "complete") {

/* If the control already has finished loading, we can
* directly set the new view. */
SetDefaultView(viewCombo, "All");
}

else {
/* Otherwise we have to register another event handler
* waiting until all of the include files used by the
* combo box are loaded as well. */
viewCombo.onreadystatechange = function() {
if (this.readyState == "complete") {
SetDefaultView(this, "All");
}
}
}
}
}

/* Load the history area. The loadArea function is defined in the CRM
* server files */

loadArea('areaContracts');

/* Immediately switch back to the main form. The previous line is needed
* to initialize the history frame. This line switches back immediately,
* so you see the main application form while the history frame is loaded
* in the background. As the whole entity form is still loading, you
* shouldn't see any flicker on your screen. */
loadArea('areaForm');

/* We have to wait until the the history frame was completely loaded, so
/* we register a new event handler, calling the code above. */

document.frames("areaContractsFrame").document.onreadystatechange =
areaContractsFrame_OnReadyStateChange;


But I still haven resolved, how to change the default filter for Invoices,
Orders and Quotes.

Andrej Strojin

unread,
Sep 4, 2007, 9:48:02 AM9/4/07
to
But I still haven resolved, how to change the default filter for Invoices,
Orders and Quotes.

Is it possible to change the default view of 4 entities at the same time,
with onLoad function?

Andrej

Michael Höhne

unread,
Sep 4, 2007, 4:29:31 PM9/4/07
to
I haven't tried that, but in theory it should work. Add four event handlers,
one for each associated view. Then call loadArea four times to initialize
each frame.

--
Michael Höhne, Microsoft Dynamics CRM MVP

Web: http://www.stunnware.com/crm2
Feed: http://www.stunnware.com/crm2/atom.aspx
Custom Lookup Dialog: http://www.stunnware.com/crm2/?area=customLookup
The JavaScript Snippets Directory:
http://www.stunnware.com/crm2/topic.aspx?id=JS13

----------------------------------------------------------

"Andrej Strojin" <Andrej...@discussions.microsoft.com> schrieb im
Newsbeitrag news:77F73413-B824-4F5E...@microsoft.com...

Andrej Strojin

unread,
Sep 5, 2007, 2:46:02 AM9/5/07
to
I had found all the necesary information for all Entities that I want to
change the default filter.

Entity - Opportunity:
The area name: areaOpps
The name of the frame containing the view combo box: areaOppsFrame
The name of the view combo box : statecode

Entity - Quotes:
The area name: areaQuotes
The name of the frame containing the view combo box:areaQuotesFrame
The name of the view combo box : statecode

Entity - Orders:
The area name: areaOrders
The name of the frame containing the view combo box: areaOrdersFrame
The name of the view combo box : statecode

Entity - Invoices:
The area name: areaInvoices
The name of the frame containing the view combo box: areaInvoicesFrame
The name of the view combo box : statecode

They all have the unique area name and the same name for the combo box.
I tried to combine the together but i haven had any luck.

Does anyone have and idea how to make this work?

Thanks
Andrej

y

unread,
Sep 21, 2007, 1:40:02 PM9/21/07
to
Great work Andrej and the CRM master Michael Höhne!

It might be silly but you could just copy the same code, change the
necessary value names (you know where) and rename the functions to something
else. What do you think?

0 new messages