Wednesday, July 4, 2018

Pre and Post Events

You can subscribe an event handler to automatically run immediately before a
method is run. The event handler can change the parameter values before they are
entered into the method. You can also subscribe an event handler to run
immediately after a method is run. The event handler can change the value that is
returned by the method, before the return value is received by the caller of the
method.
Event handlers for these before and after events are visible in the AOT as sub
nodes on the methods to which they apply.

Adding a Post Event Use the following procedure to add a post event to the method that is used to
determine whether or not the user may post a packing slip for the current sales
order.
1. In the AOT create a new class called
SalesTableTypeDelegate.
2. Create a new method called
mayPackingSlipBeUpdated and add
the following code



1
2
3
4
5
6
7
8
public static void mayPackingSlipBeUpdated(XppPrePostArgs _args)
{
   boolean ret;
   ret = _args.getReturnValue();
   _args.setReturnValue(ret && 
   dayOfWk(systemDateGet()) ==
   WeekDays::Monday);
}
3. Save your changes.
4. In the AOT locate the class
SalesTableType.
5. Expand the class node and find the method
mayPackingSlipBeUpdated.
6. Right-click the method and select New Event Handler Subscription.
The
EventHandler1 event handler node is created.
7. In the property sheet for
EventHandler1, set the Name property tomayPackingSlipBeUpdatedPost, set the CalledWhen property toPost, set the Class property to SalesTableTypeDelegate, set theMethod property to mayPackingSlipBeUpdated.
8. Test your modification in the sales order form and observing that the
packing slip button is only available when the packing slip can be
posted and it is a Monday.
This is of course a modification that would not normally be required. However
this kind of modification may be used in for example, a workflow. If the sales
order needs to be approved before it can be packing slip posted, then this method
could validate that it has been approved. In this way you have added a new
validation without modifying the standard code.

 
Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...