UserEventHandler afterRegister not working

Hi,
Downloaded the generated code from the Business Logic section. Modified the project using Intellij. Added the following code:

public class GenericUserEventHandler extends com.backendless.servercode.extension.UserExtender
{
 
 @Override
 public void afterRegister( RunnerContext context, HashMap userProperties, ExecutionResult<HashMap> result ) throws Exception
 {
 // add your code here
 Category bMeal = new Category();
 bMeal.setId(UUID.randomUUID().toString());
 bMeal.setName("Before Meal");
 bMeal.setLow(70);
 bMeal.setHigh(100);
 Category aMeal = new Category();
 aMeal.setId(UUID.randomUUID().toString());
 aMeal.setName("After Meal");
 aMeal.setLow(80);
 aMeal.setHigh(140);
 Backendless.Persistence.of(Category.class).save(bMeal);
 Backendless.Persistence.of(Category.class).save(aMeal);
 }
 
}

Then deployed it using Deploy.sh. It deployed successfully. However, when I try to register using the Android SDK from my android app, no records were created.
http://support.backendless.com/public/attachments/0c75d1472f1ba105cf1475a67416394c.png</img>

Did I miss something?
Appreciate any help.
Regards,
Allen

Hello!

Your code looks OK, it should work. However, we cannot reproduce this issue.
Can you please show code snippet that creates new user? Maybe, the cause is there.
Thank you!
regards,
Alex

Hi,

Here’s the code I used in my android app.

BackendlessUser user = new BackendlessUser();
user.setProperty("first_name", mFname.getEditText().getText().toString());
user.setProperty("last_name", mLname.getEditText().getText().toString());
user.setProperty("name", String.format(Locale.US, "%s %s", mFname.getEditText().getText().toString(), mLname.getEditText().getText().toString()));
user.setEmail(mEmail.getEditText().getText().toString());
user.setPassword(mPassword.getEditText().getText().toString());
Backendless.UserService.register(user, this);

My app also allows logins using the GoogleSDK and FacebookSDK. I followed the code from you site regarding how to login with these.

One other thing that I noticed. so basically I downloaded the generated code and modified it using IntelliJ and then deployed it. However, when I go back to my Backendless console in the Business Logic section, I don’t see my updated code there in the Code Generation tab. Not sure if this is relevant though. See screen shot below.

http://support.backendless.com/public/attachments/3801792f9829766bc4af1a080dcb7728.png</img>

Regards,
Allen

Speaking about code view in console - it’s expected. You’re not able to see deployed code, it’s just a template.
Did you try to run and test your handler in debug mode? Use CodeRunner.sh script for this purpose.

Hi,

It seems to work in debug mode. I then tried it again in Production but it doesn’t work there. Ran into another problem though.

I noticed that the records ownerId object do not get pre-populated with the user’s objectId. Is there a way to set these?

Regards,
Allen

For some reason, it seems to be working now on Production as well. Not sure what happened.

However, I still have that other issue though. Created another thread for that instead.

Thanks.

Ok, I’ll mark it as “answered” for now.