• varsha durgi
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I am trying to create a Contact via a portal user on Force.com Sites, but it's giving me this error. Can anyone tell me why this error is occurring and how to fix the problem?

 

System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal users cannot own partner accounts: []

 


 

I also get an error when I try to save the Account of the portal user normally through Salesforce:

 

Cannot Assign Portal Account or Contact to Portal User
You cannot assign a Portal Account or Contact to a Portal user. Please choose a different user.

 

But I do not get any error creating the contact through Salesforce itself.

Here is the code I am using:

 

 

Contact p = new Contact();

p.FirstName = FirstName;
p.LastName = LastName;
p.Email = 'xxxxxxx@xxxxxxx.com';
p.AccountId = core.getUserAccount().Id; // This custom global method gets the account id (successfully)


try {
insert p;
}catch(DMLException e){
core.message.add(String.valueOf(e), 'error');
}

 

 

 

Thanks in advance
Message Edited by admintrmp on 11-11-2009 08:52 AM