+ Start a Discussion
sravusravu 

Customer Portal User not able to create EmailMessage sObject

Hi,

When a portal user is adding a comment to a case it is not triggering an email to the case owner. So what i tried to do is to create an emailmessage record so that it can be tracked in the Emails related list of a case. But when i am trying to insert the Email Message as a portal user it is giving me the following error:

 

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

 

 

The following is the code that I am using.

 

 

 Case incident = [Select Id,Contact.Email,ContactId,OwnerId,Owner.Email,Owner.Name,CaseNumber from Case where Id='500Q0000003JYzUIAW'];
               CaseComment comment = new CaseComment();
               String reason = '<b>Number of people affected by this issue:</b>3<br/><b>Here is the business Justification:</b><br/>';
               comment.CommentBody = reason;
               comment.ParentId = '500Q0000003JYzUIAW';
               insert comment;
EmailMessage m = new EmailMessage();
               m.ParentId ='500Q0000003JYzUIAW';
               m.HtmlBody = 'Hi&nbsp;'+incident.Owner.Name+','+'<br/><u>Request to Escalate incident</u><br/><br/>'+comment.CommentBody;   
               m.Subject = 'A new comment has been added to the incident# '+incident.CaseNumber;
               m.ToAddress=incident.Owner.Email;
               m.FromAddress=incident.Contact.Email;
               m.Status='0';
               insert m;
System.debug(m);

 

 

Can portal users create emailMessages or not?

 

I tried to send an email to the owner but that is not linked to the case.

 

Any ideas how to achieve this.

 

Thanks in advance.

arizonaarizona

This is a permissions issue.

 

The contact record and the case record is not accessible to the portal user: 

 

m.ToAddress=incident.Owner.Email;
m.FromAddress=incident.Contact.Email;

 

sravusravu

Hi,

I am able to create cases through portal. From the case object I am getting the contact information. I am unable to figure what else could be the error.

 

Thanks.

Matan AlonMatan Alon
Hi,
Did you even solved this issue?
We're having the same problem.
Thanks!!