Announcements
I created a new extension from table BrazilParameters and created a new method of type edit:
public edit Name profitCenterDimAttributeName (boolean _set, BrazilParameters _brazilParameters, Name _name) { DimensionAttribute dimensionAttribute; if (_set) { dimensionAttribute = DimensionAttribute::findByName(_name); this.ProfitCenterDimensionAttribute = dimensionAttribute.RecId; } return DimensionAttribute::find(this.ProfitCenterDimensionAttribute).Name; }
Also i have created a form extension to include new fields and my intention is to call the edit method right in the new form field to perform the edit operation:
But when i performed the form, the following error showed up:
I can't figure out why this is happened, because the method do exist in the extension. Any guest?
I just found the mistake in my code. Display and edit method must be STATIC, because under the hood dynamics executes this code from FormUtilClass:
private static container CallTableDataMethodInExtensionClass(Common _common, str methodName, container inputVariables, boolean newValueIsDefault, str extensionClassName, boolean isStaticMethod) { container returnContainer; anyType returnValue; boolean set = false; anytype newValue; int inputVarsSize = conLen(inputVariables); DictClass dictClass = new DictClass(className2Id(extensionClassName)); if (dictClass != null) { DictMethod dictMethod = new DictMethod((isStaticMethod ? UtilElementType::ClassStaticMethod : UtilElementType::ClassInstanceMethod), dictClass.id(), methodName); if (dictMethod != null) { // Edit Method if (inputVarsSize > 1) { set = conpeek(inputVariables, 1); newValue = conpeek(inputVariables, 2); // For instance based edit methods parameter count is 2, as instance extension methods is marked as extension methods to C#, but // static extension methods are not. So for static extension methods, the check for the 3rd optional parameter is needed. int parmOptCheck = isStaticMethod ? 3 : 2; // if new value is default and edit method has last argument as optional parameter we want to call method with default argument value. if (newValueIsDefault && dictMethod.parameterOptional(parmOptCheck)) { returnValue = dictClass.callStatic(methodName, _common, set); } else { returnValue = dictClass.callStatic(methodName, _common, set, newValue); } } else // Display method { returnValue = dictClass.callStatic(methodName, _common); } } } returnContainer = conins(returnContainer, 1, returnValue); return returnContainer; }
Also the order from my edit method was wrong i fix the code and everything worked as expected.
André Arnaud de Cal...
293,302
Super User 2025 Season 1
Martin Dráb
232,114
Most Valuable Professional
nmaenpaa
101,156
Moderator