Ok THANKS Luo! This was fantastic and I appreciate your patience working with me through this.
I have one things left to do: combine my forms: right now I have two forms (1 that adds a new vehicle into the 'vehicle' CPT, and another that adds a new vehicle into the 'vehicle movements' cpt).
What I really want to be able to do, if possible, is present one form (at least from the user's perspective where they enter the VIN. If it already exists then the form pre-populates and they can only create a new 'vehicle movement' cpt (with some fields editable), if the VIN does not exist then they add a new vehicle in 'vehicle' cpt.
Is this possible? If it's not, is there a way to get close to what I want to do?
One more thing. I went through the pages you sent and the 'vehicle movements' recent view does not work as intended.
If you add more than one entry with the same vin it does not show the most recent one. For example, I duplicated your view and modified the loop to make it into a table and double checked that the out put was the same as before (it was). Then I added two more vehicle movements for an existing VIN but none of them appeared in the table. See screen shots attached. (Main) is the home page showing all three vehicle movements not using the view you created with my modification. testpage is with the view you created but with my modification (?page=views-editor&view_id=2260).
Also, I noticed that your third view isn't showing up - the one that calculates how long a vehicle has been in one location. Where is that located?
According to our support policy, we prefer one ticket one question, For the new questions:
https://toolset.com/forums/topic/new-entry-tracking/page/2/#post-1707897
Please check the new thread here:
https://toolset.com/forums/topic/i-have-one-things-left-to-do-combine-my-forms/
Q1) If you add more than one entry with the same vin it does not show the most recent one.
In home page, it is not a single "vehicles" post, so you will need to setup a nested view:
1) Parent post view:
- Query "vehicles" posts
- In view's loop, display below child post view
2) Child post view:
- Query "vehicle movement" posts
- Display only one item, and order by post date descending
- Filter by post type relationship between "vehicles" and "vehicle movement"
- Display "vehicle movement" information
Please have a look at the document I mentioned above:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
Q2) I noticed that your third view isn't showing up - the one that calculates how long a vehicle has been in one location. Where is that located?
I did not setup the third view in your website, it should use the same setting of first view, and output a custom shortcode to calculate days between the post date and now, Please check the my answer above:
https://toolset.com/forums/topic/new-entry-tracking/page/2/#post-1704869
Forgive me Luo but I don't think you understand what I'm trying to accomplish. This view is NOT in a post so it wouldn't be related to anything. It's a list of vehicles on a page. This is not a situation where a user clicks on a vehicle and is looking at a vehicle details page and I'm trying to display 'related vehicles'. Let's go back to the original question.
Once a user enters a new vehicle movement (with the same VIN) how can I only display the most recent entry in the list?
We could either do this with one CPT (vehicles) or with your idea of two CPTS 'vehicles' & 'vehicle movements'. But either way a new post will be entered each time when the VIN is found.
OK, lets back to the original question.
Without two post types "vehicle" and "vehicle movement", how can you track the vehicle movement history?
Without history records, how can you find the latest "vehicle movement" of specific "vehicle"?
I don't find other workaround than two post types within Toolset.
My issue is resolved now. Thank you!