6 Replies Latest reply on Mar 25, 2015 11:30 AM by ZakMcKraken

    Script Help for Portal Complication

    ZakMcKraken

      Title

      Script Help for Portal Complication

      Post

      This is really confusing me as I have never really tried to do this.  I have a portal set up within a DB, based upon a requirement (member or board member), I want the portal to have a new record added to it.  The new record must have a date, a debit, and a description line with information edited (they are already there within the portal for manual entry).  The kicker... I need one button to do this all at once as a batch process.  The find script is obviously not the issue, it's getting down to add the new record... I just get wishy washy here.

      Any help would be really appreciated!

      Thanks so much!

      Zak

        • 1. Re: Script Help for Portal Complication
          philmodjunk

          Can you explain what you mean by making this a "batch" process?

          The script for creating a single portal record is pretty simple. 

          • 2. Re: Script Help for Portal Complication
            ZakMcKraken

            Basically I want to create a button which when I click it will add values for the three records (current date, a number for a numerical field, and a Description of the transaction in the Description Field)  for all "Members" and "Life Members" in my database.

            • 3. Re: Script Help for Portal Complication
              philmodjunk

              But I really can't tell what tables and relationships you have. Need to know that in order to spell out the details. 

              • 4. Re: Script Help for Portal Complication
                ZakMcKraken

                I REALLY appreciate your help here!

                Ok, sorry, my brother is helping me here and is explaining a lot to me.  He is having the problem at adding a new record in the portal (child? sorry he says he is best at FM7 and recently used 11... 13 is very new to him)

                "membership" Database, matched with a portal "dues" to each member...  that portal has records for finacial transactions for each member.

                Fields included in the portal are: Date, Debit, Credit, Description

                The Membership Database has a field in it indicating what type of member they are... depending on their membership status, I want to have a script that will add to EVERY one of those member types a new transaction record in the portal that will have the current date, a 40.00 debit, and a description that says "Yearly Dues"

                I hope this was a bit clearer. I hope :)

                • 5. Re: Script Help for Portal Complication
                  philmodjunk

                  That helps and the basic method should have worked the same in FMP 7--except that I'll use a variable where I would have used a global field back then so your brother should be able to follow this suggested method:

                  First, you have relationship linking two tables:

                  Membership----<Dues
                  Membership::__pkMemberID = Dues::_fkMemberID

                  Of course, I don't know the name of the actual tables and fields so you'll have to adjust things to match the table and field names that you actually have.

                  And you'll have at least one layout based on Membership. That means that there's a layout that shows "Membership" in the "show records from" drop down found in layout setup for that layout. You'll also have one based on Dues unless it was deleted for some reason. You'll need both layouts for this method.

                  The following script would be run starting on the layout based on Membership:

                  #First you'll need to perform a find or do a Show All Records to get the set of Membership records for which you want to add this new Dues Record. This can be scripted or done manually. I'm leaving that up to you and starting with the very next step in the script:

                  Go to Record/Request/Page [first]
                  Loop
                     Set Variable [$ID ; value: Membership::__pkMemberID ]
                     Go to Layout ["Dues" (Dues) ]
                     New Record/Request
                     Set Field [ Dues::_fkMemberID ; $ID ]
                     Set Field [ Dues::Debit ; 40 ]
                     Go to Layout [ Original Layout ]
                     Go to record/request/page [next ; exit after last ]
                  End Loop

                  PS, while I've used the literal value 40, you can improve on the basic idea if you set up a global field with the value of your debit and then refer to that global field in place of 40 in the set field step that assigns the debit value. That way, if you should change your dues in the future, you can edit the value in the global field instead of having to modify this script.

                  • 6. Re: Script Help for Portal Complication
                    ZakMcKraken

                    This is amazing.  I just spoke to him and he said he feels shameful for not thinking of the call to the portal layout in the first place.

                    The additional global field is slick, he mentioned he would create an administration layout so I could do things like sort, range find, etc with button scripts that he'll create.  We have non-technical users that will need these added as we don't want them fiddling with find and delete all found record type functions.

                    I'll have him try this and report back with any questions if needed.  Once again thanks for your amazing help!