5 Replies Latest reply on Mar 28, 2015 11:21 AM by philmodjunk

    Field not being changed

    cosmocanuck

      Title

      Field not being changed

      Post

      Hi all!

       

      I'll try to summarize this weird problem as compactly as possible...  smiley

       

      I'm tracking donations for a charity, and running into something weird. Leaving out unrelated (AFAIK) stuff, here's the structure:

       

      There's a Contacts table, and a related Donations table. The latter has the usual fields, plus a boolean "Needs Receipt?" checkbox for each donation.

       

      To track which contacts have donations requiring a receipt, I have a field on Donations called "AmountReceiptNeeded". It's zero if "Needs Receipt?" is unchecked, or contains the donation amount if it is.

       

      The contacts table includes a field called "AmountReceiptNeededSum", which totals up the related "AmountReceiptNeeded" fields. If it's larger than zero, that donor - and their total donations requiring a receipt - are included in a portal on a “home” or “dashboard” layout.

       

      So far, so good. But:

       

      I’m trying to improve that portal’s speed by having it depend on a table relationship, not a portal filter. To do so, I’ve had to set up stored versions of the above fields since they’re all calculation fields and thus unable to be part of a table relationship. (As I've learned!)

       

      So, I have to add script steps to manually copy over the value of the original fields into non-dynamic, stored versions of those fields, whenever the “Needs Receipt?” box is checked or unchecked, or when a reciept is deleted. (Those non-dynamic fields are used in the table relationship.) And, it’s working great…. with one exception.

       

      When I delete a receipt, the “AmountReceiptNeededSum” field on Contacts dynamically updates as expected, but I need to then copy that new amount into the stored version, “AmountReceiptNeededSum_STORED”. 

       

      But it’s not happening.

       

      On the Contacts layout, it’s wrong. It’s not updated.

       

      My “Delete Donations” script (slightly paraphrased in spots) looks like this:

       

      (Custom dialog to confirm deletion)

      If (user said yes)

      Exit Script []

      End if

      Delete Record/Request [No dialog]

      Set Field [Contacts:: AmountReceiptNeededSum_STORED; Contacts:: AmountReceiptNeededSum]

       

      But on the Contacts listing, it hasn’t happened. The calculation field is working fine, but it's not being copied over to the other field.

       

      I’ve added the fields in question over on the right in the attached sample listing.

       

      I can’t figure out why this isn’t working… hope someone can point me in the right direction!

       

      Thanks,

      Adam

      sample.jpg

        • 1. Re: Field not being changed
          philmodjunk

          Are you deleting donations from a layout based on the donations layout or a layout based on contacts?

          It sounds like you are deleting a donation from a layout based on the donations table. If so, once the record is deleted, you lose connection to the donor record linked to the donation record just deleted.

          Have your script, set the donation amount to zero, commit records, set the stored field to the new value and then delete the record.

          • 2. Re: Field not being changed
            cosmocanuck

            Thanks. I had a vague sense that deleting the record was at the root of my trouble, but hadn't yet pursued it to  its logical end...

            The way I got it to work was by having TWO "commit records" steps:

                   
            • one after setting the about-to-be-deleted donation's amount to 0, 
            •      
            • one after setting the stored "donations sum" field to the same value as the calculated one. 

            I have got it to work, but notice something strange (though not a deal-breaker now):

            I opened the data document side-by-side with my Dashboard front-end doc (yes, I'm practicing good data separation), and watch the field values in both files.

            At the end of the deletion, the stored and unstored fields in the Dashboard file are correct (and the portal is working). But the visible value of the unstored field in the Data file appears out of date; however when I click on it, it corrects itself.

            Perhaps I don't need to worry about this, but should I somehow commit that field too? 

            Thanks again!

            • 3. Re: Field not being changed
              philmodjunk

              This is a known issue when you use a script in the data file to modify the data. But you shouldn't be using a script in the data file to modify the data, it should be a script in the interface file.

              • 4. Re: Field not being changed
                cosmocanuck

                Hmm, I was aware that my scripts need to be in the interface file, and only data in the data file. The script(s) in question are definitely in the interface file. But I'll check again to see if I've inadvertently done something incorrectly...

                • 5. Re: Field not being changed
                  philmodjunk

                  There could be other issues delaying the update, but I can't tell from what has been posted thus far.