Search code examples
javascriptdynamics-crmdynamics-crm-2011javascript-objectscrm

Copy Data from one entity subgrid to another entity subgrid


We have a Dynamics CRM 2011 of Microsoft. In my Opportunity entity, I enter another entity data named special services.

Every Opportunity can have multiple special services, so Opportunity has 1:N relation with special services (opportunity as primary entity) We all know that Opportunity has 1:N relation with Quote and also Order, And Quote to Order has 1:N relation.

Now I want to display special services data I entered in Opportunity entity (same data entered) in Quote and Order Form via subgrid.(in onload of the page or onclick of saving data in opportunity)

It cannot be done with relations and also with quick view form since CRM 2011 does not support quick view form.

I must write a JavaScript for this purpose. I know how to insert JavaScript written into the form via this link.

But Can anybody give a sample like this? And guide me via guide line?


Solution

  • Native Subgrid without direct relationship is not feasible.

    If it’s just for display purpose, Add a HTML web resource that shows list of special services, you have to query the related special services filtered by parent opportunity to bind the data to HTML <table> <tr> <td> elements. Embed it in whatever entity you want by passing opportunity Id to filter. Read more

    Another option is like discussed in community thread to design an opportunity form only with required subgrid & use that form in HTML webresource by entity form url.

    Update:

    I just took this as a challenge, this needs a lot of efforts to complete it. Still not 100% & look clumsy. I know this is not intended usage & I won't recommend this. May be you can give a <a href> link with the below url & user can open the form like window.open & see this indirect list.

    You have to pass opptyid as querystring to HTML (or read from parent page) & then bind the built url to IFRAME within HTML web resource, NOT IFRAME in CRM form.

    Displaying an entity form within an IFrame embedded in another entity form is not supported.

    https://testvanilla.crm.dynamics.com/main.aspx?etn=opportunity&pagetype=entityrecord&id=%7B0B98C88E-C147-E811-A95F-000D3A1A9FA9%7D&extraqs=formid%3dD7C8AF17-9076-44AF-A64C-7E94396CECE0
    

    Sub-grid of orders added in Opportunity form, then the above url is composed & given as IFRAME URL. IFRAME is in HTML web resource, HTML page is added in Order form. So Order form showing Opportunity form with related Orders.

    enter image description here