// For Appointment Type
If(
varSelectedAdminTabNewAppType && varEditSelectedAppType,
If(
Not(
IsBlank(
LookUp(
'Appointment Type',
Title = txt_Input_Appointment_Type.Value
)
)
),
Notify(
"A Appointment Type with this name already exists. Please use a different name.",
NotificationType.Error
),
If(
IsBlank(txt_Input_Appointment_Type.Value),
Set(
varSubmissionValidation,
true
),
Set(
varSubmissionValidation,
false
),
Patch(
'Appointment Type',
gal_All_Appointment_Type.Selected,
{Title: txt_Input_Appointment_Type.Value}
);
ResetForm(frm_Add_Appointment_Type);
Set(
varSelectedAdminTabNewAppType,
false
);
Notify(
"Appointment Type Saved Sucessfully",
NotificationType.Success
);
)
),
If(
Not(
IsBlank(
LookUp(
'Appointment Type',
Title = txt_Input_Appointment_Type.Value
)
)
),
Notify(
"A Appointment Type with this name already exists. Please use a different name.",
NotificationType.Error
),
SubmitForm(frm_Add_Appointment_Type)
)
);
// For Appointment Location
If(
varSelectedAdminTabNewLocation && varEditSelectedLocation,
If(
Not(
IsBlank(
LookUp(
'Appointment Location',
Title = txt_Input_Location.Value
)
)
),
Notify(
"A location with this name already exists. Please use a different name.",
NotificationType.Error
),
If(
IsBlank(txt_Input_Location.Value),
Set(
varSubmissionValidation,
true
),
Set(
varSubmissionValidation,
false
);
Patch(
'Appointment Location',
gal_All_Locations.Selected,
{Title: txt_Input_Location.Value}
);
Notify(
"Appointment Location Saved Sucessfully",
NotificationType.Success
);
ResetForm(frm_Add_Location);
Set(
varSelectedAdminTabNewLocation,
false
);
)
);
,
If(
Not(
IsBlank(
LookUp(
'Appointment Location',
Title = txt_Input_Location.Value
)
)
),
Notify(
"A location with this name already exists. Please use a different name.",
NotificationType.Error
),
SubmitForm(frm_Add_Location)
);
);
// For Users
If(
varSelectedAdminTabNewUser && varEditSelectedUser,
If(
IsBlank(tog_Is_Admin.Checked) || IsBlank(drp_Appointment_Color.Selected) || IsBlank(drp_Users.Selected),
IsBlank(DataCardValue3.Selected) ||IsBlank(DataCardValue2.Checked),
Set(
varSubmissionValidation,
true
),
Set(
varSubmissionValidation,
false
);
Patch(
Users,
gal_All_Users.Selected,
{
'User': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(drp_Users.Selected.Mail),
Email: drp_Users.Selected.Mail,
Department: drp_Users.Selected.Department,
DisplayName: drp_Users.Selected.DisplayName,
JobTitle: drp_Users.Selected.JobTitle,
Picture: ""
},
'User Name': drp_Users.Selected.DisplayName,
'User Email': drp_Users.Selected.Mail,
IsAdmin: tog_Is_Admin.Checked,
IsActive: DataCardValue2.Checked,
'Appointment Color': drp_Appointment_Color.Selected.'Color Value',
'UserRole (UserRole0)': {
Id: LookUp('User Role', Title = DataCardValue3.Selected.Value, ID),
Value: DataCardValue3.Selected.Value
}
}
);
Patch(
'Appointment Colors',
LookUp(
'Appointment Colors',
'Color Value' = drp_Appointment_Color.Selected.'Color Value'
),
{IsActive: true}
);
ResetForm(frm_Add_New_User);
Refresh(Users);
Set(
varSelectedAdminTabNewUser,
false
);
Notify(
"User Details Updated Sucessfully",
NotificationType.Success
);
),
If(
IsBlank(drp_Users.Selected) || IsBlank(tog_Is_Admin.Checked) || IsBlank(drp_Appointment_Color.Selected) || IsBlank(DataCardValue2.Checked),
Set(
varSubmissionValidation,
true
),
If(
Not(
IsBlank(
LookUp(
Users,
//'User Email' = drp_User.SelectedItems.
'User'.Email = drp_Users.Selected.Mail
)
)
),
Notify(
"A User with this Email already exists. Please use a different Email.",
NotificationType.Error
),
Set(
varSubmissionValidation,
false
);
// Else case for adding a new user without editing an existing one
Patch(
Users,
Defaults(Users),
{
'User': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(drp_Users.Selected.Mail),
Email: drp_Users.Selected.Mail,
Department: drp_Users.Selected.Department,
DisplayName: drp_Users.Selected.DisplayName,
JobTitle: drp_Users.Selected.JobTitle,
Picture: ""
},
'User Name': drp_Users.Selected.DisplayName,
'User Email': drp_Users.Selected.Mail,
IsAdmin: tog_Is_Admin.Checked,
IsActive: DataCardValue2.Checked,
'Appointment Color': drp_Appointment_Color.Selected.'Color Value',
/*'User Role': {Value: drp_User_Role.Selected.Title}*/
'UserRole (UserRole0)': {
Id: LookUp('User Role', Title = DataCardValue3.Selected.Value, ID),
Value: DataCardValue3.Selected.Value
}
}
);
Patch(
'Appointment Colors',
LookUp(
'Appointment Colors',
'Color Value' = drp_Appointment_Color.Selected.'Color Value'
),
{IsActive: true}
);
ResetForm(frm_Add_New_User);
Notify(
"New User Added Sucessfully",
NotificationType.Success;
Refresh(Users);
Set(
varSelectedAdminTabNewUser,
false
);
);
);
)
);