From bikehire you should be able to retrieve the bike record with a retrieve action. Even simpler would be to show the bikes in a listview nested in the dataview of the bike hire and add a button to mark the return. Then you have direct access to all the bikes that are associated with the bikehire entity record (as it seems from the domain model that a bikehire is can be associated with multiple bikes) Do make sure that the association is set on the bikehire of course.
Hi Lloyd Hird,
can you post some screenshots here to have an idea of what exactly you are facing issue with?
I have a really generic list of bikes. On this view I did have a Hire button but i' removed it as part of some changes i've made. When Hire is pressed, a microflow is called, and new bikeHire object is created and the Bike Status is changed to On Hire
Once hired, the user can visit the Rentals screen, which has a list of rentals, and some rental details. Again, due to some changes to try and figure out this issue, some fields are visible just becuase it was easier to have all fields added when selecting the Entity in the DataView. The data view accesses the bikeHire entity. On this view there is a 'Return button that triggers the Microflow that this question relates to.
I have made a few changes to this microflow thinking I was just not understanding it, so now I have no errors, but I am not getting the desired result when the microflow runs. i.e. the Status is not updating on the Bike entity. I thought it may filter through based on associations but I am obviously not on the right track.
Essentially, What I want to happen is, Admin creates Boke objects. A user sees the bike object, depending on which location they bike is in. i.e. is they pick location 1, they see all bikes in that location, with a status of Available. They press Hire button next to a bike. The bike Status changes to On Hire and the user has a rental/hire object associated with their user name.
When the user is finished with the bike, they view Rentals which shows bikes rented by them, they select the Return location and Press Return button. This will then change the location and and the Status in bike Entity so the bike becomes available at the location it was returned to.
As I was having trouble getting this, I tried to limit the requirement to just changing the status as part of the return, which brought me to this question.
Sorry, forgot image of MicroFlow
Hi Lloyd Hird,
We can change the status of the bike as per your scenario.
you have to change the Bike Status which is in the Bike entity. So, connect the Return button to a microflow which retrieves the bike object of that specific hire and change the object status to Available. That's it.
and a doubt that why the microflow's sequential flow is not correct i.e., why the arrow is in two directional?, check that
Hope it helps. If not please comment
Regards, Bhargav
Hi Bhargav,
I still don't seem to be able to make this work. I added a Retrieve of Bike by association from bikeHire_Bike, but now when I call the MicroFlow, I get an error that seems to point to my bike being null. I tried to do it 'From database' but this just gives me a list and I don't seem to be able to use that to change the Bike object. I think I have really confused myself.
Hi Lloyd Hird,
The domain model which you shared first and the previous one are not same.
Try: you store the Bike Id in the BikeHire and Bike Return right! Then Retrieve the Bike object with that ID and change the status
Hi Bhargav,,
Yes i know they arent they same. I have been trying to make changes to figure out why this isn't working. I am very new to Mendix.
I have been trying what you have said all along but that is where the problem is coming up. I can't seem to access the object to change the status, because the Bike object is not available to change.
If I add the Bike as a parameter, I get the error that I haven't given it a value and there isn't a default value. I feel like you keep saying the same thing over and over. I understand what you mean about retrieving the bike object, what I have a problem with is that it isn't working the way I am doing it and saying "Just retrieve the bike object and change the status" isn't helping me.