Skip to main content

Notifications

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans