0 votes

Hello,

I'm using lookup acc_accounts in a custom lookup field, and i want to filter this list to show only the users (not the groups). the custom field is in category, so i think FORMS can be used here.

Please let me know your suggestion and advises.

Thank you.
Best Regards.

asked in Efficy/ Client side by (559 points)

2 Answers

+1 vote

I suppose you can do this like the Sales Manager lookup ?
With some tweaks to make it work with your field?

FormFieldEdit.txt

field.LOOKUPUSERGROUP.Oppo {[<%Macro("GroupUsersLookup", $GROUPUSERCODE$="EFF_SALES", $FIELDNAME$="MANAGER")%>]}

MacroLibrary.txt

GroupUsersLookup {[
<%RunQuery(id="GroupMembers", sql="SELECT A.K_USER, A.FULLNAME FROM <#TABLE NAME=ACC_ACCOUNTS> A
    INNER JOIN <#TABLE NAME=ACC_GROUPS> G ON A.K_USER = G.K_USER2
    WHERE G.K_USER = (SELECT K_USER FROM <#TABLE NAME=ACC_ACCOUNTS>
    WHERE USERCODE = '$GROUPUSERCODE$') AND A.KIND = 0 AND (A.ISACTIVE = 1 OR A.K_USER = :param1) ORDER BY A.FULLNAME", param1="%%OnField('$FIELDNAME$',value='',then='0',else=`%%GetField('$FIELDNAME$')`)")%>
<select style="$STYLE$" title="" id="$FIELDNAME$" name="$FIELDNAME$" data-placeholder="<%GetLabel('Select Value')%>..." <%IfReadOnly(then='disabled')%>>
    <option></option>
<%Delay(1)%>GetDataGrid(query="GroupMembers", count=-1, TemplateText=|<#repeat>
    <option value='<#F=K_USER>' <#I=K_USER;<%GetField('$FIELDNAME$')%>=selected="selected";#ELSE=>
    <%OnArgument(ArgValue=`%%GetField('$FIELDNAME$')`,value='',then=`<#I=K_USER;<%GetUserKey()%>=selected="selected";#ELSE=>`%>><#F=FULLNAME></option></#repeat>|
)%>
</select>
]}
answered by (607 points)
Hello Stijn,

I think this work if it's a field you can add on FORMS, but this is a field created in category so how you can tweak this definition?
Thank you
Best Regards.
+1 vote

Hello Ammar,

You can rebuild your select from an Ajax Call when your HTML document has finished to load.

answered by (1.8k points)
1,167 questions
1,425 answers
1,717 comments
325 users