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 365 | Integration, Dataverse...
Answered

Javascript for Editable Grid

(0) ShareShare
ReportReport
Posted on by 1,299

Hi Experts,

I am trying to write a Javascript on the Editable grid(of opportunity product) that gets triggered onrecordselect. I want to get data from the related record and based of that manuplate the editable grid.

Ex. We have a custom field on the product called "New" which is "Yes" or "No", I want to retrieve the value of the field in the javascript so that i can manipulate the editable grid based of that.

The code that i have now is able to select or read data from the selected row which is "Opportunity product", from here how to i read "Product" (Existing product) which is a lookup- a related entity. Please help me out

function gridRowSelected(executionContext) {
var selected = executionContext.getFormContext().data.entity;
var Width= selected.attributes.getByName("as_width").getValue();
}

Thanks in advance for your response.

I have the same question (0)
  • PabloCRP Profile Picture
    1,088 on at

    Hi, Davyjones .

    where is the lookup in the editable grid?, can you add that field to the view that is using your grid?

    then you could do the same as you are doing

    data.entity.attributes.getByName("NAME_OF_THE_FIELD").getValue(), and it'll give you a array with an object as result.

    Regards.

  • Davyjones Profile Picture
    1,299 on at

    Hi Pablo,

    Thank you for your response.

    I added the lookup in the editable grid in the view and i was able to get the array, but the array did not have all the fields on the record, rather it had only the name, id and the array pointer.

    Please help.

  • Verified answer
    PabloCRP Profile Picture
    1,088 on at

    Hi, Davyjones

    You'll get just those 3 items form a lookup, for getting more data use Xrm.WebApi

    function foo(){
    var selected = executionContext.getFormContext().data.entity;
    var lookUpGrid = selected.attributes.getByName("NAME_OF_THE_FIELD").getValue()?.[0];
    if(lookUpGrid===undefined)
        return;
    Xrm.WebApi.retrieveRecord(lookUpGrid?.entityType,lookUpGrid?.id).then(
    function(res)
    {
        //your record will log with a lot of fields.
        console.log(res);
    },
    function(err)
    {
        //something gone wrong.
        console.log(err);
    });
    
    }

    Regards.

    please consider marking as an answer if it was helpful

  • Davyjones Profile Picture
    1,299 on at

    Thanks for your response and help. Appreciate it a lot

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 32

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans