The bank reconciliation should be post on 12/10/2017 but user has wrongly posted or reconciled on 12/11/2017. Then Please run the below code which will fix the issue:
//To update the bank reconcile date of the reconcile record and its transactions.
static void UpdateDate(Args _args)
{
BankAccountStatement bankAccountStatement, bankAccountStmtUpdate;
BankAccountTrans bankAccountTrans;
select RecId, AccountId from bankAccountStatement
where bankAccountStatement.AccountId == "ABC_CD" &&
bankAccountStatement.AccountStatementDate == str2Date("12/11/2017",123) &&
bankAccountStatement.AccountStatementNum == "20171012_ABC";
if(bankAccountStatement.RecId)
{
ttsBegin;
update_recordSet bankAccountStmtUpdate
setting AccountStatementDate = str2Date("12/10/2017",123)
where bankAccountStmtUpdate.RecId == bankAccountStatement.RecId;
update_recordSet bankAccountTrans
setting AccountStatementDate = str2Date("12/10/2017",123)
where bankAccountTrans.AccountId == bankAccountStatement.AccountId &&
bankAccountTrans.AccountStatement == bankAccountStatement.AccountStatementNum;
ttsCommit;
}
}
Monday, October 30, 2017
Friday, September 22, 2017
How to Display the Form With Different Colors For a Particular Control Value or Rows Color in Ax 2012
Description:-
Record
color coding can be easily achieved by overriding the displayOption method on
the form data source and writing the certain color code statements based on the
required conditions in AX.
It is
not possible with the list page as you cannot override the displayOption method
on the query data source used to show data on list page grid, neither this can
be done in the ListPageInteraction class.
We can
use an alternative to fulfil our requirement, in which we can set an indicator
on the first column of the grid of the list page.This indicator can be the
colourful small icon images. Which can be returned by display method of that
particular table based on the conditions.
You
need in sometimes to colorize specific rows with different color to do anything
in your business rule.Sometimes,during development and test we often switch
between different companies in our installation. To not mistaken us, so we
always make changes in the correct one, we made this small change in the code.
With different background-colours.
Here’s
some tips on how to color Grid Cells / rows in DAX. I’ve used the Custom table
form as an example. The code must be placed in the displayOption () method of
the DataSource.
Step 1: Create Table Name it
“A_PurchaseOrder”. And Insert Filed in Table.
1. Expand
AOT Node.
2. Open Data Dictionary Node.
3. Select Tables and right Click Select New Table.
4. Name it “A_PurchaseOrder”.
5. Now open table in Insert Some Data in A_PurchaseOrdertable.
2. Open Data Dictionary Node.
3. Select Tables and right Click Select New Table.
4. Name it “A_PurchaseOrder”.
5. Now open table in Insert Some Data in A_PurchaseOrdertable.
Step 2: Now Create Form and Name it
“A_DisplayOptionForm”. And Add List box and StringEdit Controls in Design Node.
1. Expand
AOT Node.
2. Select Form Node and Right Click Select New Form and Name it “A_DisplayOptionForm”.
3. Now Drag and Drop Table in Form DataSource.
4. Design your Form like below.
2. Select Form Node and Right Click Select New Form and Name it “A_DisplayOptionForm”.
3. Now Drag and Drop Table in Form DataSource.
4. Design your Form like below.
Step 3: Now set declare variable
backcolor in ClassDeclaration.
public class FormRun extends ObjectRun
{
int backColor;
}
Now Generate Form init Method and Set backcolor for when form open first time.
public void init()
{
super();
backColor = WinAPI::RGB2int( 0,255,0 );
}
Now generate button click method and code for selecting color and clear selected previous color of rows/cells color in form grid.
void clicked()
{
Common
common;
container c;
;
c = WinAPI::chooseColor(this.hWnd(),0,0,0,NULL);
if (conlen(c))
{
backColor = WinAPI::RGB2int( conpeek(c,1), conpeek(c,2), conpeek(c,3) );
// Clear the display options for the
once which allready has been set.
for (common =
A_PurchaseOrder_ds.getFirst(); common; common = A_PurchaseOrder_ds.getNext())
{
A_PurchaseOrder_ds.clearDisplayOption( common );
}
A_PurchaseOrder_ds.refreshEx(-1);
}
super();
}
Here we will use Conpeek for selecting color RGB value and store in Container for setting in cells/rows. Using the clearDisplayOption () method of DataSource we will clear Previous selected color.
Now
override DataSource DisplayOption method and code here for setting color for
rows/cells. First of all change in method where Common _record to your
datasourcename _objectname. For getting data from DataSource when first time
form open for selecting record from DataSource.
Otherwise
we cannot set color on each rows/cells in grid.
Now
whatever you want to put condition you can put in displayOption method for
changing rows/cells color. Here i have set many Condition for Changing Color
using if, if else if, Switch Case through.
public void displayOption(A_PurchaseOrder _PO,
FormRowDisplayOption _options)
{
//Using if elseif Condition
//if (_PO.Purchase_Date
//{
//_options.backColor(backColor);
//_options.affectedElementsByControl(A_PurchaseOrder_Purchase_Date.id());
//}
//Using if elseif Condition
//if (_PO.Purchase_Amount<3000 span="">3000>
//{
//_options.backColor(backColor);
//_options.affectedElementsByControl(A_PurchaseOrder_Purchase_Amount.id());
//}
//else if
(_PO.Purchase_Amount>5000 )
//{
//_options.backColor(8421631);
//_options.affectedElementsByControl(A_PurchaseOrder_Purchase_Amount.id());
//}
//Using SwitchCase Condition PO_Status is BasEnum Value
Switch(_PO.Status)
{
Case PO_Status::Close:
_options.backColor(backColor); //Light Yellow
_options.affectedElementsByControl(A_PurchaseOrder_Status.id());
Break;
}
//set legalentity for color
//Change property of your DataSource
CrossCompanyAutoQuery to Yes
//for Getting Other Company Data in
Current Company
//if (_PO.dataAreaId
=="cec")
//{
//_options.backColor(backColor);
//_options.affectedElementsByControl(A_PurchaseOrder_dataAreaId.id());
//}
super(_PO, _options);
}
For changing rows color I have used.
_options.backColor(backColor);
For changing text color you can use.
_options.textColor(12582912); //Blue
If you want to Change particular cell color then you have to set auto declare property to Yes for that control. For changing cell color.
_options.affectedElementsByControl(A_PurchaseOrder_Purchase_Amount.id());
If you want to Change particular cell color then you have to set auto declare property to Yes for that control. For changing particular cells text or cell color you can use.
_options.backColor(backColor);
_options.affectedElementsByControl(A_PurchaseOrder_Purchase_Date.id());
Friday, June 9, 2017
AX 7. Process(update/post opertion) the data after Data Entity import.
It’s a common requirement to perform post actions on records that are imported by Data Entity, for example to invoice created sales order or to post created journal.
To do this we need to add a new method postTargetProcess() to our Data Entity. This method is automatically called by the DMFEntityWriter class in the end of processRecords() method when all records are transferred from staging to target. It is not available from override method drop down on Data Entity because it is static and is called via reflection.
To do this we need to add a new method postTargetProcess() to our Data Entity. This method is automatically called by the DMFEntityWriter class in the end of processRecords() method when all records are transferred from staging to target. It is not available from override method drop down on Data Entity because it is static and is called via reflection.
///Please note that it can be done only in data management scenarios but not via OData because OData updates\inserts records row by row and there is no post event\method to use./// /// The definition group that should be processed. /// public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution) { //check if import job is finished if (_dmfDefinitionGroupExecution.StagingStatus == DMFBatchJobStatus::Finished) { MyStaging myStaging; //select all staging records that were processed by current execution job without errors. while select myStaging where myStaging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup && myStaging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId && myStaging.TransferStatus == DMFTransferStatus::Completed { //here you can find newly created records and update\post them. } } }
Friday, February 10, 2017
Dynamics 365 - Table Extension Predefined Method() and Userdefined Method():
public static class SalesLine_Extension
{
[PostHandlerFor(tableStr(SalesLine), tableMethodStr(SalesLine, insert))]
public static void SalesLine_Post_insert(XppPrePostArgs args)
{
SalesLine saleslineLoc;
FormDataSource salesFormDataSource;
saleslineLoc = args.getthis();
if(saleslineLoc.SalesId)
{
Info("SalesID existed");
}
salesFormDataSource = FormDataUtil::getFormDataSource(saleslineLoc);
if(salesFormDataSource)
{
salesFormDataSource.research(true);
}
}
public static void updateDefaultWarehouse(SalesLine _salesLine)
{
InventTable inventTable;
;
inventTable = InventTable::find(_salesLine.ItemId);
}
[DataEventHandler(tableStr(SalesLine), DataEventType::ModifiedFieldValue)]
public static void SalesLine_onModifiedFieldValue(Common sender, DataEventArgs e)
{
SalesLine salesLineLocal = sender;
Table table1;
if(salesLineLocal.SalesId)
{
ttsbegin;
table1.OrderNumber = salesLineLocal.SalesId;
table1.SalesType = salesLineLocal.SalesType;
table1.ItemId = salesLineLocal.ItemId;
table1.insert();
ttscommit;
}
}
[PostHandlerFor(tableStr(SalesLine), tableMethodStr(SalesLine, update))]
public static void SalesLine_Post_update(XppPrePostArgs args)
{
SalesLine salesLineLocal;
SalesTable salesTable;
salesLineLocal = args.getthis();
ttsbegin;
salesTable = salesTable::find(salesLineLocal.SalesId, true);
if (salesTable)
{
salesTable.FieldId= SalesTable_Extension::MethodName(salesTable);
salesTable.update();
}
ttscommit;
}
[PostHandlerFor(tableStr(SalesLine), tableMethodStr(SalesLine, modifiedField))]
public static void SalesLine_Post_modifiedField(XppPrePostArgs args)
{
FieldId fieldId = args.getArg('_fieldId');
SalesLine salesLine = args.getThis();
switch (fieldId)
{
case fieldNum(SalesLine, NewItemNumber):
if (salesLine.NewItemNumber)
{
ItemId itemId = salesLine.ItemId;
Info(strfmt("%1, " ItemId"));
}
break;
}
}
[PostHandlerFor(tableStr(SalesLine), tableMethodStr(SalesLine, delete))]
public static void SalesLine_Post_delete(XppPrePostArgs args)
{
SalesLine salesLine;
TableName tableName;
Args _args = new Args();
salesLine= args.getthis();
if(salesLine.RecId)
{
ttsbegin;
delete_from tableName
where tableName.OrderNumber == salesLine.SalesId
&& tableName.ItemId == salesLine.ItemId
&& tableName.LineNum == salesLine.LineNum;
ttscommit;
}
}
Subscribe to:
Posts (Atom)