preloader-matrix

Alfasith

DateTime Handlings in AX 2012 / D365

static void AlfTimeAdd(Args _args)
{
    TransDateTime    d = DateTimeUtil::getSystemDateTime();
    TransDate       d3 = today();
    TransDateTime    d1,d2;
    ;
    print d;
    print d3;
    d1 = DateTimeUtil::addHours(d,4); // To add 4 hours from current time
 
    print d1;
    d2 = Datetimeutil::newDateTime(d3,7.5*60*60); // I need today 7.30 Am
    print d2;
 
    print DateTimeUtil::addHours(d,4);
    print DateTimeUtil::addDays(d,4);
    print DateTimeUtil::addMinutes(d,4);
    print DateTimeUtil::addMonths(d,4);
    print DateTimeUtil::addYears(d,4);
     
    pause;
}

X++ Code to handle workflow event hander for current record

Hi

public void changeRequested(WorkflowElementEventArgs  _workflowElementEventArgs)
{
    ttsbegin;

    DpayWorkerReqTable::findRecId(_workflowElementEventArgs.parmWorkflowContext()
.parmRecId(), true));
    DpayWorkerReqTable.Status = DpayWorkflowStatus::NotSubmitted;
    DpayWorkerReqTable.update();
    ttscommit;
}

ERROR : Update is not allowed without specifying ValidTimeStateUpdateMode in AX 2012 / D365

Hi,

Add tableName.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);

 
inside the tts.

static void Job511(Args _args)
{
    EmplContract     emplContract;
    utcdatetime minDateTime = DateTimeUtil::minValue() , maxDateTime = DateTimeUtil::maxValue();
    ttsBegin;
    While select forUpdate
        * from emplContract
            where emplContract.AnnualLeave == “”
    {
        emplContract.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
        emplContract.AnnualLeave = “اجازة السنوية”;
        emplContract.update();
    }

ValidTimeState in child table relation in AX 2012 / D365

Hi,

   while select validTimeState(AsOnToday) * from hcmEmployment join hcmWorker
        where  hcmWorker.RecId == hcmEmployment .Worker &&
      hcmWorker.PersonnelNumber == “1269”
    {
        print hcmEmployment .ValidFrom;
    }
    pause;
}

Regards

User ID to user name or Worker Name in AX 2012 / D365

Hi,

Worker = HcmWorker::find(DirPersonUser::findUserWorkerReference(UserId));

or

    public display Name userName()
{
    DirPartyName        partyName;

    partyName = DirPersonUser::userId2Name(this.UserId);
    if (!partyName)
        partyName = (select firstonly Name from userInfo where userInfo.Id == this.UserId).Name;
    if (!partyName)
        partyName = this.UserId;
    return partyName;
}

Regards

Relation between HcmPositionDetail, HcmPositionWorkerAssignment, HcmWorker for query class in AX 2012 / D365

Hi, Query                   query = new Query(); QueryRun                queryRun; QueryBuildDataSource    qbdsHcmWorker, qbdsHcmPosition, qbdsHcmPositionDetail, qbdsHcmPositionWorkerAssign; QueryBuildRange         qbrWorker,qbrdDept; HcmPositionDetail       hcmPositionDetail; HcmWorker               hcmWorker; ; qbdsHcmWorker = query.addDataSource(tableNum(HcmWorker)); qbdsHcmWorker.addRange(fieldnum(HcmWorker,PersonnelNumber)).value(‘1020’); qbdsHcmPositionWorkerAssign = qbdsHcmWorker.addDataSource(tableNum(HcmPositionWorkerAssignment)); qbdsHcmPositionWorkerAssign.relations(false); […]

Sum() in Query class in AX 2012 / D365

Hi, To perform sum() function in Query Class. qbdsOverTimeTrans.addSelectionField( fieldnum( DAPOvertimeTransactions, Amount), SelectionField::Sum); Regards,

QueryBuildRange class to filter with never date in AX 2012 or D365

Hi, qbdsHcmPositionDetail.addRange(fieldnum(HcmPositionDetail,ValidTo)).value(date2str(dateMax(), 321,  DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4));This is used for Valid Time State Tables particularly. Regards,

Greater than or euqal to / Less than or equal to (=) in Query class in AX 2012 or D365

Hi, Greater than or equal to:queryBuildDataSource.addRange(fieldNum(HcmPositionWorkerAssignment,ValidTo));        queryBuildRange.value(SysQuery::range(today(), dateMax())); or queryBuildDataSource.addRange(fieldNum(HcmPositionWorkerAssignment,ValidTo));        queryBuildRange.value((queryRange(today(), dateMax())); Less than or equal to:  queryBuildDataSource.addRange(fieldNum(HcmPositionWorkerAssignment,ValidTo));        queryBuildRange.value(SysQuery::range( dateNull(), today())); or queryBuildDataSource.addRange(fieldNum(HcmPositionWorkerAssignment,ValidTo));        queryBuildRange.value((queryRange(dateNull(), today()));  Regards,

Time null in AX 2012 / D365

Hi, There is no timeNull() unline dateNull() in Ax 2012, where as there is an work around to handle this as timeMin() or TimeMax(). DateTimeUtil::time(dateTimeUtil::minTime());  // prints 12:00 AMDateTimeUtil::time(dateTimeUtil::maxTime());  // prints 11:59 PM Regards,

Getting current user languague in SSRS in AX 2012

Hi, =iif(Parameters!AX_RenderingCulture.Value = “ar”,FALSE,TRUE) Note:  No needs to validate using controller class or passing the values in DP class for this. In my case, I needs to change the order ofcolumn of the table in SSRS without reference to arabic from right to left and rest left to right. So I added visibity based on […]