SBX - Search With Button

SBX - Forum Post Title

Open Tab in USD

Microsoft Dynamics CRM Forum

Ram Prakash asked a question on 9 Nov 2018 1:40 PM

Question Status

Suggested Answer

HI All,

I have a Custom Hosted Control, i have a requirement to open URL from C# Custom Hosted Control, Could any one help me here?

Reply
Suggested Answer

Hi Ram Prakash,

This article lists the supported methods for opening a URL in Unified Service Desk (USD).

Reply
Ram Prakash responded on 11 Nov 2018 9:43 PM

Dear Adrian,

I would need to use C# Custom Hosted control to achieve this, do you have any code regarding this ?

Reply
Suggested Answer

Hi Ram Prakash,

Try this C# function.

public static void GoToUrl(string url)
{
     System.Diagnostics.Process.Start(url);
}
Reply
Ram Prakash responded on 11 Nov 2018 10:31 PM

Thanks Adrian for your reply, the Code which you have sent is opening in different page in IE, i need to open it up with in USD, can you please share me the same..

Reply
Kaustubh Hegde responded on 12 Nov 2018 1:59 AM
My Badges
Suggested Answer

Follow the below steps

1. Create an action with the following details

    * Hosted Control : <<Hosted Control to open>>

    * Action: Navigate

    * Data = url=[[url]]

2. Call this action from your C# code

Context globalContext = localSessionManager.GlobalSession.AppHost.GetContext();
globalContext["url"] = <<URL to pass>>;
localSessionManager.GlobalSession.AppHost.SetContext(globalContext);
FireRequestAction(new RequestActionEventArgs("*", "GlobalContextChange", globalContext));

Please let me know if you need any further details

Reply
Srikanth Alluri responded on 12 Nov 2018 9:12 AM
My Badges
Suggested Answer

The correct way of doing it is - Expose an Event to your Custom Hosted control (some thing like OpenURL), in your C# use FireEvent() method to fire this event. In your Configurations, add this event and add an Action call to it to open the Actual URL (in it's respective hosted control). This is #theway of doing things in USD :)

Reply
Kaustubh Hegde responded on 13 Nov 2018 8:54 AM
My Badges
Suggested Answer

Yes, exactly. This would be the best practice to implement this. If you want to follow the route Srikanth has mentioned,  below is the detailed procedure to do the same

1. Create an Event in USD

• Hosted Control = <<Name of the Custom Hosted Control>>

• Create an Action >> Hosted Control => <<Destination Hosted Control>>, Action => Navigate, data=> url=[[navigateurl]+], Associate this action to the event.

2. Call this event from Custom Hosted Control

Below is the code to call the Event created from C# custom hosted control

• var eventParameters = new Dictionary<string, string> { { " navigateurl", <<url from code>>} };

       FireEvent("<<Name of event created above>>", eventParameters);

Reply
Suggested Answer

Hi Ram Prakash,

This article lists the supported methods for opening a URL in Unified Service Desk (USD).

Reply
Suggested Answer

Hi Ram Prakash,

Try this C# function.

public static void GoToUrl(string url)
{
     System.Diagnostics.Process.Start(url);
}
Reply
Kaustubh Hegde responded on 12 Nov 2018 1:59 AM
My Badges
Suggested Answer

Follow the below steps

1. Create an action with the following details

    * Hosted Control : <<Hosted Control to open>>

    * Action: Navigate

    * Data = url=[[url]]

2. Call this action from your C# code

Context globalContext = localSessionManager.GlobalSession.AppHost.GetContext();
globalContext["url"] = <<URL to pass>>;
localSessionManager.GlobalSession.AppHost.SetContext(globalContext);
FireRequestAction(new RequestActionEventArgs("*", "GlobalContextChange", globalContext));

Please let me know if you need any further details

Reply
Srikanth Alluri responded on 12 Nov 2018 9:12 AM
My Badges
Suggested Answer

The correct way of doing it is - Expose an Event to your Custom Hosted control (some thing like OpenURL), in your C# use FireEvent() method to fire this event. In your Configurations, add this event and add an Action call to it to open the Actual URL (in it's respective hosted control). This is #theway of doing things in USD :)

Reply
Kaustubh Hegde responded on 13 Nov 2018 8:54 AM
My Badges
Suggested Answer

Yes, exactly. This would be the best practice to implement this. If you want to follow the route Srikanth has mentioned,  below is the detailed procedure to do the same

1. Create an Event in USD

• Hosted Control = <<Name of the Custom Hosted Control>>

• Create an Action >> Hosted Control => <<Destination Hosted Control>>, Action => Navigate, data=> url=[[navigateurl]+], Associate this action to the event.

2. Call this event from Custom Hosted Control

Below is the code to call the Event created from C# custom hosted control

• var eventParameters = new Dictionary<string, string> { { " navigateurl", <<url from code>>} };

       FireEvent("<<Name of event created above>>", eventParameters);

Reply

SBX - Two Col Forum

SBX - Migrated JS