Hi ,
How can I access the UI Buttons using formDataSourceStr COC. When I try to access the buttonInvoiceUpdate inside the class I am getting the following Error
[ExtensionOf(formDataSourceStr(SalesTableListPage,SalesTable))] final class SalesTable_SalesTable_Extension { public int active() { SalesTable salesTable= this.cursor(); FormButtonGroupControl CourseCertificate = this.formRun().design().controlName("buttonUpdateInvoice") as FormButtonGroupControl; int ret = next active(); buttonUpdateInvoice.enabled(salesTable.SalesStatus != SalesStatus::Invoiced && salesTable.WorkflowState == GD_SalesTableWFApprStatus::Approved); return ret; } }
Your code should work if the form returned from formRun() has a control called buttonUpdateInvoice and the type of this control is FormButtonGroupControl. Please test all these assumptions.
Also, if you know the form name in advance, please use formControlStr() instead of hard-codeding the control name.
Where are you calling your code?
By the way, why is the variable called courseCertificate?
Hi I tried similar functionality
where I have added a new button in the form action pane and I am calling on form datasource for enable/disable
i was getting error while debugging "object reference not set "
but this line
FormButtonGroupControl CourseCertificate = this.formRun().design().controlName("buttonUpdateInvoice") as FormButtonGroupControl;
CourseCertificate returns null
returns null for me and ultimately giving me error object reference not set how to resolve this issue
You're getting an error because you've never declared any variable called buttonUpdateInvoice. You've put the button to a variable called courseCertificate (which you never used).
Also, never hard-code object names as strings, because then compiler can't found the problem if a button gets renamed or something. Use intrinsic functions such as formControlStr().
Can you try this ?
public int active() { int ret; ret = next active(); SalesTable salesTable = this.cursor(); FormButtonGroupControl invoiceBtn = this.formrun().design().controlName(formControlStr(SalesTableListPage, buttonName)) as FormButtonGroupControl; invoiceBtn.enabled(<<<>>>) return ret; }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Andrés Arias as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Sohaib Cheema 823 User Group Leader
André Arnaud de Cal... 673 Super User 2025 Season 2
Martin Dráb 491 Most Valuable Professional