title: How to get formContext in Ribbon command of Dynamics 365 9.0
body: <p>In Dynamics 365 9.0 there was quite a big change regarding how to access form attributes and controls - instead of <code>Xrm.Page</code> namespace, we should pass <code>executionContext</code> to a function and get <code>formContext</code> using <code>getFormContext()</code> function. This is working fine and I had never a problem with using this approach.</p>
  
  <p>However I did not figured out yet how to properly access <code>formContext</code> in functions that are called from Ribbon. The documentation says that this should be really straightforward:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/customize-dev/pass-dynamics-365-data-page-parameter-ribbon-actions" rel="noreferrer">https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/customize-dev/pass-dynamics-365-data-page-parameter-ribbon-actions</a></p>
  
  <pre><code>function myFunction(executionContext) {
      var formContext = executionContext.getFormContext();
      var focusFieldValue = formContext.ui.controls.get(PrimaryControlId).getAttribute().getValue();
  }
  </code></pre>
  
  <p>But it does not say how to pass <code>executionContext</code> to Ribbon function. In normal functions there is a checkbox <em>"Pass execution context as first parameter"</em> but what about Ribbon functions? There are parameters that we can pass into these functions, but they are simply GUID of selected records, or type of selected record or even a list of objects but I could not find in documentation, if there is a parameter equal to <code>executionContext</code>. Has anybody already solved this problem?</p>
  
  <p>Also I know that I can use Xrm.Page and it will work (for now at least...) but I would like to know, how it can be done using the latest guidelines in version 9.0</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>As per Scott's suggestion and <a href="https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming#some-client-apis-are-deprecated" rel="noreferrer">this article</a> i passed PrimaryControl to my Ribbon command but unfortunately, the argument is of type <code>Mscrm.FormControlLite</code> and it does not have <code>getAttribute</code> function or any function that would allow to access the formContext (at least I don't see anything useful). Some screenshot from Developer tools:
  <a href="https://i.stack.imgur.com/NadlW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NadlW.png" alt="enter image description here"></a></p>
  
  <p>So it looks like a form representation of some kind, but is probably not related to formContext (I assume that if a Ribbon would be called from a list of records, this item can be of type of grid or something like that)</p>