
Announcements
I am trying to patch a record in a sharepoint list.
The logic is if there is a record existing already with the status as pending then it updates the record
If there is not a record with a status pending then it creates a new record
However i need to update the display flag for the record with the approved status so the app displays the latest change and calculations can be run on the data.
If(LookUp(Forecast, CustId=Gallery2.Selected.CustId && Approved="Pending",true)=true
,Patch(Forecast, LookUp(Forecast,Title=Gallery2.Selected.TitleText.Text),
{ '1-April':Value(AprilInput.Text),
'2-May':Value(MayInput.Text),
'3-June':Value(JunInput.Text),
'4-Jul':Value(JulInput.Text),
'5-Aug':Value(AugInput.Text),
'6-Sep':Value(SepInput.Text),
'7-Oct':Value(OctInput.Text),
'8-Nov':Value(NovInput.Text),
'9-Dec':Value(DecInput.Text),
'10-Jan':Value(JanInput.Text),
'11-Feb':Value(FebInput.Text),
'12-Mar':Value(MarInput.Text),
New:1,
PendingDisplay:1 })
,
Collect(Forecast,{CustId:Gallery2.Selected.CustId,
'1-April':Value(AprilInput.Text),
'2-May':Value(MayInput.Text),
'3-June':Value(JunInput.Text),
'4-Jul':Value(JulInput.Text),
'5-Aug':Value(AugInput.Text),
'6-Sep':Value(SepInput.Text),
'7-Oct':Value(OctInput.Text),
'8-Nov':Value(NovInput.Text),
'9-Dec':Value(DecInput.Text),
'10-Jan':Value(JanInput.Text),
'11-Feb':Value(FebInput.Text),
'12-Mar':Value(MarInput.Text),
DateAdded: Now(),
Display:0,
New:1,
PendingDisplay:1
,Title: Gallery2.Selected.CustId&Text(Now())
}));
Patch(Forecast, First(FirstN(Sort(LookUp(Forecast, CustId=Gallery2.Selected.CustId && PendingDisplay = 1),DateAdded , Ascending),1)),{PendingDisplay:0})
The first Patch and collect work fine but i am having difficulty with the last patch - the sort is invalid - what have i done wrong?
worked it out and changed the lookup to a filter:
Patch(Forecast, First(FirstN(Sort(Filter(Forecast,CustId=Gallery2.Selected.CustId && PendingDisplay=1), DateAdded , Ascending),1)),{PendingDisplay:0})