Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: MJaskowski on February 25, 2020, 08:54:20 PM

Title: Create/add own button to existing view.
Post by: MJaskowski on February 25, 2020, 08:54:20 PM
Hello everyone,

I have question about create/add new button to existing view. Is it possible?

I want add button programatically to ContactInfoHistoryMultiRegion and exactly to ContactInformationView -> DockPanelContactHistoryContent -> Toolbar_Copy. I can't access to it and I don't know how to bite it. Did you have similar case?

Thank you for all tips.

Regards
Matt
Title: Re: Create/add own button to existing view.
Post by: cavagnaro on February 26, 2020, 11:11:48 AM
Check WDE samples. There is a Button sample.


Enviado de meu SM-N9600 usando o Tapatalk

Title: Re: Create/add own button to existing view.
Post by: MJaskowski on February 26, 2020, 11:31:09 AM
Hello cavagnaro,

thank you for answer. I know sample with button, I hope we talk about the same sample - I can create buttton in my NEW/OWN view, for example to ToolbarWorkplaceRegion I add new tab with button, right?

But my question is about existing view created default in WDE and more precisly I'm talking about Contacts History Tab. Or maybe I misunderstood you? Could you expand your thought?
Title: Re: Create/add own button to existing view.
Post by: cavagnaro on February 26, 2020, 11:33:05 AM
Yeah, same, just get the View name, also at Documentation, and elaborate into that.


Enviado de meu SM-N9600 usando o Tapatalk

Title: Re: Create/add own button to existing view.
Post by: MJaskowski on February 26, 2020, 04:03:33 PM
Cavagnaro,

I suppose to do something wrong or I don't know about any method. I found where is my problem, I'm adding new ViewActivator to ContactTabBottomHistoryMultiRegion but this region doesn't exist yet when ExtensionModule do Initialize() method.

[code]
public void Initialize()
{           
    container.RegisterType<IMyView, MyView>();
    container.RegisterType<IMyViewModel, MyViewModel>();
}

[/code]

then I made viewEventManager.Subscribe(CheckingEvent) which raise event after select email in ContactHistoryView

[code]

private void CheckingEvent(object obj)
        {
            string loadedAction = (obj as GenericEvent).Action[0].Action as string;
            ViewActivator toolbarContainer = null;

            if (loadedAction == "LoadInteractionInformation")
            {
                foreach (ViewActivator view in viewManager.ViewsByRegionName["ContactInfoHistoryMultiRegion"])
                {             
                    if (view.ViewName == "ContactInformationView")
                    {
                        viewManager.ViewsByRegionName["ContactTabBottomHistoryMultiRegion"].Add(
                              new ViewActivator()
                              {
                                  ViewType = typeof(IMyView),
                                  ViewName = "MyView",
                                  ActivateView = true
                              }
                        );                     
                        break;
                    }
                }
            }           
        }

[/code]

ViewActivator correctly add to region but unfortunately I don't see result. If I will add the same view to eg. ToolbarWorkplaceRegion, I see my view. I can't catch what is point.

Should I do it any other way?






Title: Re: Create/add own button to existing view.
Post by: Kubig on February 26, 2020, 04:11:08 PM
I do not see any reason for iterating the existing view. You can directly add your custom view into existing region through the ViewManager. You just need to load your module after the ContactModule is loaded, thus why you cannot insert view right now as you trying to insert it so early.

I use ContactTabBottomHistoryMultiRegion region is several projects and never have encountered any issue on that.
Title: Re: Create/add own button to existing view.
Post by: MJaskowski on February 26, 2020, 04:58:45 PM
My guess is I try too early to load my view that's why I made own event but this is wrong way. Did you do the same way or do you load view by other method? I can't catch where I am wrong.
Any keywords?

If I add ViewActivator by own event (when I have and I see ContactInfoHistoryMultiRegion region) then my view isn't visible, should I use any method or something yet?
Title: Re: Create/add own button to existing view.
Post by: MJaskowski on February 26, 2020, 08:37:13 PM
[quote] You just need to load your module after the ContactModule is loaded [/quote]

How can I catch it? By event? Could you expand thought?


Title: Re: Create/add own button to existing view.
Post by: PeteHoyle on February 27, 2020, 03:08:45 PM
Hi Matt,

In initialize method try using the viewManager.AddViewsToRegion method, then you don't need to wait for the region to already exist:


[code]            viewManager.AddViewsToRegion("ContactTabBottomHistoryMultiRegion", new List<ViewActivator>() {
                new ViewActivator()
                {
                    ViewType = typeof(ICancelRecordView),
                ViewName = "MyView",
                ActivateView = true,
                ActivateOrder = 30
                }

            });[/code]
Title: Re: Create/add own button to existing view.
Post by: MJaskowski on February 27, 2020, 03:39:02 PM
Pete!

You are an amazing guy! Thank you so much. Such a small change, and allowed me to do it the way I wanted. I understand that the AddViewsToRegion method creates a non-existent region? Something like a placeholder?

Thank you for your knowledge, again!


Matt
Title: Re: Create/add own button to existing view.
Post by: cavagnaro on February 27, 2020, 04:03:38 PM
Pete is THE guy [emoji41]

Enviado de meu SM-N9600 usando o Tapatalk

Title: Re: Create/add own button to existing view.
Post by: Kubig on March 02, 2020, 12:05:36 PM
Honestly, I am using both approaches (using AddViewsToRegion and ViewsByRegionName methods) and never have encountered issue with instanting custom view/part. I suppose there might be another issue that causes your custom part is not visible at all.
Title: Re: Create/add own button to existing view.
Post by: MJaskowski on March 03, 2020, 12:43:08 PM
I don't know why the .Add () method for viewManager did not work for the region "ContactTabBottomHistoryMultiRegion". I checked the "ToolbarWorksheetRegion" region and it works fine.

The .AddViewsToRegion () method works well in both cases. Everything is located in the main module Initialize() loaded at startup (the same as ExtensionSampleModule). Maybe it's a bug? Have I implemented something bad maybe? But I didn't create something special, so I don't think so. Any idea what could I check?
Title: Re: Create/add own button to existing view.
Post by: Kubig on March 03, 2020, 02:18:05 PM
Which version of IWS/WDE are you using?
Title: Re: Create/add own button to existing view.
Post by: MJaskowski on March 03, 2020, 02:22:20 PM
WDE 8.5.127.06
Title: Re: Create/add own button to existing view.
Post by: hsujdik on March 04, 2020, 03:42:19 PM
Include this parameter in your ViewActivator:
[code]
CreateNewRegionManager = true
[/code]

Also check how the option interaction-workspace\views.ContactTabBottomHistoryMultiRegion.activate-order is set on your WDE application object
Title: Re: Create/add own button to existing view.
Post by: MJaskowski on March 12, 2020, 08:55:21 AM
Hello,

Parameter CreateNewRegionManager has been changed on true, that was my first think about it but didn't change anything. If we talk about "interaction-workspace\views.ContactTabBottomHistoryMultiRegion.activate-order" parameter I guess we talk about CME options? If yes I checked it also and this doesn't help me, of course I added view likewise 3 other (standard) views. This did not make my view work. Of course, ordering works correctly.

Title: Re: Create/add own button to existing view.
Post by: Janis on November 15, 2021, 09:47:12 PM
Just in case if someone found this valuable topic like me today. There is one more easy workaround. Like Kubig said, we just have to register our view after ContactsModule is loaded. We can achieve this by choosing right task in the .module-config file:

[code]<task name="InteractionWorkspace.Contacts.canUse" modulesToLoad="CustomTabModule" />[/code]

Many thanks to all participiants!