• Hello again,

    Sorry to keep asking lots of questions, but once I have the main setup done, I will be good to go…so thank you for your patience.

    Is there a way with the current version, or possibly with your upgraded version to count entries in a “Multiselect Checkbox” – so for example, if the multiselect was as follows:

    Car Design:

    – Leather seats: Checked
    – Alloy wheels: Checked
    – Metallic paint: Unchecked
    – Satnav: Unchecked
    – Diesel: Checked

    So in this case all the “Checked” items would equate to 1 and all the “Unchecked” items would equate to 0, which means the total would equal 3 in the above example.

    Thank you

Viewing 15 replies - 16 through 30 (of 94 total)
  • Plugin Author xnau webdesign

    (@xnau)

    No, you have to construct your calculation template without using calculated fields in the template.

    crowwoods1

    (@crowwoods1)

    You mean I can construct a calculation template in the numeric field?

    Plugin Author xnau webdesign

    (@xnau)

    You must construct the calculation template in the Numeric Calculation field that does not use other Numeric Calculation fields.

    Numeric fields are a different thing: they do not have the ability to make calculations, they simply store a number. You can use those in the calculation template.

    crowwoods1

    (@crowwoods1)

    It sounds like I can’t use the Numeric Calculation field at all because it won’t be updated when the participant first updates their records. Only after their updates are recorded in the database before the Numeric Calculation field could work. That means the first Save is just to record their numeric fields, and the 2nd Save is to do the Numeric Calculation fields.

    My question is: can I write custom html in the attributes area of a numeric field to add up the points instead?

    crowwoods1

    (@crowwoods1)

    I mean use JavaScript in the attributes.

    Plugin Author xnau webdesign

    (@xnau)

    The Numeric Calculation field can work, because it looks for the current value in the Numeric fields, it doesn’t need to wait for the submission.

    The difference between a Numeric field and A Numeric calculation field is that a numeric field is a static value, it doesn’t have to be calculated, so its value is available on the first submission.

    As I’ve said from the beginning, the best way to do this is to write a bit of custom php to get the job done. You can put simple javascript in the field attribute configuration, but may be difficult to get it to work that way.

    crowwoods1

    (@crowwoods1)

    I do this custom coding in pdb-record-custom.php. Right?

    Plugin Author xnau webdesign

    (@xnau)

    I don’t recognize the filename, but if that is a plugin, yes, that’s a good place to put it. If that is a template, then no, that won’t work.

    The code should go into a plugin, or you can put it into your theme functions.php file.

    crowwoods1

    (@crowwoods1)

    That was pdb-records-default.php in the plugins/participant database/template folder, copied over to the participant database template folder and renamed. That was the wrong file?!

    What is the name of the plugin you’re talking about? And where is it?

    Plugin Author xnau webdesign

    (@xnau)

    That is correct for a template file, but you can’t put the filter code in there. Try adding it to your functions.php file, I provided a link to help you do that.

    crowwoods1

    (@crowwoods1)

    Roland,

    I want to see if I can do my Plan B, which is to pass the participant data to a 3-party form that can do the point calculations. I’ve already set everything up in that form to gather the actions, do the calculations, and post it back to the database. But seeing how it can’t tell who’s logged-in in pdb, I don’t know if there’s a way to pass the id from one to the other, when they’re connected by a link.

    Thanks, Ivy!

    crowwoods1

    (@crowwoods1)

    Roland,

    ok, I’m back to doing the calculations in a php file. I am putting it in a Code Snippets file. Can you tell me what the hook name should be for doing the calculations in the Participant Record? I assume my custom code comes in when the user press Save.

    Plugin Author xnau webdesign

    (@xnau)

    The filter to use is pdb-calculated_field_calc_value .

    I put together a simple plugin that provides an example of its use:

    https://gist.github.com/xnau/9bc6bfa1046e0f2927d25a10ce185ed6

    crowwoods1

    (@crowwoods1)

    Thank you so much, Roland!

    I modified it for my purpose, but nothing gets written to the database.

    It almost sounds like the return would do it. I have 4 calculated fields to write back to the database, so I put this at the end of the program.

    $result = array($role_points, $one_time_points, $regular_points, $total_points);
    return $result;
    }

    What do I need to write back to the database?

    Plugin Author xnau webdesign

    (@xnau)

    It will write to the database normally, you don’t need to do anything because the calculation is performed when the record is updated.

    If you look at the plugin debugging log (with debugging enabled) you’ll see the write.

Viewing 15 replies - 16 through 30 (of 94 total)
  • The topic ‘Numeric Calculation’ is closed to new replies.