I know this is alot of code... it does not error but it doesn't produce what I thought it would do...
_c is meant to give the _p some info as single row with single columns.
However, what's happening is that _c is passing records to _p as opposed to a single value.
So walking through it...
_c is a GroupBy of all comments by ProjectID giving me the most recent comment for each ProjectId (sorted descending Created value)
so _c.MostRecentComment should be the latest column and not a set of records (in the way I envision it). Any thoughts what I'm doing wrong...
With(
{
_c: ForAll(
GroupBy(
'Project Comments',
"ProjectId",
"GroupedItems"
),
With(
{
_top: First(
Sort(
GroupedItems,
Created,
Descending
)
)
},
{
ProjectId: ProjectId,
MostRecentComment: _top.Comment,
DateCreated: _top.Created,
CommentWho: _top.'Created By'.DisplayName,
StatusId: _top.StatusId,
PercentComplete: _top.PercentComplete,
CommentCount: CountRows(GroupedItems)
}
)
)
},
ClearCollect(
ProjectStatus,
ForAll(
Projects As _p,
With(
{
_cat: LookUp(
'Project Lookup Values',
ID = _p.ProjectCategoryId,
Title
)
},
Patch(
_p,
{
ProjectCategory: _cat,
MostRecentComment: _c.MostRecentComment,
DateCreated: _c.DateCreated,
CommentWho: _c.CommentWho,
PercentComplete: _c.PercentComplete,
CommentCount: _c.CommentCount
}
)
)
)
)
)