Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Misbehaviour of scripts in Hub View

(0) ShareShare
ReportReport
Posted on by 940

Hi All,

The scenario is like I have 2 account form (Parent-Child account). I am creating the cases from the child account form using subgrid of case entity.

Also, I have another subgrid on the Parent account form which is used to display all the cases which are made under the related child account record.

So for this, I implement a JS code to show all the cases made under the related child account on the Parent Account Form within another Case Subgrid.

Code is given below: -

function DisplayCases() {

// get Contacts Sub grid
var accountChildCasesGrid = window.parent.document.getElementById("CasesRelatedtoSites")


// Get the ID of the current account
var rootAccountID = Xrm.Page.data.entity.getId();

// Check that the subgrid is ready
if (accountChildCasesGrid == null){
setTimeout('DisplayCases()',1000);
return;
}

// Construct FetchXML for contacts in this account and its child accounts
var fetchXml = "<fetch version='1.0' mapping='logical'>";
fetchXml += "<entity name='incident'>";
fetchXml += "<attribute name='title'/>";
fetchXml += "<attribute name='customerid'/>";
fetchXml += "<attribute name='statecode'/>";
fetchXml += "<order attribute='title' descending='false' />";
fetchXml += "<link-entity name='account' from='accountid' to='customerid' link-type='inner' >";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='accountid' operator='eq-or-under' value='" + rootAccountID + "' />";
fetchXml += "<condition attribute='accountid' operator='not-null' />";
fetchXml += "</filter>";
fetchXml += "</link-entity>";
fetchXml += "</entity>";
fetchXml += "</fetch>";

// Layout of subgrid.
var LayoutXml = "<grid name='resultset' object='8' jump='new_name' select='1' preview='1' icon='1'>" +
" <row name='result' id='new_boat'>" +
"<cell name='title' width='100' />" +
"<cell name='customerid' width='100' />" +
"<cell name='statecode' width='100' />" +

"</row>" +
"</grid>";


// make sure control is ready and set data and refresh the subgrid
if (accountChildCasesGrid.control != null){
accountChildCasesGrid.control.SetParameter("fetchXml", fetchXml);
accountChildCasesGrid.control.refresh();
}
else{
setTimeout('DisplayCases()',1000);
}
}

So problem is only that this script is working as expected in standard view but not in Hub View.

Please suggest for the same.

*This post is locked for comments

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    Kalpavruksh D365 CoE 2,545 on at
    RE: Misbehaviour of scripts in Hub View

    Hi Shakti ,

    It is not possible to apply custom fetchXml to the subgrid in a supported way.

    5025.subgrid2.jpg

    5025.subgrid2.jpg

    Read more: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/grids/gridcontrol

    Alternatively, you can create a custom grid, using a popular library DataTable JS https://datatables.net/ and data operations using WebAPI: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/online.

  • RE: Misbehaviour of scripts in Hub View

    Thank you Kalpavruksh,

    Then can you please suggest to me that which syntax I have to have used to access the subgrid control.

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    Kalpavruksh D365 CoE 2,545 on at
    RE: Misbehaviour of scripts in Hub View

    Hi Shakti,

    document.getElementById is an unsupported method but many of the developers were using it.

    Now this method has been completely blocked in new UI (Hub/UCI)

    6765.MicrosoftTeams_2D00_image.png

    Read more: docs.microsoft.com/.../use-javascript

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans