cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sindhureddy
Helper III
Helper III

Condition to remove items from SPList and add to another List in sharepoint

Hi,
I have an app which is used to create training dates. So now I want to delete the completed training programs from the SPList and add the same data to new SPList based on the Enddate (if enddate < Today). I have one gallery, can we check this condition in items property of gallery or can we perform this on AppStart.

Thanks in advance.

2 ACCEPTED SOLUTIONS

Accepted Solutions
CNT
Super User
Super User

@sindhureddy It would be better to do it in the OnStart of the App. You can use the following syntax,

ForAll(Filter(yourSPList, enddate < Today()),
	Patch(otherSPList, Defaults('otherSPList'), ThisRecord);
	Remove(yourSPList, ThisRecord)
)

View solution in original post

@sindhureddy Try this (with EndDate is same in both SPList),

With({varRecords:Filter('Training Request List', EndDate<Today())}, 
	ForAll(varRecords,
		Patch(CompletedTrainings, Defaults(CompletedTrainings), ThisRecord);
		Remove('Training Request List', ThisRecord)
	)
)

 

View solution in original post

9 REPLIES 9
CNT
Super User
Super User

@sindhureddy It would be better to do it in the OnStart of the App. You can use the following syntax,

ForAll(Filter(yourSPList, enddate < Today()),
	Patch(otherSPList, Defaults('otherSPList'), ThisRecord);
	Remove(yourSPList, ThisRecord)
)

@CNT Thanks for the reply. I am getting error for ThisRecord, Can you please help me with this.
Screenshot (52).png

@sindhureddy As the error says there is some name mismatch between EndDate and Enddate. Could you show me the full formula.

@CNT I have one SPList called Training Tracker App where all the requests are stored, now based on the end date I want to delete the training requests which have completed the trainings and move them to another SPList called(CompletedTrainings).
Screenshot (56).pngScreenshot (57).png Screenshot (58).png

@sindhureddy Is the Column name spelt correctly in the CompleteTrainings  sharepoint list? It must be EndDate.

@CNT Yes, EndDate is spelt same in both the lists but it's showing the below error so I tried with Enddate.
In the attached screenshots EndDate is spelt same in both the SPLists

When EndDate is same in both SPList I am getting this errorsWhen EndDate is same in both SPList I am getting this errorsScreenshot (62).png

@sindhureddy Try this (with EndDate is same in both SPList),

With({varRecords:Filter('Training Request List', EndDate<Today())}, 
	ForAll(varRecords,
		Patch(CompletedTrainings, Defaults(CompletedTrainings), ThisRecord);
		Remove('Training Request List', ThisRecord)
	)
)

 

@CNT Thank you so much, By considering your formulas tried with this formula and it's working for me
Collect(CompletedTrainings,
ShowColumns(
Filter('Training Request List', EndDate < Today()), "ReqID","Category","StartDate","EndDate","Title","Trainer_Name","Mode")
);

@sindhureddy Glad to help!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,274)