I'm toying with an idea of auto-activating (or deactivating) contacts for Communities/customer portal after certain criteria have been met on their contact records. It would look something like this (inefficient stub, for demonstration purposes):
- Go through Contacts in trigger, pulling list of contacts to activate/deactivate
- If there are contacts to activate/deactivate, query for any existing Portal users linked to these contact records. Activate/Deactivate accordingly (via
- For any remaining contacts (who didn't match existing users), create & insert new portal user accounts.
My question is: would this work?
- I know how to create portal users and manage their permissions in Apex
- I also know that there are some API restrictions on creating/updating User records in the same transaction where you update other data
- But I don't know if those limits apply to portal users, or in trigger contexts, or if there are ways to make it work anyway using @future calls or some other technique.
I can definitely explore this, but thought I'd ask here in case anyone has experience with this approach or whether it would work.