0 votes

Hi all,

I would like to customize a multi-value field with data fetched from a custom query.

The multi-value is linked to the companies table and when I run my query and I try to populate the field, the custom declaration is ignored.

My example:

field.F_CONCURRENTEN.Oppo{[ 
<%RunQuery(id="Competitors", SQL="select comp.K_COMPANY, comp.NAME from COMPANIES comp
    inner join COMP_COMP cc on comp.K_COMPANY = cc.K_COMPANY2
    where cc.RELATION in (35) and cc.K_COMPANY=:p1", param1="%%RunScript(getMainDetail, detail=Comp)")%>

<select multiple name="$FIELD$" id="$FIELD$">
    <option></option>
    <%GetDataGrid(query="Competitors", templateText=|<#repeat>
        <option value="<#F=K_COMPANY>" <%OnField($FIELD$, value="<#F=K_COMPANY>", then="SELECTED")%>><#F=NAME></option>
    </#repeat>|)%>
</select>
]}

The result I get is a list of

Any suggesions?

asked in Efficy/ Client side by (164 points)

2 Answers

+3 votes

Elements with multiple values have to be posted ; separated.

e.g. for the competitors multi value in Opportunities, you see this in the commit post

COMPETITORS:;1;2;

I assume you don't post the value in the same way. I don't see the data-ajax-url and data-json attributes added to your element. Note also that Efficy uses a input, not a select element. The attributes will be used by the SELECT2 library

<input type="text" 
  name="COMPETITORS" id="COMPETITORS"  
  maxlength="255" title="" value=";1;2;"   
  data-ajax-url="dialog?_macro=JsonMultiValueList&_macrofile=MacroAjax&edithandle=5&field=COMPETITORS"
  data-json=""
>
answered by (7.4k points)
+1 vote

Thank you Kristof.

I fixed it by doing the following:

FormFieldsEdit

field.F_CONCURRENTEN.Oppo {[
    <%GetEdit('$FIELD$',
    data-ajax-url='dialog?_macro=MultiValue_OPPO_Concurrenten&_macrofile=MacroAjax&Key=<%RunScript(getMainDetail, detail=Comp)%>',
    data-json='{<%GetField("$FIELD$", type="MULTIVALUE", json=T)%>}')]}

MacroAjax

MultiValue_OPPO_Concurrenten {[
<%Delay(0)%>RunQuery(id='CompetitorsQuery', store='1',
SQL='select comp.K_COMPANY, comp.NAME from COMPANIES comp
inner join COMP_COMP cc on comp.K_COMPANY = cc.K_COMPANY2
where cc.RELATION in (35) and cc.K_COMPANY=:p1' 
, param1='%%GetArgument("Key")')%><%Delay(0)%>GetDataGrid(query='CompetitorsQuery', count=-1, norecords='', nolinefeed=T, templatetext=|[<#repeat>
{
     "id":<#F=K_COMPANY;nospace=T>
    ,"text":"<#F=NAME;jsontext=T;nospace=T>"
}<#S=;SEPARATOR=,></#repeat>
]|)%>]}

Also: in Conficy you need to link the field to the right lookup / table

answered by (164 points)
1,246 questions
1,517 answers
1,858 comments
328 users