How to add a custom field into a velocity report

Dave.Price
Dave.Price Member, Jama Connect Interchange™ (JCI) Posts: 1

I have a custom text field named "legacy_id" that I am trying to add as a new column in a velocity trace report. When using:

"td rowspan=$span class=$contentStyle>$!source.legacy_id</td>"

the column is not populated with the data in the report. If I substitute "source.legacy_id" for a different predefined field such as "source.text1", the report shows the data. What do I need to do to get the custom field I have created to display in the velocity report?

Comments

  • Alessandro Valli
    Alessandro Valli Member, Data Exchange, Jama Connect Interchange™ (JCI) Posts: 789
    edited June 3

    Hi Dave,

    please use the uniquefieldname$itemtypeid, like legacy_id$4711. 4711 is the API-ID you can find under admin-organization-item types for the desired item type

    Best regards,

    Alessandro

    Alessandro
    Systems Engineer
    SICK AG
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    Thanks for this reply Alessandro, but that doesn't seem to work for me either:

    I based my report off the 2up2down one in github but trying to add custom fields I try:

    <td style='border-top: $borderTop;'>$doc.software_function_area$163</td>
    

    And it just shows up as "$doc.software_function_area$163" in the excel cell

    Just tried these too:

    <td style='border-top: $borderTop;'>
    $doc.get("software_function_area")
        A
    </td>
    <td style='border-top: $borderTop;'>
    ${doc["software_function_area"]}
    B
    </td>
    <td style='border-top: $borderTop;'>
    ${doc["software_function_area$163"]}
    C
    </td>
    <td style='border-top: $borderTop;'>
    $doc.get("software_function_area$163")
        D
    </td>
    

    and they also don't work

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    It appears my previous comments somehow got deleted?

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    In short, Alessandro's comment doesn't seem to work for me in an Excel. I tried:

    ${doc["software_function_area$163"]}
    $doc.get("software_function_area$163")
    $doc.software_function_area$163
    

    and none worked

    Andrew MacCormack

    LumiraDX
  • Adriaan Arnason
    Adriaan Arnason Member Posts: 21

    For velocity reports you can try: $velocityReportUtil.getValueForField($source, "legacy_id", $dateFormat).

    The $dateFormat can just be an empty variable.

  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73
    edited June 19

    Looks like this forum software doesn't like velocity code somehow, it keeps removing it when I try and post, so here's a pic:

    OK, the picture upload also doesn't work. sigh

    Here's a gist link instead:

    https://gist.github.com/amaccormack-lumira/e1916b0e853c04fbbfaf599b97954444

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    In the end I wanted to have a lot of custom fields in the report so I did this to make a dictionary of the whole lot:

    		#set ( $customFieldValueMap = {} )
      		#foreach( $fieldObj in $doc.getCustomFields() )
    			## Attempt to do lookup
    			#set ($fieldValue = $lookupDao.getLookup($mathTool.toInteger($fieldObj.textValue)).name)
    			## If it fails, use as is
    			#if (!$fieldValue)
    				#set ($fieldValue = $fieldObj.textValue)
    			#end
    			#set ( $success = $customFieldValueMap.put($customFieldById[$fieldObj.getFieldId()], $fieldValue))
    	  	#end
    
    

    ^ Seems that the pre-formatted thing strips leading whitespace, which is kind the point of preformatted!

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73
    #set ( $customFieldValueMap = {} )
    #foreach( $fieldObj in $doc.getCustomFields() )
    	## Attempt to do lookup
    	#set ($fieldValue = $lookupDao.getLookup($mathTool.toInteger($fieldObj.textValue)).name)
    	## If it fails, use as is
    	#if (!$fieldValue)
    		#set ($fieldValue = $fieldObj.textValue)
    	#end
    	#set ( $success = $customFieldValueMap.put($customFieldById[$fieldObj.getFieldId()], $fieldValue))
    #end
    
    

    In the end, I'm using a lot of custom fields so wrote the above to create a dictionary of them all

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    Just tried all of these and they don't work either:

    <td style='border-top: $borderTop;'>
    $doc.get("software_function_area")
        A
    </td>
    <td style='border-top: $borderTop;'>
    ${doc["software_function_area"]}
    B
    </td>
    <td style='border-top: $borderTop;'>
    ${doc["software_function_area$163"]}
    C
    </td>
    <td style='border-top: $borderTop;'>
    $doc.get("software_function_area$163")
        D
    </td>
    

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    Just tried all of these and none work either:

    <td style='border-top: $borderTop;'>
    $doc.get("software_function_area")
        A
    </td>
    <td style='border-top: $borderTop;'>
    ${doc["software_function_area"]}
    B
    </td>
    <td style='border-top: $borderTop;'>
    ${doc["software_function_area$163"]}
    C
    </td>
    <td style='border-top: $borderTop;'>
    $doc.get("software_function_area$163")
        D
    </td>
    

    Thanks for any tips

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    Just tried these too:

    $doc.get("software_function_area")
    
    ${doc["software_function_area"]}
    
    ${doc["software_function_area$163"]}
    
    $doc.get("software_function_area$163")
    
    

    and none work

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73
    #set ( $customFieldValueMap = {} )
    #foreach( $fieldObj in $doc.getCustomFields() )
      ## Attempt to do lookup
      #set ($fieldValue = $lookupDao.getLookup($mathTool.toInteger($fieldObj.textValue)).name)
      ## If it fails, use as is
      #if (!$fieldValue)
        #set ($fieldValue = $fieldObj.textValue)
      #end
      #set ( $success = $customFieldValueMap.put($customFieldById[$fieldObj.getFieldId()], $fieldValue))
    #end
    
    

    Andrew MacCormack

    LumiraDX
  • Andrew MacCormack
    Andrew MacCormack Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 73

    Looks like suddenly all the posts that went missing are back! 🤔

    Andrew MacCormack

    LumiraDX