Send different welcome emails to new users based on their roles

Hmmm, that is not possible, since there is no Users table when using “Data Tables” category :frowning:

And my fault for saying that I used upsertUser as method, that was one of my functions! :grimacing:

I AM using Register User to do the actual creation:

I am trying log output’ing for these three methods now, and none of them are getting anything:

22:47:39.380 | SERVER_CODE | INFO | [347235] user.afterEmailConfirmed (handlers/user/afterEmailConfirmed.js)
22:47:39.380 | SERVER_CODE | INFO | [347235] user.afterRegister (handlers/user/afterRegister.js)
22:47:39.380 | SERVER_CODE | INFO | [347235] user.afterUpsert (handlers/user/afterUpsert.js)

I’ll go through and add handlers for everything under the Users category to see if I can get anything…

Nothing… nada… zilch…

Ok, I give up, I’ll find another way to send those emails for now.

I checked the log file and I see the following, so the log messages are definitely there:

Not really: Those messages are coming only when I use the REST console.

When using the Register User codeless block, nothing happens. When that is used, nothing is created.

My upsertUser logs are from before and after the Register User codeless block is used, those appear in the log, but nothing from Register User:

22:59:1.639 | SERVER_CODE | INFO | [349022] Building ServerCode Model for path (/opt/backendless/repo/dff48c1b-107f-426c-b45a-5141767de217/files/servercode/CODELESS/userAdmin/PRODUCTION)
22:59:1.641 | SERVER_CODE | INFO | [349022] ServerCode Model built in 7ms
22:59:1.645 | SERVER_CODE | INFO | [349022] [F399AB76-5FC8-39B9-FF6A-25A6B386D600] [INVOKE SERVICE] services.userAdmin.upsert
22:59:1.903 | upsertUser | DEBUG | Creating new user...
22:59:2.75 | upsertUser | DEBUG | User account created!
22:59:2.290 | SERVER_CODE | INFO | [349022] Processing finished in 663.702ms

But I’ll just go ahead and send the email directly in my code during account creation instead, and skip all this event stuff.

Do you use the Register User codeless block in the UI or in Cloud Code? If the latter, then it makes sense that the handler is not triggered. API calls made from an API service will not trigger Event Handlers since it could lead to an infinite recursion:

Request -> API Service -> API Call -> Event Handler -> Calls API Service (this starts recursion)

I understand you do not do in your app, but someone could (if we didn’t have that limitation) and it would have rather painful result.

In Cloude Code, yes. And I see what you mean.

Well, then at least my head is a bit clearer, and I’ll continue getting those Email Templates to work. Thanks for sticking with me and helping out though!! :slight_smile:

1 Like