• firdoss mohd 1
  • NEWBIE
  • 4 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
I am new to development and I am working on Leave Management App where I need to add 4 leaves for field 'Total Leaves' on Contact Object at the end of every month for all Employees.

I am assuming I should go with Trigger. Can anyone help me with this trigger.
 I am creating a Lightning Action that will execute an apex class from another developer (AuditPledgesAndPayments.AuditRecords(Campaign.Id,true);). I can create the Action that uses a component, but I can't find an example of a component just executing the class. Any help would be appreciated.
Hello everyone! 

VALUE(TEXT( FLOOR(heure_fin__c - heure_debut__c) ) & TEXT( ROUND(MOD((heure_fin__c - heure_debut__c)*24,24),0)) & TEXT( ROUND( MOD((heure_fin__c - heure_debut__c)*1440,60) ,0)))

I create this formula field to calculate the number of days, hours and minutes But I want to separate them by a symbol like ","

What must be the solution here? 
I am making updates to a specific formula field that is currently indexed. After I made the changes the field is no longer indexed (which is normal) and I contacted Salesforce Support to index the field again. They said the formula field no longer met the requirements to be indexed and after looking at the reference material I'm not sure what change I made caused this. Is there an easy way to check my formula and make sure it can indexed by Salesforce Support?
In Salesforce for Outlook, I only get a radio button option so I can only select one opportuntiy to associate an email to. How can I write some APEX code or something that might allow me to associate one email with multiple opportunities? Are there other discussions on this? 
Hello All,

I have a scenario that i need to identify in trigger,whether Account record got updated from Standard layout or from any DML statement. Here i am using standard layout. Account will update using DML from many places aswell.

Can anyone provide some suggestions on this.
Hi All,

we have enabled [Restrict picklist to the values defined in the value set ]in Lead. How to allow OLD pick list values when converting Lead to Opportunity for this we are using Custom meta data for new Picklist values is allowing but Old pick list values is not allowing.

Thanks
KMK

 
  • May 15, 2020
  • Like
  • 0
can anyone please tell me how to fix the issue.
my Apex method is
public class ServiceRequestEmailHandler {
  public static void sendSingleEmail(List<Id> RecordId){
                List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(integer i=0; i<RecordId.size(); i++) {
                for(Service_Request__c sR : [Select id, Name, Status__c, Customer_Email__c, Oil_Checks_Touchup_Cost__c, Total_External_Repair_Cost__c, Total_Internal_Repair_Cost__c, Total_Effort_Required__c, Total_Repair_Cost__c FROM Service_Request__c  WHERE Id = :RecordId[i] ]){
                if(sR.Status__c == 'Closed' && sR.Customer_Email__c !=null){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sR.Customer_Email__c);
                mail.setToAddresses(sendTo); 
                mail.setReplyTo('think4u007@gmail.com');
                mail.setSenderDisplayName('ASD Servicing Company');
                List<String> ccTo = new List<String>();
                ccTo.add('mayanktripathi201194@gmail.com');
                mail.setCcAddresses(ccTo);
                mail.setSubject('Billing Deatils for the Servicing with ASD Company ');
                String body = '<html><body>Dear ' + sR.Name + ' It was a pleause to assist you with your Vehicle servicing.<br><br>Below are the details of Your biliing : <br> Oil Check & Touchup Cost: ' + sR.Oil_Checks_Touchup_Cost__c + ' <br> Total External Repair Cost: ' + sR.Total_External_Repair_Cost__c + ' <br> Total Interior Repair Cost: ' + sR.Total_Internal_Repair_Cost__c + ' <br> Effort Required by the Serviceman: ' + sR.Total_Effort_Required__c + ' <br> Overall Vehicle Servicing Cost: ' + sR.Total_Repair_Cost__c + ' <br> Thanks for Visiting us. <br><br>Have a Nice Day!</body></html>';
                mail.setHtmlBody(body);
                mails.add(mail);
   }          
  } 
               
 } 
       Messaging.sendEmail(mails);
} 
}

And my trigger is
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
    List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.RecordTypeId);
}
    ServiceRequestEmailHandler.sendSingleEmail(sRequest); 
}

​​​​​​​
I have created a Case object like below
Case testCase = new Case(
            Subject = 'Test record',
            Status = 'New',
            Origin = 'Phone',
            Priority = 'Medium');

I am getting below output when I serialize it using JSON.serialize(testCase). 

{"attributes":{"type":"Case"},"Subject":"Test record","Status":"New","Origin":"Phone","Priority":"Medium"}

Any idea why did "attributes" property add to the JSON and how to avoid it or is there any predefined method to stop coming in JSON? 
I got 2 objects Service_Request__c(Parent) and Service_Line__c(Child). All I'm trying to do is update a field of parent object from child.based on the following condition.
In the following code, I'm not getting how to update the parent.
please suggest how to proceed.
public class StatusClosedHandler {
    public static void statuschange (String RecordId){
        integer count = 0;
        List<Service_Line__c> sLine = new List<Service_Line__c>();
     for(Service_Line__c sl : [Select id, Name, Status__c,Line_Type__c, Service_Request__r.Status__c,Service_Request__r.Name from Service_Line__c WHERE Service_Request__c = :RecordId ]){
         if(sl.Status__c == 'Completed'){
             count++; 
    }
             if(count == 3){  
             sl.Service_Request__r.Status__c = 'Closed';   
    }
             sLine.add(sl);
    }
             update sLine;
    }
  }

 
