I was just writing an IScript for the Approval Workflow Engine (AWE) that called the Approval Manager class to approve a transaction. The transaction failed because the Application Classes used in the Event notification handler used the %Component
system variable. This would have been fine except %Component
cannot be called from an IScript. To work around this, I wrapped the calls to %Component
in a function that checks whether the execution context is a component. Here is the code:
Function GetComponentName() Returns String
If (%ContentType = "c") Then
Return %Component;
Else
Return "";
End-If;
End-Function;
If you are writing your code in a Page or a Component and use the %Component
system variable, then you shouldn't have any problems. But, if your code is in a FUNCLIB or Application Class, a reusable component, then be aware that one of those "reuses" might be from PeopleCode that runs outside a Component (IScript, AppEngine, Message Subscription, etc). If that is the case, then please be kind to the developer that follows you by wrapping your calls to %Component
in a function that tests to see if your code is executing within a Component.