Tuesday, October 27, 2015

AX 2012:Find() method

Find Method And Exists Method

find :-
Returns a record that matches the index passed on the parameters.
All tables should have 1 find method.
static InventTable find(PurchId purchId, boolean update = false)
{
PurchTable purchTable;
;
purchTable.selectForUpdate(update);
if (purchId)
{
select firstonly purchTable
index hint purchIdx
where purchTable.PurchId == purchId;
}
return purchTable;
}

call Find method In Table level :
public void modifiedField(fieldId _fieldId)
{
;
super(_fieldId);
switch(_fieldId)
{
case fieldNum(purchline,Site) :
{
this.Site = PurchTable::find(this.PurchId).Site;
}
break;
}
}
use Find method in Form:
Form->Datasource->Field->modified()
public void modified()
{
PurchTable pt;
;
super();

PurchLine.Site = PurchTable::find(PurchLine.PurchId).Site;
// Or u can use following 
//pt = PurchTable::find(PurchLine.PurchId);
//PurchLine.Site  = pt.Name;
}
exists :-
Along with  find method, we can also have exist an exists method.
It basically works the same as the find method, exists methods returns true if a
record with the  index specified by the parameter is found.
public void modified()
{
PurchTable pt;
;
super();

PurchLine.Site = PurchTable::find(PurchLine.PurchId).Site;
// Or u can use following 
//pt = PurchTable::find(PurchLine.PurchId);
//PurchLine.Site  = pt.Name;
}

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8