6 Replies Latest reply on Aug 11, 2013 12:47 PM by davidsan

    Prevent New Records from being Created in a Portal

    user17418

      I have two tables. One has a portal pointing to the other. When the parent record gets locked, how do I prevent other users from creating more child records via the portal?

      (locked in this context means, based upon the data and state of the record, I the developer have deemed that this record should no longer be editable, so I use Record Level Security to no longer allow editing of the record.)

       

      Right now, I have two layouts. One that you can add more child records via the portal, but when the Parent Record Status = Closed, it goes to the other layout that doesn't have the ability to create a child record via a portal.

       

      But that doesn't seem to be the best solution as the protection is based upon the layout used.

       

      A Further Constraint:

      While I can't create a new child record, I can still modify the existing child records. That is something else I wish to prevent when Parent Record Status = Closed. Well only a subset of fields. I still need the owner of a child record to be able to come in and mark the child record as done. (I have been doing this by not allowing access to certain fields in the Portal in Browse mode)

       

      Any ideas?

       

      Thanks

      Zorba

        • 1. Re: Prevent New Records from being Created in a Portal
          opotoc

          Hi,

           

          Put a transparent button over the portal rows:

          If the parent is locked, do something useless (like set empty variable..). The portal is no longer accessible, the button will prevent this.

          If it's not locked go the the field in the portal to be edited/created.

          Maybe you will have to get the current portal row on click to redirect the click to the right row.

           

          Using multiple "psyeudo" buttoms you can lock any field on your layout.

          Please don't forget to assign an object name for every field/object you want to go to.

           

          Best,

          Alexander

          • 2. Re: Prevent New Records from being Created in a Portal
            davidsan

            I have solved this issue using a field in the parent that cannot be modified: a lock field.

             

            In order to create child records from the parent I set a validation in the child table primary key that only let create records if the lock field in the parent is open. Since record creation on this table is only accessed through the parent it has no security issues.

             

            This technique cannot prevent the last row of a portal to be filled but it does not allow to commit the record, it reverts it to the previous state. I think portal records locking can only be done using your technique of using another portal view with diferent options in the relationship graph or with interface hacking (transparent buttons and such).

             

            At the database level, it seems create cannot be limited by the schema, but commit can.

            • 3. Re: Prevent New Records from being Created in a Portal
              keywords

              If you disallow creation of portal rows via the relationship, instead controlling this process via a script, you will be able to more readily handle the locking issue because it will no longer possible for anyone to simply click in the blnk last portal row to create a new record, and you can also set the portal to not allow direct entry in Browse mode.

              • 4. Re: Prevent New Records from being Created in a Portal
                davidsan

                I think it is not possible to toggle the "allow creation of records" in the relationship graph by scripting or calculation. Remember he wants to lock the master and detail records once they are marked as locked. Very useful in invoices, for example.

                 

                So he would need two relationships. One for showing and one for editing and a script to switch between both layouts when convenient. However, not showing is not locking.

                 

                Having one layout for entering data and one layout for showing data (when editing is not allowed) is a nice solution but still you need to make sure no one can bypass the user interface an insert rows in the database when a record is locked.  The foolproof way is in the database schema.

                • 5. Re: Prevent New Records from being Created in a Portal
                  keywords

                  I think it is not possible to toggle the "allow creation of records" in the relationship graph by scripting or calculation.

                   

                  That is not what I was suggesting.

                  • 6. Re: Prevent New Records from being Created in a Portal
                    davidsan

                    I would like to understand better what you are suggesting.

                     

                    I assume that what you are saying is to create two layouts. One with editable portal (allow create on the relationship graph) and one with a non editable portal (allow create on the relationship graph empty). After you fill the info in the layout with editable portal then provide a mechanism to navigate to the other layout with non editable portal. This way an "invoice" could be locked after printed, for example.

                     

                    This works and the question is not about that. You are not avoiding record creation on the table which is the issue, just not showing the interface. From another layout or interface new records on the detail table could be created.

                     

                    The only way I have found to lock the database at schema level is using a field validation since "security" does not provide a "limit..." on create records.

                     

                    To avoid editing on child records, I have activated in the security of the database the option "limit..." and insert a calculation that takes into consideration the field record status closed. If status is not closed, then allow editing of the child records.