• Kevin McAuliffe 14
  • NEWBIE
  • 5 Points
  • Member since 2014

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

We would like to eliminate the possibility of accidentally creating a scenario where a customer can view another customer's data in a Customer Portal.  We've discovered one way this could happen is by creating a sharing rule where records are shared with a Role + Internal and Portal Subordinates.   Validation rules and Apex Triggers can only trigger on sObjects, as I understand it, so I don't think either of those options would work

Are there any other options we could pursue to restrict the options on sharing rules?

Thank you.
AND(

/*Profile exceptions - API's and Ops*/
$Profile.Id <>"00e300000******", /* AppStore User */
$Profile.Id <>"00e300000*******", /* Webstore User */
$Profile.Id <>"00e300000*******",
$Profile.Id <>"00e300000********", /* System Administrator (Ops) */
/*Case Record Type - Customer Source Request*/
$RecordType.Id = '01230000********',
ISNEW(), 

/*Case Criteria - Technical Advice*/
ISPICKVAL(Reason,"Technical Advice"),
NOT(ISPICKVAL(Related_Product__c,"Commerce Cloud")),
NOT(ISPICKVAL(Account.Premier_AOV_Band__c,"$1M-5M")),
NOT(ISPICKVAL(Account.Premier_AOV_Band__c,"$25M+"))
)
  • April 05, 2019
  • Like
  • 0
I'm trying to build a lightning component based on the Trailhead Contacts Nearby project, except using Accounts instead.  I'm getting the following error screen when I try to drag it to a Lightning Page:

User-added image


Controller: 
public with sharing class AcctController {

    @AuraEnabled
    public static List<Account> findNearby(Double latitude, Double longitude, Double maxDistance) {
        return Database.query('SELECT Id, Name, BillingStreet, BillingCity, BillingState, Next_Contract_Expiration__c, Current_Contract_Volume__c, Phone FROM Account' +
                       ' WHERE DISTANCE(Location__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\') < '+ maxDistance +
                       ' ORDER BY DISTANCE(Location__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\')');
        
    }

}

Component:
<aura:component controller="AcctController" implements="flexipage:availableForAllPageTypes">

    <aura:attribute name="maxDistance" type="integer"/>
    <aura:attribute name="latitude" type="Decimal"/>
    <aura:attribute name="longitude" type="Decimal"/>
    <aura:attribute name="Account" type="Account[]"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <div>
        <h2>Accounts Nearby</h2>
        <ul>
            <aura:iteration items="{!v.Account}" var="Account">
                <li>
                    <h3><a href="{! '#/sObject/' + Account.Id + '/view'}">{!Account.Name}</a></h3>
                    <aura:if isTrue="{! Account.BillingCity}">
                        <p><a href="{! 'http://maps.apple.com?q=' + Account.BillingStreet + ', ' + Account.BillingCity}">
                            {!Account.BillingStreet}<br/>
                            {!Account.BillingCity}, {!Account.BillingState}<br/>
                            {!Account.Current_Contract_Volume__c} + '  ' + {!Account.Next_Contract_Expiration__c}</a></p>
                    </aura:if>
                    <p><a href="{! 'tel:' + Account.phone}">{!Account.Phone}</a></p>
                </li>
            </aura:iteration>
        </ul>
    </div>

</aura:component>

The code is basically the same as the ContactsNearby, which appropriate changes made to desired fields and object, and it does not give off any code errors when saving, so syntax must be somewhat acceptable.  Any thoughts?
Getting following error while running application. Command: heroku open

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exceptionorg.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 1 in the generated java file The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238) org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262) org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
 
I have configured Email-to-Case functionality to my sandbox and for routing address customers will send emails with their queries, while sending emails they may include some screenshots .

Sample Email Content: 


Hi this is google image and below image screen shot

 User-added image

What Salesforce functionality happen here is by defualt email text will be populated to description field and screen shot will get stored into attachments. and under case object we do have Emails related list where we can see original email content which customer has sent.

But the problem is my customer wants to see original content which customers has sent with in the description field .

So I have created one custom description field and datatype is Rich text area. 

Customization i have done : 

Created workflow rule on EmailMessage Object and tried to populate EmailMessage object HtmlBody field into Case object description (Custome field ) .
text is populated but images are not able to see and some empty textboxes i can see like below.
User-added image


So above solution is not working and again i have done some tirgger on EmailMessage object to update htmlbody into desc field

like below : 

first i put event after insert only but still its doesnt work for me so again i put all the events but no luck.

trigger UpdateDescTrigger on EmailMessage (after insert,after update,before insert ,before update) {
    //set<id> CaseIds = new set<Id>();
    map<Id,EmailMessage> MapEmailMessage = new map<Id,EmailMessage>();
    for(EmailMessage e:trigger.new){
        MapEmailMessage.put(e.ParentId,e);
    }
   
    list<Case> lstC = [select Id,Description__c from Case where id in:MapEmailMessage.keyset()];
    for(Case c:lstC){
        if(MapEmailMessage != null && MapEmailMessage.get(c.Id) != null )
            c.Description__c = MapEmailMessage.get(c.Id).HtmlBody;
    }
    update lstC;
   
}


My question is : i want to automatically update HTMLBody of EmailMessage into Case Description__c (Custom field)

But if i edit case record manually  and saved its working for me when i have done below trigger.


trigger updateCasse on Case (before update) {
    set<Id> parentIds = new set<Id>();
    map<Id,EmailMessage> mapEmailMessage = new map<Id,EmailMessage>();
    for(Case c:trigger.new){   
        parentIds.add(c.Id);
    }   
    list<EmailMessage> lste = [select id,HtmlBody,parentId from EmailMessage where parentid in:parentIds and Incoming = true];
   
    if(lste.size() > 0 ){
     for(EmailMessage e:lste){
         mapEmailMessage.put(e.parentId,e);
     }
     list<Case> lstC = new list<Case>();
     for(Case c:trigger.new){ 
      if(mapEmailMessage != null && mapEmailMessage.get(c.Id) != null)   
          c.description__c = mapEmailMessage.get(c.Id).HtmlBody;       
     }
    }
}

Plz help me.