Content of one element in one list, stored in another list emlement

ahmedo

Member
Hello,

I must say, the more you delve into Fabrik deep, the more you appreciate the brilliant minds behind it. Thank you for a wonderful product. I am almost sure, there is so much to learn.

Here is my question.

I have two lists that have the following elements:

List_A:
Date_of_Purchase (date)
Maintenence_End_Date (date) - calculated (basically 12 months added to date_of_purchase)
New_Maintenance_Date (date) - by default, the same as maintenance_end_date when this record is first entered

List_B: (when customer renews maintenance)
Date_of_Renewal (date)
End_of_Renewal (date) (calculated basically 12 months added to date_of_renwal)

What I want to do is, when I save the record in List_B, I would like the element New_Mainenance_Date in List_A to have the same value as End_of_Renewal in List_B.

How do I do that?

Thank you once again.
 
Does List_B have a join element to List_A, so you know which row in List_A needs to be updated? Know as an FK (Foreign Key), which points to a PK (Primary Key) on another table. Or, alternatively, a join on List_A which points back to List_B.

If so, you can use the 'upsert' form plugin, which is designed to do exactly that, update/insert rows on another table, referenced by a join on the form (or the FK on the other table).

The upsert plugin settings can be a little opaque - it can work in two ways, either using an FK element on "this" form to point to the PK of the other list (the one you want to update), or with an FK on the other list pointing back to the PK of "this" form.


-- hugh
 
Does List_B have a join element to List_A, so you know which row in List_A needs to be updated? Know as an FK (Foreign Key), which points to a PK (Primary Key) on another table. Or, alternatively, a join on List_A which points back to List_B.

If so, you can use the 'upsert' form plugin, which is designed to do exactly that, update/insert rows on another table, referenced by a join on the form (or the FK on the other table).

The upsert plugin settings can be a little opaque - it can work in two ways, either using an FK element on "this" form to point to the PK of the other list (the one you want to update), or with an FK on the other list pointing back to the PK of "this" form.


-- hugh
Thanks Hugh for the reply. Yes, List_B has two elements that are related to List_A. The first is the customer_name element, which is a databasejoin that is read from List_A. The other element called serial_number which is a cascadingdropdown and read from List_A. I only need to update one element in List_A in a row where the serial_number or the customer_name is picked, and not add a new row.

I will test this today.

Thank you once again.
 
I have added the upsert plug-in under the Edit Form (plug-in tab), checked the documentation, but could not see the Options as per documentation. In addition, what should be the Row value (it cannot be left blank as I am going to update only the element in a row in List_A). Thanks.
 
Assuming you are doing PK mode (where you have a join on List_B pointing to the PK of List_A) then the "Row value" would be the placeholder of that join element (and if it is a join, you'd want to append _raw). So if the element on List_A is "listb_id", then {List_B___lista_id_raw}.

Note that it usually helps if you use the real table and element names, then I can give you the exact information.

-- hugh
 
Thanks again.

Here are the actual names used

List 1
Name: fbk_licenses_main (instead of List_A in the above question)
Elements:
new_end_date (this is the one that I want it to be changed when I save my submission in form Maintenance

List 2:
fbk_maintenance (instead of List_B)
Form: Maintenance
Elements:
end_date

Once I save my record in the Maintainance form, I want the value of end_date to be stored in the element new_end_date in the fbk_licenses_main list.

If I could do that in PHP, I would not mind. Our PHP developer is on leave this week.

Thank you.
 
Thanks again.

Here are the actual names used

List 1
Name: fbk_licenses_main (instead of List_A in the above question)
Elements:
new_end_date (this is the one that I want it to be changed when I save my submission in form Maintenance

List 2:
fbk_maintenance (instead of List_B)
Form: Maintenance
Elements:
end_date

Once I save my record in the Maintainance form, I want the value of end_date to be stored in the element new_end_date in the fbk_licenses_main list.

If I could do that in PHP, I would not mind. Our PHP developer is on leave this week.

Thank you.
What you haven't given me is the name of the join on the maintenance form that points to the row in the license table you want to update. Well, it might not be a join, depending on how your app is structured, but it'll be an element that stores the ID of the license row.


Sent from my HTC6545LVW using Tapatalk
 
I am not sure if this is what you are looking for... let's see.
the databasejoin element that I am using is maintenance___customer_name
 
OK, then that's what goes in "Row value".

Connection: site (unless you are working on a secondary connection)
List: fbk_licenses_main
Insert/update: update only
PK or FK: PK
Foreign / Primary key: id (or whatever the PK element is on the maintenance table, which will be 'id' if you created it in Fabrik)
Row value: {maintenance___customer_name}
Values: add a value as ...

Key: new_end_date
Value: {maintenance___end_date}
Default: (leave blank)
Eval: no

Condition: (leave blank)

That should do it. Although when dealing with dates, things can be a bit of a crap shoot as they get a bit complex with formats and time zones ... but give it a go ... if it doesn't work, I'll test it here.

Note - you said {maintenance___customer_name}, but you also said the table is fbk_maintenance, so those placeholders may need that fbk_ prefix.

-- hugh
 
Thanks Hugh for the effort.

I tried on a test table (thank god for that). At the start, nothing seems to happen. Then, after some fiddling, my list (list B) with the form with the element that is supposed to influence the other list element, had the same records as the List_A. Weird. More fiddling and List_A will have an additional row with the field that I wanted it to change but instead of having the value it had the actual field name (or whatever value I put (so instead of having the actual value of maintenance___end_date, it had the name of the element (maintenance___end_date).

I would try again with an easier list, form, and elements and see what happens.
 
I'll have to log in to your site to see. Add a backend login in http://fabrikar.com/you/my-sites. Create a login for me (don't use your default admin account), so you can disable the account when I'm not actively looking at an issue for you. And make sure it's in any groups that ACL's on your app require.

-- hugh
 
Thanks Hugh,

I set the stage for you with a completely new website dedicated to getting the best out of Fabrik. Please check the link you gave me.

I have created two lists with all the necessary elements.
- employees_main
- employees_salary

When adding records to the employees' salary form, I want the value of the new salary to be written to the current salary in the employees' main list.

I have created few records too.

I have tried my best to get it working. I must have tried more than 30 combinations but it did not work. So any help from your side will be greatly appreciated.
 
I'll have to log in to your site to see. Add a backend login in http://fabrikar.com/you/my-sites. Create a login for me (don't use your default admin account), so you can disable the account when I'm not actively looking at an issue for you. And make sure it's in any groups that ACL's on your app require.

-- hugh
Hi Hugh,

Any luck? I have created a site and posted the login info in the http://fabrikar.com/you/my-sites as instructed in your post above.

Tbanks.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top