+ Start a Discussion

Trigger to convert from Contact to Portal user

Hi  All,


I  have written a trigger in Leads to convert the Leads from WEB-TO-LEAD   to  Contacts/Accounts.

But i dont know how to write a trigger to convert from contact to portal user. The event should be After insert.

Please anybody help me to sort out this issue.





You can create portal user associated with Site method Site.createPortalUser(). If you want person Accounts to be Portal users you should use createPersonAccount​PortalUser(). See the full documentation here. http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm


Using Sites u can only create customer portal user not a partner portal user

whixh type of portal user u r try to create
u can not create portal user from code


Hi  bvramkumar,

Thanks for your reply.

Can you send me sample trigger to convert the Contact to Customer portal User.

(Event is   after insert).

If i try to convert using Site.createPortalUser();

Throwing error as follows:


(System Code)
Trigger.ConverttoPortaluser: line 16, column 1
03:46:50.070 (6899180070089892)|FATAL_ERROR|System.TypeException: That operation is only allowed from within an active site.

(System Code)





Has you been able to solved it ?