Code Snippet populating sample data in referral list

Chapter - 06

Visit to buy the book on Citizen Development https://go.citizendeveloper.codes/buynow

Code Snippet #5

Populating sample data in referral list

It uses the ClearCollect function to create or update a collection named locReferralList. This collection is populated with a series of sample records, each representing information about a referral.

    ClearCollect(
        locReferralList,
        {
            FriendName: "Steve",
            FriendEmail: "Steve@gmail.com",
            ReferralNotes: "The application submitted. The application is under review.",
            StateToolTip: "The application submitted",
            State: Icon.LogJournal,
            LastUpdated: DateAdd(
                Now(),
                -1
            )
        },
        {
            FriendName: "Vijay",
            FriendEmail: "Vijay@outlook.com",
            ReferralNotes: "The referral bonus unlocked! You will receive instructions for claiming the payout.",
            StateToolTip: "The referral bonus unlocked!",
            State: Icon.Unlock,
            LastUpdated: Now()
        },
        {
            FriendName: "Priyanka",
            FriendEmail: "Priyanka@gmail.com",
            ReferralNotes: "The referral bonus settled. The payout amount is credited in your account XX162",
            StateToolTip: "The referral bonus settled.",
            State: Icon.Money,
            LastUpdated: DateAdd(
                Now(),
                -5
            )
        },
        {
            FriendName: "Farida",
            FriendEmail: "Farida@gmail.com",
            ReferralNotes: "The applicant needs support from the admission team. Help needed on the admission documentation.",
            StateToolTip: "Admission Team Support Needed.",
            State: Icon.Support,
            LastUpdated: DateAdd(
                Now(),
                -4
            )
        },
        {
            FriendName: "John",
            FriendEmail: "John@gmail.com",
            ReferralNotes: "The applicant needs support from the admission team. Help needed on the admission documentation.",
            StateToolTip: "Admission Team Support Needed.",
            State: Icon.Unlock,
            LastUpdated: DateAdd(
                Now(),
                -9
            )
        },
        {
            FriendName: "Sundar",
            FriendEmail: "Sundar@gmail.com",
            ReferralNotes: "The referral bonus settled. The payout amount is credited in your account XX162",
            StateToolTip: "The referral bonus settled.",
            State: Icon.Money,
            LastUpdated: DateAdd(
                Now(),
                -10
            )
        },
        {
            FriendName: "Allen",
            FriendEmail: "Allen@gmail.com",
            ReferralNotes: "The applicant needs support from the admission team. Help needed on the admission documentation.",
            StateToolTip: "Admission Team Support Needed.",
            State: Icon.LogJournal,
            LastUpdated: DateAdd(
                Now(),
                -7
            )
        }
    );

Explanation

  • ClearCollect Function: - ClearCollect(collectionName, items...): This function clears any existing data in the specified collection (collectionName) and then collects the items into it. In your code, locReferralList is the name of the collection being created or updated.

  • Records in the Collection: - Each record in the collection is defined within curly braces {} and represents information about a referral. The fields in each record are:
    • FriendName: The name of the friend being referred.
    • FriendEmail: The email address of the friend.
    • ReferralNotes: Notes or comments about the referral’s status or other relevant information.
    • StateToolTip: A short tooltip description about the current state of the referral.
    • State: An icon from the Power Apps icon library (such as Icon.LogJournal, Icon.Unlock, Icon.Money, Icon.Support) representing the current status or category of the referral.
    • LastUpdated: The date and time when the referral was last updated. This is calculated using DateAdd(Now(), -n), where n is the number of days ago the record was last updated.
  • Usage of DateAdd and Now:
    • Now() returns the current date and time.
    • DateAdd(Now(), -n) subtracts n days from the current date, setting the LastUpdated field to a past date.

In summary, this code is creating or updating a collection named locReferralList with detailed records of different referrals. Each record includes information like the friend’s name and email, notes on the referral, a tooltip for quick information, an icon to visually represent the status, and the last updated date.

Happy #low-code learning

Visit: www.citizendeveloper.codes

Id: Chapter-06-CS00005

Category: Chapter 06

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

Code Snippet # 8
Chapter-06-CS00008 - Code Snippet # 8
Code Snippet # 1
Chapter-08-CS00001 - Code Snippet # 1
Code Snippet # 1
Chapter-06-CS00001 - Code Snippet # 1