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?