• Pavani Akella 9
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 9
    Replies
An installed package(Declarative Lookup Rollup summary) has an automated trigger. This trigger is resulting in throwing "dlrs_CaseTrigger: System.LimitException: dlrs:Too many SOQL queries: 101" error when Salesforce is receiving batch insert of cases. How do I move the trigger to not throw SOQL query exception.

trigger dlrs_CaseTrigger on Case
    (before delete, before insert, before update, after delete, after insert, after undelete, after update)
{
    dlrs.RollupService.triggerHandler();
}

Thanks in advance
I would like to write an apex trigger to to do a field update to kickoff your workflow/process builder when a case is escalated. The process builder does not send an email when a case is escalated. I'm new to development. Can someone please share the snippet of code if you are have written one for your org please.

Thanks in advance
I would like to add a clause in the query where status not equal to "Approved or Closed or Denied". How do I add that logic in this query
List<Case> cas=Database.query('SELECT Id,CaseNumber FROM Case WHERE AccountId =\''+sc+'\' AND VIN_Entry__c =\''+ event.VIN__c+'\'');

Thanks in advance!
 
HI,

I wrote a query to calculate the distance for geolocation and show in the map if the distance is less than 0.25 miles. But for some reason the query is calculating more than 1/4th mile distance. Can you please look into the query and let me know the mistake I made.

 for (Vehicle_Daily_Checkin__e event : Trigger.New) {                  
              
       List<Account> acc=Database.query(
            'SELECT Id, Name, Location__c, BillingLatitude, BillingLongitude FROM Account '+
            'WHERE (public_service_center__c != \'N/A\' OR public_service_center__c != \'No\')'+
            'AND DISTANCE(BillingAddress, GEOLOCATION(' +event.Latitude__c + ', ' +event.Longitude__c + '), \'mi\') < 0.25') ;

Thanks in advance
Can someone please please help me writing test classes. It's urgent.

public without sharing abstract class XmlPayloadController {
    public static final String XML_HEADER { get; } 
    
    public Case theCase { get; private set; }
    
    static { 
        XML_HEADER = '<?xml version="1.0" ?>';
    }
    
    public virtual String getBusinessUnit() {
        for (Replacement_Part__c rp : theCase.Replacement_Parts__r) {
            if (String.isNotBlank(rp.Replacement_Item__r.Business_Unit__c)) {
                return rp.Replacement_Item__r.Business_Unit__c;
            }
        }
        return null;
    }
    
    public virtual String getDeptId() {
        String deptId = '';
        String businessUnit = getBusinessUnit();
        if (businessUnit == 'M140') {
            deptId = '170';
        }
        else if (businessUnit == 'M170') {
            deptId = '172';
        }
        return deptId;
    }
    
    protected void loadCase(Id caseId) {
        // TODO: add new custom fields when they become available
        theCase = [SELECT Id, CaseNumber,
                          Account.PeopleSoft_Customer_ID__c,
                          Account.PeopleSoft_Vendor_ID__c,
                          Ship_To_Address__r.Sequence_Number__c,
                   Business_Unit__c
                    FROM Case WHERE Id = :caseId];
    }
}
Hello,;

Can someone please help me change the miles from 1 mile to 1/4th mile please. Below is the apex code

DISTANCE(BillingAddress, GEOLOCATION(' +event.Latitude__c + ', ' +event.Longitude__c + '), \'mi\') < 1') ;

Thanks in advance
Integer i=1,counter=2;
do{
System.debug(i);
i++;
counter++;
}while(i==20&&counter==21);

What would be the output of the code?
Thanks in advance!
 
We are using "Salesforce tabs and Visualforce" template and would like to move to "Napili" template. Can someone please givem recommendations of how to write a java script code to move from old URL to new URL?

Thanks in advance!
Hi,

I'm a newbee to Development and I'm learning how to write apex coding.

Can someone please help me to modify the apex trigger and help me write a test class to this event trigger

trigger Checkin on Vehicle_Daily_Checkin__e (after insert) {
    List<VIN__c> records = new List<VIN__c>();
    for (Vehicle_Daily_Checkin__e event : Trigger.New) {
        List<VIN__c> existingRecords = Database.query(
            'SELECT VIN_External_ID__c, Odometer__c, Longitude__c, Latitude__c, Last_Signal_Datetime__c ' +
            'FROM VIN__c WHERE VIN_External_ID__c=\'' + event.VIN__c + '\'');
        
        if(existingRecords.size() != 0) {
            existingRecords[0].Odometer__c=event.Odometer__c;
            existingRecords[0].Longitude__c=event.Longitude__c;
            existingRecords[0].Latitude__c=event.Latitude__c;
            existingRecords[0].Last_Signal_Datetime__c=event.Last_Signal_Datetime__c;
            update existingRecords[0];
            records.add(existingRecords[0]);
        }
        else {
            VIN__c record=new VIN__c();
            record.VIN_External_ID__c=event.VIN__c;
            record.Odometer__c=event.Odometer__c;
            record.Longitude__c=event.Longitude__c;
            record.Latitude__c=event.Latitude__c;
            record.Last_Signal_Datetime__c=event.Last_Signal_Datetime__c;
            records.add(record);
        }
        String sc;
        List<Account> acc=Database.query(
            'SELECT Id, Name, Location__c FROM Account '+
            'WHERE (public_service_center__c != \'N/A\' OR public_service_center__c != \'No\')'+
            ' AND DISTANCE(Location__c, GEOLOCATION(' +event.Latitude__c+ ', ' +event.Longitude__c + '), \'mi\') < 2') ; 
        String cId;
        for(Account a:acc){
           
            sc=a.Id;
            List<Case> cas=Database.query('SELECT Id,CaseNumber FROM Case WHERE AccountId =\''+ sc +'\' AND VIN_Entry__c =\''+ event.VIN__c+'\'');
            for (Case c : cas) {
                cId = c.Id;
                break;
            }            
        }
        
        Enhanced_Daily_Checkin__e enchancheck=new Enhanced_Daily_Checkin__e(CaseID__c = cId,Last_Signal_Datetime__c=event.Last_Signal_Datetime__c,Latitude__c=event.Latitude__c,Longitude__c=event.Longitude__c,Odometer__c=event.Odometer__c,VIN__c=event.VIN__c,ServiceCenterID__c=sc); 
            EventBus.publish(enchancheck);
        System.debug('Published enhanced event'+enchancheck);
    }    
 
    upsert records;
}

Thanks in advance!
Pavani
 
Can someone please help me to write and understand a test class for Apex trigger on platform event:

trigger Checkin on Vehicle_Daily_Checkin__e (after insert) {
    public List<VIN__c> records = new List<VIN__c>();
    for (Vehicle_Daily_Checkin__e event : Trigger.New) {
        System.debug('Starting trigger');
         List<VIN__c> existingRecords = Database.query(
            'SELECT VIN_External_ID__c, Odometer__c, Longitude__c, Latitude__c, Last_Signal_Datetime__c ' +
            'FROM VIN__c WHERE VIN_External_ID__c=\'' + event.VIN__c + '\'');
        
        if(existingRecords.size() != 0) {
            existingRecords[0].Odometer__c=event.Odometer__c;
            existingRecords[0].Longitude__c=event.Longitude__c;
            existingRecords[0].Latitude__c=event.Latitude__c;
            existingRecords[0].Last_Signal_Datetime__c=event.Last_Signal_Datetime__c;
            update existingRecords[0];
            records.add(existingRecords[0]);
        }
        else {
            VIN__c record=new VIN__c();
            record.VIN_External_ID__c=event.VIN__c;
            record.Odometer__c=event.Odometer__c;
            record.Longitude__c=event.Longitude__c;
            record.Latitude__c=event.Latitude__c;
            record.Last_Signal_Datetime__c=event.Last_Signal_Datetime__c;
            records.add(record);
        }
        System.debug('Above service center query');
        String sc;
         List<Account> acc=Database.query(
            'SELECT Id, Name, Location__c FROM Account '+
            'WHERE (public_service_center__c != \'N/A\' OR public_service_center__c != \'No\')'+
            ' AND DISTANCE(Location__c, GEOLOCATION(' +event.Latitude__c+ ', ' +event.Longitude__c + '), \'mi\') < 2') ; 
        System.debug('Account list query');
        String cId;
        for(Account a:acc){
            // Retrieve any open Case records for a vehicle within 1000 feet of a service center
            sc=a.Id;
        System.debug('Above case query');    
            List<Case> cas=Database.query('SELECT Id,CaseNumber FROM Case WHERE AccountId =\''+ sc +'\' AND VIN_Entry__c =\''+ event.VIN__c+'\'');
            for (Case c : cas) {
                cId = c.Id;
                break;
            }            
        }
        
        Enhanced_Daily_Checkin__e enchancheck=new Enhanced_Daily_Checkin__e(CaseID__c = cId,Last_Signal_Datetime__c=event.Last_Signal_Datetime__c,Latitude__c=event.Latitude__c,Longitude__c=event.Longitude__c,Odometer__c=event.Odometer__c,VIN__c=event.VIN__c,ServiceCenterID__c=sc); 
            EventBus.publish(enchancheck);
        System.debug('Published enhanced event'+enchancheck);
    }    
    // Insert all cases corresponding to events received.
    upsert records;
}

Thanks in advance!
I'm having a difficult time to get my code coverage increased (I'm still a newb on the dev end).
My class is working but I don't have test class. My code coverage is 65%

Apex class:

public static void sendPartOrderAndReturnEmail(List<Case> caseList, Map<id,Case> oldMap){
        if (DoNotReplyId == null) {
            DoNotReplyId = [SELECT id FROM OrgWideEmailAddress where Address = 'cleantech.warranty@roush.com' limit 1].id;
        }
        if (emailSent == true)
            return;

        string orderPartLineItems;
        string orderPartLineItemsTxt;
        string htmlBody;
        string textBody;
        string emailFromAddress;
        string emailSubject;

        set<string> emailToSet = new set<string>();
        set<string> orderEmailAddSet = new set<string>();
        set<String> rctOrderEmailAddSet = new set<string>(); 
        set<String> rppOrderEmailAddSet = new set<string>(); 

        list<Parts_Order_Email__c> orderEmailAddresses = new list<Parts_Order_Email__c>([SELECT Order_Person_Email__c, RCT_Dominos__c,  RPP__c FROM Parts_Order_Email__c]);

       
        for (Parts_Order_Email__c p: orderEmailAddresses){
            if (p.RCT_Dominos__c == True){
                rctOrderEmailAddSet.add(p.Order_Person_Email__c);
            }
            if (p.RPP__c == True){
                rppOrderEmailAddSet.add(p.Order_Person_Email__c);
            }
        }

        list<Replacement_Part__c> updReplaceParts = new list<Replacement_Part__c>();

        map<Id,list<Replacement_Part__c>> replacePartMap = new map<id,list<Replacement_Part__c>>();

        set<id> caseIds = new set<id>();

        for (Case c: caseList){
            if (c.status == 'Resolution Provided'){
                caseIds.add(c.id);
            }
        }
        
        list<Replacement_Part__c> partsList = new list<Replacement_Part__c>([SELECT id, Case__c, Replacement_Item__r.Name, Replacement_Item__r.Description__c, Return_Part__c, Order_Email_Sent__c, Return_Email_Sent__c, Replacement_Part_Checkbox__c
               FROM Replacement_Part__c WHERE Case__c in :caseIds ORDER BY Case__c]);

        for (Replacement_Part__c p: partsList){
            
            if (p.Replacement_Part_Checkbox__c == true && p.Order_Email_Sent__c == false){
                if (replacePartMap.containsKey(p.Case__c)){
                    replacePartMap.get(p.Case__c).add(p);
                }
                else{
                    replacePartMap.put(p.Case__c, new list<Replacement_Part__c>{p});
                }
            }
        }

        for (Case c: caseList){
            
            if(replacePartMap.containsKey(c.id)){
                orderPartLineItems='';
                orderPartLineItemsTxt='';
                for (Replacement_Part__c r: replacePartMap.get(c.id)){
                    orderPartLineItemsTxt = orderPartLineItemsTxt + r.Replacement_Item__r.Name + '  ---  ' + r.Replacement_Item__r.Description__c + '\n\n';
                    orderPartLineItems = orderPartLineItems +
                        '<tr>'+
                            '<td style="vertical-align: top;">' + r.Replacement_Item__r.Name  + '<br></td>' +
                            '<td style="vertical-align: top;">' + r.Replacement_Item__r.Description__c + '<br></td>'+
                        '</tr>';
                        r.Order_Email_Sent__c = true;
                        updReplaceParts.add(r);
                }
                htmlBody = orderPartsEmail(c.id, c.CaseNumber, c.Subject, c.Claim_Type_new__c, orderPartLineItems);
                textBody = orderPartsTextEmail(c.CaseNumber, c.Subject, c.Claim_Type_new__c, orderPartLineItemsTxt);
                emailFromAddress = 'Roush CleanTech Customer Support';
                emailSubject = 'Order Parts';
                
                if (c.VIN_Vehicle_Program__c == 'RPP'){
                    orderEmailAddSet.addAll(rppOrderEmailAddSet);
                }
                else{
                    orderEmailAddSet.addAll(rctOrderEmailAddSet);
                }
                orderEmailAddSet.remove(null);
                if (orderEmailAddSet.size()>0)
                    sendHTMLEmail(orderEmailAddSet, emailSubject, htmlBody, textBody, emailFromAddress);
            }
        }

    update updReplaceParts;
    emailSent=True;
    }
    
    private static String orderPartsEmail(string caseId, string caseNumber, string caseSubject, string claimType, string orderPartList){

        String domain = ([select count() from Organization where isSandbox = true] == 1)? 'https://test.salesforce.com' : 'https://login.salesforce.com';
        String caseUrl = domain + '/'+ caseId;

        return  'Please order replacement parts for the following case.<br></br>'+
                'Case Number: ' + caseNumber + '<br>'+
                'Case Subject: ' + caseSubject + '<br>'+
                'Claim Type: ' + claimType + '<br></br>'+
                '<table style="text-align: left; width: 75%;" border="1" cellpadding="2" cellspacing="2">' +
                    '<tbody>'+
                        '<tr align="center">'+
                            '<td colspan="2" rowspan="1" style="vertical-align: top; background-color: rgb(204, 204, 204);"><span style="font-weight: bold;">Parts to Order</span><br>'+
                            '</td>'+
                        '</tr>'+
                        '<tr>'+
                            '<td style="vertical-align: top; background-color: rgb(204, 204, 204); font-weight: bold;">Part Name<br></td>'+
                            '<td style="vertical-align: top; background-color: rgb(204, 204, 204); font-weight: bold;">Part Description<br></td>'+
                        '</tr>'+
                        orderPartList+
                    '</tbody>'+
                '</table><br>'+
                'The link to the case is below.<br></br>'+
                caseUrl;
    }
    private static String orderPartsTextEmail(string caseNumber, string caseSubject, string claimType, string orderPartList){
        return  'Please order replacement parts for the following case.\n\n' +
                'Case Number: ' + caseNumber + '\n\n' +
                'Case Subject: ' + caseSubject + '\n\n' +
                'Claim Type: ' + claimType + '\n\n' +
                orderPartList+ '\n\n';
    }
Hi,

I have written a HTML code for web-to-case form with 'RECAPTCHA' code but it is working when I'm trying to deploy it in website. Below is the code:

<apex:page>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
 function timestamp() { var response = document.getElementById("g-recaptcha-response"); if (response == null || response.value.trim() == "") {var elems = JSON.parse(document.getElementsByName("captcha_settings")[0].value);elems["ts"] = JSON.stringify(new Date().getTime());document.getElementsByName("captcha_settings")[0].value = JSON.stringify(elems); } } setInterval(timestamp, 500); 
</script>
<script type="text/javascript">
function recaptcha_callback(){
$('.button').prop("disabled", false);
}
</script>


<form action="https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" method="POST">

<input type="hidden" name='captcha_settings' value='{"keyname":"captchacode","fallback":"true","orgId":"00D80000000PSJg","ts":""}'>
<input type="hidden" name="orgid" value="00D80000000PSJg">
<input type=hidden name="recordType" id="recordType" value="01234000000URAx">
<input type="hidden" name="retURL" value="http://www.roushcleantech.com/training_request_form_landing_page/">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="pavani.akella@roush.com">                                        -->
<!--  ----------------------------------------------------------------------  -->

Your Name:<input  id="00N34000005gy3N" maxlength="30" name="00N34000005gy3N" size="20" type="text" required=true /><br>

