Skip to main content
Content Starts Here

We've Moved!

Please note that we have moved to our New Forum site.


Ask Search:
Josh SmeatonJosh Smeaton 

How do you delay the instantiation of a View within IWS?

We have a view that we create for "primary calls" (not a consult, basically). See the code below.
 
_viewManager.ViewsByRegionName["InteractionDetailsRegion"].Insert(0,
                new ViewActivator
                    {
                        ViewType = typeof(IMyView),
                        ViewName = "MyView", 
                        ActivateView = true,
                        ActivateOrder = 1,
                        Condition = (ref object ctx) => { 
                            var primary = Helpers.IsPrimaryContact(ref ctx);
                            Log.InfoFormat("Interaction Primary? {0}", primary);
                            return primary;
                        }
                    });
But I would like to delay the view being created until the call has Established. Similarly, I'd like to not create the view during a Preview interaction, but create it once the User calls the customer.

The NotepadView works exactly how I'd like my view to work. The NotePad view isn't created until the call has established. I can't work out how to emulate this behaviour. Has anyone done something similar?
 
Best Answer chosen by Josh Smeaton
Andrew BudwillAndrew Budwill
Hi Josh,

I am not sure how to delay the instantiation in terms of seconds, but I do know how to delay the instantiation and trigger it off some other action occurring.

For example, register your view like this (possibly without a condition):
 
viewManager.ViewsByRegionName["InteractionsBundleRegion"].Add(
    new ViewActivator()
    {
     ViewType = typeof(IMyCustomControlView),
     ViewName = "MyCustomControlView",
     ActivateView = true,
     DynamicOnly = true
     });

Then, after the action occurs that you want to drive displaying your view, do the following:
 
// pay attention to hierarchy here again, BundleView is an immediate child of region MainBundleRegion
IBundleView bundleView = (IBundleView)viewManager.GetViewInRegion(this, "MainBundleRegion", "BundleView");
viewManager.InstantiateDynamicViewInRegion(bundleView, "InteractionsBundleRegion", "MyCustomControlView", "some id", this.Context);

This will allow you to dynamically show your view based on some logic occurring.  In your case you might want to examine what command chains are run when the user dials a preview record, and insert a custom command that actually displays the view (2nd block of code).

Regards,
Andrew

All Answers

Andrew BudwillAndrew Budwill
Hi Josh,

I am not sure how to delay the instantiation in terms of seconds, but I do know how to delay the instantiation and trigger it off some other action occurring.

For example, register your view like this (possibly without a condition):
 
viewManager.ViewsByRegionName["InteractionsBundleRegion"].Add(
    new ViewActivator()
    {
     ViewType = typeof(IMyCustomControlView),
     ViewName = "MyCustomControlView",
     ActivateView = true,
     DynamicOnly = true
     });

Then, after the action occurs that you want to drive displaying your view, do the following:
 
// pay attention to hierarchy here again, BundleView is an immediate child of region MainBundleRegion
IBundleView bundleView = (IBundleView)viewManager.GetViewInRegion(this, "MainBundleRegion", "BundleView");
viewManager.InstantiateDynamicViewInRegion(bundleView, "InteractionsBundleRegion", "MyCustomControlView", "some id", this.Context);

This will allow you to dynamically show your view based on some logic occurring.  In your case you might want to examine what command chains are run when the user dials a preview record, and insert a custom command that actually displays the view (2nd block of code).

Regards,
Andrew
This was selected as the best answer
Josh SmeatonJosh Smeaton
Hah, exactly what I was after, thanks. I was wondering how DynamicOnly worked. I tried to trace my way through NotepadView a few times and came up empty. I should have asked this question years ago =)