11 Replies Latest reply on Jun 2, 2014 9:19 AM by philmodjunk

    limit of portal records

    hanstrager

      Title

      limit of portal records

      Post

           I just need to make a script that sets a limit to how many records i can add to my portal without using a button.

           I have made the following script:

           If [ Count ( Knit MeasurementsTemplate::Type template ID_FK ) ≥ 8 ]
           Show Custom Dialog [ Title: "No enough space"; Message: "No more space for meassurements";
           Default Button: “CANCEL”, Commit: “Yes” ]
           Else
           Set Variable [ $TechID; Value:Knit Measurement Type Templates::Id ]
           Freeze Window
           Go to Layout [ “KNIT Measurement temp” (Knit MeasurementsTemplate) ]
           New Record/Request
           Set Field [ Knit MeasurementsTemplate::Type template ID_FK; $TechID ]
           Go to Layout [ original layout ]
           End If

           I just don't know hoe to add this script to my portal so it only adds a record to the portal if I'm in the last empty portal row..? I tried to add the script as a script trigger in my text field but couldn't find a suitable scrip trigger. Does anyone have any good advise to solve this..?

      Screen_Shot_2014-05-25_at_16.57.11.png

        • 1. Re: limit of portal records
          philmodjunk

               OnObjectEnter should work, just have the script check for a value in the portal table's ...ID_PK field and only count values/show this message if that field is empty. If the field is not empty, have the script exit without doing anything.

          • 2. Re: limit of portal records
            hanstrager

                 I've change the script to this:

                 If [ Count ( Knit MeasurementsTemplate::Type template ID_FK ) ≥ 8 ]
                 Show Custom Dialog [ Title: "No enough space"; Message: "No more space for fabric on page for more meassurements";
                 Default Button: “CANCEL”, Commit: “Yes” ]
                 Else If [ IsEmpty(Knit MeasurementsTemplate::MeassurementDescription) ]
                 Set Variable [ $TechID; Value:Knit Measurement Type Templates::Id ]
                 Freeze Window
                 Go to Layout [ “KNIT Measurement temp” (Knit MeasurementsTemplate) ]
                 New Record/Request
                 Set Field [ Knit MeasurementsTemplate::Type template ID_FK; $TechID ]
                 Go to Layout [ original layout ]
                 Go to Field [ Knit MeasurementsTemplate::MeassurementDescription ]
                 End If

                  

                 I've tried to add a 'Go to Field' in the end, since i when I go into the last row and it's empty it just makes another portal record but my courser goes out of the field. So at the moment i have to fill the portal with 8 records and then access them one by one everytime getting the "No more space for fabric on page for more meassurements" message, in order to go into my MeassurementDescription field. thought a 'Go to Field' would sort this but it doesn't. Any ideas how I can fix this..?

            • 3. Re: limit of portal records
              philmodjunk

                   You only want to count records if you have clicked into the "add row" at the bottom of the portal, correct?

                   So your script should start with:

                   If [ IsEmpty ( Knit MeasurementsTemplate::Type template ID_FK ) ]
                     //Put your script here
                   End IF

                   Then the script will only check the number of entries if you are clicking into the bottom add row to try and add a new portal record.

              • 4. Re: limit of portal records
                hanstrager

                     I now have the following:

                     If [ IsEmpty (Knit MeasurementsTemplate::Type template ID_FK) ]
                     If [ Count ( Knit MeasurementsTemplate::Type template ID_FK ) ≥ 8 ]
                     Show Custom Dialog [ Title: "No enough space"; Message: "No more space for fabric on page for more meassurements"; Default Button: “CANCEL”, Commit: “Yes” ]
                     Else
                     Set Variable [ $TechID; Value:Knit Measurement Type Templates::Id ]
                     Freeze Window
                     Go to Layout [ “KNIT Measurement temp” (Knit MeasurementsTemplate) ]
                     New Record/Request
                     Set Field [ Knit MeasurementsTemplate::Type template ID_FK; $TechID ]
                     Go to Layout [ original layout ]
                     Go to Field [ Knit MeasurementsTemplate::MeassurementDescription ]
                     End If
                     End If

                     but when I click in the bottom row a record is being created, but then it jumps into the field of the the first row. I need it to stay inside the newly added record.

                • 5. Re: limit of portal records
                  philmodjunk

                       I don't understand why you are clicking into the bottom "add" row of the portal but using the script to create a new record. What is the purpose to that? If you have an "add row"--the blank row below the last actual portal record brought about by the "allow creation of records via this relationship" setting, you don't need to use the script to create the record, simply entering data into one of the fields in the add row will create the new related portal table record.

                  • 6. Re: limit of portal records
                    hanstrager

                         you got a point!

                         I tried this script:

                         If [ IsEmpty (Knit MeasurementsTemplate::Type template ID_FK) and
                         Count ( Knit MeasurementsTemplate::Type template ID_FK ) ≥ 8 ]
                         Show Custom Dialog [ Title: "No enough space"; Message: "No more space for fabric on page for more meassurements";
                         Default Button: “CANCEL”, Commit: “Yes” ]
                         Else
                         Go to Field [ Knit MeasurementsTemplate::MeassurementDescription ]
                         End If

                         but it only stops me from making records if I click into the portal and there's all ready 8 records, it doesn't stop me if i fx, have 6 records and add 3 records in a row without clicking out of the portal.

                          

                    • 7. Re: limit of portal records
                      philmodjunk

                           What trigger are you using and set on what layout object, to perform this script?

                           That shouldn't happen if you set up each editable field in the portal row with the OnObjectEnter trigger to perform this script. Tabbing into the next portal row should trip the OnObjectEnter trigger on that field unless I am forgetting some key detail here.

                      • 8. Re: limit of portal records
                        philmodjunk

                             You may find it a simpler option to remove the "allow creation" option and use a button to add new portal rows. That way, the script can always count rows and not allow additional records if the limit was reached.

                        • 9. Re: limit of portal records
                          hanstrager

                               I'm going with the 'add button' instead...

                               I just can't seem to have my portal not automatically add records when I click last row, even though i have switched off 'allow creation through this relationship', and switched off the scrip trigger in my field I used before

                          • 10. Re: limit of portal records
                            hanstrager

                                 Sorry realised my mistake in wrong table... It's all working... Thanks for your help

                            • 11. Re: limit of portal records
                              philmodjunk

                                   From your original screen shot, that's not the correct relationship to be modifying. From you original screen shot, table occurrences named MeasurementsTemplate and Measurements Types Template are not even visible.

                                   Instead, you have a relationship between Knits MeasurementsTemplate and Knits Measurements Types Template. Unless you have renamed those two table occurrences, it appears that you need to remove this modification from a different relationship than the one shown in your last post.