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

Parent/Child and data events

phil's Avatar

phil

01 Sep, 2016 01:18 AM

Hi Folks,

I have a parent and child form ($contact_records) where I set a 'child status' ($contact_records.status_of_contact). I would like to update the parent status to reflect the latest (by date... $contact_records.contact_date) 'child status'. Is this possible?

  1. Support Staff 1 Posted by Alex Helms on 01 Sep, 2016 12:13 PM

    Alex Helms's Avatar

    Hello Phil,

    When you say date, is this is user defined field or do you just mean the most recently created child record?

    Something like this should work if you mean the most recently created child record:

    ON('save-repeatable', 'repeatable_section', function(event) {
    SETSTATUS(LAST(REPEATABLEVALUES($repeatable_section, 'repeatable_field')));
    });
    
  2. 2 Posted by phil on 02 Sep, 2016 03:10 AM

    phil's Avatar

    Thanks Alex, I will give that a try when I get back to the computer

    Cheers - Phil,
    On the road with his iPad

  3. 3 Posted by phil on 05 Sep, 2016 01:55 AM

    phil's Avatar

    Not quite Alex - TASMAPS account - PW - Work in Progress - Outreach Form 2016/17

    repeatable section - contact_records
    repeatable field - status_of_contact

    ON('save-repeatable', 'status_of_contact', function(event) {
    SETSTATUS(LAST(REPEATABLEVALUES($contact_records, 'status_of_contact')));
    });

  4. 4 Posted by phil on 08 Sep, 2016 02:08 AM

    phil's Avatar

    If I use

    ON('save-repeatable', 'contact_records', function(event) {
    SETSTATUS(LAST(REPEATABLEVALUES($contact_records, 'status_of_contact')));
    });

    I get an error 'status must be string'? 'status_of_contact' is a single choice list so I would have thought it was a string already

  5. Support Staff 5 Posted by Alex Helms on 08 Sep, 2016 06:32 PM

    Alex Helms's Avatar

    Ok, so I learned a few things today.

    First, you cannot obtain the values captured in a field in other child records through a repeatable event. To get around this, we had to change from the save-repeatable event to the change event that looks at the repeatable section. So the code is run anytime a child record is added or deleted.

    Second, Using the REPEATABLEVALUE expression actually produces an array of objects, so what was being produced with the LAST() expression was basically the 'field' that contained the last value in it, but not the actual value. To pull the actual value out you have to use the CHOICEVALUE() expression.

    In the end, this is what I was able to get to work:

    ON('change', 'contact_records', function(event) { 
      var lastStatus = LAST(REPEATABLEVALUES($contact_records, 'status_of_contact'));
    SETSTATUS(CHOICEVALUE(lastStatus));
    });
    

    I did save this code to your app, so you should be good to go.

  6. 6 Posted by phil on 08 Sep, 2016 11:04 PM

    phil's Avatar

    Many thanks Alex

    Support such as this is what keeps me coming back to Fulcrum. As a non coder it's the sort of assistance I need to help me keep learning.

    Cheers - Phil,
    On the road with his iPad

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