Forum Discussion

MichaelTamoush's avatar
MichaelTamoush
Qrew Captain
6 years ago

Combined field for related fields?

Many times when I have two different related fields pulling in information, if I want to display it more simply on a report, I will simply make a formula text field: totext([Field 1) & totext([Field 2]). 

In this case, I have two related fields, lets call them Related Parts and Related Pieces. In each case, there will be only EITHER a related part or a related piece.

Is it possible to make one field that will display which ever one it is, plus link to it? Essentially, doing what I showed above but not displaying as text - instead displaying as their name with link still live. 



------------------------------
Mike Tamoush
------------------------------
  • Hi Mike, 

    The way that you can accomplish this is to create a formula Richt Text field.  You would create an if statement where the condition is what determines whether the [Related Parts] will be shown or [Related Pieces].  Then, as far as I know, you would need to create an anchor tag to create the link.  The following is an example:


    var text displayValue = if([Condition] = true, [Related Parts Proxy], [Related Pieces Proxy]);
    var number recordID = if([Same Condition as above] = true, [Related Parts], [Related Pieces]);
    var text tableID = if([Same Condition as above] = true, [_DBID_Parts], [_DBID_Pieces]);
    var text URL = URLRoot() & "db/" & $tableID & "?a=dr&rid=" & $recordID;

    "<a href='" & $URL & "'>" & $displayValue & "</a>"

    ------------------------------
    Brandon Drake
    JHI Group
    Monroeville OH
    ------------------------------
    • MichaelTamoush's avatar
      MichaelTamoush
      Qrew Captain
      Thanks Brandon.

      One of my related fields uses the record ID for key, and is numeric. The other uses a related field that is not the record ID, and is a Unique key field that is text. How would I alter the above code to account for that?

      ------------------------------
      Mike Tamoush
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        Mike
        When specifying a record in a URL you can specify the rid or the key

        &rid=
        &key=

        so just replace "&rid=" with "&key="


        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------