Hi Everyone,
I am a relatively new developer in JS Dynamics/CDS and am trying to piece together my first script.
This forum has been incredibly helpful in providing examples and other solutions and so I'm making my first
post to see if I can get help on an issue that I haven't yet seen discussed.
I am trying to do the following:
1. Load a Java Script upon loading a record in a Model Driven App
2. I want the Java Script to evaluate the records in a sub-grid on the Form
3. Based on certain conditions, set a field on the main form accordingly.
I have so far attempted to code for 1&2 but I am not seeing any activity once it loads. Can anyone spot what I am missing?
function onLoad (executionContext) { var formContext = executionContext.getFormContext(); formContext.data.process.addOnStageChange(onStageChange) } function onStageChange(executionContext) { function QC_WeightVerification(executionContext) { var formContext = executionContext.getFormContext(); // get the form Context var gridContext = formContext.getControl("Subgrid_Tracker"); // get the grid context // Perform operations on the subgrid var myRows = gridContext.getGrid().getRows(); var myRow = myRows.get(); var gridRowData = myRow.getData(); var xxx_qcweightverification = formcontext.getattribute("xxx_qcweightverification") var xxx_qcweightallowance = formcontext.getattribute("xxx_qcweightverification") var qc_weight_test = gridRowData.filter(xxx_qcweightallowance >= xxx_qcweightverification) if(qc_weight_test.isArray(emptyArray) && empty.Array.length) alert(true) else alert(false) } }