Hi,
I have the following code in the OnSuccess method of a forn control:
If(CheckboxAddToOutlookCalendar.Value,
UpdateContext({
OutlookEvent:
Office365.V2CalendarPostItem(ddCalendar.Selected.Value,Event.EventName,
DateAdd( Event.StartTime, -TimeZoneOffset( Event.StartTime ), Minutes ),
DateAdd(Event.EndTime,-TimeZoneOffset(Event.EndTime),Minutes),
{
Body:Event.EventNotes,
Location:LookUp('[dbo].[Rooms]',RoomId=Event.RoomId,RoomName),
Reminder:1440,
ShowAs:"Busy"
}
),
Enrollment: First(Filter('[dbo].[Enrollments]',EnrollmentId=FormNewEnrollment.LastSubmit.EnrollmentId))
});
Patch('[dbo].[Enrollments]',Enrollment,
{OutlookCalendarId:ddCalendar.Selected.Value, OutlookEventId:OutlookEvent.Id});
);
ResetForm(FormNewEnrollment);
Refresh('[dbo].[View_Enrollment]');
Back();
Back()
Powerapps is coinplaining that the Patch function has some invalid arguments (for boith the 'Enrollment' and 'OutlookEvent.Id' parameters.
If I move the UpdateContext and Patch statements outside of the If statement , like this:
//If(CheckboxAddToOutlookCalendar.Value,
UpdateContext({
OutlookEvent:
Office365.V2CalendarPostItem(ddCalendar.Selected.Value,Event.EventName,
DateAdd( Event.StartTime, -TimeZoneOffset( Event.StartTime ), Minutes ),
DateAdd(Event.EndTime,-TimeZoneOffset(Event.EndTime),Minutes),
{
Body:Event.EventNotes,
Location:LookUp('[dbo].[Rooms]',RoomId=Event.RoomId,RoomName),
Reminder:1440,
ShowAs:"Busy"
}
),
Enrollment: First(Filter('[dbo].[Enrollments]',EnrollmentId=FormNewEnrollment.LastSubmit.EnrollmentId))
});
Patch('[dbo].[Enrollments]',Enrollment,
{OutlookCalendarId:ddCalendar.Selected.Value, OutlookEventId:OutlookEvent.Id});
//);
ResetForm(FormNewEnrollment);
Refresh('[dbo].[View_Enrollment]');
Back();
Back()It works just fine.
I am trying to set some local variables from within and If Statement using UpdateContext and using thos local variables within the same if statement,
Is this not allowed?

Report
All responses (
Answers (