Your Email:<input  id="00N34000005gy3S" maxlength="80" name="00N34000005gy3S" size="20" type="text" required=true /><br>

Your Phone:<input  id="00N34000005gy3X" maxlength="40" name="00N34000005gy3X" onkeydown="formatPhoneOnEnter(this, event);" size="20" type="text"required=true  /><br>

Service Center Requesting Training:<textarea  id="00N34000005gy3c" name="00N34000005gy3c" type="text" wrap="soft" required=true ></textarea><br>

Requested Training Location Address:<textarea  id="00N34000005gy3h" name="00N34000005gy3h" type="text" wrap="soft" required=true ></textarea><br>

City:<input  id="00N34000005gy3m" maxlength="20" name="00N34000005gy3m" size="20" type="text" required=true /><br>

State:<input  id="00N34000005gy3r" maxlength="20" name="00N34000005gy3r" size="20" type="text" required=true /><br>

Location Contact(if different):<input  id="00N34000005gy3w" maxlength="30" name="00N34000005gy3w" size="20" type="text" /><br>

Location Phone #:<input  id="00N34000005gy41" maxlength="40" name="00N34000005gy41" onkeydown="formatPhoneOnEnter(this, event);" size="20" type="text" /><br>

Approx No. of attendees:<input  id="00N34000005gy46" maxlength="20" name="00N34000005gy46" size="20" type="text" required=true /><br>

Product Focus for training:<select  id="00N34000005gy4B" name="00N34000005gy4B" title="Product Focus for training"><option value="" required=true >--None--</option><option value="Blue Bird Propane">Blue Bird Propane</option>
<option value="Blue Bird CNG">Blue Bird CNG</option>
<option value="Ford E-450">Ford E-450</option>
<option value="Ford F450/F-550">Ford F450/F-550</option>
<option value="Ford F-650/F-750">Ford F-650/F-750</option>
<option value="Ford F-53/F-59">Ford F-53/F-59</option>
</select><br>

Time Frame:<input  id="00N34000005gy4G" maxlength="30" name="00N34000005gy4G" size="20" type="text" required=true  /><br>

Comments:<textarea  id="00N34000005gy4L" name="00N34000005gy4L" type="text" wrap="soft"></textarea><br>

<input type="hidden"  id="external" name="external" value="1"/><br>

<div class="g-recaptcha" data-sitekey="6LfLGjUUAAAAAAPyqw7rghuHXYD3DggnQ2Mwz7z_" data-callback="recaptcha_callback"></div>

<input type="submit" name="submit"id="submitBtn" disabled="true" class="button">


</form>
</apex:page>
Thanks in advance for the help
I would like to remove "comment" button from feed for community portal users
I would like to auto-populate contact name when an email address is given in the case.

Can someone please hep me with this?

Thanks in advance
I have written a VF page but I'm not able to call the child objects fields in Case object. Can someone help me with the code:

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Case"
    subject="Test: "
    replyTo="support@acme.com" >
    
<messaging:htmlEmailBody >
<html>
    <body>
    <STYLE type="text/css">
        TH {font-size: 12px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
        TD  {font-size: 14px; font-face: arial} 
        TABLE {border: solid #CCCCCC; border-width: 1}
        TR {border: solid #CCCCCC; border-width: 1}
     </STYLE>
     <font face="arial" size="3">
Dear {!recipient.name},
 
<p>Please order replacements parts for the following case</p>

CaseNumber :{!relatedTo.CaseNumber} <br/>
Subject : {!relatedTo.Subject} <br/>
Claim_Type_new : {!relatedTo.Claim_Type_new__c} <br/><br/><br/>

<table border="1">
  
<font face="arial" size="4">
  <tr > 
        <th>Part Name</th><th>Description</th>
    </tr>  
    <apex:repeat var="cx" value="{!relatedTo.Replacement_Parts__r}">
        <tr>
           <td>{!cx.Replacement_Item__c}</td>
            <td>{!cx.Description__c}</td>
        </tr>
    </apex:repeat>   
    </font>           
</table>
<p />
<p>Your UPS tracking number is: {!relatedTo.Replacement_Parts__r.Tracking_ID__c}<br/></p>
<p>PS Order#: {!relatedTo.Replacement_Parts__r.MSR_PS_ID__c}<br/></p>    
<p>Repair Order Number: {!relatedTo.Repair_Order_Number__c}<br/></p>   
            </font>
               
        </body>
    </html>
</messaging:htmlEmailBody> 

</messaging:emailTemplate>

Thanks in advance
I have written a visualforce page but I'm stuck how to keep the table spacing(lines) and also how to add few other fields:

I would like to add the below fields:
Please order replacements parts for the following case.
Case Number: 
Case Subject: TEST CASE
Claim Type: Warranty

The link to the case is below. https://cs1.salesforce.com/500S0000008x9mL

And also I would like to see a line spacing between each row
Part NameDescription
a1XS0000001eJ05MAEDNO - B28 - BRACKET- SRM - REWORKED
a1XS0000001eJ0FMAUWASHER - 19/32in ID X 1-11/64in OD - 11/64in THICKNESS - AL
a1XS0000001eJ07MAECLAMP - 1/2in EPDM CUSH GALVANIZED MED DUTY - HOLE DIAMETER


<messaging:emailTemplate recipientType="Contact"
    relatedToType="Case"
    subject="Test: "
    replyTo="support@acme.com" >
    
<messaging:htmlEmailBody >
<html>
    <body>
    <STYLE type="text/css">
        TH {font-size: 12px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
        TD  {font-size: 12px; font-face: verdana } 
        TABLE {border: solid #CCCCCC; border-width: 1}
        TR {border: solid #CCCCCC; border-width: 1}
     </STYLE>
     <font face="arial" size="4">
Dear {!recipient.name},
 
<p>Please order replacements parts for the following case</p>

[ CaseNumber ] - [ Subject] - [ Claim_Type_new]
<table border="0" >
  <tr > 
        <th>Part Name</th><th>Description</th>
    </tr>  
    <apex:repeat var="cx" value="{!relatedTo.Replacement_Parts__r}">
        <tr>
           <td>{!cx.Replacement_Item__c}</td>
            <td>{!cx.Description__c}</td>
        </tr>
    </apex:repeat>                 
</table>
<p />
            </font>
        </body>
    </html>
</messaging:htmlEmailBody> 

</messaging:emailTemplate>

Can someone help me how to do? Thanks in advance
I have written an apex trigger and it is trowing me an error at line 13 col 17 stating "Error: Compile Error: unexpected token: '=' at line 13 column 17". Can someone help me resolve the error.

trigger Update_TrackingId_MSRLineItem_to_ReplacementPart on MSR_Line_Item__c (after update) 
{
 Map<Id, Replacement_Part__c> replacement  = new Map<Id, Replacement_Part__c>();
    List<Id> listIds = new List<Id>();
    
    for(MSR_Line_Item__c msr : Trigger.new)
    {
        if(msr.Tracking_ID__c != null && msr.MSR_PS_ID__c != null && msr.Replacement_Part__c != null)
        {
        listIds.add(msr.Replacement_Part__c);        
        }        
    }
    replacement = new Map<Id, Replacement_Part__c>([SELECT Id, Tracking_Id__c, MSR_PS_ID__c (SELECT Id, Tracking_Id__c, MSR_PS_ID__c FROM MSR_Line_Items__r) FROM Replacement_Part__c WHERE ID IN:listIds]);
    
    for(MSR_Line_Item__c newmsr : Trigger.new)
    {
        
        Replacement_Part__c rpart = new Replacement_Part__c();
        if(newmsr.Replacement_Part__c != null)
        {
            if(replacement.get(newmsr.Replacement_Part__c) != null)
            rpart = replacement.get(newmsr.Replacement_Part__c);
        }
        if(newmsr.Tracking_ID__c != null && newmsr.MSR_PS_ID__c != null)
        {
            rpart.Tracking_ID__c = newmsr.Tracking_ID__c;
            rpart.MSR_PS_ID__c = newmsr.MSR_PS_ID__c;
        }
        
    }
    update replacement.values();
}

Thanks in advance
I have written an apex trigger and it is trowing me an error at line 13 col 17 stating "Error: Compile Error: unexpected token: '=' at line 13 column 17". Can someone help me resolve the error.

trigger Update_TrackingId_MSRLineItem_to_ReplacementPart on MSR_Line_Item__c (after update) 
{
 Map<Id, Replacement_Part__c> replacement  = new Map<Id, Replacement_Part__c>();
    List<Id> listIds = new List<Id>();
    
    for(MSR_Line_Item__c msr : Trigger.new)
    {
        if(msr.Tracking_ID__c != null && msr.MSR_PS_ID__c != null && msr.Replacement_Part__c != null)
        {
        listIds.add(msr.Replacement_Part__c);        
        }        
    }
    replacement = new Map<Id, Replacement_Part__c>([SELECT Id, Tracking_Id__c, MSR_PS_ID__c (SELECT Id, Tracking_Id__c, MSR_PS_ID__c FROM MSR_Line_Items__r) FROM Replacement_Part__c WHERE ID IN:listIds]);
    
    for(MSR_Line_Item__c newmsr : Trigger.new)
    {
        
        Replacement_Part__c rpart = new Replacement_Part__c();
        if(newmsr.Replacement_Part__c != null)
        {
            if(replacement.get(newmsr.Replacement_Part__c) != null)
            rpart = replacement.get(newmsr.Replacement_Part__c);
        }
        if(newmsr.Tracking_ID__c != null && newmsr.MSR_PS_ID__c != null)
        {
            rpart.Tracking_ID__c = newmsr.Tracking_ID__c;
            rpart.MSR_PS_ID__c = newmsr.MSR_PS_ID__c;
        }
        
    }
    update replacement.values();
}

Thanks in advance
An installed package(Declarative Lookup Rollup summary) has an automated trigger. This trigger is resulting in throwing "dlrs_CaseTrigger: System.LimitException: dlrs:Too many SOQL queries: 101" error when Salesforce is receiving batch insert of cases. How do I move the trigger to not throw SOQL query exception.

trigger dlrs_CaseTrigger on Case
    (before delete, before insert, before update, after delete, after insert, after undelete, after update)
{
    dlrs.RollupService.triggerHandler();
}

Thanks in advance
I would like to write an apex trigger to to do a field update to kickoff your workflow/process builder when a case is escalated. The process builder does not send an email when a case is escalated. I'm new to development. Can someone please share the snippet of code if you are have written one for your org please.

Thanks in advance
I would like to add a clause in the query where status not equal to "Approved or Closed or Denied". How do I add that logic in this query
List<Case> cas=Database.query('SELECT Id,CaseNumber FROM Case WHERE AccountId =\''+sc+'\' AND VIN_Entry__c =\''+ event.VIN__c+'\'');

Thanks in advance!
 
Can someone please please help me writing test classes. It's urgent.

public without sharing abstract class XmlPayloadController {
    public static final String XML_HEADER { get; } 
    
    public Case theCase { get; private set; }
    
    static { 
        XML_HEADER = '<?xml version="1.0" ?>';
    }
    
    public virtual String getBusinessUnit() {
        for (Replacement_Part__c rp : theCase.Replacement_Parts__r) {
            if (String.isNotBlank(rp.Replacement_Item__r.Business_Unit__c)) {
                return rp.Replacement_Item__r.Business_Unit__c;
            }
        }
        return null;
    }
    
    public virtual String getDeptId() {
        String deptId = '';
        String businessUnit = getBusinessUnit();
        if (businessUnit == 'M140') {
            deptId = '170';
        }
        else if (businessUnit == 'M170') {
            deptId = '172';
        }
        return deptId;
    }
    
    protected void loadCase(Id caseId) {
        // TODO: add new custom fields when they become available
        theCase = [SELECT Id, CaseNumber,
                          Account.PeopleSoft_Customer_ID__c,
                          Account.PeopleSoft_Vendor_ID__c,
                          Ship_To_Address__r.Sequence_Number__c,
                   Business_Unit__c
                    FROM Case WHERE Id = :caseId];
    }
}
I would like to remove "comment" button from feed for community portal users
I have written an apex trigger and it is trowing me an error at line 13 col 17 stating "Error: Compile Error: unexpected token: '=' at line 13 column 17". Can someone help me resolve the error.

trigger Update_TrackingId_MSRLineItem_to_ReplacementPart on MSR_Line_Item__c (after update) 
{
 Map<Id, Replacement_Part__c> replacement  = new Map<Id, Replacement_Part__c>();
    List<Id> listIds = new List<Id>();
    
    for(MSR_Line_Item__c msr : Trigger.new)
    {
        if(msr.Tracking_ID__c != null && msr.MSR_PS_ID__c != null && msr.Replacement_Part__c != null)
        {
        listIds.add(msr.Replacement_Part__c);        
        }        
    }
    replacement = new Map<Id, Replacement_Part__c>([SELECT Id, Tracking_Id__c, MSR_PS_ID__c (SELECT Id, Tracking_Id__c, MSR_PS_ID__c FROM MSR_Line_Items__r) FROM Replacement_Part__c WHERE ID IN:listIds]);
    
    for(MSR_Line_Item__c newmsr : Trigger.new)
    {
        
        Replacement_Part__c rpart = new Replacement_Part__c();
        if(newmsr.Replacement_Part__c != null)
        {
            if(replacement.get(newmsr.Replacement_Part__c) != null)
            rpart = replacement.get(newmsr.Replacement_Part__c);
        }
        if(newmsr.Tracking_ID__c != null && newmsr.MSR_PS_ID__c != null)
        {
            rpart.Tracking_ID__c = newmsr.Tracking_ID__c;
            rpart.MSR_PS_ID__c = newmsr.MSR_PS_ID__c;
        }
        
    }
    update replacement.values();
}

Thanks in advance
Hello all,

I need to add a picklist field to the CommunitiesSelfReg VF page, but am getting the error below because I need to change it from inputext to inputfield, otherwise it won't show the drop-down menu.

"Could not resolve the entity from <apex:inputField> value binding '{!purchasedfrom}'.  <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."

VF Page:

 
<apex:page id="communitiesSelfRegPage" showHeader="true" controller="CommunitiesSelfRegController" title="{!$Label.site.user_registration}">
     <apex:define name="body">  
      <center>
<apex:form id="theForm" forceSSL="true">
                    <apex:pageMessages id="error"/>
                    
                    
                    <apex:panelGrid columns="2" style="margin-top:1em;">
                      <apex:outputLabel style="font-weight:bold;color:red;" value="First Name" for="firstName"/>
                      <apex:inputText required="true" id="firstName" value="{!firstName}" label="First Name"/>
                      <apex:outputLabel style="font-weight:bold;color:red;" value="Last Name" for="lastName"/>
                      <apex:inputText required="true" id="lastName" value="{!lastName}" label="Last Name"/>
                      <apex:outputLabel style="font-weight:bold;color:red;" value="{!$Label.site.email}" for="email"/>
                      <apex:inputText required="true" id="email" value="{!email}" label="{!$Label.site.email}"/>
                      
                      <apex:outputLabel style="font-weight:bold;color:red;" value="Phone" for="phone"/>
                      <apex:inputText required="true" id="phone" value="{!phone}" label="Phone"/>
                      <apex:outputLabel value="Title" for="title"/>
                      <apex:inputText required="true" id="title" value="{!title}" label="Title"/>                      
                      <apex:outputLabel style="font-weight:bold;color:red;" value="Company" for="companyname"/>
                      <apex:inputText required="true" id="companyname" value="{!companyname}" label="Company"/>                      

                      <apex:outputLabel style="font-weight:bold;color:red;" value="Street" for="street"/>
                      <apex:inputText required="true" id="street" value="{!street}" label="Street"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="City" for="city"/>
                      <apex:inputText required="true" id="city" value="{!city}" label="City"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="Zip" for="postalcode"/>
                      <apex:inputText required="true" id="postalcode" value="{!postalcode}" label="Zip"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="Country" for="country"/>
                      <apex:inputText required="true" id="country" value="{!country}" label="Country"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="State" for="state"/>
                      <apex:inputText required="true" id="state" value="{!state}" label="State"/>
                      
                      <apex:outputLabel value="Product Owner" for="productowner"/>
                      <apex:inputText required="true" id="productowner" value="{!productowner}" label="Product Owner"/>
<!--                       <apex:outputLabel value="Purchased From" for="purchasedfrom"/> -->
<!--                       <apex:inputText required="true" id="purchasedfrom" value="{!purchasedfrom}" label="Purchased From"/> -->
                      <apex:outputLabel value="Serial Number" for="serialnumber"/>
                      <apex:inputText required="true" id="serialnumber" value="{!serialnumber}" label="Serial Number"/>
                      
                      <apex:inputfield value="{!u.Purchased_From__c}"/>  
                      
					  <apex:outputLabel value="{!$Label.site.community_nickname}" for="communityNickname"/>
                      <apex:inputText required="true" id="communityNickname" value="{!communityNickname}" label="{!$Label.site.community_nickname}"/>                      
                      <apex:outputLabel value="{!$Label.site.password}" for="password"/>
                      <apex:inputSecret id="password" value="{!password}"/>
                      <apex:outputLabel value="{!$Label.site.confirm_password}" for="confirmPassword"/>
                      <apex:inputSecret id="confirmPassword" value="{!confirmPassword}"/>
                      <apex:outputText value=""/>
                      <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/>
                    </apex:panelGrid> 
                  <br/>
</apex:form>
     </center>
      <br/>
    </apex:define>

</apex:page>

Class:
 
/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
public with sharing class CommunitiesSelfRegController {

  public String firstName {get; set;}
  public String lastName {get; set;}
  public String email {get; set;}
  public String phone {get; set;}
  public String title {get; set;}
  public String companyname {get; set;}
  public String street {get; set;}
  public String city {get; set;}
  public String postalcode {get; set;}
  public String country {get; set;}
  public String state {get; set;}
  public String productowner {get; set;}
  public String purchasedfrom {get; set;}
  public String serialnumber {get; set;}
  public String password {get; set {password = value == null ? value : value.trim(); } }
  public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
  public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
  
  public CommunitiesSelfRegController() {}
  
  private boolean isValidPassword() {
    return password == confirmPassword;
  }

  public PageReference registerUser() {
  
    // it's okay if password is null - we'll send the user a random password in that case
    if (!isValidPassword()) {
      System.debug(System.LoggingLevel.DEBUG, '## DEBUG: Password is invalid - returning null');
      ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
      ApexPages.addMessage(msg);
      return null;
    }  

    
    String profileId = '00ej0000000jJMR'; // To be filled in by customer.
    
    String accountId = '001g000000QMTDX'; // To be filled in by customer.  

    // Set this to your main Communities Profile API Name
    String profileApiName = 'PowerCustomerSuccess';
    //String profileId = [SELECT Id FROM Profile WHERE UserType = :profileApiName LIMIT 1].Id;
    //List<Account> accounts = [SELECT Id FROM Account LIMIT 1];
    //System.assert(!accounts.isEmpty(), 'There must be at least one account in this environment!');
    //String accountId = accounts[0].Id;
    
    String userName = email;

    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.Phone = phone;
    u.Title = title;
    u.Street = street;
    u.City = city;
    u.PostalCode = postalcode;
    u.Country = country;
    u.State = state;
    u.Product_Owner__c = productowner;
    u.Purchased_From__c = purchasedfrom;
    u.Serial_Number__c = serialnumber;
    u.CompanyName = companyname;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.CommunityNickname = communityNickname;
    u.ProfileId = profileId;
    
    String userId = Site.createPortalUser(u, accountId, password);
   
    if (userId != null) { 
      if (password != null && password.length() > 1) {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful and password ok - returning site.login');
        return Site.login(userName, password, null);
      }
      else {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful but password not ok - redirecting to self reg confirmation');
        PageReference page = System.Page.CommunitiesSelfRegConfirm;
        page.setRedirect(true);
        return page;
      }
    }
    System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation not successful - returning null');
    return null;
  }
}


Thanks!!!

Ronaldo.