Opened 3 days ago

Last modified 3 days ago

#3199 addressed defect

Modify Big Cooperator Dataview: Enhance Display Field Formatting

Reported by: Benjamin Haag Owned by: Benjamin Haag
Priority: medium Milestone:
Component: Dataviews (CT) Version: N/A
Severity: 1 -- Low Effort Keywords:
Cc: stacey.estrada@…, lisa.burke@… Database Engine: N/A
Operating System: N/A

Description (last modified by Benjamin Haag)

The Big Cooperator Lookup dataview creates its display field by conditionally concatenating a set of text fields based on their being not NULL. However, missing fields result in excess commas being shown, which requires manual formatting before the data can be incorporated into mailing labels and other documents.

This dataview should show commas only when they are separating known values.

There are other dataviews that incorporate the same logic; Trac tickets will be created to address them as well.

Below is the SQL behind big_cooperator_lookup:

SELECT
  DISTINCT co.cooperator_id AS value_member,
  LTRIM(RTRIM(COALESCE(co.last_name, '') + ', ' + 
              COALESCE(co.first_name, '') + ', ' + 
              COALESCE(co.organization, '') + ', ' + 
              COALESCE(co.address_line1, '') + ', ' + 
              COALESCE(co.city, '') + ', ' +  
              COALESCE(g.adm1,'') + ', ' + 
              COALESCE(co.postal_index,'') + ', ' + 
              COALESCE(cvl.title,g.country_code,''))) AS display_member,
  s.site_short_name AS site,
  COALESCE(su.is_enabled, 'N') AS account_is_enabled,
  CASE WHEN co.cooperator_id = co.current_cooperator_id THEN 'Y' ELSE 'N' END AS is_current_address
FROM
  cooperator co 
  LEFT JOIN sys_user su ON co.cooperator_id = su.cooperator_id
  LEFT JOIN site s ON co.site_id = s.site_id
  LEFT JOIN geography g ON co.geography_id = g.geography_id
  LEFT JOIN code_value cv ON g.country_code = cv.value AND cv.group_name = 'GEOGRAPHY_COUNTRY_CODE'
  LEFT JOIN code_value_lang cvl ON cv.code_value_id = cvl.code_value_id AND cvl.sys_lang_id = __LANGUAGEID__
WHERE
  ((co.created_date > COALESCE(:createddate, '1753-01-01'))
    OR (co.modified_date > COALESCE(:modifieddate, '1753-01-01'))
    OR (co.cooperator_id IN (:valuemember))
    OR (co.cooperator_id BETWEEN :startpkey AND :stoppkey)
    OR (su.created_date > COALESCE(:createddate, '1753-01-01'))
    OR (su.modified_date > COALESCE(:modifieddate, '1753-01-01'))
    OR (s.created_date > COALESCE(:createddate, '1753-01-01'))
    OR (s.modified_date > COALESCE(:modifieddate, '1753-01-01'))
    OR (g.created_date > COALESCE(:createddate, '1753-01-01'))
    OR (g.modified_date > COALESCE(:modifieddate, '1753-01-01'))
    OR (cv.created_date > COALESCE(:createddate, '1753-01-01'))
    OR (cv.modified_date > COALESCE(:modifieddate, '1753-01-01'))
    OR (cvl.created_date > COALESCE(:createddate, '1753-01-01'))
    OR (cvl.modified_date > COALESCE(:modifieddate, '1753-01-01'))
  )

Change History (3)

comment:1 by Benjamin Haag, 3 days ago

Modified big_cooperator_lookup on dev.

Full dataview SQL attached. The specific change is below.

   CONCAT_WS(', ',
    NULLIF(LTRIM(RTRIM(co.last_name)), ''),
    NULLIF(LTRIM(RTRIM(co.first_name)), ''),
    NULLIF(LTRIM(RTRIM(co.organization)), ''),
    NULLIF(LTRIM(RTRIM(co.address_line1)), ''),
    NULLIF(LTRIM(RTRIM(co.city)), ''),
    NULLIF(LTRIM(RTRIM(g.adm1)), ''),
    NULLIF(LTRIM(RTRIM(co.postal_index)), ''),
    NULLIF(LTRIM(RTRIM(COALESCE(cvl.title, g.country_code))), '')
) AS display_member,

comment:2 by Benjamin Haag, 3 days ago

Status: assigned → addressed

comment:3 by Benjamin Haag, 3 days ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.