Tuesday 22 October 2019

DIFFERENCE BETWEEN PRE AND POST EVENT HANDLERS IN DYNAMICS D365 AX 2012

DIFFERENCE BETWEEN PRE AND POST EVENT HANDLERS IN DYNAMICS D365 AX 2012 

Below are the dfferences.
OnValidatingField: Happen when Validating Field, sync event
OnValidatedField: happen after field is validated, async event
Validatefield(Pre): Happen before Validatefield
Validatefield(post) Happen after Validatefield

Thanks,
Vikas Mehta.

how to write validateField method in Dynamics AX, d365

validateField method in Dynamics AX, d365

 public boolean validateField(FieldId _fieldIdToCheck)
    {
        boolean ret;

        ret = super(_fieldIdToCheck);

        switch(_fieldIdToCheck)
        {
            case fieldNum(InventTable, HSNCodeTable_IN) :
                  if (this.HSNCodeTable_IN)
                {
                    ret = ret && checkFailed("@TaxGST:LabelCheck");
                }
                break;
        }
        return ret;
    }


Below is an event handler of validate field in D365
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[DataEventHandler(tableStr(InventTable), DataEventType::ValidatedField)]
public static void InventTable_onValidatedField(Common sender, DataEventArgs e)
{     
                ValidateFieldEventArgs event = e as ValidateEventArgs;
                InventTable InventTable= sender as InventTable;
                //do anything
}

Similarly we can have Posthandler for salesline or inventtable as an example.

[PostHandlerFor(tableStr(SalesLine), tableMethodStr(SalesLine, validateField))]
    public static void SalesLine_Post_validateField(XppPrePostArgs args)
    {
        SalesLine salesLine = args.getThis();
        FieldId fieldId = args.getArg("_fieldId");
        boolean ret = args.getReturnValue();

        switch(fieldId)
        {
            case fieldNum(SalesLine, LinePercent):
                if (salesLine.LinePercent > 100)
                {
                    ret = ret && checkFailed("Wrong");
                }
                break;
        }

        args.setReturnValue(ret);
    }

Thanks,
Vikas Mehta.

How to Initialize or populate data in Temporary tables in Dynamics ax D365

How to Initialize or populate data in Temporary tables in Dynamics ax D365

public void init()
{
    TempTable  tempTable;
    ;

    tempTable= element.args().record();

    super();

    TempTable_DS.setTmpData(tempTable);//the name of the temporary database 
}

thanks,
vikas Mehta.

how to get original value of a table in Dynamics D365 ,ax 2012

how to get original record of a table in Dynamics D365 ,ax 2012

Hi all,
So in order to get the original record while updating any record in a table you will need the original/previously unchanged record to compare in some scenarios.
In that case you can use the below code as shown.

    public void update()
    {
        InventTable     this_Orig           = this.orig();
      
        ttsbegin;

       super();

      
        if (this_Orig.SalesModel                       != this.SalesModel              ||
            this_Orig.SalesPriceModelBasic      != this.SalesPriceModelBasic    ||
            this_Orig.SalesContributionRatio    != this.SalesContributionRatio  ||
            this_Orig.SalesPercentMarkup        != this.SalesPercentMarkup)
        {
            InventTable::updateAutoSalesPrice(this.ItemId);
        }
        ttscommit;
    }
thanks,
Vikas Mehta.

Monday 21 October 2019

HOW TO RESET TTS ,Transaction reset ttsabort fix

how to reset TTS

static void jobResetTTS(Args _args)
{
    while (appl.ttsLevel() > 0)
    {
        info(strfmt("Level %1 aborted",appl.ttsLevel()));
        ttsAbort;

    }

}

TRY CATCH CODE IN DYNAMICS AX ,D365 ,AX 2012 CODE

TRY CATCH CODE IN DYNAMICS AX ,D365 ,AX 2012 CODE

