Skip to main content

Get lookup control of editable grid in Dynamics CRM 2016 using JavaScript

A look up control value of the editable grid can be captured using JavaScript. One thing to note, always check Pass execution context as the first parameter shown in below image. Without this you won't be able to work on editable grids. Editable grids doesn't work in the Xrm.Page context.

Handler properties of Editable Grid

Your javascript web resource will have following code. In code below, look up value is being checked and based upon that other controls in the grid will be disabled.

       
  
function gridDisableEstimatesOnStatusChange(executionContext)
{
     var entityObject = executionContext.getFormContext().data.entity;
     var statusValue = entityObject.attributes.getByName('##lookup control logical name##').getValue();
     if(statusValue != 0)
     {
  var estimateControl = entityObject.attributes.getByName('##control's logical name##').controls.get(0);
         estimateControl.setDisabled(true);
  // Set value of any other control
  entityObject.attributes.getByName('##control's logical name##').setValue(##value to set##);
     }
}
  
 


thanks.
p.

Comments

Popular posts from this blog

AX 7 - Get record marked and record selected on grid control in X++

Marked Records In AX, we often face a situation where we need to get the reference of those records which are marked on grid control. Using below code you can get those marked records in X++. Records marked can be seen in screenshot on the left. Array markedRecords = gridControl_DS.recordsMarked(); var lastMarkedRecord = markedRecords.lastIndex(); You will get a recId of last marked record in lastMarkedRecord. Using recordMarked() method of grid control data source, you can get an array of marked records which can be used for further iteration based on requirement. Selected Records At the same time, there is another operation called as Selected Records. When a grid control loads, a default first record is selected from the grid. To iterate through selected records, use below code. for (inv = gridControl_ds.getFirst(true) ? gridControl_ds.getFirst(true) : gridControl_ds.cursor(); inv; inv = gridControl_ds.getnext()) {    //logic here } gridControl_...

Mark Customer Transaction from X++ in AX2012

Use below code to mark customers open transaction from X++. static void MarkOpenTransaction() {     custInvoiceJour custInvoiceJour;     SalesTable  salesTable;     specTrans   specTrans;     custTrans   custTrans;     custTransOpen   custTransOpen;     TaxWithholdTrans    taxWithHoldTrans;     TaxWithhold_CustPaym taxWithhold;     CustVendOpenTransManager manager;     ExchangeRateHelper  exch;     AmountCur   totalSettleAmount;     ;     select firstOnly custInvoiceJour where custInvoiceJour.InvoiceId == '004452' ; // && _custInvoiceJour.SalesId == xml_SalesID.text();     if (custInvoiceJour)     {         ttsBegin ;  ...