Override afterRegister in business logic

Hi!

I have some problems when trying to use this functionality.
All I do is:

 @Async 
 @Override 
 public void afterRegister (RunnerContext context, HashMap userValue, ExecutionResult <HashMap> result) throws Exception 
 {
     System.out.println ("hello afterRegister"); 
 } 

But in the CodeRunner I get an exception:
“Argument type mismatch” and I don’t see my attempt to print the output.

I appreciate any help.

How long ago did you download CodeRunner from our site?

Regards,
Mark

Like 3-5 weeks: v1.2

In Backendless Business logic docs i see a different definition of the function afterRegister:

@Override

public HashMap afterRegister( RunnerContext context, HashMap userValue, ExecutionResult savedValue ) throws Exception

{

// add your custom logic here

return super.afterRegister( cobtext, userValue, savedValue);

}

Hi Sasha,

I was not able to reproduce the problem. I created a handler using code generator in Backendless Console. The code looks like this:

public class GenericUserEventHandler extends com.backendless.servercode.extension.UserExtender
{
    
  @Async
  @Override
  public void afterRegister( RunnerContext context, HashMap userValue, ExecutionResult<HashMap> result ) throws Exception
  {
    System.out.println( "in afterRegister" );
  }
}

Then I register a user with REST (using curl):

curl -H application-id:MY_APP_ID -H secret-key:MY_REST_SECRET_KEY -H Content-Type:application/json -H application-type:REST -X POST -d '{"email":"foobar@backendless.com", "password":"123456"}' http://api.backendless.com/v1/users/register

As expected, I am getting the output of System.out.println in my code runner.

What does your registration request look like?

Regards,
Mark

Hi!

Yes, works If i do it with curl. But if do it from my application does not work, and i get the exception argument type mismatch. Seems strange that the user is added to the database anyway.

Thanks.

I suspect it is a problem with a request which your app makes. Do you use REST api or our SDK? Can you show the code that makes the request?