web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to use the "Open Org Chart" ribbon button (LinkedInExtension) from a contact

(0) ShareShare
ReportReport
Posted on by 105

Hi guys,

The "Open Org Chart" ribbon button (LinkedInExtension)  opens up a contact hierarchy for contacts from the same account.

I can start the contact hierarchy if I set the accounts Guid and name with Ribbon Workbench on a button on the contact form:

0358.pastedimage1586249923011v1.png
But I am not able to start this hierarchy view from within a js file (ribbon button), although I load the same JS file and call the Function with the needed paramater.

What could be the issue?

Is there a way to start this contact hierarchy view from a contact, using the account of the contact?

Thanks in advance for your help!

I have the same question (0)
  • Ioannis Vrasenikis Profile Picture
    on at

    Hi ratiusv,

    could you share some screenshots on what you would expect to happen and what actually happens with your approach?

    You are most probably aware, but I would like to highlight that invoking out of the box scripts in custom button actions might stop functioning after updates get applied and contain web resource changes.

  • ratiusv Profile Picture
    105 on at

    Hi Ioannis,

    Yes, I am aware that "custom button actions might stop functioning after updates get applied and contain web resource changes." :)

    I want to be able to start the "Open Org Chart" LinkedIn Extension from the CONTACT entity.

    pastedimage1586851703367v1.png

    This "Open Org Chart" button is defaulf only available on accountt entity and I want the same functionality beeing started from the contact entity form.

    If I just copy the logic from the button on account entity to the button on the contact entity it does not work because in the JavaScript of the LinkedIn Extension the entity ID (from the account) is expected.

    From the account, the "r.prototype.ViewOrgChart" method is called, and as we can see, it depends on the entity ID (from the account, because it is started from the account form).

    All the "r.prototype.xxx" functions I mention below are functions from the LinkedIn Extension.

    r.prototype.ViewOrgChart = function () {

    if (null != Xrm.Page.data && null != Xrm.Page.data.entity) {

    var t = Xrm.Page.data.entity.getId(),

    e = Xrm.Page.data.entity.attributes.get("name") ? Xrm.Page.data.entity.attributes.get("name").getValue() : "";

    this.ValidateAndOpenOrgChart(t, e)

    }},

    Of course, if I start this method from a contact it does not work :(. Nothing happens by pressing the ribbon button.

    But, I can call the next function directly from the contact ribbon button ( and it works) , but I must  give the method a static account ID.

    This means that for any of my contacts in the whole organization, the same "OrgChart" belonging to the same accountId will be shown - this is not correct !!!!!

    r.prototype.ViewOrgChartFromGrid = function (t) {

    var e = t[0].Id,

    n = t[0].Name;

    this.ValidateAndOpenOrgChart(e, n)

    },

    So, my idea was to call this method from a custom JavaScript code that is called by a ribbon button on the contact form and dinamically pass the "parentcustomerid" as accountId.

    Unfortunately, I am able to load the Extension JS file, but the logic does not work. Nothing happens :(

    This is my code in the custom JS file that is called from the ribbon button:

    declare let Form;

    export function OpenOrgChart(primaryControl: Xrm.ExecutionContext<any>): void {
      Form = primaryControl;

      var url = Form.applicationContext.DataSource._serverUri + "/webresources/LinkedInExtensions/Account/LinkedInExtensions_Account.js";
      loadScript(url, RunCodeAfterLoadingScript);
    }

    function loadScript(url, callback) {
      // Adding the script tag to the head as suggested before
      var head = document.head;
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = url;

      // Then bind the event to the callback function.
      // There are several events for cross browser compatibility.
      script.onload = callback;

      // Fire the loading
      head.appendChild(script);
    }

    function RunCodeAfterLoadingScript() {
      var account_attr = Form.getAttribute('parentcustomerid');
      if (account_attr === null) {
        alert("Please select a valid Client for this contact first!")
        return;
      }
      var account_ref = account_attr.getValue();
      var id = account_ref[0].id;
      var name = account_ref[0].name;
      alert("id=" + id + "; name=" + name);

      LinkedInExtensions.Account.Instance.ValidateAndOpenOrgChart(id, name); - Nothing happens after calling this method - no error, no result.

    I expected here the LinkedIn extension in the picture above to be started, belonging to the provided accountId 

    }

    Best regards, 

    Sorin

  • ratiusv Profile Picture
    105 on at

    Hello all,

    maybe I have scared you with the long text I wrote....

    So, I will try to reformulate ...

    Does anyone know if it is possible to add the "Open Org Chart" button (that shows up on accounts) to a contact - to show up on a contact view or form?

    pastedimage1589357197564v3.png

    Best regards, 

    Sorin

  • Suggested answer
    ratiusv Profile Picture
    105 on at

    Hello guys,

    After I got help from colleagues, I finnaly solved this problem:

    After adding the "Open Org Chart" button on the Contact Form, I have followed these steps:

    1) I have loaded the needed Javascript ($webresource:LinkedInExtensions/Account/LinkedInExtensions_Account.js) with null as "Function Name", as I just want to load the JS file in Ribbon Workbench to be able to call the methods within this JS file in the second "CustomJavascriptAction"

    2) call a function in the ContactRibbon.js to execute a function from the previously loaded JS file

    pastedimage1590685538357v2.png

    And the function is:

    function OpenOrgChartFromForm(formContext) {
       if (formContext.getAttribute("parentcustomerid").getValue() != null) {
          var parentCustomerId = formContext.getAttribute("parentcustomerid").getValue()[0].id;
          var parentCustomerIdParameter = parentCustomerId.replace("{", "").replace("}", "");
          var parentCustomerName = formContext.getAttribute("parentcustomerid").getValue()[0].name;

          LinkedInExtensions.Account.Instance.ValidateAndOpenOrgChart(parentCustomerIdParameter, parentCustomerName);
       }
    }

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans