Forum Discussion

BaileyDesormeau's avatar
BaileyDesormeau
Qrew Member
4 months ago

Many to Many Relationship, Auto Fill Reference Field

My problem is that when i add an attachment from the inspection reports table the information that is added to the attachment table is from the inspection report table and not from the light tower table. 

I have 3 tables, light towers, attachments and inspection reports. light towers have many attachments, inspection reports have many attachments. When i add an attachment from an inspection report, I do not like how the light tower information such as light tower number, is not in the same field as the light tower number that comes from the light tower table. In order for it to populate in the field from the light tower table i have to manually choose the light tower again from a drop down. Obviously this reference field is already filled when i create an attachment from the inspection reports table. Is there anyway to have the related light tower field auto filled based on the related inspection report? Meaning, when I add an attachment from the inspection report table, I do not also have to add the related light tower to the attachment. It would auto populate. Heres a picture of what I am dealing with on the attachment table. If i saved the attachment like this, fields based on the service report would be populated and fields from the light tower table would be blank, i do not like how that look son the default report and I know there must be a way to get both of those on the same light tower. Thanks in advance!



------------------------------
Bailey Desormeaux
------------------------------

7 Replies

  • Are your light tower table and inspection reports table related? For example - do light towers have many inspection reports? If yes - then you can simply add the [Related Light Tower] field in your Add Record Button as an additional parameter so it auto fills as you expect. 

    No matter what - in order for the light tower to populate from an inspection report - you have to know which light tower it should be when you're coming from the inspection report. 



    ------------------------------
    Chayce Duncan
    ------------------------------
    • BaileyDesormeau's avatar
      BaileyDesormeau
      Qrew Member

      Are your light tower table and inspection reports table related?
      Chayce Duncan,  01-11-2024 15:52

      Yes they are

      If yes - then you can simply add the [Related Light Tower] field in your Add Record Button as an additional parameter so it auto fills as you expect. 
      Chayce Duncan,  01-11-2024 15:52

      Can you please show me an example of this? Thanks so much!



      ------------------------------
      Bailey Desormeaux
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        On your inspection report - go into the settings for the add button that you're clicking. 

        The format should be something like: 

        URLRoot() & "db/" & [_DBID_ATTACHMENTS]  & "?a=API_GenAddRecordForm" & 
        "&_fid_A=" & [Record ID#]

        In this case - fid_A should have a # instead of A. That fid is the 'related inspection report' on the attachment. So you need to add another similar to that to pass in your related light tower like: 

        URLRoot() & "db/" & [_DBID_ATTACHMENTS]  & "?a=API_GenAddRecordForm" & 
        "&_fid_A=" & [Record ID#] & 
        "&_fid_B=" & [Related Light Tower]

        Where you need swap the value of B with the field ID of the related light tower field in the Attachments table. 



        ------------------------------
        Chayce Duncan
        ------------------------------