web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Subgrid addCustomView Unified Interface On-Premise

(0) ShareShare
ReportReport
Posted on by

I am trying to set a custom view in JavaScript for a sub-grid in an on-premise unified inteface environment. I am unable to find the right component to use the documented function.

Here is what I have:

function CreateInvoicesView(executionContext) {
formContext = executionContext.getFormContext();

// filter by invoice for the selected Lot
var lot = formContext.getAttribute("sd_lot").getValue();

if (lot != null) {

try {

var grid = formContext.getControl("Invoices");

if (grid == null) {
setTimeout(function () { CreateInvoicesView(executionContext); }, 1000);
return;
}

var viewId = "{0b3ab277-8bc0-46a4-94c0-97cdcad7660e}";
var entityName = "invoices";
var viewDisplayName = "Lot Invoices";

var lotId = lot[0].id.replace("{", "").replace("}", "");

var fetchXml =
"<fetch version='1.0' mapping='logical' output-format='xml-platform' distinct='true'>" +
"<entity name='invoice'>" +
"<attribute name='sd_posteddocumentno'/>" +
"<attribute name='name'/>" +
"<attribute name='sd_invoicedate'/>" +
"<attribute name='duedate'/>" +
"<attribute name='totalamount'/>" +
"<attribute name='sd_totalamountoutstanding'/>" +
"<filter type='or'>" +
"<condition attribute='sd_targetnavcompany' value='0' operator='ne'/>" +
"<condition attribute='sd_targetnavcompany' operator='not-null'/>" +
"</filter>" +
"<filter type='and'>" +
"<condition attribute='statecode' operator='eq' value='0'/>" +
"<condition attribute='sd_approvedcontractorinvoice' value='1' operator='ne'/>" +
"<condition attribute='sd_lot' value='" + lotId + "' operator='eq'/>" +
"</filter>" +
"<order descending='true' attribute='sd_invoicedate'/>" +
"</entity>" +
"</fetch>";

var layoutXml =
"<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" +
"<row name='result' id='invoiceid'>" +
"<cell name='sd_posteddocumentno' width='75'/>" +
"<cell name='name' width='200'/>" +
"<cell name='sd_invoicedate' width='75'/>" +
"<cell name='duedate' width='75'/>" +
"<cell name='totalamount' width='75'/>" +
"<cell name='sd_totalamountoutstanding' width='100'/>" +
"</row>" +
"</grid>";

grid.addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
} catch (e) {
alert(e);
}
}
}

I get the error: grid.addCustomView is not a function. 

Any ideas what I am doign wrong?

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Rodney Barabasz,

    addCustomView() function is only supported by Lookup control type.(It's the same as addCustomFilter function) You could not use it on subgrid.

    Reference:

    docs.microsoft.com/.../addcustomview

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hi,

    I think for subgrid you should use SetCurrentView function/Client API.

    docs.microsoft.com/.../setcurrentview

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
11manish Profile Picture

11manish 46 Super User 2026 Season 2

#2
Travis South Profile Picture

Travis South 45

#3
Ayesha Wajahat Profile Picture

Ayesha Wajahat 18

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans