1 Reply Latest reply on Feb 10, 2015 2:31 PM by philmodjunk

    Table relationship for creating new related record without a portal.

    ericjlindholm

      Title

      Table relationship for creating new related record without a portal.

      Post

       

      I would like to create a table relationship that would create a new related record without a portal.  For example I have a user/task relationship.

      User::ID -------<Tasks::Assigned to

      I have a portal of tasks that have been created but to add a new one, I need a go to the last portal record which is usually too far down the list to be convenient.  I can also create a second portal that is filtered to show only the uncreated record.  

       

      Portals in Popovers in footers do not proper display valuelists from filemaker go so I would like to create a table relationship for the new task.  Is this possible?  What is the best way?

      I have been creating separate layout for this function and writing a lot of scripts to make this work but it would simplify things a lot to because i have the space on my layouts already(they are in a filtered portal that does not work on iPad.  )

        • 1. Re: Table relationship for creating new related record without a portal.
          philmodjunk

          In terms of set up, it's really simpler to use a script to change to a layout based on the portal, create the new related record and return. You can specify a sort order for your portal, BTW, that puts such a newly created record at the top of your portal so that tapping a button to add a new record causes a new blank row to appear at the top of your portal.

          But if you want to create a new record via a relationship without changing records, it can be done:

          Define a field cOne in your parent table with this calculation:

          1

          Define a number field, Create, in the portal table.

          Define this relationship to an added occurrence of the portal's table:

          Parent::cOne = Portal|Create::Create

          Enable "allow creation of records..." for Portal|Create.

          Use this script:

          Set FIeld [Portal|Create::_fkParentID ; Parent::__pkParentID ]
          Set Field [Portal|Create::Create ; "" ]
          Commit Records ---> I think you'll need this step to get your screen to update, but feel free to try to do it without the commit and see.

          How it works. Using set field to set a field (any field) from the portal's table will create a new related record if the following two conditions are True:

          a) allow creation is enabled
          b) no such related record currently exists for the current parent record.

          So without the second set field step, this would only work once to create a new related record. The second set field breaks the relationship between the current parent record and the portal record so that the script can be run again to create another new record.