• Ben Burbridge 7
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello,

Here's the scenario : one active community, one account, two contacts. The 2 contacts have the same email address. You want to create a community user for contact One, it associates with contact Two.

Code in CommunitiesSelRegController, called by a commandButton in apex page :

public void test()
    {
        Account a = new Account(Name='Account test', OwnerId='005A0000001fgpe' ); //Owner = me, must have a role
        insert a;
       
        List<Contact> lc = new list<Contact>{
                new Contact(LastName='One', email='same@mail.com', AccountId=a.Id),
                new Contact(LastName='Two', email='same@mail.com', AccountId=a.Id),
                new Contact(LastName='Three', email='different@mail.com', AccountId=a.Id)
                    };
        insert lc;
       
        User u = new User();
        u.userName = lc[1].email;
        u.email = lc[1].email;
        u.FirstName = 'test';   
        u.LastName = lc[1].LastName;
        u.alias = 'watvr';
        u.CommunityNickName=u.alias;
        u.ProfileId = '00eA0000000yex2'; //Customer community user profile
        u.ContactId = lc[1].Id;
         u.CompanyName = a.Name;
        system.debug(u);     // will output User:{ ...ContactId = Two.Id ...}
        String userId = Site.createPortalUser(u, a.Id, null, true);
        system.debug(u);// will output User:{ ...ContactId = One.Id ...}
        }

Don't know where to report this bug...

Hi, 

 

How to write a code for Email validation in apex class ....

 

this is my page

============

<apex:page controller="JstestController">
<apex:form id="myform">
<apex:pagemessages />
<apex:pageBlock id="myblock">
Email Address: <apex:inputText value="{!email}" id="email"/><br/><br/>
<apex:commandButton value="Click me!" action="{!checkEmail}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

 

class

.....................

 

public class JstestController
{
public String email { get; set; }
public PageReference checkEmail()
{

}

}

 

how to wrete email validation for input text  field ....

help me.......

 

  • October 29, 2012
  • Like
  • 0