Get SalesFormLetter class from SalesEditLines form formRun using PreHandler AX7 - event-handling

I need to make some changes on closeOk of SalesEditLines form. As I know, I am not able to change the standard methods, so I need to create an event handler for closeOk.
[PreHandlerFor(formStr(SalesEditLines), formMethodStr(SalesEditLines, closeOk))]
public static void SalesEditLines_Pre_closeOk(XppPrePostArgs args)
{
FormRun sender = args.getThis() as FormRun;
Object callerObject = sender.args().caller();
}
The question is - how can i access a SalesFormLetter through SalesEditLines form formRun using PreHandler?

You can see the following line in init method of SalesEditLines form
salesFormLetter = element.args().caller();
So your callerObject is an instance of SalesFormLetter class, you need just cast it to proper type.
Please check the following link:
https://learn.microsoft.com/en-us/dynamicsax-2012/developer/expression-operators-is-and-as-for-inheritance

Related

Does formsflow support setting user task extension value as a variable?

Instead of hardcoding the value of formName in the task extension property of modeler, I need to place the formName value as a variable(e.g., ${formname}).
This is implemented in one of our listeners i.e; FormConnectorListener to get the extension property value in dynamic. Please refer https://github.com/AOT-Technologies/forms-flow-ai/blob/master/forms-flow-bpm/src/main/java/org/camunda/bpm/extension/hooks/listeners/task/FormConnectorListener.java
You can add a java listener that should implement org.camunda.bpm.engine.delegate.JavaDelegate and can access the extension property with the general xml api.
public void execute(DelegateExecution execution) throws Exception {
CamundaProperties camundaProperties = execution.getBpmnModelElementInstance().getExtensionElements().getElementsQuery()
.filterByType(CamundaProperties.class).singleResult();
Collection<CamundaProperty> properties = camundaProperties.getCamundaProperties();
for (CamundaProperty property : properties) {
System.out.println(property.getCamundaValue());
}
}
In the above overriden method you can get the variable by using:
execution.getVariable(StringUtils.substringBetween(property.getCamundaValue(), "${", "}"));

Create Contactor with paramater for ExternalAction

How I can create Contactor in code effect for ExternalAction ,
I have this code
[ExternalAction(typeof(Service), "SendEmail")]
And I want send email when success Evaluate but without write send code in SendEmail, I want use call interface to send it , like this
private readonly IEmailService email;
public Service(IEmailService emailService)
{
email = emailService;
}
[Action("Send Email", "Send Email to Someone")]
public void SendEmail(Rule Rule, [Parameter(ValueInputType.User, Description = "Output message", DataSourceName = "UserList")] int userId)
{
email.sene(userId);
}
You are trying to use the instance action method. For the engine to be able to invoke such a method it needs to instantiate your type. Your Service class doesn't have an empty (parameterless/default) constructor. Obviously, the engine won't have an instance of your EmailService at evaluation time. Therefore, it can't invoke your instance method. Either add a default constructor to your Service class and find another way to pass EmailService to the Service class or use a static method with value type parameters.

AS3 (animate cc 2018) Why does date keep coming back undefined?

I'm a beginner, so I'm sensing I'm making a simple mistake but I haven't been able to figure it out or find reference to a similar error on other forums.
My end goal is to create a graphic that changes colour depending on the time of day. Right now my issue is that I can not get a Date object to return anything for the life of me.
This is all I have put in a file called Main.as, that is called in one of the keyframes:
public class Main extends MovieClip {
var myDate1:Date = new Date();
trace(myDate1);
}
According to the API, if I don't define a specific date it should just take the current date from my system. But instead of doing the trace I keep getting "error 1120: Access of undefined property myDate1".
Why am I getting this error?
I should note I'm trying to make this for mobile so I've been testing the movie using AIR launcher.
Your script is wrong. You are not supposed to write code directly inside the class body. You need to define methods:
public class Main extends MovieClip
{
// Class constructor.
public function Main()
{
super();
// Output the current date.
trace(NOW);
}
// Static class property that always returns the current date.
static public function get NOW():Date
{
return new Date;
}
}

Getting method name related to a rest service

