web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

compare a new record with exisitng valid Time StateTable records

(1) ShareShare
ReportReport
Posted on by 1,307
Hi,
I have a table with Valid Time State field type set to Date. I have to write x++ logic to to validate ValidFrom and ValidTo of a new record with the exsiting records and get a validate info if date range is not appropriate rather than system throwing an error.
Lets say, I have three records for an item and vendoraccount with different date ranges.
 
ItemIDVEndAccountValidFromValidTo
0000875410009812/1/201912/1/2021
0000875410009812/2/20215/6/2023
000087541000985/7/2023Never

I have to add a 4th record for the same itemid and vendoraccount with validfrom and validTo.
 
Is there a function or a keyword that checks right away than manually checking using a while loop query?

while select validtimestate(dateNull(),dateMax()) setuptable
                where  setuptable.VendAccount == this.VendAccount &&                       
                       setuptable.ItemId == this.ItemId                       
{
}
 
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    239,880 Most Valuable Professional on at
    You said you want to "check right away than manually checking using a while loop query", but what is it that you want to check? Why can't you use the normal behaviour of the framework? Which ValidTimeStateMode is your index using?
  • Lakshmi Karambakkam Profile Picture
    1,307 on at
    ValidTimetateMode  is set to No Gap.Since I am writing this code in Data Entity during import project so the records in import file are inserted into the valid Time State table.
  • André Arnaud de Calavon Profile Picture
    305,946 Super User 2026 Season 1 on at
    Hi Lakshmi,
     
    What would be the difference for someone using your data entity if you have your own validation or the system default validation? In case there are wrong dates provided, the system should prevent inserting the records anyway. Do you want to present another error message compared to the standard error? If so, why should someone using your entity get a different experience compared to standard data entities having date effectiveness enabled on the underlying tables? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 461 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 458 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 450

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans