Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

Subgrid addCustomView Unified Interface On-Premise

Posted on by Microsoft Employee

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
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Subgrid addCustomView Unified Interface On-Premise

    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/

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Subgrid addCustomView Unified Interface On-Premise

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans