Enable the legacy navigation bar in system administrator > setup > client performance options.
Keep Daxing!!
Enable the legacy navigation bar in system administrator > setup > client performance options.
I got a requirement to add few fields while creating customer and those fields data should be auto populated from customer group.
[ExtensionOf(tableStr(CustTable))]
final class custTable_Extension
{
public void modifiedField(FieldId _fieldId)
{
next modifiedField(_fieldId);
switch(_fieldId)
{
case fieldNum(CustTable, CustGroup):
this.MarkGUA = CustGroup::find(this.CustGroup).MarkGUA ;
break;
}
}
}How to populate data in form with temp table data source using X++ In D365FO.
Here I am using RecordInsertList to insert data in Temp table.
[Form] Public void init() { CustTable custTable = element.args().record(); MyTempTable.linkPhysicalTableInstance(MyTempTable::getTempTable(custTable)); // add tempTable instance }
[Table method] Public static MyTemptable getTempTable(CustTable _custTable) {MYTempTable myTempTable; SalesTable salesTable; RecordInsertList tempRecordInsertList = new RecordInsertList(tableNum(MYTempTable), true, true, true, false, true, myTempTable); while select salesTable where salesTable.CustAccount == _custTable.CustAccount { myTempTable.clear(); myTempTable.CustAccount = salesTable.CustAccount; myTempTable.SalesId = salesTable.SalesId; tempRecordInsertList.add(myTempTable); } tempRecordInsertList.insertDatabase(); return myTempTable;}
MyTempTable MyTempTableLoc;
MyTempTableLoc.linkPhysicalTableInstance(MyTempTable);// temp table buffer from init method.select MyTempTableLoc where 'your condition';while select myTempLoc { // your logic }
In D365FO we get few BP warnings.
To rectify this need to use below command.
SuppressBPWarning('BPParameterNotUsed', 'False positive') Below is the example for validate method.
[FormDataSourceEventHandler(formDataSourceStr(WHSLocation, WMSLocation),
FormDataSourceEventType::ValidatingWrite),
SuppressBPWarning('BPParameterNotUsed', 'False positive')]
public static void WMSLocation_OnValidatingWrite(FormDataSource sender, FormDataSourceEventArgs e)
{
}Keep Daxing!!
Today we see to add default filter in Systemdefinedfiterpane.
For this we need to use QueryFilter class. Write the below method in form init method. I am using vend group table.
[ExtensionOf(formStr(VendGroup))] public final class TestVendGroupForm_Extension { public void init() { next init(); // QueryFilter qFilter; QueryBuildDataSource qbd = VendGroup_ds.queryBuildDataSource(); // qFilter = VendGroup_ds.query().addQueryFilter(qbd, fieldStr(VendGroup, PaymTermId)) VendGroup_ds.query().addQueryFilter(qbd, fieldStr(VendGroup, PaymTermId)); //VendGroup_ds.query().addQueryFilter(qbd, fieldStr(VendGroup, Name));
// ------Or--------------- this.addFilterPaneRanges(); } /// <summary> /// Adds ranges to filter pane. /// </summary> protected void addFilterPaneRanges() { QueryBuildDataSource inventSumQbds = InventSum_DS.query().dataSourceName(InventSum_DS.name()); SysQuery::findOrCreateRange(inventSumQbds, fieldNum(InventSum, ItemId)); QueryBuildDataSource inventTableQbds = InventTable_DS_DS.query().dataSourceName(InventTable_DS_DS.name()); SysQuery::findOrCreateRange(inventTableQbds, fieldNum(InventTable, NameAlias));
} }
Keep Daxing!!
}
Keep Daxing!!
Hi guys, Today we see how to filter the records in form using X++.
Way 1:
public QueryBuildRange qbr;//declare this variable globally. public void init()// dataSource init method { super(); qbr = this.query().dataSourceTable(tableNum(InventSite)).addRange(}
Way 2:
public void executeQuery()// dataSource { FormRun formRun = element; if (formRun.args().menuItemName() == menuItemDisplayStr(InventSite)) { this.initializeQueryFromType(); } next executeQuery(); } public void initializeQueryFromType() { QueryBuildDataSource qbDataSource; ; qbDataSource = this.query().dataSourceTable(tableNum(InventSite)); qbDataSource.clearDynalinks(); qbDataSource.addRange(fieldNum(InventSite, isActive)).value(SysQuery::value(NoYes::Yes));
}
Keep Daxing!!
We see how to add symbol icons to the grid in Dynamics 365FO. I have to add icons to the records based on qty.
For this,
1. I have created a display method on my table.
[SysClientCacheDataMethod(true)]
public display container logo()
{
ImageReference imageReference;
container image;
//imageReference = ImageReference::constructForSymbol(
this.QtyAvailable mod 2 ? 'GreenCheck' : 'RedX');
str name = this.QtyAvailable mod 2 ? 'GreenCheck' : (
this.QtyAvailable mod 3 ? 'YellowTriangle': 'RedX');
imageReference = ImageReference::constructForSymbol(name);
if (imageReference)
{
image = imageReference.pack();
}
return image;
}
2. Created new Form image control in the form grid and set up the properties for that control.
Keep Daxing!!
Hi guys, I got a requirement like I have to add my custom dialog to the standard New button. I have to change the standard new button operation and I have to add a custom one. Please refer below for the solution.
Way 1:
Way 2:
Mytable mytable;
Today we see how to add image to custom button in d365fo. I got a requirement like I have to add standard button images to my custom buttons.
For this I have set up one property. Just check below.
Image location as symbol.
Normal Image as new(required symbol name).
Refer below link for button image names.
Keep Daxing!!
Hi guys, Today we see how to Based on security roles to enable or disable the Fields in a form in D365 FO.
Please check below code.
[FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]
public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
securityrole role;
securityuserrole userrole;
boolean check;
select firstonly RecId from role
join userrole
where role.recid == userrole.securityrole
&& role.name== 'Test'
&& userrole.user == curuserid();
check = (role.recid ? true : false);
sender.object(fieldNum(SalesTable, TestField)).allowEdit(check);
}
Keep Daxing!!
Hi guys, Today we see how to get selected records from the grid in Ax 2012 using X++.
write below code in the clicked method.
void clicked()
{
CustomerTable customerTableLoc;
CustomerTable_DS.Anymarked();// check user selected the record or not.
for (customerTableLoc= getFirstSelection(CustomerTable_DS);customerTableLoc;customerTableLoc=CustomerTable_DS.getNext())
{
if (customerTableLoc.recid)
{
info(customerTableLoc.CustAccount);
}
}
}
-------------------------------------------Or-------------------------------------------------
CustomerTable customerTableLoc;
MultiSelectionHelper helper = MultiSelectionHelper::construct();
helper.parmDatasource(CustomerTable_DS);
customerTableLoc = helper.getFirst();
while (customerTableLoc.RecId)
{
info(customerTableLoc.CustAccount);
customerTableLoc = helper.getNext();
Result:
Keep Daxing!!
Hi guys ,Today we see how to enable Unbonded fields on form in ax 2012 using X++.
Here i write code in active method. Just check below example.
if(Table.Name== "Test")
{
Table_ds.object(fieldNum(Table, Field)).enabled(true);
}
------------Or-----------
Table_ds.object(fieldNum(Table, Field)).enabled(Table.Name== "Test");
Examples:
public int active()
{
int ret;
ret = super();
Table_ds.object(fieldNum(Table, Field)).enabled(Table.Name== "Test");
return ret;
}
Below example for Vendor Bank account number and name.
public int active()
{
int ret;
ret = super();
VendBankAccount_ds.object(fieldNum(VendBankAccount, AccountNum)).enabled(VendBankAccount.WorkflowStatus==WorkflowStatus::Approved || VendBankAccount.WorkflowStatus==WorkflowStatus::NotSubmitted);
VendBankAccount_ds.object(fieldNum(VendBankAccount, Name)).enabled(VendBankAccount.WorkflowStatus==WorkflowStatus::Approved || VendBankAccount.WorkflowStatus==WorkflowStatus::NotSubmitted);
return ret;
}
Keep Daxing!!
Hi guys,Today we see Filtering records in a Form in AX 2012 using X++.
Based on My Combo Box selection I have to filter the record in grid
On Form ClassDeclaration:
public class FormRun extends ObjectRun
{
QueryBuildRange qr;
}
Apply the Range on Form DataSource Init():
public void init()
{
super();
qr=this.query().dataSourceName('InventSum').addRange(fieldNum(InventSum,Itemid));
}
On Form DataSource executeQuery():
public void executeQuery()
{
qr.value(Gender.valueStr());
super();
}
IF its Enum Type Write Code on Selection change Method.
On ComboBox SelectionChange() Method Call Data Source Execute Query():
public int selectionChange()
{
int ret;
ret = super();
InventSum_ds.executeQuery();
return ret;
}
IF its String or int Type Write Code on modified Method.
public void modified()
{
int ret;
ret = super();
InventSum_ds.executeQuery();
return ret;
}
Keep Daxing!!
Hi frnds, Today we see how to restrict the user to open form , if That form is already open by other users in AX 2012.
Here I take 2 customized Forms With customized Table.In customized table UserId field is added.
And based that user id I am Implement the code.
In child form i added Init method And Close method.
Init Method:
public void init()
{
DaxTestIn daxTestIn;
Formrun formrun;
super();
daxTestIn = element.args().record();
formrun = element.args().caller();
if (!daxTestIn.User)
{
ttsBegin;
daxTestIn.User = curUserId();
daxTestIn.doUpdate();
ttsCommit;
}
else if(daxTestIn.User != curUserId())
{
throw error(strFmt("The same AccountNum(%1) is already opened by %2", daxTestIn.AccountNum,daxTestIn.user));
}
}
Close Method:
public void close()
{
DaxTestIn daxTestIn,daxTestInLoc;
Formrun formrun;
super();
daxTestIn = element.args().record();
formrun = element.args().caller();
if (daxTestIn.User)
{
ttsBegin;
select forUpdate daxTestInLoc where daxTestInLoc.RecId==daxTestIn.RecId;
daxTestInLoc.User = ' ';
daxTestInLoc.doUpdate();
ttsCommit;
}
}
Output:
If i try open 1001 record It throw that error.
That 1001 record is is already used by other user.
Keep Daxing !!
I saw other Blog they consider SessionId and they worked on sales order.Check below link for that blog.