Hi Friends,
All I want to do is updating a position description since people promoted for a new title. Title is stored in hcmpositiondetail table.
If I update it, it's going to create a new record and with updated valid from/to date. But, it keeps throwing error "Cannot create a record in Position details (HcmPositionDetail). Invalid value specified for 'Expiration'. It cannot be less than the 'Expiration' of the last record."
So, what I did is just doing an insert, that worked for some positions. Some still get same error. Those position not working are those with multiple jobs in working history.
Following are part of code.
if(HcmPositionDetail.Description !=positionName) //inserting new one
{
newHcmPositionDetail.job = HcmPositionDetail.job;
newHcmPositionDetail.Position = HcmPositionDetail.Position;
newHcmPositionDetail.Description = positionName;
newHcmPositionDetail.ValidFrom = startDateTime;
newHcmPositionDetail.ValidTo = endDateTime;
newHcmPositionDetail.validTimeStateUpdateMode(ValidTimeStateUpdate::CreateNewTimePeriod);
newHcmPositionDetail.insert();
Can some one point out where is the problem?