web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How could I simplify t...
Power Apps
Unanswered

How could I simplify this code....Its a doozy!

(0) ShareShare
ReportReport
Posted on by 363

I have a bunch of code that repeats and need some help simplifying it because it has become quite long and difficult to manage. I will do my best to explain it.  Below is the interface 

colbyturybury_1-1686062130566.png

 

In a typical architectural engineering project there are 3 submittals(Where content is sent to the owner), a 100% DD, 60% CD, and a 90% CD. I have some code that creates 3 calendar invites per submittal. One on the date of the submittal, another 3 days prior for a QC check, and a Clash Report 5 days prior. I have code for each of the calendar invites. When added up there are 9 calendar invites sent out and that means 9 blocks of code with various variables swapped out. Below is the code for the submittal date, QC date, and Clash Report date.

 

Submittal Date:

Office365Outlook.V4CalendarPostItem(
//Users calendar, dont change
LookUp(Office365Outlook.CalendarGetTables().value, DisplayName = "Calendar").Name,
// Subject of the meeting, you can change
txtFirstDeliverable.Text & " | " & txtProjectNumber.Text & " - " & txtProjectName.Text,
// The time the meeting starts converted to UTC time. Replace Now with the date time you want the meeting
DateAdd(DateTimeValue(dat100DD.SelectedDate + Time(10,00,00)), 0, TimeUnit.Minutes),
DateAdd(DateTimeValue(dat100DD.SelectedDate + Time(10,00,00)), 30, TimeUnit.Minutes),
"Central Standard Time",

//OPTIONAL
{
requiredAttendees:emailAdresses.Text,
body: "This is an autogenerated calendar invite for the project " & txtProjectNumber.Text & " - " & txtProjectName.Text & ". This invite is to remind you that the QC set for 100% DDs are due today " & "(" & dat100DD.SelectedDate & ")."
}
);

 

QC Date:

Office365Outlook.V4CalendarPostItem(
//Users calendar, dont change
LookUp(Office365Outlook.CalendarGetTables().value, DisplayName = "Calendar").Name,
// Subject of the meeting, you can change
txtFirstDeliverable.Text & " QC | " & txtProjectNumber.Text & " - " & txtProjectName.Text,
// The time the meeting starts converted to UTC time. Replace Now with the date time you want the meeting
DateAdd(DateTimeValue(var100DD_QC_Date + Time(10,00,00)), 0, TimeUnit.Minutes),
DateAdd(DateTimeValue(var100DD_QC_Date + Time(10,00,00)), 30, TimeUnit.Minutes),
"Central Standard Time",

//OPTIONAL
{
requiredAttendees:emailAdresses.Text,
body: "This is an autogenerated calendar invite for the project " & txtProjectNumber.Text & " - " & txtProjectName.Text & ". This invite is to remind you that the QC set for " & txtFirstDeliverable.Text & " are due today " & "(" & var100DD_QC_Date & ")."
}
);

 

Clash Report date:

 

Office365Outlook.V4CalendarPostItem(
//Users calendar, dont change
LookUp(Office365Outlook.CalendarGetTables().value, DisplayName = "Calendar").Name,
// Subject of the meeting, you can change
txtFirstDeliverable.Text & " CLASH REPORT | " & txtProjectNumber.Text & " - " & txtProjectName.Text,
// The time the meeting starts converted to UTC time. Replace Now with the date time you want the meeting
DateAdd(DateTimeValue(var100DD_CR_Date + Time(10,00,00)), 0, TimeUnit.Minutes),
DateAdd(DateTimeValue(var100DD_CR_Date + Time(10,00,00)), 30, TimeUnit.Minutes),
"Central Standard Time",

//OPTIONAL
{
requiredAttendees:emailAdresses.Text,
body: "This is an autogenerated calendar invite for the project " & txtProjectNumber.Text & " - " & txtProjectName.Text & ". This invite is to remind you that the CLASH Report for " & txtFirstDeliverable.Text & " is due today " & "(" & var100DD_CR_Date & ")."
}
));

 

 

Categories:
I have the same question (0)
  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @colbyturybury ,

     

    There's another way to do this using Power Automate Flow for creating your Calendar Items. 

    Then you trigger the Flow within the App without performing huge operations, thus increasing efficiency.

     

    Hope this helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard