Hello Team,
Am new to power apps, I have been building an approval dashboard for the Multi step Dynamic approvers Based on Tutorial By @RezaDorrani ,i modified the 'Export Reports' SharePoint List to Include the following Columns Approval Link ,Current Approver, Next Approver, Previous Approver and Completed Approvers Column,
Once user Submits Anew Request, I want to be able To pull up a list of approvers From the Expense Types SharePoint List and patch this approvers to the approvers column in Expense Reports SharePoint list and also get the current approver and Next approver
Once someone Logs in as the an approver and he is the current Approver, he should be able to see the request and approve by Launching the Approval Link from Power Apps,
Then Expense Report list should then be updated by patching the current approver as the completed and previous approver and the next approver as the Current approver, and the Flow continues that way, The New Current approver should be able to go through the same process as the previous approver, if the current approver is the Final approver update the approval status and move the current approver to the completed approver Column, Below are some Screen Shots to guide,
i was trying to use concepts by @krinshana rachakonda in his tutorial building dynamic approval without flow
CODE TO SET CURRENT APPROVER AND NEXT APPROVER AT START OF THE FLOW
Set(
varSelectedApprovers,
// NewRequestForm.LastSubmit
LookUp(
'Expense Types',
Title = NewRequestForm.LastSubmit.'Expense Type'.Value
)
);
//ResetForm(Self); RequestHide()
//ResetForm(Self); RequestHide()
Set(
varSubmittedExpenseItem,
// NewRequestForm.LastSubmit
LookUp(
'Expense Reports',
ID = NewRequestForm.LastSubmit.ID
)
);
Set(
BlankPerson,
Table(
{
Claims: Blank(),
DisplayName: Blank(),
Email: Blank(),
Department: Blank(),
Picture: Blank(),
JobTitle: Blank()
}
)
);
If(
varSubmittedExpenseItem. 'Approval Status'. Value = "Pending" && IsBlank(First(varSubmittedExpenseItem.'Completed Approvers').DisplayName),
ClearCollect(
varApprovers,
varSubmittedExpenseItem.Approvers
);
Set(
varFirstApprover,
Table(First(varApprovers))
);
Remove(
varApprovers,
Table(First(varApprovers))
);
If(
CountRows(varApprovers) > 0,
Set(
varNextApprover,
Table(First(varApprovers))
),
BlankPerson
);
Set(
varUpdatedItem,
Patch(
'Expense Reports',
varSubmittedExpenseItem,
{
Approvers: If(
NewRequestForm.LastSubmit.Amount > 500,
varSelectedApprovers.Approvers2,
varSelectedApprovers.Approvers1
),
'Current Approver': varFirstApprover,
'Previous Approver': BlankPerson,
'Completed Approvers': Table(
{
Claims: Blank(),
DisplayName: Blank(),
Email: Blank(),
Department: Blank(),
Picture: Blank(),
JobTitle: Blank()
}
),
'Next Approver': varNextApprover,
'Approval Status': {Value: "Pending"}
}
)
)
)
CODE UPON CLICK OF APPROVE BUTTON BY APPROVER
Set(
varUpdatedItem,
LookUp(
'Expense Reports',
ID = varUpdatedItem.ID
)
);
Set(
varMsgFlag,
true
);
Set(
BlankPeople,
Table(
{
Claims: Blank(),
DisplayName: Blank(),
Email: Blank(),
Department: Blank(),
Picture: Blank(),
JobTitle: Blank()
}
)
);
If(
varUpdatedItem.'Approval Status'.Value = "Pending" && First(varUpdatedItem.'Current Approver').Email = User().Email,
/* ClearCollect(
colCompletedApprovers,
//varSubmittedExpenseItem.'Completed Approvers'
varUpdatedItem.'Completed Approvers'
//varUpdatedItem.'Previous Approver'
); */
ClearCollect(
colCompletedApprovers,
//varApprovedTask.'Assigned To'
//varSubmittedExpenseItem.'Current Approver'
varUpdatedItem.'Current Approver'
);
ClearCollect(
colApprovers,
//varSubmittedExpenseItem.Approvers
varUpdatedItem.Approvers
);
ClearCollect(
colRemainingApprovers,
colApprovers
);
ForAll(
colApprovers,
RemoveIf(
colRemainingApprovers,
ThisRecord in colCompletedApprovers
)
);
//If(
//varUpdatedItem.'Approval Status'.Value ="Pending"&& First(varUpdatedItem.'Current Approver').Email=User().Email,
Set(
varUpdatedItem,
Patch(
'Expense Reports',
varUpdatedItem,
{
'Previous Approver': varUpdatedItem.'Current Approver',
//'Previous Approver': varApprovedTask.'Assigned To',
'Completed Approvers': colCompletedApprovers,
'Current Approver': If(
CountRows(colRemainingApprovers) = 0,
BlankPeople,
Table(First(colRemainingApprovers))
),
'Next Approver': If(
CountRows(colRemainingApprovers) = 1,
BlankPeople,
Table(
First(
RemoveIf(
colRemainingApprovers,
Email = First(colRemainingApprovers).Email
)
)
)
),
'Approval Status': If(
IsBlank(First(colRemainingApprovers).DisplayName),
{Value: "Approved"},
{Value: "Pending"}
)
}
)
)
);
Set(
varMsgFlag,
false
);
Any Help will be highly appreciated thanks