cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Station1901
Level: Powered On

Update with Historical data

Hello,

I am creating a power app which will manage long distance jobs issued to our fleet of vehicles.  On the whole it works apart from one problem which I can't seem to solve.  If a vehicle is issued a job and the driver then calls back to say he can't do the job for whatever reason I want the controller to be able to delete the job and for the car to be put back in it's original place in the queue before the job was issued to it.

 

I have 2 tables - The first table is 'Cars' which holds the list of cars - each car has its own individual number, (Column name: 'CALLSIGN') in the queue and the date of that vehicles last long distance job (Column Name: 'LASTROTA').

The second table is 'LDR' which holds all of the data from the completed jobs issued to the vehicles.  (Column name: 'VehicleNo' which is the same as 'CallSign'), 'DateAccept' is the date the job completed. I use table LDR to look up the Job History of a particular vehicle.  When a job is added to the PowerApp a button is pressed and it automatically adds the job to the LDR table (VehicleNo & DateAccept) and also patches the (CALLSIGN & LASTROTA) information into the table 'Cars'.- Works Perfectly !!

 

Now I need to create a Delete button that will totally remove a job from the LDR table for a selected vehicle AND Patch the previous job complete date for that vehicle into the 'Cars' table in the 'LastRota' column.

 

I am still new to using PowerApps so I'm not sure if this is at all possible or how I would even begin to start to do this so any help or suggestions would be very much appreciated.  The App on the whole works perfectly as I does a lot of other things so I really don't want to start from scratch if I can help it.

 

5 REPLIES 5
Dawidvh
Level 10

Re: Update with Historical data

Hi @Station1901

 

Well done, sounds like a cool app.

 

What part are you struggling with on the Delete and Patch for the following:

"Now I need to create a Delete button that will totally remove a job from the LDR table for a selected vehicle AND Patch the previous job complete date for that vehicle into the 'Cars' table in the 'LastRota' column."

 

To Delete, you can use RemoveIf

RemoveIf(LDRTable,ID=IDToRemove)
Station1901
Level: Powered On

Re: Update with Historical data

Thanks for getting back to me @Dawidvh,  I'm ok with the delete record part I can get a button to delete a record in the LDR table but I want the same button to perfom 2 functions.  I need it to delete the record in the LDR table AND add the vehicles previous 'DateAccept' (stored in the LDR table) to the 'LastRota' column in the 'Cars' table.  If there is no previous job data to take from 'DateAccept' I will need 'LastRota' to be todays date (Now).

 

The LDR table is the table that builds up and stores the Historical data for each vehicles jobs the 'Cars' table sorts the queue of vehicles based on the 'LastRota' date.

Dawidvh
Level 10

Re: Update with Historical data

Hi @Station1901

 

Consider the following:

RemoveIf(LdrTable,Id=IdToRemove);

Set(previousDate,Last(Filter(LdrTable,carID=applicableCarID)).dateToFetch);

Patch(carTable,Lookup(carTable,ID=IdToUpdate),{DateFieldSmiley Tonguereviousdate})

Let me know if this does work.

 

Station1901
Level: Powered On

Re: Update with Historical data

Thanks again @Dawidvh, Sorry I'm an absolute beginner at this.  The part RemoveIF has Id=IDToRemove.  Where does the ID part come from or what does this relate to?

Dawidvh
Level 10

Re: Update with Historical data

Hi @Station1901,

 

You mentioned that you are ok with removing the record, then you don't need the RemoveIf as you can merely use the method that you have been using to remove the record.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 320 members 4,076 guests
Please welcome our newest community members: