1 2 3 Previous Next 31 Replies Latest reply on May 5, 2017 12:34 AM by BruceRobertson

    Set Variable Set Field

    kaotishe

      I am trying to set up a script to create a new record in the child table but also carry in the key from the parent table. Basically I want it to copy kp_ID_SIPMAjobsTotals from line 3 to the kf_ID_SIPMAjobsTotals in line 7 of the script. And while it does create a new record in the child table it does not copy the id number into it? what am I doing wrong?

       

      Screen Shot 2017-05-04 at 1.24.16 PM.png

        • 1. Re: Set Variable Set Field
          philmodjunk

          Are you sure that you are on the correct layout, one based on SIPMA jobs Totals Table, when you perform this script?

          • 2. Re: Set Variable Set Field
            kaotishe

            No I am not, I am trying to do it from the portal for that table on the clients table. Is that possible?

            • 3. Re: Set Variable Set Field
              philmodjunk

              The portal is based on SIPMA jobs totals table?

               

              What user action performs this script?

              • 4. Re: Set Variable Set Field
                kaotishe

                Yes, the portal is based on SIPMA Jobs Totals Table.

                 

                The script takes the user to a layout to add a reorder to the job for that client which is why it is in the portal for SIPMA Jobs Totals Table on SIPMA Clients. This way when a reorder needs to be logged the user can go to the client scan down the portal and click the button to add the reorder. It saves the step of going to the SIPMA Jobs Totals Table and then running the script, though I want to also include that option. I was thinking one script would do both, but I guess I need a different one to run from the portal?

                • 5. Re: Set Variable Set Field
                  philmodjunk

                  But the portal's table would be the child table and I have no idea what relationship between it's TO and "SIPMA Reorders" exists in your database. This is certainly not creating a new record in the portal's table.

                   

                  Is your button located inside the row of the portal?

                   

                  And what relationship exists between SIPMA Jobs Totals Table and SIPMA ReOrders?

                   

                  And what do you see that indicates that this field does not get a value?

                  • 6. Re: Set Variable Set Field
                    kaotishe

                    SIPMA Clients is the parent to SIPMA Jobs Totals Table

                    SIPMA Jobs Total Table is the parent to SIPMA ReOrders

                     

                    On SIPMA Clients is a portal with a condensed view of key fields from SIPMA Jobs Totals Table AND a button to add record to the table SIPMA ReOrder which is where I would like to run the script from.

                     

                    I can run the script from the SIPMA Jobs Totals Table and it does carry the kp_ID_SIPMAJobsTotalsTable into the foreign key field in Reorders provided I run it from SIPMA Jobs Totals Table but it does not carry that information over if I run it from a button located in the portal on SIPMA Clients. Though from there it does create a new record in the SIPMA ReOrders table.

                     

                    I was thinking I could use one script in both locations and had not tested it from SIPMA Jobs Totals Table until you asked me what layout I was running it from.

                    • 7. Re: Set Variable Set Field
                      philmodjunk

                      "condensed view"? (I am wondering what that means)

                       

                      It doesn't sound like your portal is based on the table occurrence that you think it is based on or the script would work. Either that, or the portal where you are clicking the button is the blank "add row", or this field is empty on the row where you click the button.

                      • 8. Re: Set Variable Set Field
                        siplus

                        Let's say you have

                         

                        Parent ---< Child

                         

                        based upon PK_ParentID = FK_ChildID.

                         

                        Now,

                        Define a new field gCreatorUUID in parent

                        Define field PK_Child_UUID in child

                        Define a relationship parent-child based upon 2 keys:

                            PK_ParentID = FK_ChildID      and

                            gCreatorUUID = PK_Child_UUID

                         

                        Set this relationship as being able to create new records. Call it ParentChildCreate.

                         

                        Sitting on the Parent record, you can now create a new record in Child, simply by

                         

                        Set Field [ gCreatorUUID; get(UUID) ]

                        Set Field [ParentChildCreate::PK_Child_UUID; gCreatorUUID]

                         

                        you will see the newly created record via the original Parent ---< Child relationship.

                        you can set other fields in the child via ParentChildCreate::

                        • 9. Re: Set Variable Set Field
                          kaotishe

                          Condensed view in that the child table has about 30 fields but only four of them are used in the portal on SIPMA Clients. The row is associated with a job and does have information in those for fields. The portal does NOT contain the primary key as there is no reason to display it there, but that is the information that is not being copied to the new record in the child layout. I will double-check the occurrences and see if something there is off.

                           

                          A second question I have on this. as the script stands now it takes the user to the SIPMA ReOrders layout when the button is clicked so that the user can enter data to that record. Is it possible to do this in a popover as opposed to changing layouts?

                          • 10. Re: Set Variable Set Field
                            philmodjunk

                            siplus just posted a way to do that. It's a much better option than changing layouts to add records. But your original script should work as written provided that the context and data at the time of the script executes is correct.

                            • 11. Re: Set Variable Set Field
                              kaotishe

                              To set other fields with this do I still need the set variable set field steps? Or is it just a set field step I need in the script?

                              • 12. Re: Set Variable Set Field
                                philmodjunk

                                With the method he recommended, no variables are needed as you never change context from that of the current record (and portal row) on your layout.

                                • 13. Re: Set Variable Set Field
                                  kaotishe

                                  Ok so the left half of this screenshot is from setting up a script which uses Set Variable Set Field and changes layouts in order to add a reorder to the child table SIPMA ReOrders. The right half uses UUID and a popover to do the same thing. BUT the one on the right only displays the most recent record in the child table in the portal. If I go to the child table layout I can see that the other records are they AND that they did record the key for the parent table, they just don't show in the portal.... It now only shows the most recent record from the child table in the portal??? And this kind of weirdness pretty much sums up every time I try to make a solution in FM...

                                   

                                  Screen Shot 2017-05-04 at 7.22.46 PM.png

                                  • 14. Re: Set Variable Set Field
                                    kaotishe

                                    For some reason using the UUID method from above appears to be creating a fond set of the most recent records and that found set of one record is all the portal is displaying. Any Ideas why this would be happening and how to fix it?

                                    1 2 3 Previous Next