It is crucial to have an environment strategy which tends to be fully automated.
Your company probably needs an environment where you always have the same code than in production, and can daily overwrite the database with a fresh copy from production.
This first goal would be to debug production issues quickly.
It also simulates your actual production environment as closely as possible to perform some tests.
For quite a long time we have got option to schedule a power automate flow and use the LCS API to call a refresh . However, you cannot ask to your functional team to update your interface parameters daily.
Being able to execute a job directly in the power automate flow would be awesome. A quick development is the only barrier before achieving that.
First, Develop a data entity called PostRefreshDB, then add methods which extend common
Please find below some useful examples:
Activate all users
[SysODataActionAttribute("ActivateAllUsers", false)]
public static void ActivateAllUsers()
{
UserInfo UserInfo;
ttsbegin;
while select forupdate userInfo where userInfo.Enable == NoYes::No
&& UserInfo.id != "Admin"
&& UserInfo.id != "axrunner"
&& UserInfo.isMicrosoftAccount == false
{
try
{
userInfo.Enable = NoYes::Yes;
userInfo.update();
}
catch
{
info(strFmt("could not enable user %1",userInfo.id));
continue;
}
}
ttscommit;
}
Delete Azure active directory applications
[SysODataActionAttribute("DeleteAzureActiveDirectoryApp", false)]
public static boolean DeleteAzureActiveDirectoryApp()
{
SysAADClientTable azureParam;
delete_from azureParam;
return true;
}
Assign system admin role to users
[SysODataActionAttribute("AssignSysAdminRole", false)]
public static void AssignSysAdminRole()
{
SecurityRole role;
SecurityUserRole userRole;
UserInfo userInfo;
while select forupdate userRole
join userInfo
where userRole.User == userInfo.Id
join role where role.RecId == userRole.SecurityRole
&& role.AotName == "xxxxxxxxxxxxxxxxx"
{
select role where role.Name == "System administrator";
userRole.User = userInfo.id;
userRole.SecurityRole = role.RecId;
userRole.AssignmentMode = RoleAssignmentMode::Manual;
userRole.AssignmentStatus = RoleAssignmentStatus::Enabled;
SecuritySegregationOfDuties::assignUserToRole(userRole, null);
}
}
You will be able to see those actions in Power automate.
Find the component Execute action of Dynamics 365
Select your environment where you would like to execute the method
Select the method in the Action drop down list
You are all set. You don't need to worry about the daily refresh.
Comments