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 theitemsinto it. In your code,locReferralListis 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 asIcon.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 usingDateAdd(Now(), -n), wherenis 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)subtractsndays from the current date, setting theLastUpdatedfield 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
Amit Puri, Advisor and Consultant, Strengthening Digital Experiences, Modernize Cloud Journey with AI-Driven Transformation!