Hello everyone, I want to ask about change value for incremental ID I have an entity with this attribute I have a logic to retrieve incremental AlarmID like below Here the complete code if (parseInteger(substring($LatestAlarm/AlarmID, 9)) < 9) then 'ALR-'+parseInteger(formatDateTime(trimToYears([%CurrentDateTime%]),'yyyy'))+'-000' + toString(parseInteger(substring($LatestAlarm/AlarmID, length($LatestAlarm/AlarmID) - 4)) + 1) else if (parseInteger(substring($LatestAlarm/AlarmID, 9)) < 99) then ' ALR-'+parseInteger(formatDateTime(trimToYears([%CurrentDateTime%]),'yyyy'))+'-00' + toString(parseInteger(substring($LatestAlarm/AlarmID, length($LatestAlarm/AlarmID) - 4)) + 1) else if (parseInteger(substring($LatestAlarm/AlarmID, 9)) < 999) then 'ALR-'+parseInteger(formatDateTime(trimToYears([%CurrentDateTime%]),'yyyy'))+'-0'+toString((parseInteger(substring($LatestAlarm/AlarmID, length($LatestAlarm/AlarmID) - 4)) + 1)) else 'ALR-'+parseInteger(formatDateTime(trimToYears([%CurrentDateTime%]),'yyyy'))+'-'+toString((parseInteger(substring($LatestAlarm/AlarmID, 9)) + 1)) This is how I retrieve $LatestAlarm It run smoothly from AlarmID = ALR-2024-0001 to ALR-2024-9999. But when the latest data is ALR-2024-10000, when I inserted next data, it still throws ALR-2024-10000 not ALR-2024-10001 Can anyone give me insight for this logic?
asked
Fadil Fidrian
2 answers
0
Hi, Fadil Fidrian
Before Change Activity take retrieve activity and list aggregative count pass the 'ALR-'+parseInteger(formatDateTime(trimToYears([%CurrentDateTime%]),'yyyy'))+'-000' + toString(parseInteger(substring($LatestAlarm/AlarmID, length($LatestAlarm/AlarmID) - 4)) + 1).