10 Replies Latest reply on Dec 7, 2015 2:43 PM by thong127

    Line Items

    thong127

      Hello All,

       

      I have a Material Database That Im using now, I added another table Which I called Material Milestone,

       

      Materials Table

      Field NameTypeOptions
      Materials IDTextAuto Enter, Serial

       

      Milestone Table

      Field NameTypeOptions
      id_MilestoneTextIndexed

       

      My two tables are connected by their ID's above with = sign

       

      I made a portal to my Materials Table (Show related record from Material Milestone)

       

      I have also a button to create my milestone which perform the following script

       

      Set Variable [$id ; Value:Materials::Materials ID]

      Go to Layout ["Milestone"(Material Milestone)]

      New Record/Request

      Set Field (Material Milestone::id_Milestone)

      Go to layout (original layout)

      Go to Field [Material Milestone::Creation Date]


      My problem is when I click my button the created record is not showing in my portal but when I go to the my Milestone Layout the created record is there.


      and when I created a new record in my Material Table then I click my button it will show the created record in the portal.


      Is there a way that I Can add a milestone of each material without manually entering them?


      Thank you.


      thong


        • 1. Re: Line Items
          coherentkris

          Set Field (Material Milestone::id_Milestone)

          Their is a missing value or formula here

          Set Field [<table::field>; <value or formula>]

           

          But thats probably not going to solve your problem and in order to solve your problem we need to knwo the relationship between materials and milestones..

           

          if the relationship between materials and milestones is one material can have many milestones then Set Field (Material Milestone::fk_material_id ; $id ) might do the trick. If that is not the relationship between materials and milestones then the script has to do something different and we need to know the details.

          • 2. Re: Line Items
            thong127

            Thank you for the reply,

             

            Yes, one material has many milestones. Can you please specify about this "Set Field (Material Milestone::fk_material_id ; $id )" I dont know what Im going to do.

             

            Thank you.

            • 3. Re: Line Items
              DanielShanahan

              thong127 wrote:

              Can you please specify about this "Set Field (Material Milestone::fk_material_id ; $id )" I dont know what Im going to do.

               

              Thank you.

               

              You simply forgot to set the second parameter for the Set Field script step.  That's what coherentkris is telling you.  Set Field has two parameters:

              1. What field do you want to set?

              2. What data do you want in the field.

               

              In the script you posted in the original post, the Set Field only has the first parameter.  You've already defined the data you want for the second parameter.  Simply add the variable $id as the Calculated result (see attached)

               

              SetField.png

              • 4. Re: Line Items
                thong127

                Hi Daniel,

                 

                Thank you. I got it. But still not solving my problem.

                unless I will add a new record..then my related record will show on my portal.

                 

                Thanks.

                • 5. Re: Line Items
                  DanielShanahan

                  Sorry thong127, I guess I don't quite understand what's failing.  Can you post a screenshot?  Or better yet, a copy of the file?

                  • 6. Re: Line Items
                    keywords

                    I suspect you have the relationship itself wrong. The logic is that every record in every table should have its own automatically assigned unique ID (either a serial or UUID); I assume this is the function of Materials ID in the Materials table and id_Milestone in the Milestones table (there is a naming issue there, but that's another matter). OK so far. BUT:

                    you appear to be using these two fields as the basis of your relationship—this is wrong. What you need in the Milestones table is a foreign key MaterialsID field, and the link between the two tables to be:

                     

                    Materials::Materials ID = Milestones::Materials ID

                     

                    If you do this, then each milestone record will have its own unique ID, and also have a non-exclusive Materials ID which will show which Materials record it belongs to.

                    1 of 1 people found this helpful
                    • 7. Re: Line Items
                      thong127

                      Hi Daniel,

                       

                      I already have existing records on my Materials Table and I added the Milestone Table in order for me to track in which materials was used in.

                       

                      Thanks.

                      • 8. Re: Line Items
                        DanielShanahan

                        Ok, but can you post a screenshot or a copy of the file?

                         

                        A copy of the file would be best as would could test the primary key=foreign key as keywords mentions.

                         

                        You can make a clone of the file without records by going to File/Save a Copy As.../Type: clone (no records)

                        • 9. Re: Line Items
                          thong127

                          Hi Daniel,

                           

                          Its working now. Thank you so much.

                           

                          Thanks Everyone!

                          • 10. Re: Line Items
                            thong127

                            Thanks Keywords, Its working Now. That's solved the problem.

                             

                            thong