System.Exception ex;
   try
   {
       FormletterService.Run()      
   }
   catch(Exception::CLRError)
   {
       ex = ClrInterop::getLastException();
        if (ex != null)
        {
           ex = ex.get_InnerException();
           if (ex != null)
           {
               throw error(ex.ToString());
           }
    }

}

Thanks,
Vikas Mehta.  

HOW TO GET GRID RECORDS IN DYNAMICS AX

HOW TO GET ALL THE GRID RECORDS IN DYNAMICS AX 

If you want to get the records of all the selected records in the grid on a form then write the below code in the clicked method of the form,
we can loop it for multiple records and can do any task required.

for (custInvoiceJourLoc = getFirstSelection(custInvoiceJour_ds);
custInvoiceJourLoc;
custInvoiceJourLoc = custInvoiceJour_ds.getNext())
{
// do some tasks here.

}

Thanks,
Vikas Mehta.

HOW TO GET DIMENSION FROM A RECORD

HOW TO GET DIMENSION FROM A RECORD

static void getCustomerDimension(Args _args)
{
    CustTable                         custTable = CustTable::find("Cust001");
    DimensionAttributeValueSetStorage dimStorage;
    Counter i;
      
    dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
  
    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        info(strFmt("%1 = %2", DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name,        
                               dimStorage.getDisplayValueByIndex(i))); 
    }

   

Thanks,
Vikas

Open form from Infolog Dynamics Ax 2012 Open form on message click

Dynamics Ax 2012 Open form from Infolog  
Open form on message click

SysInfoAction_FormRun    infoAction = SysInfoAction_FormRun::newFormName(formStr(CustTable));

infoAction.parmDescription("Open form Customer Details");
infoAction.parmCallerBuffer(CustTable); // automatic dynalink
info("Purchase invoice contains VAT IN. Please record TAX Invoice Number in ID Localization module after this.", "", infoAction);

Thanks,
Vikas Mehta.

Get worker name from Employee position with SQL Queries in dynamics AX 2012

 Get worker name from Employee position with SQL Queries in dynamics AX 2012

select top 1 name from DIRPARTYTABLE
inner join HcmWorker ON HcmWorker.PERSON = DIRPARTYTABLE.RECID
AND HcmWorker.RECID =
(select top 1 worker from HCMPOSITIONWORKERASSIGNMENT 
INNER JOIN HCMPOSITION ON HCMPOSITIONWORKERASSIGNMENT.POSITION =  HCMPOSITION.RECID
AND HCMPOSITION.POSITIONID = 'POS123'
where GETDATE() between HCMPOSITIONWORKERASSIGNMENT.VALIDFROM AND HCMPOSITIONWORKERASSIGNMENT.VALIDTO);


thanks,
Vikas Mehta.

GET USERNAME AND SECURITY ROLES IN DYNAMICS AX 2012

GET USERNAME AND SECURITY ROLES IN DYNAMICS AX 2012
display Notes getUserIdAndRoles()
{
    DirPerson               DirPerson;
    DirPersonUser           DirPersonUser;
    SecurityUserRole        SecurityUserRole;
    SecurityRole            SecurityRole;
    Notes                   returnNotes;
    str value;
    ;
  
    DirPerson       = DirPerson::find(this.Person);
    DirPersonUser   = DirPersonUser::findWorker(this.RecId);
    returnNotes      = strFmt("User ID : %1 \n\n ",DirPersonUser.User);
    returnNotes      = strFmt("%1Security Roles : \n",returnNotes);
    
    while select * from SecurityUserRole
        where SecurityUserRole.User == DirPersonUser.User
    join SecurityRole
        where SecurityRole.RecId == SecurityUserRole.SecurityRole
    {
        if(subStr(SecurityRole.Name,1,1) == '@')
        {
            value = SysLabel::labelId2String2(SecurityRole.Name, companyinfo::languageId());
            returnNotes = strFmt("%1 %2\n",returnNotes,value);
        }
        else
        {
            returnNotes = strFmt("%1 %2\n",returnNotes, SecurityRole.Name);
        }
    }
    
    return returnNotes;
}

