1 2 Previous Next 16 Replies Latest reply on Mar 7, 2016 12:14 PM by bigtom

    Popup selector - add new row in related table

    cillion

      Hi!

      Do someone know how to make a popup selector (which person to add, already existing) that adds a new row in the portal/related tabel?

        • 1. Re: Popup selector - add new row in related table
          bigtom

          Unclear question but I think I understand.

           

          You need a Popup for the key field with a value list that sets the field to the key but displays the correct visual data from a second field. You also need to have "Allow creation of records via relationship" enabled.

          • 2. Re: Popup selector - add new row in related table
            cillion

            Yes, a pop up dialog, with a dropdownlist of registrated candidates. After pressing add in the dialog will add the selected candidate to that project the user is on. I have started on this script, that is not doing the job at the moment. Looking like this:

             

            2016-03-04_12-04-35.jpg

            • 3. Re: Popup selector - add new row in related table
              bigtom

              There is a much easier way to do this without a script or a dialog box, which may not work how you expect.

               

              Just add a drop down list to the candidate name field in the portal and the relationship will automatically add the candidate to the project.

              • 4. Re: Popup selector - add new row in related table
                cillion

                No the portal itself dont allow the user to create a new row in the portal? That you mean?

                 

                Is it hard to get this to work with a script though ? Do my script have much work to get it to work?

                • 5. Re: Popup selector - add new row in related table
                  bigtom

                  Why not use the portal to create a new row itself?

                  • 6. Re: Popup selector - add new row in related table
                    bigtom

                    What version of FM are you using?

                    • 7. Re: Popup selector - add new row in related table
                      cillion

                      because then the user need to scroll dont to the bottom each time, and the ProjectID needs to be the same as the active projekt, and the Kandidate ID needs to be the same as the candidate choosen.

                      • 9. Re: Popup selector - add new row in related table
                        bigtom

                        I am assuming you are using value list with candidate ID but showing candidate name for the selector.

                         

                        Have you considered using a popover instead of a dialog box? A button that opens a popover with a single row portal to add new candidate directly would work and not need a script. I think this is a good idea for you.

                         

                        You can keep what you have and add an on object modify trigger in your selector to confirm the add via dialog and then script going to the last row of portal and script the add of the ID to create a new record.

                         

                        If your projects can have many candidates and those candidates can be on more than one project, are you using a join table?

                        • 10. Re: Popup selector - add new row in related table
                          bigtom

                          Using a portal the project ID would be automatic via the relationship. All you need to enter is the candidate ID in the last row.

                          • 11. Re: Popup selector - add new row in related table
                            cillion

                             

                            I am assuming you are using value list with candidate ID but showing candidate name for the selector.

                             

                            Yes.

                             

                             

                            Have you considered using a popover instead of a dialog box? A button that opens a popover with a single row portal to add new candidate directly would work and not need a script. I think this is a good idea for you.

                             

                            Changed the button to popover now, lets try your suggestion

                             

                             

                            You can keep what you have and add an on object modify trigger in your selector to confirm the add via dialog and then script going to the last row of portal and script the add of the ID to create a new record.

                             

                            If your projects can have many candidates and those candidates can be on more than one project, are you using a join table?

                            This I did not quite understand. Yes the portal is the join tabel between candidates and projekts

                            Should I:

                            1. In the popover, insert a new field called choose_candidate with a dropdownlist assigned to it

                            2. set onmodify-trigger on this, and select a script to trigger

                            3. script to trigger should be ?

                             

                            Is this suggestion?

                            • 12. Re: Popup selector - add new row in related table
                              bigtom

                              There were a few different ideas mixed there.

                               

                              Let's work with the popover.

                               

                              If you have a popover window add a single row portal with no scroll that always goes to last row or has a filter to show no other current records with the selector directly in the portal. No scripts, no global fields.

                               

                              If you prefer to use a global field or variable with a script you can but it is not needed.

                              • 13. Re: Popup selector - add new row in related table
                                cillion

                                 

                                If you have a popover window add a single row portal with no scroll that always goes to last row or has a filter to show no other current records with the selector directly in the portal. No scripts, no global fields.

                                 

                                Do you have a example of this? To be honest I dont know how to do this, but if its a easier way than below, I would happely try this.

                                 

                                If you prefer to use a global field or variable with a script you can but it is not needed.

                                I have already tried this with a script and a button:

                                 

                                2016-03-07_09-21-03.jpg

                                 

                                The transfer script looks like this, and it does not work properly tough:

                                 

                                2016-03-07_09-28-55.jpg

                                • 14. Re: Popup selector - add new row in related table
                                  bigtom

                                  Your script has a few problems. There is no reference of the related record and if there are zero related records the script goes no where anyway. After the new record/request you are not setting any fields so no candidate is added.

                                   

                                  Your popover does not have a portal in it so nothing different that when it was on the main layout area.

                                   

                                  Maybe try somethig closer to this if using a script:

                                   

                                  Show Custom Dialog ["new Canditade"; "Confirm adding " & Project::z_newcandidate & " to the project."]

                                   

                                  If Get(lastmessageChoice) = 1]

                                       set variable[ $canidate; Project::z_newcandidate]

                                       set variable[$project; ProjetcID]

                                       freeze window

                                       got to layout[ candidate-project ]

                                       new record request

                                       set field (projectID_fk; $project)

                                       set field (canididateID_fk; $candidate)

                                       commit record

                                       go to layout[ original]

                                       refresh window

                                  Else

                                       Exit

                                   

                                   

                                  Also, you could post your solution file and I can set it up so you can see the examples of how it can be done and you can learn from that.

                                  1 2 Previous Next