Skip to main content
Solved

sql query for multi select custom fields values in an event

  • October 19, 2022
  • 3 replies
  • 615 views

Forum|alt.badge.img
  • Do Gooder (Customer)
  • 9 replies

Hi all, we have a challenging problem, for creating a custom report we are trying to write a sql query that retrieves events with their custom values.

We don't have a problem with custom string values or single select lookup.The problem is with multi select custom field values, that we want to retrieve as comma separated values (i.e val1, val2 etc)

We were wondering if someone has some piece of code as an example that you can share with us

 

thanks!

Best answer by MennovH

Hi Alberto,

 

I have done this in the past. The following SQL will retrieve the values from the multi-select custom field with the shortcode ‘MULTI TEST’. Just amend the where clause and the jwcp.jptsys_web_cust_prop_sc = 'MULTI TEST' as needed.

select incident.incident_id,
stuff((SELECT distinct ', '  + cast(d.jptsys_web_lkup_data_n as varchar(100))
                    FROM 
                                jptsys_web_cust_prop_mult m, jptsys_web_cust_prop_cont c, jptsys_web_lkup_data d, jptsys_web_cust_prop jwcp
                            WHERE 
                                jwcp.jptsys_web_cust_prop_id = c.jptsys_web_cust_prop_id AND
                                m.jptsys_web_cust_prop_cont_id = c.jptsys_web_cust_prop_cont_id AND
                                d.jptsys_web_lkup_data_id = m.jptsys_web_lkup_data_id AND
                                jwcp.jptsys_web_cust_prop_sc = 'MULTI TEST'
                                and c.entity_id = incident.incident_id
                               FOR XML PATH('')),1,1,'') "multi_select_values"
from incident where incident.incident_id = 455

 

Screenshot of results: 

 

Regards,

 

Menno

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+10
  • Hero (Employee)
  • 46 replies
  • Answer
  • October 21, 2022

Hi Alberto,

 

I have done this in the past. The following SQL will retrieve the values from the multi-select custom field with the shortcode ‘MULTI TEST’. Just amend the where clause and the jwcp.jptsys_web_cust_prop_sc = 'MULTI TEST' as needed.

select incident.incident_id,
stuff((SELECT distinct ', '  + cast(d.jptsys_web_lkup_data_n as varchar(100))
                    FROM 
                                jptsys_web_cust_prop_mult m, jptsys_web_cust_prop_cont c, jptsys_web_lkup_data d, jptsys_web_cust_prop jwcp
                            WHERE 
                                jwcp.jptsys_web_cust_prop_id = c.jptsys_web_cust_prop_id AND
                                m.jptsys_web_cust_prop_cont_id = c.jptsys_web_cust_prop_cont_id AND
                                d.jptsys_web_lkup_data_id = m.jptsys_web_lkup_data_id AND
                                jwcp.jptsys_web_cust_prop_sc = 'MULTI TEST'
                                and c.entity_id = incident.incident_id
                               FOR XML PATH('')),1,1,'') "multi_select_values"
from incident where incident.incident_id = 455

 

Screenshot of results: 

 

Regards,

 

Menno


Forum|alt.badge.img
  • Author
  • Do Gooder (Customer)
  • 9 replies
  • October 21, 2022

Menno you are always the best


Forum|alt.badge.img
  • Author
  • Do Gooder (Customer)
  • 9 replies
  • October 26, 2022

if anyone needed ifs support pointed me to the link on the wiki with the examples I was looking for

https://wiki.axiossystems.com/assyst11-5Wiki/index.php/Installation:Database_Schema_for_Additional_Custom_Fields#Retrieving_values_of_custom_fields


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings