This site has been archived. Please visit help.fulcrumapp.com for our new support documentation and contact information.

Filter Repeatable Value Array?

Parker Wittman's Avatar

Parker Wittman

17 Jul, 2015 03:57 PM

**Note: This is mainly an academic question at this point. I know there are other ways to design my app to not have to handle such a contingency. Still, I'm curious if this is possible:

Say I have a repeatable values section of my app which lists all measurement devices at a given monitoring location. For simplicity's sake, lets say the repeatable values section of my app ("$Device_List") has just two parts: "Device_ID" and "Actively_Monitored_YN". Let's also say I have a repeatable value section of my app where I record various measurements collected at that monitoring location. In the "$Measurements" repeatable values section I ask the user to enter the ID of the device from which they're taking a measurement. Say then, I want to somehow validate that entry and make sure they've entered a Device ID that matches an Actively Monitored device associated with the given monitoring location. They key here is that I only want Device_IDs that have "Actively_Monitored_YN" set to "Yes".

If I use the REPEATABLEVALUES() function to return an array, can I filter the output based on another field in the Repeatable Values section?

From there, I figure if I then have an array of all the actively monitored devices at my location I can validate the Device_ID from the measurement record by seeing if it exists in the array of actively monitored devices.

In an ideal world, of course, I'd give them a dropdown of monitored devices created on the fly from the the device list array... alas, I'm pretty sure that's not possible.

Thanks!

  1. Support Staff 1 Posted by Alex Helms on 17 Jul, 2015 04:17 PM

    Alex Helms's Avatar

    Hello,

    I do not think what you are seeking to do is possible. We do have a new field type coming out soon. This field type will allow you to link records from one app to another. Included in this is functionality that will allow you to filter the records contained in the linked app. We hope to have this released later this month.

    What you are seeking to do may be possible with this new feature, but I will have to test this out to see if it is possible. I will let you know.

    Thanks,
    Alex

  2. 2 Posted by Parker Wittman on 17 Jul, 2015 04:18 PM

    Parker Wittman's Avatar

    Cool. Thanks Alex. I'm excited to hear about the new feature. That will be an amazing perk to our workflows.

  3. 3 Posted by Parker Wittman on 18 Jul, 2015 12:28 AM

    Parker Wittman's Avatar

    I actually think I've got a workable solution to this:

    (NOTE: "device_id" and "actively_monitored_yn" are both required...so I can be reasonably sure the arrays are of the same length. Still, I check to make sure that's the case anyways)

    var devices = REPEATABLEVALUES($device_list,"device_id");
    var mon_yn = REPEATABLEVALUES($device_list,"actively_monitored_yn");
    var active_devices = [];
    var device_check = "No Match";
    
    if (devices && devices.length > 0 && mon_yn && mon_yn.length > 0 && devices.length == mon_yn.length) {
      
     for (i = 0; i < devices.length; i++) {
        if (mon_yn[i] == 1) {
          active_devices.push(devices[i]);
       }
      }  
    
    }
    
    if (active_devices && active_devices.length > 0){
     for (i = 0; i < active_devices.length; i++) {
       if ($measured_device_id == active_devices[i]){
            device_check = "Ok!";
       }
     }
    }
         
    SETRESULT(device_check)
    

    This essentially gives me a result "device_check" that I can use in a calcualted field to tell the user that they entered a valid device_id from the list of actively monitored devices. Sweet.

    Now, ideally, I could create a choice list on the fly from an array calculation... but I don't think that functionality exists yet.

    I'd appreciate feedback on my approach if you have any!

  4. Support Staff 4 Posted by Alex Helms on 20 Jul, 2015 02:53 PM

    Alex Helms's Avatar

    Hello Parker,

    Nice! I will ask one of the developers to take a look at this and provide any feedback if they feel that it is needed.

    You are correct, the expressions in the calculation field are limited to only affect that specific field.

    Thanks,
    Alex

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac