web
You’re offline. This is a read only version of the page.
close
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,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
    237,965 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
    301,109 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans