I have a template that requries a BrowseBox(ABC).
I wanted to limit the available selections to the primary file, so I used this approach. #PROMPT(‘Field2’,FIELD(%Primary)),%CpField
However, this does not list the fields inside the DateTime structures, and these are the fields I needed here.
I have workaround without scope, but ideally I would like to limit available fields to those that are both in the primary file and visible in the listbox
In this type of tricky situation, I tend to create a local multi-valued symbol within a #PREPARE section above the #PROMPTs. Then I can make my #PROMPT,FROM(%ThatSymbol). Within the #PREPARE section, you can apply any logic necessary for your situation.
It has been a while since I needed to write new templates, so I am rusty.
It seems the variables from the parent template is not available during #PREPARE?
I looked in my old templates and they usually can access %ListControl.
But I get "Unknown variable ‘%ListControl’.
This is my attempt
#GROUP(%GWBTab2) #! How to sort
#!-----------------------------------------------
#TAB('2 How to sort')
#PREPARE
#DECLARE(%GWBBrowseColumns),MULTI
#DECLARE(%GWBBrowseColumnCount)
#FIND(%ControlInstance,%ActiveTemplateParentInstance,%Control)
#PURGE(%GWBBrowseColumns)
#DECLARE(%GWBLocalVariableColumnsInlist)
#SET(%GWBLocalVariableColumnsInlist,'0,0') #! Ensure there are always at leat two values for inlist to search
#FOR(%ControlField)
#ADD(%GWBBrowseColumns,%ControlField)
#SET(%GWBBrowseColumnCount, %GWBBrowseColumnCount + 1)
#FIND(%Field,%GWBBrowseColumns)
#IF(%Field = '')
#SET(%GWBLocalVariableColumnsInlist,%GWBLocalVariableColumnsInlist & ',' & %GWBBrowseColumnCount)
#ENDIF
#ENDFOR
#ENDPREPARE
...rest of tab
Correct! In #PREPARE you are within the context of entering the #PROMPTs. The %ListControl value isn’t set until code generation time. However, you should still be able to get to that control. First of all, look to see how %ListControl itself is set:
#SET(%ListControl,%GetControlName())
Here’s that called group in ABWindow.tpw:
#GROUP(%GetControlName,%SearchReport=%False),PRESERVE #!Gets the control name for the current active template
#IF(%Searchreport)
#FIND(%ReportControlInstance,%ActiveTemplateInstance,%ReportControl)
#RETURN (%ReportControl)
#ELSE
#FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
#RETURN (%Control)
#END