Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Nathan Explosion Posted March 16, 2016 Posted March 16, 2016 As it appears that it's not possible to have a computed field in a database (ie a field whose value is calculated based on other fields in the record) so I'm having to look at alternatives. "You could just calculate the value when displaying the record" I hear you say....yes, and it works fine. But I'd like to be able to allow people to sort the record table on these calculated fields. So....option available: use JS on the form which will re-calculate a field when one of the other fields changes. Nice and easy. Problem: included JS in a page doesn't get included when editing a record. I've included a little alert("test"); in a page, and it fires when viewing the record listing, and when viewing the record. But when you edit the record, it doesn't fire. Is include JS supposed to work like that?
Nathan Explosion Posted April 1, 2016 Author Posted April 1, 2016 Just to come back to this - I've worked around this by plonking my JS code in to the Google Analytics section on the site and it meets the need I have. But I'd prefer not to do this so if anyone has any input in to whether or not this functionality should be available, and how to achieve it?
Flitterkill Posted April 3, 2016 Posted April 3, 2016 You may need to include the js on the record form templates. ACP - Pages - Templates - Add Template - Choose Database - and then from the drop-down for type the last one is Record Form which handles record entry and editing. Plonk it in there somewhere and if it works, great. If not maybe it helps to narrow down the problem. Otherwise sticking it somewhere in the global template as you already figured out gets the job done.
Nathan Explosion Posted April 3, 2016 Author Posted April 3, 2016 Sorry - was half asleep and misread that. Yep, that will work too - all inline in there, or I can host a js file off somewhere and call that in. Shame as the JS template section is a great one-stop shop to isolate things off to a specific db/page.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.