Hello Manfred,
It is easy to do.
The first thing is to check if the method you're calling exists with
the 'TableHasMethod' function. Afterwards you execute with
the 'CallStatic' method of the table.
Something like this:
container methodNames;
CustTable cust;
String methodName;
;
methodNames = ["MethodA","MethodB","MethodC"]
for(i = 1; i <= conLen(methodNames); i++)
{
methodName = conPeek(methodNames, i);
if (tableHasMethod(cust,methodName))
{
cust.callStatic(methodName);
}
}
Hope this helps.
Regards,
Peter
--- In [email protected], "smeagul2303"
<[EMAIL PROTECTED]> wrote:
>
>
> Hello,
>
> I want to call methods from an object dynamically.
> Let's say I have a container including strings. The strings are
> methodnames of an object. Now I want to go through the container
and
> sending each method to the object.
>
> What is the construction for that ?
>
> With a table and fieldIds it is easy:
>
> Container fieldIds;
> CustTable cust;
>
> fieldIds = conPoke(fieldIds, conLen(fieldIds)+1, fieldNum(cust,
> Name));
> fieldIds = conPoke(fieldIds, conLen(fieldIds)+1, fieldNum(cust,
> Address));
> .....
>
> all fieldIds are in the container. To make a call to a custtable I
do:
>
> for(i = 1; i <= conLen(fieldIds); i++)
> {
> fieldId = conPoke(fieldIds, i);
> info(strfmt("FieldId %1 Value: %2", fieldId, custTable.
(fieldId)));
> }
>
> So with fieldIds I do the call: table.(fieldId)
> but how do I do it with methods ?
> object.methodName ?? That is a syntax error.
>
> Regards
>
> Manfred
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

