1 Reply Latest reply on Mar 26, 2012 11:13 AM by philmodjunk

    Making records read only based on conditions.



      Making records read only based on conditions.


       This is probably fairly simple, but before i start it i would like to know the best way to accomplish my desried result.

      I would like to make an invoice record read only after it has been paid. One of my fields is "invoice status". The conditions are new, pending, shipped and paid. I think the obvious method would be to create code that would render the record read only based on the criteria of the field once it has been changed to paid.

      Could I get a little help on the code to do that. I'm not that great at coding and it would probably take me all night to get it right. Also my other consideration is this: What about the relational information that is being brought over from other tables? Like line item info and shipping addresses. For example, say a customer moves, I update his shipping address. Now the invoice would reflect the change. I dont want that, i want it to show where it originally shipped and nothing else. How do i keep this information from changing.  Any thoghts on this would be great. thanks


        • 1. Re: Making records read only based on conditions.

          We lock our records in much the same manner. Please note that if you have this typical setup for invoicing:


          Then you need to lock both the Invoice record and the related LineItems records.

          To start, see "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis" for a detailed description of how to set this up.

          You'll want to use a Lock expression such as:

          Invoices::Invoice Status ≠ "Paid"

          For the Line Items table as well as invoices. But this leaves one loop hole open. It's still possible to create a new line item record for a paid invoice in the portal to line items. You can lock out this possibility in two ways and I suggest you use both:

          On the fields in line items that appear in the portal, define this validation calculation:

          Invoices::Invoice Status ≠ "Paid"

          This will catch any such cases and pop up an error message.

          Then I defined a script with:

          If [Invoices::Invoice Status = "Paid"]
            Commit Record
          End If

          and set it up with the OnObjectEnter trigger for the portal so that attempts to enter data in the bottom blank 'add' row of the portal could not be done.