10 Replies Latest reply on Feb 8, 2013 1:22 PM by RickWhitelaw

    Committing record in portal

    ericjlindholm

      Title

      Committing record in portal

      Post

           I have many equipment list in an event.  equipment lists are created in a portal on the event page by adding a name to the list.  There is a script activated by a button that searches for line items in the equipement list and creates one if there are none.  The problem is my users activate the script before committing the name of the list(creating the serial ID numer for that equipment list).  It works the second time you hit becasue the EQ list ID has been commited.  How can I get it to commit between the time they stop typing the name and hitting the button.  I tried commiting the record in the script that is activated but then is only responds to the first portal row.   I think some sort of trigger in the eq list name field that commits the record?  THANKS

           =

        • 1. Re: Committing record in portal
          philmodjunk

               Can you spell out what you are doing in more detail. Maybe by posting your script as well as spelling out your relationships involved?

               The details in that script could be crucial.

               On a second note, not sure why you need a script to 'search for line items'...

               To post a script to the forum:

                 
          1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
          2.      
          3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
          4.      
          5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          6.      
          7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format. (Use the HTML option on the database tab panel and click "Source" in the Post A Answer tool bar to paste the text into the forum's HTML editor.)
          • 2. Re: Committing record in portal
            ericjlindholm

                                My only issue is the Equipment List Record is not created until the name is committed.  but my users type the name and click the button that activates this script without commiting the name/creating an equiqment list record. 

                                My script is as follows

            Freeze Window

            Set Variable [ $EVENTID; Value:EVENT::Event ID ] Set Variable [ $EQLID; Value:Equipment List::eq list id ] Go to Layout [ “Quote Input” (Line Items) ]
            Set Error Capture [ On ]

            Perform Find [ Specified Find Requests: Find Records; Criteria: Line Items::Event ID: “=$EVENTID” AND Line Items::EQ list ID: “= $EQLID” ]

            [ Restore ]

            If [ Get ( FoundCount )=0 ]
            New Record/Request
                                Set Field
            [ Line Items::Event ID; $EVENTID ] Set Field [ Line Items::EQ list ID; $EQLID ]

            End If

            Perform Find [ Specified Find Requests: Find Records; Criteria: Line Items::Event ID: “=$EVENTID” Omit Records; Criteria: Equipment List::EQ list status: “="Declined"” ]
                                [ Restore ]

            Perform Script [ “Sort Line Items” ] Adjust Window

            [ Resize to Fit ]

                  

            • 3. Re: Committing record in portal
              philmodjunk

                   Apologies, but this doesn't fully answer my request for more detail.

                   What relationships do you have in place?

                   Your script references three different tales: Event, EquipmentList and LineItems.

                   How are they linked in relationshps?

                   And on which of these is your layout based? Events?

                   This all looks a bit puzzling because the go to layout script step should, I think, cause the records to be committed, but just from what i see here, If I were to insert a commit records step, I'd add it immediately after the second Set Variable step so that you capture the information from the active portal row before committing records and losing the focus on a specific portal row.

                    

              • 4. Re: Committing record in portal
                ericjlindholm

                     Sorry for the confusion.  The image i posted is of a portal on the event table and layout.  a new equipment list is created by naming one in the portal shown above.

                     My Relationships are :

                     Events have many equipment lists

                     Equipment list have many line items. 

                     Line Items have one inventory reference that must have  event ID and EQLIST ID fields filled out to be displayed in my Quote Input layout(referencing line items table)

                     The problem I am having is that if a user does not click outside the new equipment list name field, the equipment list ID variable cannot be set becaue it is not created until the name is commited.  placing a commit in this script does not seem to work because the portal row cannot be active until its unique ID has been created.

                • 5. Re: Committing record in portal
                  philmodjunk

                       So you have this? (subsitute your field names for mine)

                       Events---<EquipmentLists-----<lineItems

                       Events::__pkEventID = EquipmentLists::_fkEventID
                       EquipmentLIsts::__pkEquipmentLIstID = LIneItems::_fkEquipmentListID

                       

                            The problem I am having is that if a user does not click outside the new equipment list name field, the equipment list ID variable cannot be set becaue it is not created until the name is commited

                       Do you mean the the FIELD EquipmentLIsts::__pkEquipmentLIstID is not set to auto-enter a serial number value until the EquipmentLists record is committed?

                       If so, why not select the "on created" option for this auto-enter setting?

                       If not, please continue to fill in the missing details.

                  • 6. Re: Committing record in portal
                    ericjlindholm

                         The field is set to auto-enter serial number on creation but in this portal, it does not create until a name is filled in.  If i name it and then click outside the name field, a serial number is generated.  But if I trigger the script while the name field is still active, it will not capture the eq list ID because it generates after the varible is captured. 

                          

                    • 7. Re: Committing record in portal
                      philmodjunk

                           Which serial number are we talking about?

                      Set Variable[ $EVENTID; Value:EVENT::Event ID ]

                      Set Variable[ $EQLID; Value:Equipment List::eq list id ]

                           Red or blue?

                      • 8. Re: Committing record in portal
                        ericjlindholm

                             Red.   it commits.  just after the script has ran.  when i go back through it.  it works

                        • 9. Re: Committing record in portal
                          philmodjunk

                               The change in layout immediately after this step commits the record.

                               Try this code at the beginning of your script:

                               Set Variable [$Row ; Value: Get ( ActivePortalRowNumber ) ]
                               Commit Records[]
                               Go to Object ["object name of this portal goes here"]
                               Go to Portal Row [ No dialog ; $Row ]

                               You'll need to use the Name box in the inspector's position tab to give the portal an object name to use with the go to object step. Go to Object makes sure that the correct portal has the focus so that go to portal row is applied to the correct portal.

                               If you have a single portal on your layout, this step is not striclty necessary, but makes for a safer script as your script will continue to work correctly even if you add another portal to the layout at a later date.
                                

                          • 10. Re: Committing record in portal
                            RickWhitelaw

                                 That's odd. The new record should be created as soon as you begin typing the name. It sounds like you have the auto-enter serial number set to On Commit. You have said it's set to On Creation though. Odd.