Personalized Community is here!
Quickly customize your community to find the content you seek.
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
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All 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