Notifications
Announcements
No record found.
Hi,
My requirement is to access variable initialized in a CoC in another CoC.
I have a CoC of Form init() method. In this method I have declared and initialized a variable. I have another CoC of the form datasource method executeQuery(). Now I want to get the value of the variable from the CoC of init() method.
Can anyone help me on how to access variable of init() method CoC in executeQuery() method CoC
If you declare a variable inside a method (such as init) it's visible only in init method. CoC doesn't change this fact. ExecuteQuery can't see any local variables of init method.
You can add a form level variable, then it will work.
This is how my code is
Init CoC
[ExtensionOf(formStr(FormName))]final class FormName_Extension{ int variable1;
public void init() { next init(); variable1 = 10; }
}
executeQuery CoC
[ExtensionOf(formDatasourceStr(FormName, CustTable))]final class FormNameDS_Extension{ public void executeQuery() { next executeQuery(); //Need to access variable1 here }}
OK, so the variable is not in the init method CoC.
You should be able to access it via element.variable1. If not, you can create a "getVariable1()" method in your first class and call that from the second class to get the variable.
I was not seeing the intellisense on typing 'element.' But when I copy pasted it worked.
Thanks !
IntelliSense is not always working very well with CoC, so it always makes sense to just "type and compile" and see if something works :)
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 Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 503 Most Valuable Professional
André Arnaud de Cal... 434 Super User 2025 Season 2
BillurSamdancioglu 278 Most Valuable Professional