i thought about a solution in which the id or the name of an codeunit is given as a parameter into a variant (or somtehing else) … then i would like to start then run()-method using the variable … i thought this could work because of the isCodeunit method but it still doesn’t have any sense so is there any way to cast a variable ?
You can assign a Codeunit to a Variant variable and you can check if the Variant contains a Codeunit with the ISCODEUNIT function, but I don’t think it’s possible to then run the Variant. I couldn’t even assign the Variant back to the same Codeunit. But if I understand correctly, you could simply store the Codeunit ID in an Integer variable and then use the CODEUNIT.RUN(CodeunitID) to execute the correct Codeunit. Take a look at the Job Scheduler in Attain (if you have it) under Service Management, Setup. It has a lot more options but the basic idea is the same.