How can I run a class from alert rules in axapta - axapta

Hi everybody I want to create alert rule in axapta. But some class will run when rules run. I want that class to work with the new rule. How can I do this?

You can create custom event action and call your logic there.
Class representing an action must inherit from the EventAction Class, and it must implement the execute method. For each event rule, the Alerts module creates a list of action class IDs that must be instantiated. The individual execute method that is associated with each respective class ID is called whenever a rule matches an event. The list of actions is customizable. For more information, see
How to: Add Custom Actions for Alerts

Related

How to override subscriber in Shopware 6?

I would like to override a plugin's event subscriber. Is it possible by just adjusting the priority in the service.xml?
Are there any other ways to disable a subscriber?
I disabled the subscriber by decorating it.
That way I could simply add a new getSubscribedEvents() function, that returns an empty array.
see:
https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/adjusting-service
Subscribers are also normal symfony services, so a simple decorating of the service should work.
Create your own subscriber and add to it's DI declaration the "decorates" attribute with the class name of the original subscriber as value.

Should actions only be used when updating state?

Reducers listen for actions of a certain type and then update the store as needed, but should you use an action without changing the store?
Maybe on route changes or on button clicks so that what the user does shows up in timemachine, or is this abusing actions?
Actions are linked to reducers through their 'type', in general actions should be linked with at least one reducer.
It seems like you can achieve the functionality you are looking for by creating a function inside your component that is your method called by the onClick, submit, or whatever activity happens, something like this:
myOnCLickMethod(passedInfo){
const {dispatch} = this.props
//any JavaScript code you need
dispatch(myAction(passedInfo))
}
This ensures you can do anything you want that doesn't touch the state while still allowing for actions to fire and state changes when that activity happens.
An action is a call for state change. So if route changes or button clicks don't change the state of your app, you shouldn't use actions for them. Maybe log is more relevant in this scenario.

How to pass data to a ClassFactory-generated instance in Flex?

I have created an item-renderer (IListItemRenderer) to customize the display of a datagrid, and I override the data getter/setter to pass in the relevant variable. So far, so good.
In the item-renderer I have a button, which, when clicked, should display a form populated with various fields of the aforementioned variable. To do this, Button is overridden so that it displays whatever IFactory implementation it is passed.
private function instantiateDropdown():void
{
_dropdownFactory = new ClassFactory(MyPanel);
_dropdownFactory.properties = {boundData: _myVariable};
}
<buttons:PopUpButton id="editButton" dropdownFactory="{_dropdownFactory}" toolTip="Edit" source="{skins.ButtonImages.Edit}" click="edit_clickHandler(event)" />
My IFactory implementation is a panel containing my form, and it is displayed when the button is clicked, as desired. However, the variable is not set. It seems that in order to instantiate my IFactory before the overridden button needs to access it, my new ClassFactory() statement needs to be in the preinitialize event handler, but the variable has not been set at that time. Setting the properties of my IFactory instance after it has been created (e.g. in the click event) does not appear to work.
How should I pass my variable to my ClassFactory-generated instance so that it populates the form correctly?
Using lazy instantiation for the creation of the dropdownFactory (MyPanel in the question) in the class overriding Button (PopUpButton in the question), I was able to call instantiateDropdown in the creationComplete event instead of preinitialize, which allowed the PopUpButton to initialize with the correct properties (_myVariable in the question).

Actionscript 3: Why override custom event...and when to override it?

I always have a question about override custom event. I am not sure why or what do to inside override function. I searched google but didn't get too many feedbacks. I appreciate if someone can light me up. Thanks.
EDIT:
My projects seem work fine even though I use my custom event without override. Anyone could explain it? Thanks.
In general, you need to override a function when its use needs to be modified. So for instance, say I have a class called Car. In this class I have a function called go() which starts the car.
Now if i extend this class into another class called PickupTruck, I need to override the Car class' go function so it not only starts the car, but also attaches the Trucks trailer.
So in your case you have to override the clone method of your CustomEvent class because it should return a new CustomEvent instead of a new Event.
From the docs:
When creating your own custom Event
class, you must override the inherited
Event.clone() method in order for it
to duplicate the properties of your
custom class. If you do not set all
the properties that you add in your
event subclass, those properties will
not have the correct values when
listeners handle the redispatched
event.
So, you can have a problem if you don't override clone and redispatch an Event. Also, the problem is not only that the custom properties will not be copied. The clone method will be called on the base class, Event. This will return an Event object, not a CustomEvent. If you have a handler that expects a CustomEvent and receives an Event, an error will be thrown and the code in your handler will not run.

call flex initComplete at a specific time

Below is the overriden on complete function for a preloader in Flex.
private function initComplete(e:Event):void
{
//dispatchEvent(new Event(Event.COMPLETE));
cp.status.text="Configuring... Please Wait";
}
What I want to do is when the app has finsihed loading I want to change the preloaders text to "configuring".
Then I want to go and do a bunch of setup stuff in my code.
Once I've done all the setup I wanted how can I get the Preloader to dispatch its Event.complete from else where in my code?
I tried Application.application.preloader but it comes up null.
So I guess my question really is how to access a preloader from anywhere in my application.
Would a better approach be to have all setup classes as members of my preloader class?
One thing that might help is a Model-View-Controller pattern. Are you using a framework for your application like Mate, Swiz, or Cairngorm?
If you were using Mate, for example, you could do something like this:
Create an AppStateManager class with a property (e.g. applicationState)
Create an EventMap with an EventHandler for the FlexEvent.INITIALIZE event. In this handler, set the AppStateManager.applicationState to something like "CONFIGURING"
Your EventMap has an injector that injects the applicationState property into a view. The injector listens for changes to this property and updates the view. In this case it might just be injected into your main view.
In the main view, you have a public bindable property also called applicationState that gets injected by Mate.
In the setter for this property, you can have an if/then or a switch that does different tasks depending on the state. For example, if applicationState == "COMPLETE", then this.preloader.dispatchEvent(Event.COMPLETE) or something like that.
The details are pseudo-sketched out but the idea is to use Flex's bindings to notify view components when changes have been made, and to have shared objects that maintain state. Not sure if that's what you're looking for...
The component LifeCycle does specific stuff in a specific order, and the near final element is to make the component visible.
It sounds to me like you want to defer this setting of visible to true to do other stuff. But, I imaging if you were making use of the component LifeCycle this would be a non-issue.
What sort of app init stuff do you need to do?

Resources