In my lighting page on the picklist filed is there. I want to set read-only that filed using a lighting component.
Hello Experts

I am new to the Visualforce, 
i am working on a requirement where live Location has to be tracked on the VF page Google maps Including Markers with help of Geolocation latitude and langitude which must be fetched from custom object (Contact_Check_In__c)

My Custom Object name is Contact_Check_In__c
 and i have fields called geolocation(GeoLocation__c)
With Lot of effort and searching i came accross vf page and apex controller, all is ok but it is not capturing the Live Geolocation

all i want is vf page has to take the dynamic geolocation from the record and show it on the google maps on vf page

i refered this blogs still not able to resolve my issue
https://developer.salesforce.com/forums?id=906F0000000AKp5IAG
https://success.salesforce.com/answers?id=90630000000guBkAAI

Any help would be highly appreciated

Below are my VF page
<apex:page StandardController="Contact_Check_In__c" extensions="MyCheckInController" lightningStylesheets="true" docType="HTML-5.0">

<html>
  <head>
   <title>Check In Detail</title>
   <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 90%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 90%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>

  <body onload = "loadMap()">
    <h2>Check In on the Map</h2>
    <div id = "map" ></div>
      <script>

        
        function loadMap() {
          // Initialize Google Maps
          const mapOptions = {
            center:new google.maps.LatLng(13.0161331,76.0898104),
            zoom: 13
          }
          const map = new google.maps.Map(document.getElementById("map"), mapOptions);
          
          var text = '{!JsonCheckInData}';
          var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
            var icons = {
              parking: {
                icon: iconBase + 'parking_lot_maps.png'
              },
              library: {
                icon: iconBase + 'library_maps.png'
              },
              info: {
                icon: iconBase + 'info-i_maps.png'
              }
            };
            
          var obj = JSON.parse(text);
          //alert(obj);
          //return obj;
          var x;
          var jsonData='';
          var loc1='';
          var loc2;
          var address='';
          for (x in obj) {
           
            temp=obj[x].location.split(",");
            loc1=temp[0].replace("[", "");
            loc2=temp[1].replace("]", "");
            
                                   
            let marker = new google.maps.Marker({
              map: map,
              icon:icons['library'].icon,
              position: new google.maps.LatLng(loc1, loc2),
              title: 'Person Name:' +  obj[x].name + ' CheckIn:' +obj[x].checkIn 
            })
            
            
          } 
        
        }
      </script>
      <!--<script src = "https://maps.googleapis.com/maps/api/js"></script>-->
     <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBqqej11sosokXGaQTk_-Zw9AIXMVkXoAE&callback=loadMap">
    </script>
    {!JsonCheckInData}
  </body>
</html>
</apex:page>

My Controller
 
public class MyCheckInController {

    public MyCheckInController(ApexPages.StandardController controller) {

    }


    public list<Contact_Check_In__c> LstContactCheckIn{get;set;}
    
    public string JsonCheckInData{get;set;}

    public MyCheckInController(){
        
        LstContactCheckIn=[Select Id, CheckIn_Date_Time__c, GeoLocation__latitude__s, GeoLocation__longitude__s, Contact__r.Name from Contact_Check_In__c];
        
        list<WrpData> lstWrpData=new list<WrpData>();
        
        for(Contact_Check_In__c Check:LstContactCheckIn){
               string strLocation='[' + string.valueOf(check.GeoLocation__latitude__s) + ','  + string.valueOf(check.GeoLocation__longitude__s)+ ']';
               WrpData wrp=new WrpData(check.Contact__r.Name, strLocation, string.ValueOf(check.CheckIn_Date_Time__c),string.valueOf(check.GeoLocation__latitude__s),string.valueOf(check.GeoLocation__longitude__s));
               lstWrpData.add(wrp);
        }
        
        JsonCheckInData=Json.Serialize(lstWrpData);
        
    }
    
    public class WrpData{
        
        public string name{get;set;}
        public string location{get;set;}
        public string checkIn{get;set;}
        public string lat{get;set;}
        public string lng{get;set;}
        public WrpData(string nm,string loc,string chkIn, string lt,string ln){
            name=nm;
            location=loc;
            checkIn=chkIn;
            lat=lt;
            lng=ln;
        }
    }
   
}

​​​​​​​

 
Hello there,
I am getting following error while sending the data from third party
"error":{"code":"CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY","message":"accountTrigge: execution of BeforeInsert\n\ncaused by: System.NullPointerException: Attempt to de-reference a null object\n\nClass.TriggerAccount.calculateTime: line 23, column 1\nClass.TriggerAccount.handle: line 12, column 1\nClass.Triggers.manage: line 51, column 1\nTrigger.accountTrigger: line 53, column 1"

Please guide me
 
I have an existing visualforce page, with a custom controller.
In the apex-code I'm using 
ApexPages.currentPage().getParameters().get('id')];

Now I'm calling this same VF page from the Utility-bar. Unfortunateley it doesn't have the context of the record-id.

How can I resolve the easiest way, so I can maintain most of the logic of the VF page?
Hi, I need help - I need to automate account import from CSV file to Salesforce standard Account object. This is weekly scheduled activity and the CSV file will be in FTP folder. there is no visualforce page involved.Can anyone provide any reference to achieve this task.

Thanks