Hi,
I added a new int64 control (reference group) without filling dataSource, reference field, replacement field group properties on the form and I want it to look as tree view
then in the init method of the form (CaseDetailCreate) i added this line
ACaseCategory.RegisterOverrideMethod(methodStr(FormReferenceGroupControl, lookup), formMethodStr(CaseDetailCreate, AOverrideCaseCategoryLookup));
public void AOverrideCaseCategoryLookup(FormReferenceGroupControl _formReferenceGroupControl) { SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(CaseCategoryHierarchyDetail), _formReferenceGroupControl); sysTableLookup.addLookupfield(fieldNum(CaseCategoryHierarchyDetail, CaseCategory)); Query query = new Query(); QueryBuildDataSource queryBuildDataSource; queryBuildDataSource = query.addDataSource(tableNum(CaseCategoryHierarchyDetail)); CaseCategoryHierarchyDetail caseCategoryHierarchyDetail; CaseCategoryType caseCategoryType; select firstonly RecId from caseCategoryHierarchyDetail where caseCategoryHierarchyDetail.CaseCategory == Control1.text() if (caseCategoryHierarchyDetail) { this.findCaseCategoryChildAndSubChild(caseCategoryHierarchyDetail.ParentRecId, queryBuildDataSource); } sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); } public void findCaseCategoryChildAndSubChild(RefRecId _ParentRefRecId, QueryBuildDataSource _queryBuildDataSource) { CaseCategoryHierarchyDetail caseCategoryHierarchyDetail; while select caseCategoryHierarchyDetail where caseCategoryHierarchyDetail.parentRecId == _ParentRefRecId { _queryBuildDataSource.addRange(fieldNum(CaseCategoryHierarchyDetail,ParentRecId)).value(queryValue(caseCategoryHierarchyDetail.RecId)); this.findCaseCategoryChildAndSubChild(caseCategoryHierarchyDetail.RecId, _queryBuildDataSource); } }
Hi Mohit,
I already did that. In the previous thread. Remember you wrote code for me to show me how to get children based on a parent.
Even now, when i created a new categoryRecId EDT .. it's somhow the same..right? As u saw from previous comments i added a method called setCaseCategory so that i use it in filters to get what's below it.
Or am i missing something about your suggestion?
The thing is how can i amend the code of CaseCategoryLookup form in order to return specific nodes(assuming i created a duplicate form and i can change the code as i want)
By duplicating patent category field I mean the form control that is storing value 1A, the one you mentioned in other thread
'let's say I have a form control where it's value is 1A
I have another control, where I want to amend the lookup to get the following result, which is anything under 1A'
If you duplicate that parent category control to create new form control which will display values based on category selected in parent category field. Note that I haven't created filter in Tree control, so not sure if there is easy way to do it.
??
Hi Mohit,
Yes there is a value for both caseCategory and CaseCategoryType.
Do u mean duplicating the caseCategoryRecId(standard reference group) for the parent instead of creating a new EDT? But does it make a difference?
If yes, i did this and i duplicated the standard form "caseCategoryLookup' that is used for the parent but i didn't know how to amend the range as the code is complex for the tree and where should i add the recursive code
Reminder: i need to get all children nodes -- not just one level
Are you getting value of Case category and case category type in your lookup form?
Also, I think you have parent category field and you need to create a child category field lookup. How about duplicating the parent category field and adding range on child category field lookup.
Any idea Anyone?
Hi Mohit,
yes and i got same result, here's what I did --- can you please tell me what I need to do more to get the required result?
1. I created this EDT
2. I created an extension of "CaseDetailBase" table and added this EDT as a field in it. In addition to a relation similar to the original relation: (this is the table I need to add to right?)
3. I added the control to the form "CaseDetailCreate" form via extension
4. This is the code for "CaseDetailCreate" Form
////// Extension class for CaseDetailCreate form /// [ExtensionOf(formStr(CaseDetailCreate))] final class CaseDetailCreateA_Extension { public void init() { next init(); CaseDetailBase_ACaseCategoryRecId.RegisterOverrideMethod(methodStr(FormReferenceGroupControl, lookup), formMethodStr(CaseDetailCreate, aOverrideCaseCategoryTestLookup)); } public void aOverrideCaseCategoryTestLookup(FormReferenceGroupControl _formReferenceGroupControl) { Args args = new Args(); CaseCategoryType caseCategoryType; Object formRun; args.name(formStr(ACaseCategoryHierarchyDetailLookup)); args.caller(_formReferenceGroupControl); formRun = classfactory.formRunClass(args); formRun.setCaseCategory('Accident'); formRun.setCategoryType(str2Enum(caseCategoryType,'General')); formRun.init(); _formStringControl.performFormLookup(formRun); } }
5. Here's the customized lookup form
[Form] public class ACaseCategoryHierarchyDetailLookup extends FormRun { CaseCategory caseCateogry; CaseCategoryType categoryType; void setCaseCategory(CaseCategory _caseCategory) { caseCateogry = _caseCategory; } void setCategoryType(CaseCategoryType _categoryType) { categoryType = _categoryType; } [DataSource] class CaseCategoryHierarchyDetail { ////// /// public void init() { QueryBuildDataSource queryBuildDataSource; CaseCategoryType caseCategoryType; super(); queryBuildDataSource = this.query().dataSourceTable(tableNum(CaseCategoryHierarchyDetail)); CaseCategoryHierarchyDetail caseCategoryHierarchyDetailLocal; select firstonly caseCategoryHierarchyDetailLocal where caseCategoryHierarchyDetailLocal.CaseCategory == caseCateogry && caseCategoryHierarchyDetailLocal.CategoryType == categoryType; if (caseCategoryHierarchyDetailLocal) { this.findCaseCategoryChildAndSubChild(caseCategoryHierarchyDetailLocal.ParentRecId, queryBuildDataSource); } } public void findCaseCategoryChildAndSubChild(RefRecId _ParentRefRecId, QueryBuildDataSource _queryBuildDataSource) { CaseCategoryHierarchyDetail caseCategoryHierarchyDetailLocal; while select caseCategoryHierarchyDetailLocal where caseCategoryHierarchyDetailLocal.parentRecId == _ParentRefRecId { _queryBuildDataSource.addRange(fieldNum(CaseCategoryHierarchyDetail,ParentRecId)).value(queryValue(caseCategoryHierarchyDetailLocal.RecId)); this.findCaseCategoryChildAndSubChild(caseCategoryHierarchyDetailLocal.RecId, _queryBuildDataSource); } } } }
Hi, Instead of unbound field, have you tried creating new EDT, adding your custom lookup form as formRef in EDT, creating a table field. Add a bound control just like mentioned in the articles.
can anyone help? I've been trying for hours now with no luck
Hi Mohit,
I've added a new string control to "CaseDetailCreate" form (not bound to a datasource). And overrided it's lookup like this:
////// Extension class for CaseDetailCreate form /// [ExtensionOf(formStr(CaseDetailCreate))] final class CaseDetailCreateA_Extension { public void init() { next init(); ACaseCategoryTest.RegisterOverrideMethod(methodStr(FormStringControl, lookup), formMethodStr(CaseDetailCreate, aOverrideCaseCategoryTestLookup)); } public void aOverrideCaseCategoryTestLookup(FormStringControl _formStringControl) { Args args = new Args(); CaseCategoryType caseCategoryType; Object formRun; args.name(formStr(ACaseCategoryHierarchyDetailLookup)); args.caller(_formStringControl); formRun = classfactory.formRunClass(args); formRun.setCaseCategory('Accident'); formRun.setCategoryType(str2Enum(caseCategoryType,'General')); formRun.init(); _formStringControl.performFormLookup(formRun); } }
[Form] public class ACaseCategoryHierarchyDetailLookup extends FormRun { CaseCategory caseCateogry; CaseCategoryType categoryType; void setCaseCategory(CaseCategory _caseCategory) { caseCateogry = _caseCategory; } void setCategoryType(CaseCategoryType _categoryType) { categoryType = _categoryType; } [DataSource] class CaseCategoryHierarchyDetail { ////// /// public void init() { QueryBuildDataSource queryBuildDataSource; CaseCategoryType caseCategoryType; super(); queryBuildDataSource = this.query().dataSourceTable(tableNum(CaseCategoryHierarchyDetail)); CaseCategoryHierarchyDetail caseCategoryHierarchyDetailLocal; select firstonly caseCategoryHierarchyDetailLocal where caseCategoryHierarchyDetailLocal.CaseCategory == caseCateogry && caseCategoryHierarchyDetailLocal.CategoryType == categoryType; if (caseCategoryHierarchyDetailLocal) { this.findCaseCategoryChildAndSubChild(caseCategoryHierarchyDetailLocal.ParentRecId, queryBuildDataSource); } } public void findCaseCategoryChildAndSubChild(RefRecId _ParentRefRecId, QueryBuildDataSource _queryBuildDataSource) { CaseCategoryHierarchyDetail caseCategoryHierarchyDetailLocal; while select caseCategoryHierarchyDetailLocal where caseCategoryHierarchyDetailLocal.parentRecId == _ParentRefRecId { _queryBuildDataSource.addRange(fieldNum(CaseCategoryHierarchyDetail,ParentRecId)).value(queryValue(caseCategoryHierarchyDetailLocal.RecId)); this.findCaseCategoryChildAndSubChild(caseCategoryHierarchyDetailLocal.RecId, _queryBuildDataSource); } } } }
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156