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 :
Microsoft Dynamics CRM (Archived)

Dynamics 365 9.0: formContext in Entity view

(0) ShareShare
ReportReport
Posted on by 680

Hi Experts,

I have a button that creates a copy of the current open record or selected record in Entity view. We added an additional parameter to the existing function for the primaryControl. The issue is the primaryControl is null when we are on the Entity view.

How can I access primaryControl or formContext from Entity view?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Flydancer Profile Picture
    1,332 on at

    Hi LMP,

    it's not done by adding the parameter to your function only. You have to use RibbonWorkBench (Link 1) or modify the xml manually (Link 2) to pass the primaryControl to your function.

    mscrmtechie.blogspot.com/.../get-formcontext-in-ribbon-command.html

    docs.microsoft.com/.../pass-dynamics-365-data-page-parameter-ribbon-actions

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
  • LMP Profile Picture
    680 on at

    Hello Flydancer,

    We have updated the command to also pass "Crm Parameter = PrimaryControl" to our JavaScript function. It's working fine when we are on the record view but on the entity view, the PrimaryControl is null.

    Record View

    2018_2D00_12_2D00_03_5F00_14h36_5F00_29.png

    Entity View

    2018_2D00_12_2D00_03_5F00_14h36_5F00_29.png

    Below is our function

    2018_2D00_12_2D00_04_5F00_06h48_5F00_27.png

  • LMP Profile Picture
    680 on at

    Hi Ravi,

    We haven't checked this yet.

    We will check this. Thanks.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi LMP,

    You need to use Crm Parameter = SelectedControlSelectedItemReferences, this will return you the selected records from the entity view. There are examples in the links I shared above.

    Hope this helps.

  • LMP Profile Picture
    680 on at

    Hi Ravi,

    Thanks for the reply. I can retrieve the selected record on the Entity view, that is not the issue.

    I am upgrading the JavaScript code from Xrm.Page to formContext. On the one of the function, it has have the below code:

    "Xrm.Page.data.entity.getId()", and wants to change to "FORMCONTEXT.data.entity.getId".

    I added additional parameter to the function and is passing the primaryControl. On the record/form view, I can get the formContext from primaryControl but when on the Entity view, primaryControl is null (screenshot on previous post) that is why we are unable to access formContext.

    How can I access formContext from Entity view?

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You will not get form context on the entity homepage grid (Entity view) as the form context builds when you open a form.

    The method FORMCONTEXT.data.entity.getId "Returns a string representing the GUID value for the record."

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/formcontext-data-entity/getid

    Hope this helps.

  • Suggested answer
    LMP Profile Picture
    680 on at

    Hi Ravi,

    I just realized. You are absolutely right that I will never get formContext from view because there is no form! Now I think I know the solution.

    Thank you~

  • sunny1306 Profile Picture
    30 on at

    Hi

    I am not getting the GUID of the selected record in HomeGridView with the same Js. Help me with this

  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi Sunny,

    Please refer below below link:

    https://d365demystified.com/2020/06/21/pass-selected-rows-guids-to-ribbon-button-in-d365-ribbon-workbench/

    Thanks,
    Pradeep.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans