0 votes

Hello,

I'm trying to filter multi-select field in category based on value chosen in lookup on Main tab in Cases. I've tried to achieb this by adding this piece of JS to MacroEditSCustom

if($('#CASETYPE').val()){
            var newDataAjaxURL = "dialog?_macro=JsonDynaMultiValueListCaseCat&_macrofile=MacroAjax&edithandle=<%GetEditHandle()%>&field=CATEGORY-CASE$GENERAL-F_CATEGORY&casetype=" + $('#CASETYPE').val();
            var $FieldName = $("#CATEGORY-CASE$GENERAL-F_CATEGORY")
            if($FieldName.length){
                $FieldName.attr('data-ajax-url', newDataAjaxURL);
            }
        }

and the definition in MacroAjaxCustom

JsonDynaMultiValueListCaseCat {[<%Delay(0)%>RunQuery(id='DynaMultiValueListCaseCat', 
    SQL='Select F_CATEGORY as F_CATEGORY_EN, * from LK_CASE_CATEGORY CC where f_case_type like :param1 and disabled = 0 order by k_sort',
    Param1="%;<%GetArgument('casetype')%>;%"
    )%>
    <%Delay(0)%>GetDataGrid(query='DynaMultiValueListCaseCat', count=-1, norecords='', sort='F_CATEGORY_<%GetLanguage()%>' , nolinefeed=T, templatetext=|[<#repeat>
    {
         "id":<#F=K_CASE_CATEGORY>
        ,"text":"<#F=F_CATEGORY_<%GetLanguage()%>;jsontext=T;nospace=T>" 

    }<#S=;SEPARATOR=,></#repeat>
]|)%>]}

Plus changing CASETYPE in Forms with definition LOOKUPMASTER and add it in FormFieldsEditCustom

field.LOOKUPMASTER {[<%GetEdit("$FIELD$", type="LOOKUP", onchange="JavaScript:CebPerform('CEB_STATE');")%>]}

so every time user chooses new value it refresh the page and set new URL on attribute "data-ajax-url".

It works fine if i save directly the case, but if i hit the button "apply" then it's not working, even the attribute has the right URL, but on clicking on the field i get the standard ajax-url

enter image description here

enter image description here

Please advise.
Thank you for your help in advance.
Best Regards.

asked in Efficy/ Client side by (559 points)

1 Answer

0 votes

Hello,

I did the same custom as you using the js module features instead of the MacroEditS file and I did reproduce your behavior and I havn't find an easy solution. Maybe using the native select2 feature and constructor by script would be the best way to do it.

please if you consider it please remember to double check the concatenated selected values string in db if you didn't use the standard c efficy constructor (macro)

answered by (983 points)
1,165 questions
1,423 answers
1,713 comments
325 users