Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2019 release wave 2 Discover the latest updates and new features to Dynamics 365 planned through March 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 Timeline
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
Some days ago my colleague suggested to GET a record in WHILE construction to modify this record which is on the cycle, for example instead of this construction:
IF MyRec.FINDSET(TRUE) THEN REPAT
MyRec.Value := Value1;
UNTIL MyRec.NEXT = 0;
she suggested to use the following construction:
IF MyRec.FINDSET THEN REPAT
MyRec2.Value := Value1;
UNTIL MyRec.NEXT = 0;
I see this not reasonable. Are there cases when we really do this way?
We use 2009 R2 but the qustion is opened for upper RTC versions as well.
Help to understand the issue please.
Depends on the filter and the data you want to modify.
When modifying a value within the filter, I would use another record-instance.
Otherwise it is not necessary.
See the two Examples here which highlight the difference: docs.microsoft.com/.../findset-function--record-
Additionally, consider to use MODIFYALL for certain situations.
This is absolutely reasonable general approach.
What if you have a set of setranges and setfilters before the loop. What if what you're changing is making the record not match the filters anymore. NEXT is the case here.
Look how NEXT works. It is looking on a current record you're on and based on the key and filters, gets the next record. But when the record has just become out of filters, then NEXT is simply unpredictable. This was pointed in numerous discussions.
Considering how often just a simple loop suddenly gets additional filters, it is strongly recommended to use another rec variable to modify the record. This is a general recommendation allowing you to avoid problems in future and making you to refactor a little less code.
But technically speaking, as Hannes said, it could work fine for the cases when you modify a field that is not filtered.
Business Applications communities