Code Snippets - Citizen Development in Microsoft 365, Power Up Your Creativity: Embark on Your Journey with Microsoft Power Fx
Download the code snippets file
Chapter-06-Code-Snippet #1
// Code-Snippet #1
Concat(
FirstN(
Shuffle(
Split(
"abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789",
""
)
),
8
),
Result
)
Chapter-06-Code-Snippet #2
// Code-Snippet #2
If(
IsMatch(
txtFriendEmail.Text,
"^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$"
) && Last(
Split(
txtFriendEmail.Text,
"@"
)
).Result in [
"gmail.com",
"outlook.com"
],
DisplayMode.Edit,
DisplayMode.Disabled
)
Chapter-06-Code-Snippet #3
// Code-Snippet #3
If(
'Send-a-email-to-friend-with-referral-code'.Run(
txtFriendEmail.Text,
"Referral Instructions",
lblReferralCode.Text,
User().FullName
),
Notify(
"Email sent to " & txtFriendEmail.Text,
NotificationType.Success
);
Reset(txtFriendEmail);
,
Notify(
"Error, We are not able to send mail!",
NotificationType.Error
)
);
Chapter-06-Code-Snippet #4
// Code-Snippet #4
ClearCollect(
locSortDropdown,
Table(
{
DisplayColumn: "No sort", ColumnName: ""
},
{
DisplayColumn: "State", ColumnName: "State"
},
{
DisplayColumn: "Friend Name", ColumnName: "FriendName"
},
{
DisplayColumn: "Last Updated", ColumnName: "LastUpdated"
}
)
);
Chapter-06-Code-Snippet #5
// Code-Snippet #5
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
)
}
);
Chapter-06-Code-Snippet #6
// Code-Snippet #6
If(
!IsBlank(drpColumns.Selected.ColumnName),
UpdateContext({locSortOrder: !locSortOrder});
ClearCollect(
locReferralList,
SortByColumns(
locReferralList,
drpColumns.Selected.ColumnName,
If(
locSortOrder,
Ascending,
Descending
)
)
);
)
Chapter-06-Code-Snippet #7
// Code-Snippet #7
UpdateContext({locFiltered: !locFiltered});
If(
locFiltered,
ClearCollect(
locReferralList,
Filter(
locReferralList,
State in [
Icon.LogJournal,
Icon.Unlock
]
)
),
ClearCollect(
locReferralList,
{
FriendName: "Steve",
FriendEmail: "Steve@gmail.com",
ReferralNotes: "The application submitted. The application is under review.",
StateTip: "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.",
StateTip: "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",
StateTip: "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.",
StateTip: "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.",
StateTip: "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",
StateTip: "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.",
StateTip: "Admission Team Support Needed.",
State: Icon.LogJournal,
LastUpdated: DateAdd(
Now(),
-7
)
}
)
);
If(
!IsBlank(drpColumns.Selected.ColumnName),
ClearCollect(
locReferralList,
SortByColumns(
locReferralList,
drpColumns.Selected.ColumnName,
If(
locSortOrder,
Ascending,
Descending
)
)
);
);
Chapter-06-Code-Snippet #8
// Code-Snippet #8
If(
!IsBlank(txtSearch.Text),
ClearCollect(
locReferralList,
Search(
locReferralList,
txtSearch.Text,
"FriendName",
"FriendEmail",
"ReferralNotes"
)
),
ClearCollect(
locReferralList,
{
FriendName: "Steve",
FriendEmail: "Steve@gmail.com",
ReferralNotes: "The application submitted. The application is under review.",
StateTip: "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.",
StateTip: "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",
StateTip: "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.",
StateTip: "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.",
StateTip: "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",
StateTip: "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.",
StateTip: "Admission Team Support Needed.",
State: Icon.LogJournal,
LastUpdated: DateAdd(
Now(),
-7
)
}
)
);
Chapter-06-Code-Snippet #9
// Code-Snippet #9
Reset(drpColumns);
Reset(txtSearch);
UpdateContext({locFiltered: false});
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
)
}
);