Skip to main content

Notifications

Announcements

No record found.

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,295
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                       
{
}
 
 
 
  • André Arnaud de Calavon Profile Picture
    293,082 Super User 2025 Season 1 on at
    compare a new record with exisitng valid Time StateTable records
    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? 
  • Lakshmi Karambakkam Profile Picture
    1,295 on at
    compare a new record with exisitng valid Time StateTable records
    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.
  • Martin Dráb Profile Picture
    231,872 Most Valuable Professional on at
    compare a new record with exisitng valid Time StateTable records
    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?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,082 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,872 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans