For  resetting and updating the data

Chapter - 08

Visit to buy the book on Citizen Development https://go.amitpuri.com/buynow

Code Snippet #8

For resetting and updating the data

This code snippet performs several operations to reset certain controls and context variables, refresh a data source, and update a context variable with a filtered set of data from that data source.

   Reset(txtSearch);
    UpdateContext(
        {
            locSortOrder: false,
            locFiltered: false
        }
    );
    Refresh(Referrals);
    UpdateContext(
        {
            tabReferrals: Filter(
                Referrals,
                'Referrals (Views)'.'My Referrals'
            )
        }
    ); 

Explanation

  • Resetting a Text Input Control:- Reset(txtSearch);: Resets the txtSearch text input control. This typically means clearing any text the user might have entered in the search box.

  • Updating Context Variables:- UpdateContext({ locSortOrder: false, locFiltered: false });: This line updates two context variables, locSortOrder and locFiltered, setting both to false. These variables are likely used to track the state of sorting and filtering in the app.

  • Refreshing the Data Source:- Refresh(Referrals);: Refreshes the Referrals data source. This is often used to ensure that the app is working with the latest data, especially if the data might have been changed elsewhere (like in a different user session or outside of the app).

  • Filtering Data and Updating Context Variable:- UpdateContext({ tabReferrals: Filter(Referrals, 'Referrals (Views)'.'My Referrals') });: This updates the tabReferrals context variable with a filtered subset of the Referrals data source. The Filter function is applied to select only those records from Referrals that meet the criteria defined by 'Referrals (Views)'.'My Referrals'. This could be a specific view or condition within the Referrals data source.

In summary, this code snippet is designed to reset and update the state of an application interface, particularly for features related to searching, sorting, and displaying referral data. It clears a search input, resets sorting and filtering states, refreshes the data source to ensure up-to-date data, and then applies a predefined filter to the data to update a context variable. This functionality is useful for scenarios like clearing user input and returning to a default or initial view of data in an application.

Happy #low-code learning

Visit: www.amitpuri.com

Id: Chapter-08-CS00008

Category: Chapter 08

Amit Puri, Advisor and Consultant, Strengthening Digital Experiences, Modernize Cloud Journey with AI-Driven Transformation!

Code Snippet # 5
Chapter-06-CS00005 - Code Snippet # 5
Code Snippet # 7
Chapter-06-CS00007 - Code Snippet # 7
Code Snippet # 3
Chapter-08-CS00003 - Code Snippet # 3