Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Method (GreaterThanUtcNow()) failing build & sync

(1) ShareShare
ReportReport
Posted on by 189
Hello Cmmunity Experts,
 
I have one custom data entity which has many data sources and the parent in HcmPosition. Among first joins is HcmPositionDetails which has an outer join relation with HcmPosition.

 
 
I have added one range on the ValidTo field of HcmPositionDetails but its throwing build error afterwards.
 
"A local variable named '_isAnyFieldSet_' cannot be declared in this scope because it would give a different meaning to '_isAnyFieldSet_', which is already used in a parent or current scope to denote something else."
 



Not sure why this is the case as in the following documentation from Microsoft the method is mentioned to use for date range queries.
https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/fin-ops/get-started/advanced-filtering-query-options#advanced-date-queries-that-use-sysqueryrangeutil-methods
 
Looking forward to helpful responses :)
 
Best Regards.
  • Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    Method (GreaterThanUtcNow()) failing build & sync
    The range is applied, but is the range value correct? I still expect a hard-coded value, which isn't what you wanted. Please look at the actual view in SSMS to see what you've generated. That the view gave you the correct result at that moment doesn't mean that it'll be correct tomorrow.
  • Verified answer
    alinawaz Profile Picture
    alinawaz 189 on at
    Method (GreaterThanUtcNow()) failing build & sync
    Changing the join type to Inner Join from Outer join has resolved the problem.
    Build and Sync is successful, plus the range is also applied.
     
    Thanks guys :)
    Cheers
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    Method (GreaterThanUtcNow()) failing build & sync
    What you're trying to do is logically wrong, therefore if you get rid of the error, it still won't to do what you want.
     
    A data entity is a SQL view in the database. The view can't connect to F&O and execute X++ code, including greaterThanUtcNow() function. It simply can't work. The only thing you could get is getting greaterThanUtcNow() executed on DB sync, therefore the time of the DB sync would be hard-coded in the entity definition. It wouldn't use the current date time when querying the data.
     
    Date-effective data entities require a different approach. Please refer to F&O documentation (Date effectivity) for details.
  • Verified answer
    Komi Siabi Profile Picture
    Komi Siabi 12,729 Most Valuable Professional on at
    Method (GreaterThanUtcNow()) failing build & sync
  • alinawaz Profile Picture
    alinawaz 189 on at
    Method (GreaterThanUtcNow()) failing build & sync
    Yes that Error started appearing only after I added the range on HcmPositionDetail Datasource.
    Plus, when I add the same range on the Data entity's range node, there is no build or sync error but the range isn't working either. Checked the data in SQL.
  • Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    Method (GreaterThanUtcNow()) failing build & sync
    Hi alinawaz,
     
    Are you sure the error started appearing after u added the range?  so if you remove this range, would the error go?

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans