1 2 Previous Next 16 Replies Latest reply on Jan 4, 2013 11:50 AM by hanstrager

    Calculation in a portal..?

    hanstrager

      Title

      Calculation in a portal..?

      Post

           I've made a portal in one of my layouts, which I've modified a little so it looks a bit like a small form instead of a list view.

           I have 3 problems im wondering whether someone knows how to solve..?

           1) is there a way so that everytime i add a record in the portal, that it dosen't automatically add the next one and have a button to add the next one instead..?

           2) is there a way to do so when you delete the info in the value list where it says "fabric" the record disappears as it hasen't been added yet

           3) the portal is based on a conditional value list from "fabric" and "name" and then autofills the rest of the fields from a related table. I don't want to have anyone to change the info in the fields of the autofills except from the related tabel. Is there a way to do so the noone can change the values in the portal..?

           Is there anyone who know where to start with any of all this..? Please see picture

            

      portal_questions.jpg

        • 1. Re: Calculation in a portal..?
          philmodjunk

               1) Go to Manage | database | relationships, double click the relationship line and clear the "allow creation of records..." check box for the portal's table occurrence. Then add a button that performs this script:

               Set variable [$ID ; value: LayoutTable::PrimaryKey ]
               Freeze Window
               Go To Layout [Specify layout based on portal table]
               New Record/Request
               Set Field [PortalTable::ForeignKey ; $ID] ---> This step links the new record to the current record on the  layout so that it will appear in your portal
               Go To Layout [Original Layout]

               Be careful of any script triggers on either of these two layouts. The change in layouts can trip OnLayoutEnter, OnLayoutExit, OnRecordLoad, OnOBjectEnter and OnObjectExit script triggers. Sometimes you have to set a value in a global variable that these scripts check before doing anything to keep them from interfering with this script.

               2) No you cannot as you have created that new record the instant you selected a value in the value list or when you ran the script I just posted. But a script trigger on the fabric field could detect onObjectExit when the field is empty and then delete this portal row record. You might instead want to add a button to the portal row that deletes that portal record. You can examine the delete portal row record in my Known Bugs List database. It can be imported freely into any file and can delete the portal row record from any portal in your database where you add a button to perform that script. If you use this script, be careful to examine what data is passed to this script as a script parameter as this is what is used by the script to display a confirmation message

               3) While in layout mode, select a field that you do not want to allow users to edit, then go to the Behavior section on the Inspector's Data tab and clear the checkbox for browse mode. This will prevent any user from entering the field while in browse mode.
                

          • 2. Re: Calculation in a portal..?
            hanstrager

                 1) I've now made a button that are performing the script your descriping above just have a few questions to what i need to put as parameters?

                  

                 Set variable [$ID ; value: LayoutTable::PrimaryKey ] What do I put as name and value..?
                 Freeze Window
                 Go To Layout [Specify layout based on portal table] this is the layout where my portal is placed?
                 New Record/Request
                 Set Field [PortalTable::ForeignKey ; $ID] what do I set the target field as..?
                 Go To Layout [Original Layout]

                 2) First and foremost thank you for making these scripts avaliable for free, I guess it's christmas...

                 I've imported the script and attached it to a button on my portal, but nothing happens when i push the button..? is there anything I've done wrong..?

                  

            • 3. Re: Calculation in a portal..?
              philmodjunk

              What do I put as name and value..?

                   What do you have in your database? You need a field that uniquely identifies each record in the table. Most of the time in FileMaker, this is a field with an auto-entered serial number. Use that field here.

              this is the layout where my portal is placed?

                   No. This is a different layout where the table occurrence listed in the portal's portal setup drop down (Show Related Records From), is specified in Layout Setup (Show Records From). That way, New Record/Request creates a new record in the portal's table not the table referenced by your original layout.

              what do I set the target field as..?

                   What do you have in your database? On your original layout, it refers to a table in your database and your portal refers to a table in your database. In manage|Database|Relationships, you have a relationship linking these two tables. Using the names I've used, they'd be named and match fields like this:

                   LayoutTable::PrimaryKey = PortalTable::ForeignKey

                   If this were an invoices solution with an invoice layout and a portal to line items, it might look like this:

                   Invoices::__pkInvoiceID = LineItems::_fkLineItemID

                   You'll need to use the table and field names from the relationship used to set up this portal in place of the names that I have used in my example.

              • 4. Re: Calculation in a portal..?
                hanstrager

                What do I put as name and value..?

                What do you have in your database? You need a field that uniquely identifies each record in the table. Most of the time in FileMaker, this is a field with an auto-entered serial number. Use that field here.

                     I have set name to: $Line Items ID    and     Value field to: Line Items::ID

                this is the layout where my portal is placed?

                No. This is a different layout where the table occurrence listed in the portal's portal setup drop down (Show Related Records From), is specified in Layout Setup (Show Records From). That way, New Record/Request creates a new record in the portal's table not the table referenced by your original layout.

                     Have set this to: Go to Layout ["Line Items"(Line Items)]

                what do I set the target field as..?

                What do you have in your database? On your original layout, it refers to a table in your database and your portal refers to a table in your database. In manage|Database|Relationships, you have a relationship linking these two tables. Using the names I've used, they'd be named and match fields like this:

                LayoutTable::PrimaryKey = PortalTable::ForeignKey

                If this were an invoices solution with an invoice layout and a portal to line items, it might look like this:

                Invoices::__pkInvoiceID = LineItems::_fkLineItemID

                You'll need to use the table and field names from the relationship used to set up this portal in place of the names that I have used in my example.

                     Have set this to TECHNICAL SHEET 2::xTechnical sheet_ID = Line Items::TechSheetID_FK

                      

                     Now the portal dosen't show anything at all (because i unchecked the "allow creation of records via relation ship" inbetween the relationship of Technicalsheet 2 and Line items), so I've tried to take the button out of the portal which dosen't work either. I don't know if my set up is correct, so have attached my relation graph, to see if this will help.

                     aswell my delete button dosen't work which you kindly posted in the first post, is there something i need to do here to make it work, now you can see my relationships..?

                      

                      

                      

                • 5. Re: Calculation in a portal..?
                  philmodjunk

                       In Layout setup for the layout where you have the portal, do you have Technical Seet 2 selected in "show records from"?

                       In portal setup for the portal, do you have Line Items selected?

                       You would not want an "add" button for this script located inside the portal. Put it on the layout, outside of the portal instead.

                       If you still cannot get this to work, please post the exact script that you are trying to get to work.

                       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 paste the text into the forum's HTML editor.)
                  • 6. Re: Calculation in a portal..?
                    hanstrager

                         I can't find where in the layout setup, it says the layout that contains my portal, shows records from "Technical Sheet 2". But in layout mode it says the layout is based on the "Technical Sheet 2" table aswell as in manage layouts it says it's assosiated with "Technical Sheet 2"

                         "Line Items" is selected in the portal setup.

                         this is how my script looks which is attached to the button outside of my portal:


                         Set Variable [ $Line Items ID; Value:Line Items::ID ]
                         Freeze Window
                         Go to Layout [ “Line Items” (Line Items) ]
                         New Record/Request
                         Set Field [ TECHNICAL SHEET 2::xTechnical sheet_ID = Line Items::TechSheetID_FK ]
                         Duplicate Record/Request
                         Go to Layout [ original layout ]
                          

                    • 7. Re: Calculation in a portal..?
                      philmodjunk

                           Why do you use Duplicate Record/Request?

                           The first line should be:

                           Set Variable [$TechID ; value: Technical Data Sheet 2::xTechnical Sheet ID ]

                           The set field step, should then read:

                           Set Field [ Line Items::TechSheetID_FK ; $TechID ]
                            

                           Note that there is no = sign in the set field and there is a semi colon instead. When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                      • 8. Re: Calculation in a portal..?
                        hanstrager

                             iiiiit's working - only one problem - since my portal is in a tab-control menu - and everytime i hit add a-new-record-button in the portal it jumps all the way to the first tab, and I then have to navigate all the way back again... is there something i can put in the script so it let me stay in the tab where the portal is..?

                        • 9. Re: Calculation in a portal..?
                          philmodjunk

                               Ok, that's an easy one.

                               Enter layout mode. Select the tab you want to keep uppermost by clicking it.(click once to select the tab control, click again to select the tab panel)

                               Use the name box in the Inspector's data tab to give this tab panel an object name.

                               Then you can use the go to object script step, located after the go to layout step that returns you to your original layout, to re-select the desired tab panel.

                          • 10. Re: Calculation in a portal..?
                            hanstrager

                                 it sounds - so easy, and therefore im a bit embarrassed i can't find where to give my tab an object name. I've clicked it twice, though there's nowhere in the "data" section in the inspector panel i can fill anyhing in.

                                 In the "position" tab there is a name field, which i assume is the object name...?

                                 I've put the name in the name field as "fabrictab"

                                 and in my button script i now in stead of go to layout i use:

                                 Go to Object[Object Name: "fabrictab"]

                                 which now sends me to "Line Items" table when i click the button...

                            • 11. Re: Calculation in a portal..?
                              philmodjunk

                                   ooops. It's on the position tab. What was I thinking? blush

                              • 12. Re: Calculation in a portal..?
                                hanstrager

                                     i for some reason can't get it to work.

                                     I've named my tab "fabrictab" i then go into the script of my button, deletes previous script step (go to layout) and changes it into Go To Object.

                                     Then i'll try to specify which object to go to, so in object name i write: "fabrictab", but when i go into browse mode and push the button it sends me to the "line items table". Then i've tried to go to specify a calculation and put "fabrictab", but gives me an error saying "fabrictab is not a table" which is understandable. Then I try TECHNICAL SHEET 2::"fabrictab" but says "field not found".

                                     Im a bit lost to what now to put in, tried a few google searches, and seems everyone is saying i should just put in "fabrictab", but it doesen't work..?

                                • 13. Re: Calculation in a portal..?
                                  philmodjunk

                                       I don't understand what you are describing. Doesn't your button use Perform Script?

                                       Why would you delete the go to layout step? Your script must still change layouts, but once you have changed layouts back to the layout with the tab control, you can use go to object to put the focus back on "fabridtab", popping it back to the front. Thus you need both go to layout and go to object.

                                  • 14. Re: Calculation in a portal..?
                                    hanstrager

                                         Ohhh - my fault, thought i had to deactivate go to layout, but when it's in it works perfect...
                                          Thank you so much, for taking you time to explain me this over 13 posts...

                                         The only thing is how to delete the rows again, i attached the script you gave me from i the first post to a button, and it dosen't do anything, tried to look through the script and the description text, though it made not much sense to me..:(

                                         is this something you want me to open a new post with..?

                                    1 2 Previous Next