In Unified Service Desk (USD) you can use the RunXrmCommand to interact with your CRM forms.

The example I’ve given below is an action call which will expand a tab on my forms called “stats”.

Xrm.Page.ui.tabs.get("stats").setFocus();
Xrm.Page.ui.tabs.get("stats").setDisplayState("expanded");

 

I have played around with other javascript, some things I expect to work don’t!

A couple of useful examples that do work include (I will add more as I confirm what works);

Display a notification in the notification bar.

Xrm.Page.ui.setFormNotification("Stats Opened", "INFO", "1");

Give an alert.

alert("Hello Stats");

11 responses to “USD – RunXrmCommand”

  1. In the KM Control loaded in the USD, I want to filter the knowledge articles by language. I enabled the language filter. To set a language, I need to run a javascript. When I am running this in the IE developer tool console window it works. However when I run the same javascript using “RunScript” in the KB Search hosted control, nothing happens. Do you know any solution for this?

    Like

    1. You will most likely need to use RunXrmCommand not RunScript

      Like

      1. Thank you for a quick reply. I tried both RunScript and RunXrmCommand. Both does not work for “KM Control”.

        Like

      2. I understand your issue now. Sorry, I didn’t click that you wanted to do this on the km control. I guess you already know that you can use SetSearchProps to enable the filter. But as far as I can see we don’t have an option to pick the language. To run Javascript on a crm form you’d use RunXrmCommand but the KM Control is not of type CRM Page. Therefore it seems that these commands aren’t working. (I haven’t tried this myself but that would seem a likely reason.) If my assumptions are right here you may find there isn’t a simple approach do achieve this with the KM Control. Sorry.

        Like

  2. Hi Neil,
    First of all, thanks for your blog and all your articles about certifications, they are amazing!

    I have a question, is there a way to fire a workflow from an Action Call in USD? probably using a RunXrmCommand action?

    Am I going crazy over here?

    Regards!
    Jaime

    Like

    1. Thanks Jamie.

      I haven’t actually done this!

      But I would expect you can use a Process.callWorkflow command in a RunXrmCommand action.

      Have you tried that?
      If you continue to hit problems please send me a copy of your action and I will look deeper.

      Thanks

      Neil.

      Like

  3. Gerardo Flores Avatar
    Gerardo Flores

    Hello Neli,
    The V9 Client API uses the form context parameter (formContext) instead Xrm.page command (deprecated).
    How can I code Action Call script using V9 API Client for “CRM Page” hosted controls?
    If I use runXrmCommand action then how can i get that parameter? (“CRM Page” hosted controls)
    Also, by calling web resources (webResourceName) doesn’t work.

    Any Idea?

    Thanks Neil.

    Like

    1. Don’t shoot messenger … with CRM Page on classic web client I am not sure you can. You need to use unified client and take the new approach to runxrmcommands. (Which doesn’t need xrm.page) xrm.page is deprecated but I assume will always work with the classic web client. But we should expect to have to migrate to new unified client. And in that environment xrm.page is not the long term / correct approach. So you need to move away from xrm.page AND Classic web client.

      Like

Leave a comment

Trending

Website Powered by WordPress.com.