REINDEX IN DYNAMICS AX D365 SCRIPT TO REINDEX TABLE ON DATABASE


REINDEX IN DYNAMICS AX D365 SCRIPT TO REINDEX TABLE ON DATABASE
DECLARE @Database VARCHAR(255)   
DECLARE @Table VARCHAR(255) 
DECLARE @cmd NVARCHAR(500) 
DECLARE @fillfactor INT
SET @fillfactor = 90
DECLARE DatabaseCursor CURSOR FOR 
SELECT name FROM master.dbo.sysdatabases  
WHERE name IN ('DATABASENAME')   ///YOUR TABLE NAME HERE
ORDER BY 1 
OPEN DatabaseCursor 
FETCH NEXT FROM DatabaseCursor INTO @Database 
WHILE @@FETCH_STATUS = 0 
BEGIN 
SET @cmd = 'DECLARE TableCursor CURSOR FOR SELECT ''['' + table_catalog + ''].['' + table_schema + ''].['' +
  table_name + '']'' as tableName FROM [' + @Database + '].INFORMATION_SCHEMA.TABLES
  WHERE table_type = ''BASE TABLE'''  
-- create table cursor 
   EXEC (@cmd) 
   OPEN TableCursor  
FETCH NEXT FROM TableCursor INTO @Table  
   WHILE @@FETCH_STATUS = 0  
   BEGIN  
Print  ('ALTER INDEX ALL ON ' + @Table)
                SET @cmd = 'ALTER INDEX ALL ON ' + @Table + ' REBUILD WITH (FILLFACTOR = ' + CONVERT(VARCHAR(3),@fillfactor) + ')'
                EXEC (@cmd)
FETCH NEXT FROM TableCursor INTO @Table  
   END  
CLOSE TableCursor  
   DEALLOCATE TableCursor 
FETCH NEXT FROM DatabaseCursor INTO @Database 
END 
CLOSE DatabaseCursor  
DEALLOCATE DatabaseCursor

HOW TO SHRINK DATABASE LOG SQL LOGS D365

HOW TO SHRINK DATABASE LOG SQL LOGS D365

Shrink database log.

USE DatabaseName;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DatabaseName
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DatabaseFileLogName, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE DatabaseName
SET RECOVERY FULL;
GO

Thanks,
Vikas Mehta

Saturday 19 October 2019

Database synchronization failed. You may have to do a full build of the package ApplicationSuite and all of its dependent packages. D365 Error

D365 synchronization Failed  Database synchronization failed. You may have to do a full build of the package ApplicationSuite and all of its dependent packages. 

There can be multiple reasons for the database synchronization failure.

1) While doing a full build if you get the sync failure then check the error messages .If you have got any error as below.
"The CREATE UNIQUE INDEX statement terminated because a duplicate key"
then this is a purely data related issue you will have to fix the data and then sync again.

2) If you get errors during Data Entity synchronization then it might be a case that you have duplicated or used the same label for an entity which is being used.
Solution : Change the label of the Entity or table.

3) In case of below error .
SqlException:Execution Timeout Expired. 
Solution : Try to do it again after restarting .
Or else you will have to check the resources being utilized and use it to best .

Thanks,
Vikas Mehta.

IIS Express service not available while debugging add to process d365

IIS Express service not available while debugging ->add to process in dynamics d365

At times while you are trying to debug a code and when you try to add iisexpress service to add the process debugger.
You do not find the service in the list.
In that case you will have to goto services and find the service world wide web and restart it .
Restarting the VS might also help in this case.

Thanks,
Vikas Mehta

The property ‘ComputedFieldMethod’ must be set with the name of a valid data entity method if ‘IsComputedField’ is set to ‘Yes’. D365 Error

D365 Error : The property ‘ComputedFieldMethod’ must be set with the name of a valid data entity method if ‘IsComputedField’ is set to ‘Yes’.


Solution :
Set the "Is Computed Field" property of the field  to No.

Thanks,
Vikas Mehta.

RUN REPORT FROM BUTTON CLICK IN AX 2012

RUN REPORT FROM BUTTON CLICK IN AX 2012 
void clicked()
{
    Args                args;
    ReportRun       reportRun;
    CustTrans       custTrans;
    ;
     select firstonly custTrans where custTrans.recid == '1231232';
    args    = new args();
    args.name(reportstr(ReportName)); // Report name to be called
    args.record(custTrans); 
    args.parm(custTrans.transID); // In case there are additional paramters..
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportRun.run();
}

Thanks,
Vikas Mehta

Make sure that SQL Server Reporting Services is configured correctly. SSRS AX 2012 ERROR

Make sure that SQL Server Reporting Services is configured correctly. Verify the Web Service URL and Report Manager URL configuration in the SQL Reporting Services Configuration Manager.

Above error is caused because the AX was not being installed with Admin rights on sql.

steps to resolve :
1) Run AX as admin.
2) In AX -> system admin module > Report server settings > validate
3) If you get succeeded , then the issue is solved.
4) In case you are still facing this issue then check the rights on the ssrs .(in case the report is deployed on different server you will need to make sure theat the rights are assigned there too).

Thanks,
Vikas Mehta.

QueryExecuting Event handler in D365

Event Handler for Query Eecuting in D365

  [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::QueryExecuting)]
    public static void SalesLineCurrencyID_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)

    {

        sender.query().dataSourceName(sender.name()).addRange(fieldnum(SalesLine,     CurrencyID)).value(queryValue('INR'));

    }

THANKS

Monday 14 October 2019

D365 FUNCTIONAL INTERVIEW QUESTIONS [UPDATED 2021]

D365 F&O FUNCTIONAL INTERVIEW QUESTIONS

Below are the general functional interview questions asked .Please note that the interview questions might vary based on the role /requirement of the functional role /module. eg.Trade and logistics consultant,functional consultant,Manufacturing,etc.
eg

Dynamics 365 Functional Interview Questions

  • Sales Process
  • Purchase Process , matching Rule 
  • Production Process(Production role)
  • Inventory posting
  • Environment setup
  • Workflows /Number sequence setup
  • Types of document creation like FDDs and approach.
  • Company setup, Financial integration overview
  • Financial Essentials,how to block transactions of any user.
  • Using Dimensions
  • General ledger
  • Chart of accounts setup
  • Ledgers, Journals and Postings
  • Ledger posting setup
  • Different documentation and their analogy
  • Inventory costing, variance posting analysis
  • Reconciliation for Inventory and Cash
  • Sales TAX Setup and Configure
  • Fixed assets overview, setup, listing and postings and transactions
  • Budgeting and Planning
  • Budget iterations with Fixed Assets
  • Bank accounts and overview of Credit card integration and options
  • Intercompany accounting transactions and postings
  • Payment authorizations workflow
  • Multi-currency, multi-language and multi-company setup
  • AR/AP Setup, Postings, Transactions
  • Vendor payments, Customers payments
  • Inventory close, Year end, Month end close activities and procedures
  • Understand Forms, Reports, Setup and Parameters for Financial flow and process
  • Cash and Bank management setup
  • Financial statements
  • Balance sheet reporting
  • Income statement and Summary & Detail statements for Payments and Cash flow
  • AR and AP reconciliation
  • Document handling and Dashboard
  • Inquiries and Reports and Functions
  • All Financial Month end close processes in Microsoft Dynamics AX
  • Business decisions using Dynamics AX Reports and Workflows and Approvals
  • DIXF Import Export process with example.and challenges
  • Advanced Inventory concepts
  • Scenario based question and provided solution.
  • Approach of Custom developments for some process.
  • Inventory valuation process
  • Monthly inventory closure procudure
  • Explain LIFO, FIFO, and standard in inventory.
  • Difference transfer order and transfer journal
  • Difference between different journals

 GENERAL QUESTIONS :

What is your role in project?

How many Dynamics implementations have you completed?

What industries do you have experience in?

Tell me about the biggest challenge you’ve faced in your recent projects and how you overcame it.

What are your strongest functional skills?

Are you just limited to a particular module or you would like to explore other areas of functional consultant also ?

Saturday 12 October 2019

how to get all datasource in form event handlers in dynamics d365

how to get all datasource in form event handlers in dynamics d365

[FormEventHandler(formStr(HcmWorkerPositions), FormEventType::Closing)]
    public static void HcmWorkerPositions_OnClosing(xFormRun sender, FormEventArgs e)
    {
        FormRun         element = sender;
        FormRun         formrun;
        FormDataSource  formDatasource;
        int             idx;
        str             name;

        formrun = element.args().caller();

        name = element.args().callerName();
//sender.dataSource(formDataSourceStr(HcmWorkerPositions, hcmWorker)); you can also try this.
        if(formrun && name == 'hcmWorker')//hcmworker is second datasource.
        {           
            for(idx=1;formrun.dataSourceCount();idx++)
            {
                if(formrun.dataSource(idx).cursor() is HcmEmploymentDetail)
                {
                    formDatasource = formrun.dataSource(idx);
                    formDatasource.research(true);
                    break;
                }
            }
        }
    }

WHAT IS METHODS IN DATA ENTITY IN D365

DATA ENTITY METHODS CALLING SEQUENCE IN D365

Data entites method calling sequence in D365FO


Here is a sequence of method’s calls during export:
1. initValue
2. validateField
3. validateWrite
4. update
4.1. doUpdate
4.1.1. persistEntity
4.1.1.1. doPersistEntity
4.1.1.1.1. initializeDataSources
4.1.1.1.1.1. initializeEntityDataSource
Note: initializeDataSource is called once for each DataSource in Entity.
4.1.1.1.2. mapEntityToDataSources
Note: initializeDataSource is called once for each DataSource in Entity.
4.1.1.1.3. saveDataSources
4.1.1.1.3.1. updateEntityDataSource
4.1.1.1.4. mapEntityToDataSource (maybe for another record)
4.1.1.1.5. saveDataSources
4.1.1.1.5.1. updateEntityDataSource for update operation and (insertEntityDataSource for insert)
4.1.1.1.5.1.1. mapDataSourceToEntity
4.1.1.1.5.1.2. doSaveDataSource
4.1.1.1.5.1.2.1. updateDataSource
4.1.1.1.5.1.2.1.1. preupInsertDataSource
4.1.1.1.5.1.2.1.1.1. validateWrite of table
Plus:
postLoad
This method is called during the export for setting the value to unmapped fields after entity is downloaded to datasource.

EXPORT:
       Entity- postLoad()
       staging - insert()
       Entity- postLoad() - depends on records

IMPORT:
       staging - postLoad()
       Entity - postLoad()
       Entity - initValue()
       Entity - validateField() - depends on no of fields
       Entity - validateWrite()
       Entity - insert() / update()
       Entity - persistEntity()
       Entity - initializeEntityDataSource()
       Entity - mapEntityToDataSource()
       Entity - insertEntityDataSource() / updateEntityDataSource()
       Entity - mapDataSourceToEntity()
       staging - postLoad()

EVENT HANDLERS IN D365

EVENT HANDLERS IN D365 

With D365 event handlers play very important and hence we need to know how and when to use them to maximum benefit.
Below are some of the codes which uses event handlers in different situation and how the form source are cached.These code needs to be return in a new class with final.
eg. final class HcmPos_Extension
{
}
if you decorate your class with the [ExtensionOf(formStr(HcmPosition ))] then you can also write the code for the table extensions
in the same class.
So let us consider the form HcmPosition .
In order to create an event handler for a method just right click and copy the event handler as shown below.

EVENT HANDLERS IN D365 ,dynamics 365 event handler,PostHandlerFor,PreHandlerFor,DataEventHandler,FormEventHandler,OnInitialized,how to event handlers,FormEventType::Initialized,pre and host handler,coc,chain of commands, event handler in d365 code,modified event in d465 prehandler,validate,update,delete,insert,formdatasource,sender,formrun

1)
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormEventHandler(formStr(HcmPosition), FormEventType::Initialized)]
public static void HcmPosition_OnInitialized(xFormRun sender, FormEventArgs e)
{     
FormDataSource hcmposition_ds = sender.dataSource(formDataSourceStr(HcmPosition, HcmPosition));

 //you can also directly specify the datasource name - > //sender.dataSource('HcmPosition');
 }
As shown in the above example you can get the datasource and do further coding as per the requirement.

 [FormEventHandler(formStr(HcmPositionMassUpdate), FormEventType::Initialized)]
    public static void HcmPositionMassUpdate_OnInitialized(xFormRun _sender, FormEventArgs _e)
    {
        // Initialize the instance of this form extension handler now that the controls exist
        FormRun positionMassUpdateForm = _sender as FormRun;
        HcmPositionMassUpdateFormEventHandler extensionInstance = positionMassUpdateForm.getExtensionInstance(classStr(HcmPositionMassUpdateFormEventHandler));
        extensionInstance.init();
    }

2) how to get the current selected record in the event handler when clicked on some button.
Below code will give you the selected record in the hcmposition variable.
You can get the form run also.
[FormControlEventHandler(formControlStr(HcmPosition, HcmPositionNewPosition), FormControlEventType::Clicked)]
        public static void HcmPositionNewPosition_OnClicked(FormControl sender, FormControlEventArgs e)
        {

            HcmPosition hcmposition = sender.formRun().dataSource(1).cursor();//hcmposition is the //primary datasource.

        FormButtonControl callerButton = sender as FormButtonControl;  //Retrieves the button
        FormRun form = sender.formRun(); //Gets the formRun

In case you want to select any other datasource you can do the following

        FormDataSource hcmWorker_ds = form.dataSource(formDataSourceStr(HcmWorker, HcmWorker)) as FormDataSource;

        FormDataSource HcmPositionDetail_ds= form.dataSource(formDataSourceStr(HcmWorker, HcmPositionDetail)) as FormDataSource;

        HcmWorker hcmWorker = hcmWorker_ds.cursor();

        //Set up args with all of the information you've retrieved     
    }

3) In order to get the formrun use the below
 FormRun formRun = sender.formRun() as FormRun;

4) In order to validate a std field you will have to use the below code.
    /// <summary>
    /// Event handler for the validated event on the BudgetPurposeType field on the HcmTmpBudgetPurposeType data source on the HcmPositionMassUpdate form.
    /// </summary>
    /// <param name="_sender">The form control raising the event.</param>
    /// <param name="_e">Args for the event.</param>
    [FormDataFieldEventHandler(formDataFieldStr(HcmPositionMassUpdate, HcmTmpBudgetPurposeType, BudgetPurposeType), FormDataFieldEventType::Validated)]
    public static void BudgetPurposeType_OnValidated(FormDataObject _sender, FormDataFieldEventArgs _e)
    {
        HcmTmpBudgetPurposeType tmpBudgetPurposeTypeLocal;
        HcmTmpBudgetPurposeType hcmTmpBudgetPurposeType = _sender.datasource().cursor();

        // Validate for duplicates.
        tmpBudgetPurposeTypeLocal.setTmpData(hcmTmpBudgetPurposeType);

        select firstonly RecId from tmpBudgetPurposeTypeLocal
                    where tmpBudgetPurposeTypeLocal.BudgetPurposeType == hcmTmpBudgetPurposeType.BudgetPurposeType
                    && tmpBudgetPurposeTypeLocal.LegalEntity == hcmTmpBudgetPurposeType.LegalEntity;

        if (tmpBudgetPurposeTypeLocal.RecId)
        {
            throw error("@Workforce:TheBudgetPurposeTypeIsAlreadyInUse");
        }
    }


3) Similarly if you want to write code on form modified or active on initialize you can use the below code
Sales Table Form --> Events --> OnActivated

 ////</summary>
     ////<param name="sender"></param>
     ////<param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]
    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        boolean     allowEdit = true;

   
        SalesTable           SalesTable     = sender.cursor();
        FormDataSource      salesTable_ds  = sender.formRun().dataSource("SalesTable");
        FormRun             element       = sender.formRun();
        FormControl         ShippingDateRequested   = element.design(0).controlName("Delivery_ShippingDateRequested");
     
        if (ShippingDateRequested    == datenull())
{
ShippingDateRequested.enabled(false);
}
else
{
ShippingDateRequested.enabled(true);
}
    }

similarly you can write pre and post event handlers as below for different tables.
 [PostHandlerFor(tableStr(InventTrans), tableMethodStr(InventTrans, AmountMst))]
    public static void InventTrans_Post_anyValidateMethod(XppPrePostArgs args)
    {
        boolean ret = args.getReturnValue();
        InventTrans  InventTrans = args.getThis() as InventTrans;
        if (InventJournalName::find(InventTrans.Qty > 0 && InventTrans.CostPrice == 0)
        {
            ret = checkFailed(strFmt("Cost Price is 0 for Line %1",InventTrans.LineNum));
        }
        args.setReturnValue(ret);
    }

Below code executes after the standardd init method of the formMethodStr(HcmPositionMassUpdate, init)
if you wan to do somthing befoore the code execution write a pre event handler
  /// <summary>
    /// Post-event handler for the init method of the HcmPositionMassUpdate form.
    /// </summary>
    /// <param name="_args">Args for the event.</param>
    [PostHandlerFor(formStr(HcmPositionMassUpdate), formMethodStr(HcmPositionMassUpdate, init))]
    public static void HcmPositionMassUpdate_Post_init(XppPrePostArgs _args)
    {
        FormRun positionMassUpdateForm = _args.getThis();

        HcmPositionMassUpdateBase positionMassUpdateBase = positionMassUpdateForm.parmPositionMassUpdateBase();
        Args args = positionMassUpdateBase.parmFormArgs();

        if (args.record() && args.record().TableId == tableNum(HcmPositionForecastScenario))
        {
            HcmPositionMassUpdateFormEventHandler::disableFinancialDimensionTab(args, positionMassUpdateForm);
        }
    }


 [DataEventHandler(tableStr(HcmPositionWorkerAssignment), DataEventType::Deleted)]
    public static void HcmPositionWorkerAssignment_onDeleted(Common _sender, DataEventArgs _e)
    {
        HcmWorkerHelper::getDepartmentRecIdsCacheClear();
    }


    [DataEventHandler(tableStr(HcmPositionWorkerAssignment), DataEventType::Inserted)]
    public static void HcmPositionWorkerAssignment_onInserted(Common _sender, DataEventArgs _e)
    {
        HcmPositionWorkerAssignment positionWorkerAssignment = _sender as HcmPositionWorkerAssignment;

        PayrollWorkerTaxRegion::refreshTaxRegionsForWorkerAtPosition(positionWorkerAssignment.Worker, positionWorkerAssignment.Position);
    }

In case there are some changes which needs to be done in a standard method in between the code.
    /// <summary>
     /// </summary>
    public void initForm()
    {
        next initForm();
        //do something here.
    }

Thanks,
Vikas Mehta.

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...