I wanted to know if there exist a way of retrieving the actual method name associated to a rest service provided. Lets suppose my url is http://localhost:8080/v1/mytesturl now i want to retrieve the actual method name that is associated with this url.
Actually we are maintaining some key/value pair specific to the method that we have created and i need to make some checks based on the method name that gets executed using these values.
Plz let me know if there exist some way to do that..
Simply get the method name from the Object class.
#RestController
#RequestMapping("")
public class HomeController {
#RequestMapping("/mytesturl")
#ResponseBody
public String getMethodName() {
return new Object(){}.getClass().getEnclosingMethod().getName();
}
}
i got the solution by using this
Map<RequestMappingInfo, HandlerMethod> handlerMethods = RequestMappingHandlerMapping.getHandlerMethods();
HandlerExecutionChain handler = RequestMappingHandlerMapping.getHandler(requestr);
HandlerMethod handler1 = null;
if(Objects.nonNull(handler)){
handler1 = (HandlerMethod) handler.getHandler();
handler1.getMethod().getName()
}
this provide me with what i wanted..

GWT Editor framework

Is there a way to get the proxy that editor is editing?
The normal workflow would be:
public class Class implments Editor<Proxy>{
#Path("")
#UiField AntoherClass subeditor;
void someMethod(){
Proxy proxy = request.create(Proxy.class);
driver.save(proxy);
driver.edit(proxy,request);
}
}
Now if i got a subeditor of the same proxy
public class AntoherClass implements Editor<Proxy>{
someMethod(){
// method to get the editing proxy ?
}
}
Yes i know i can just set the proxy to the Child editor with setProxy() after its creation, but i want to know if there is something like HasRequestContext but for the edited proxy.
This usefull when you use for example ListEditor in non UI objects.
Thank you.
Two ways you can get a reference to the object that a given editor is working on. First, some simple data and a simple editor:
public class MyModel {
//sub properties...
}
public class MyModelEditor implements Editor<MyModel> {
// subproperty editors...
}
First: Instead of implementing Editor, we can pick another interface that also extends Editor, but allows sub-editors (LeafValueEditor does not allow sub-editors). Lets try ValueAwareEditor:
public class MyModelEditor2 implements ValueAwareEditor<MyModel> {
// subproperty editors...
// ValueAwareEditor methods:
public void setValue(MyModel value) {
// This will be called automatically with the current value when
// driver.edit is called.
}
public void flush() {
// If you were going to make any changes, do them here, this is called
// when the driver flushes.
}
public void onPropertyChange(String... paths) {
// Probably not needed in your case, but allows for some notification
// when subproperties are changed - mostly used by RequestFactory so far.
}
public void setDelegate(EditorDelegate<MyModel> delegate) {
// grants access to the delegate, so the property change events can
// be requested, among other things. Probably not needed either.
}
}
This requires that you implement the various methods as in the example above, but the main one you are interested in will be setValue. You do not need to invoke these yourself, they will be called by the driver and its delegates. The flush method is also good to use if you plan to make changes to the object - making those changes before flush will mean that you are modifying the object outside of the expected driver lifecycle - not the end of the world, but might surprise you later.
Second: Use a SimpleEditor sub-editor:
public class MyModelEditor2 implements ValueAwareEditor<MyModel> {
// subproperty editors...
// one extra sub-property:
#Path("")//bound to the MyModel itself
SimpleEditor self = SimpleEditor.of();
//...
}
Using this, you can call self.getValue() to read out what the current value is.
Edit: Looking at the AnotherEditor you've implemented, it looks like you are starting to make something like the GWT class SimpleEditor, though you might want other sub-editors as well:
Now if i got a subeditor of the same proxy
public class AntoherClass implements Editor<Proxy>{
someMethod(){
// method to get the editing proxy ?
}
}
This sub-editor could implement ValueAwareEditor<Proxy> instead of Editor<Proxy>, and be guaranteed that its setValue method would be called with the Proxy instance when editing starts.
In your child editor class, you can just implement another interface TakesValue, you can get the editing proxy in the setValue method.
ValueAwareEditor works too, but has all those extra method you don't really need.
This is the only solution I found. It involves calling the context edit before you call the driver edit. Then you have the proxy to manipulate later.