Notifications
Announcements
No record found.
Hi Team,
I am creating COC of main method of SalesFormLetter class. I want to access to the variable" numberofrecords" declared inside the main method in my COC but it is showing error "The qualifier "numberofrecords" is not valid in this context. Use a variable of this type instead."
can anyone suggest how to get the value in COC ?
You can't access method variables with Chain of Command. Your COC code runs outside the wrapped method. And a method variable only exists within the method.
But you can see that in this scenario numberOfRecords is fetched from the contract class: (outputContract.parmNumberOfOrdersPosted()). So you can fetch it from there.
Hi Nikolaos,
can you please show me how to do that ? I tried but got the error that "output contract is not declared". Please find the below code.
[ExtensionOf(classstr(SalesFormLetter))]
final class LNTSalesFormLetter_Extension
{
public static void main(Args args)
SalesTable salesTable;
Counter locrecords;
next main(args);
if(args.menuItemName() == menuItemActionStr(SalesFormLetter_Proforma_Invoice_Action))
if(outputContract.parmNumberOfOrdersPosted() > 0 )
salesTable = FormDataUtil::getFormDataSource(args.record()).cursor();//args.record();
}
Trying to wrap main() looks like a bad idea to me. Why don't you wrap an instance method, where you can access instance variables of the class?
Next time you share your code, please click "Use rich formatting" and then Insert -> Insert code. This way your code will be easier to read.
You can't get it by wrapping the main method. The contract is initialized inside main method.
Could you please first explain what you are trying to achieve functionally? Then we can suggest solutions.
As others suggested, it would be good if you give an example or explain more what you're trying to do.
Also, "main" is a static method, typically called from menu items. They typically just create an instance of the class and run it (with or without some sort of dialog first). It's likely you can create your own class with your own main() method, and do what you need to do. Potentially you can extend the original menu item to use your class instead.
But again, it would be good to understand what you're trying to do.
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.
André Arnaud de Cal... 467 Super User 2025 Season 2
Martin Dráb 420 Most Valuable Professional
BillurSamdancioglu 241 Most Valuable Professional