Tuesday, January 17, 2023

Update on a valid time state table is not allowed without specifying a ValidTimeStateUpdateMode using X++

 While Updating the valid timestate table I am getting the below error.

" Update on a valid time state table is not allowed without specifying a ValidTimeStateUpdateMode".


To overcome this I have followed the below logic.

We need to use the "validTimeStateUpdateMode" method at table level.


    HCMPositionWorkerAssignment		hCMPositionWorkerAssignment;

    hCMPositionWorkerAssignment = HCMPositionWorkerAssignment::Find(_recId);

    //select forUpdate * from hCMPositionWorkerAssignment where hCMPositionWorkerAssignment.recid== _recId;

    ttsBegin;
    hCMPositionWorkerAssignment.Field1 		= "New Value";
    hCMPositionWorkerAssignment.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);

    //hCMPositionWorkerAssignment.ValidFrom 	= today(); // If you want to update fromDate or todate values
    //hCMPositionWorkerAssignment.ValidTo	= dateMax();
    hCMPositionWorkerAssignment.update();
    ttsCommit;

Keep Daxing!!

No comments:

Post a Comment