Hi,
I'm trying to assign the value of a formReferenceGroupControl
FormReferenceGroupControl name = sender.formRun().design().controlName(formControlStr(CaseDetailCreate, DirPartyTable_Name)) as FormReferenceGroupControl; HcmWorker hcmWorker = HcmWorker::findByPersonnelNumber(conPeek(con,counter)); -- hcmWorker has a value name.value(DirPartyTable::findRec(hcmWorker.Person).RecId); //it fails here
Well, you may want it, but it won't work. So maybe you should consider a design that can actually do what you need.
Hi Martin,
But caseDetail form already has dirPartyTable_name control...and if you manually create the case by filling the name field in the caseDetail form..when u click ok, then you can see that the same value is also appearing in caseDetailCreate form.
So what I want to do is fill the name field in caseDetail by code instead of manually filling it..so that at the end it appears in caseDetailCreate
It's nice that it opens CaseDetail, but that's not the form where you're setting the value. You're using DirPartyTable control of CaseDetailCreate form.
I think you shouldn't play with form controls at all; you should write a value to DirPartyTable field of CaseDetailBase data source. And should you should do it when saving the record, or sooner.
Hi Martin,
here's the full code. When the button for "CaseDetailCreate" form closes it opens the caseDetail Form
The worker field is filled
[FormControlEventHandler(formControlStr(CaseDetailCreate, OK), FormControlEventType::Clicked)] public static void OK_OnClicked(FormControl sender, FormControlEventArgs e) { FormStringControl worker = sender.formRun().design().controlName(formControlStr(CaseDetailCreate, XXWorker)) as FormStringControl; FormReferenceGroupControl caseCategory = sender.formRun().design().controlName(formControlStr(CaseDetailCreate, CaseCategoryHierarchyDetail_CaseCategory)) as FormReferenceGroupControl; FormReferenceGroupControl name = sender.formRun().design().controlName(formControlStr(CaseDetailCreate, DirPartyTable)) as FormReferenceGroupControl; FormRun formRun = sender.formRun(); FormDataSource formDataSource = formRun.dataSource(formDataSourceStr(CaseDetailCreate, CaseDetailBase)); CaseDetailBase caseDetailBase = formDataSource.cursor(); CaseAssociation caseAssociation; if(worker.text() != '') { Container con; SysLookupMultiSelectCtrl multiSelectCtrl = formRun.XXMultiSelectCtrl(); con = multiSelectCtrl.getSelectedFieldValues(); int counter; for(counter=1; counter <= conlen(con); counter ) { caseAssociation.EntityType = CaseEntityType::Employee; caseAssociation.CaseRecId = caseDetailBase.RecId; HcmWorker hcmWorker = HcmWorker::findByPersonnelNumber(conPeek(con,counter)); caseAssociation.RefRecId = hcmWorker.RecId; CaseCategoryHierarchyDetail caseCategoryHierarchyDetail; select firstonly caseCategoryHierarchyDetail where caseCategoryHierarchyDetail.RecId == caseCategory.value() && caseCategoryHierarchyDetail.XXIsPrimary == NoYes::Yes; if(caseCategoryHierarchyDetail) { caseAssociation.IsPrimary = NoYes::Yes; name.value(DirPartyTable::findRec(hcmWorker.Person).RecId); } caseAssociation.insert(); } } }
Yes, this code now access the right control and sets a value there.
But it doesn't mean that it makes sense. The button closes the form, doesn't it? So how you can whether the value was set or not, if the form is closed and you can't see anything?
Also, we can't know whether your code finds any worker.
Hi Maritn,
You mean you want it like this? -- it's still not working, the value is not filled in the form
[FormControlEventHandler(formControlStr(CaseDetailCreate, OK), FormControlEventType::Clicked)] public static void OK_OnClicked(FormControl sender, FormControlEventArgs e) { FormReferenceGroupControl name = sender.formRun().design().controlName(formControlStr(CaseDetailCreate, DirPartyTable)) as FormReferenceGroupControl; //more logic HcmWorker hcmWorker = HcmWorker::findByPersonnelNumber(conPeek(con,counter)); -- hcmWorker has a value name.value(DirPartyTable::findRec(hcmWorker.Person).RecId); }
No, you weren't. You were using the same control as now, DirPartyTable_Name, which isn't a reference group control. It's a string edit control.
As I said in my first reply, the reference group control is called DirPartyTable.
Hi Martin,
But at first I was using formReferenceGroupControl and then you said it's wrong.
Can you please explain more what I should do...maybe I misunderstood you
I think that trying to set the name directly isn't a good idea. You should set the value of the reference group control.
Hi Mohit and Martin,
I tried this but the value is still not set in the form
[FormControlEventHandler(formControlStr(CaseDetailCreate, OK), FormControlEventType::Clicked)] public static void OK_OnClicked(FormControl sender, FormControlEventArgs e) { FormStringControl name = sender.formRun().design().controlName(formControlStr(CaseDetailCreate, DirPartyTable_Name)) as FormStringControl; //more logic HcmWorker hcmWorker = HcmWorker::findByPersonnelNumber(conPeek(con,counter)); -- hcmWorker has a value name.text(DirPartyTable::findRec(hcmWorker.Person).Name); }
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156