History maintaining by createdby/modifiedby in history table

History maintaining by createdby/modifiedby in history table:

// + My Comment (Added by incadmin - INC-vinod - Start 24/10/2018)
void clicked()
{
    INC_DeliveryDateHistory history;
    super();

    select history where history.SalesId ==  SalesTable.SalesId;

    if(!history)
    {
        history.SalesId = SalesTable.SalesId;
        history.INC_DeliveryDate = SalesTable.INC_DeliveryDate;
        history.INC_CreatedBy = curUserId();
        history.INC_CreatedDateTime = DateTimeUtil::utcNow();
        history.insert();
        info("Delivery date is confirmed.");
    }
    else
    {
        history.SalesId = SalesTable.SalesId;
        history.INC_DeliveryDate = SalesTable.INC_DeliveryDate;
        history.INC_CreatedBy = "";
        history.INC_CreatedDateTime = str2datetime('',1);
        history.INC_ModifiedBy = curUserId();
        history.INC_ModifiedDateTime = DateTimeUtil::utcNow();
        history.insert();
        info("Modified Delivery date is confirmed.");
    }

}
// - My Comment -INC-Vinod - End

Comments

Popular posts from this blog

Getting Workflow Approvers In Dynamics AX (AX 2012)

Creating a numbersequence in form level in ax 2012

AX 2012 R3 Line by line invoicing the sales order using X++ code