Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Get all the records in...
Finance forum
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Get all the records in grid for iteration

Posted on by 99
Hi I am facing a issue while running my validation on EcoResCategoryAddProduct form. I have added the code at closedOk method but it selects only first product from the selected grid  but it actually should iterate for loop for all the products in selected product grid as u can see in below image it is throwing error for first product which ideally should should validate all the records from the selected grid
 

How do I change my for loop, to get all the records from selected grid?
 
Also how to do the db refresh?
 public void closeOk()
    {
        FormRun         callerForm = this.args().caller();
        EcoResProduct           selectedProduct;
        EcoResProductCategory   tmpEcoResProductCategory;
        EcoResProductCategory   existingEcoResProductCategory;
        container       productErrorMessages;
        if (callerForm && this.args().Caller().name() == formStr(EcoResCategory))
        {
            EcoResCategory ecoResCategory = callerForm.dataSource(formDataSourceStr(EcoResCategory, EcoResCategory)).cursor() as EcoResCategory;
            for ( selectedProduct = EcoResProductSelected_ds.getFirst(1)?EcoResProductSelected_ds.getFirst(1):EcoResProductSelected_ds.cursor();
            selectedProduct;
            selectedProduct = EcoResProductSelected_ds.getNext())
            {
                productErrorMessages += this.checkGroup(selectedProduct, ecoResCategory);
            }
            if(productErrorMessages != conNull())
            {
                throw error (strfmt(/@SYS82282/, productErrorMessages));
            }
        }
        next closeOk();
    }
 

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans