• Lokesh Rayapati4
  • NEWBIE
  • 55 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 3
    Replies
Hi,
 I want to style my PDF. By using VF page I am able to get certain contact details through putting ID in url and able to edit and update and changed fields will reflect in salesforce org. After updating it will save as PDF in Notes & Attachments to that particular record. Vf page preview is like below.....

User-added image



  So, Now the problem is that I'm trying to change the style of PDF (that is saved to particular records) from below to look like the records fields in box style .As shown below pdf have no styling.

User-added image

ShowContactDetail.vfp   ========

<apex:page controller="UpdateContactDetail">
 <style type="text/css">
  #title {
  font-size: 150%;
  margin-left: 30%;
  }
 </style>
  
  <h2 id="title">Contact</h2><br/><br/>
    <apex:form >
     <apex:pageBlock >
        <apex:pageBlockTable value="{!con}" var="b">
             <apex:column headervalue="Title">
                <apex:OutputText value="{!b.Title}" /> 
            </apex:column>   
            <apex:column headervalue="First Name">
                <apex:OutputText value="{!b.FirstName}" /> 
            </apex:column>            
            <apex:column headervalue="Last Name">
                <apex:OutputText value="{!b.LastName}" />
            </apex:column>
            <apex:column headervalue="Email">
                <apex:inputText value="{!b.Email}" />
            </apex:column>
            <apex:column headervalue="Phone">
                <apex:inputText value="{!b.Phone}" />
            </apex:column>
            
            <apex:column >
                <apex:commandLink action="{!updateRecord}" value="Update"/>                            
            </apex:column>                                                                                   
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form> 
         
</apex:page>

UpdateContactDetail.apxc =======

public class UpdateContactDetail {

  public Contact con {get;set;}
  public Id recId;

    public UpdateContactDetail ()
    {
      recId = ApexPages.CurrentPage().getparameters().get('recordId');
        getRecord();
    }
   public void getRecord() {
   
      con = [select Id, Name,FirstName, LastName, Title, Email, Phone from contact where id =:recId];   

   }    
    
    public PageReference updateRecord(){      
        try{ 
            update con;
            
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
        }
        return null;
    }
}

GeneratePDFOfContactTrigger.apxt =======

trigger GeneratePDFOfContactTrigger on Contact (after update) {
    
    GeneratePDFController.generateContactPDF(Trigger.new);
    
}

GeneratePDFController.apxc ==========

public class GeneratePDFController{ 
    public static final String FORM_HTML_START = '<HTML><BODY>';
    public static final String FORM_HTML_END = '</BODY></HTML>';
    
    public static void generateContactPDF(list<contact> contactList){
        String pdfContent = '' + FORM_HTML_START;
        for(contact con : contactList){
            try
            {
                pdfContent = '' + FORM_HTML_START;
                pdfContent = pdfContent + '<H2>Contact Information</H2>';
                
                //Dynamically grab all the fields to store in the PDF
                Map<String, Schema.SObjectType> sobjectSchemaMap = Schema.getGlobalDescribe();
                Schema.DescribeSObjectResult objDescribe = sobjectSchemaMap.get('Contact').getDescribe();
                Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
                
                //Append each Field to the PDF
                
                for(Schema.SObjectField fieldDef : fieldMap.values()){
                    Schema.Describefieldresult fieldDescResult = fieldDef.getDescribe();
                    String name = fieldDescResult.getName();
                    if(name == 'Title' || name == 'FirstName' || name == 'LastName' || name == 'Email' || name == 'Phone'){
                        pdfContent = pdfContent + '<P>' + name + ': ' + con.get(name) + '</P>';
                    }
                }
                pdfContent = pdfContent + FORM_HTML_END;
            }catch(Exception e){
                pdfContent = '' + FORM_HTML_START;
                pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>';
                pdfContent = pdfContent + FORM_HTML_END;
            }
            attachPDF(con,pdfContent);
        }
    }
    
    public static void attachPDF(Contact con, String pdfContent){
        try{
            Attachment attachmentPDF = new Attachment();
            attachmentPDF.parentId = con.Id;
            attachmentPDF.Name = con.FirstName+' '+con.LastName+ '.pdf';
            attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content
            insert attachmentPDF;
        }catch(Exception e){
            con.addError(e.getMessage());
        }
    }
    
}

  
Thank you in advance :)
Hi,
 I want to style my pdf. I want to get the record fields in a box and with good appearence.please help me in this.

User-added image

Below is my code...

========
ShowContactDetail.vfp

<apex:page controller="UpdateContactDetail">
 <style type="text/css">
  #title {
  font-size: 150%;
  margin-left: 30%;
  }
 </style>
  
  <h2 id="title">Contact</h2><br/><br/>
    <apex:form >
     <apex:pageBlock >
        <apex:pageBlockTable value="{!con}" var="b">
             <apex:column headervalue="Title">
                <apex:OutputText value="{!b.Title}" /> 
            </apex:column>   
            <apex:column headervalue="First Name">
                <apex:OutputText value="{!b.FirstName}" /> 
            </apex:column>            
            <apex:column headervalue="Last Name">
                <apex:OutputText value="{!b.LastName}" />
            </apex:column>
            <apex:column headervalue="Email">
                <apex:inputText value="{!b.Email}" />
            </apex:column>
            <apex:column headervalue="Phone">
                <apex:inputText value="{!b.Phone}" />
            </apex:column>
            
            <apex:column >
                <apex:commandLink action="{!updateRecord}" value="Update"/>                            
            </apex:column>                                                                                   
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form> 
         
</apex:page>

===============
UpdateContactDetail.apxc

public class UpdateContactDetail {

  public Contact con {get;set;}
  public Id recId;

    public UpdateContactDetail ()
    {
      recId = ApexPages.CurrentPage().getparameters().get('recordId');
        getRecord();
    }
   public void getRecord() {
   
      con = [select Id, Name,FirstName, LastName, Title, Email, Phone from contact where id =:recId];   

   }    
    
    public PageReference updateRecord(){      
        try{ 
            update con;
            
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
        }
        return null;
    }
}

=============
GeneratePDFOfContactTrigger


trigger GeneratePDFOfContactTrigger on Contact (after update) {
    
    GeneratePDFController.generateContactPDF(Trigger.new);
    
}

==============
GeneratePDFController.apxc


public class GeneratePDFController{ 
    public static final String FORM_HTML_START = '<HTML><BODY>';
    public static final String FORM_HTML_END = '</BODY></HTML>';
    
    public static void generateContactPDF(list<contact> contactList){
        String pdfContent = '' + FORM_HTML_START;
        for(contact con : contactList){
            try
            {
                pdfContent = '' + FORM_HTML_START;
                pdfContent = pdfContent + '<H2>Contact Information</H2>';
                
                //Dynamically grab all the fields to store in the PDF
                Map<String, Schema.SObjectType> sobjectSchemaMap = Schema.getGlobalDescribe();
                Schema.DescribeSObjectResult objDescribe = sobjectSchemaMap.get('Contact').getDescribe();
                Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
                
                //Append each Field to the PDF
                
                for(Schema.SObjectField fieldDef : fieldMap.values()){
                    Schema.Describefieldresult fieldDescResult = fieldDef.getDescribe();
                    String name = fieldDescResult.getName();
                    if(name == 'Title' || name == 'FirstName' || name == 'LastName' || name == 'Email' || name == 'Phone'){
                        pdfContent = pdfContent + '<P>' + name + ': ' + con.get(name) + '</P>';
                    }
                }
                pdfContent = pdfContent + FORM_HTML_END;
            }catch(Exception e){
                pdfContent = '' + FORM_HTML_START;
                pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>';
                pdfContent = pdfContent + FORM_HTML_END;
            }
            attachPDF(con,pdfContent);
        }
    }
    
    public static void attachPDF(Contact con, String pdfContent){
        try{
            Attachment attachmentPDF = new Attachment();
            attachmentPDF.parentId = con.Id;
            attachmentPDF.Name = con.FirstName+' '+con.LastName+ '.pdf';
            attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content
            insert attachmentPDF;
        }catch(Exception e){
            con.addError(e.getMessage());
        }
    }
    
}

Thank you in advance 
public with sharing class Auracsv {
    @AuraEnabled
    public static void processData(String fileData,String sobjectName,List<String> fields) {
        
        Schema.SObjectType targetType = Schema.getGlobalDescribe().get(sobjectName);
        try{
            if(fileData!=null){ 
                String[] fileLines = new String[]{};
                    fileLines = fileData.split('\n');
                    
                List<sObject> myList = new List<sObject>();
                for (Integer i=1,j=fileLines.size();i<j;i++){
                    String[] inputvalues = new String[]{};
                        inputvalues = fileLines[i].split(',');
                    sObject obj = targetType.newSObject();
                    integer rowsize=inputvalues.size();
                    
                    for(integer l=0;l<rowsize-1;l++){
                        system.debug('fields.get(l)'+fields.get(l)); 
                        if(String.isNotBlank(inputvalues[l]) )
                        {
                            String value= inputvalues[l].length()>255 ? inputvalues[l].substring(0,254) : inputvalues[l];
                            obj.put(fields.get(l),value);
                        }else{
                            obj.put(fields.get(l),'');
                        }
                           
                    }
                    myList.add(obj);   
                }
                insert myList;
            
            }
            
        }catch(Exception e){
            System.debug('exception'+e);   
        }  
    }
    
    @AuraEnabled
    public static List<Map<string,string>> getObjectList()
    {
        List<Map<string,string>> SObjectList = new List<Map<string,string>>();
        
        for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
            String name = objTyp.getDescribe().getName();
            SObjectList.add(new Map<string,string>{'label'=>name,'value'=>name});
            System.debug('name'+name);
            
        }
        return SObjectList;  
        
    }
    
    @AuraEnabled
    public static List<Sobject> updateData(string objectName, string file){
        system.debug('Json : '+file+'----------'+objectName);
        Blob json = EncodingUtil.base64Decode(file);
        system.debug('Json file : '+json.tostring());
        String[] fileLines = json.tostring().split('\n');
        string[] headers = fileLines[0].split(',');
        List<Sobject> objectList = new List<Sobject>();
        for(integer i=1; i<fileLines.size() ;i++){
            string[] rows = fileLines[i].split(',');
            sObject sObj = Schema.getGlobalDescribe().get(objectName).newSObject();
            for(integer j=0;j<headers.size();j++){
                sObj.put(headers[j].trim(), rows[j].trim());
            }
            objectList.add(sObj);
            
        }
        system.debug('Object : '+objectList);
        insert objectList;
        return objectList;
    }
}

Heres my WIP test class code====

@isTest
public class TestAuracsv {
    public static String[] csvFileLines;
    public static Blob csvFileBody;
    
     @TestSetup
    static void Accountdata(){
        Account acc = new Account();
        acc.Name = 'Lokesh';
        acc.AccountNumber = '56293723';
        acc.Type = 'Other';
        acc.Industry = 'Chemicals';
        insert acc; 
    }
    @IsTest
    static void testmethod1(){
        Account acc = new Account();
        acc.Name = 'Lokesh';
        insert acc;
        
        Test.startTest();       
        csvFileBody = Blob.valueOf(str);
        String csvAsString = csvFileBody.toString();
     
        AccountListController.updateData('Account', EncodingUtil.base64Encode(Blob.valueOf(str)));
        AccountListController.getObjectList();
         
    }
}

As I'm newbiee.There are some errors in test class and I'm trying to clear that.

 
public class EmployeeController {
    
    @AuraEnabled
    public static list<Map<String,Object>> getLightningPickListValues(String fieldName, string objectName) {
        list<Map<String,Object>> returnList = new list<Map<String,Object>>();
        try {
            returnList.add(new Map<String,Object>{'label'=>'--Select--','value'=>'--Select--'});
            Map<String, schema.SObjectField> feildMap = Schema.getGlobalDescribe().get(objectName.trim()).getDescribe().fields.getMap();
            list<Schema.PicklistEntry> values = feildMap.get(fieldName.trim()).getDescribe().getPickListValues();
            for (Schema.PicklistEntry obj : values) {
                returnList.add(new Map<String,Object>{'label'=>obj.getLabel(),'value'=>obj.getValue().remove('\'').escapeUnicode()});
            }
            System.debug('MAP with FEILD TYPE : '+returnList);
        } catch (Exception e) {
            System.debug('Error in lightning picklist values : '+e.getMessage()+' at line no :'+e.getLineNumber());
            
        }
        return returnList;
    }
    
    @AuraEnabled
    public static List<Map<string,object>> getEmployee(string typeEmployee){
        List<Map<string,object>> returnList = new List<Map<string,object>>();
        Map<string,string> imageMap = new Map<string,string>();
        List<employee__c> employeeList;
        if(typeEmployee == 'All'){
            employeeList = [select id, name,Date_of_Birth__c,Mobile__c,Blood_Group__c from employee__c];
        }else{
             employeeList = [select id, name,Date_of_Birth__c,Mobile__c,Blood_Group__c from employee__c where Department__c =:typeEmployee ];           
        }
        Set<Id> tempSet = new Set<Id>(); 
        for(employee__c emp : employeeList){
            tempSet.add(emp.Id);
        }
        system.debug('Temp Set : '+tempSet);
        for(ContentDocumentLink doc : [SELECT Id, ContentDocumentId, ContentDocument.LatestPublishedVersionId,ContentDocument.LatestPublishedVersion.Title,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId In :tempSet]){
            imageMap.put(doc.LinkedEntityId,doc.ContentDocument.LatestPublishedVersionId);
        }
        for(employee__c emp : employeeList){
            string imageUrl = imageMap.get(emp.Id) == null ? 'https://img.lovepik.com/original_origin_pic/19/01/17/ffea3ab99d95aca466f5c9f3ccb6a7f3.png_wh300.png' : 'https://emorphis-b-dev-ed.my.salesforce.com/sfc/servlet.shepherd/version/download/'+imageMap.get(emp.Id);
            returnList.add(new Map<string,object>{
                'Name'=>emp.name,'Date_of_Birth__c'=>emp.Date_of_Birth__c,'Mobile__c'=>emp.Mobile__c,'Blood_Group__c'=>emp.Blood_Group__c,'Image'=>imageUrl
            });
        }        
        return returnList;
    }
    
     @AuraEnabled
    public static List<employee__c> updateEmployee(List<employee__c> dataList , string file){
        system.debug('Data before update : '+dataList);
        upsert dataList;
        if(string.isNotBlank(file)){
            ContentVersion conVer = new ContentVersion();
            conVer.ContentLocation = 'S'; 
            conVer.PathOnClient = 'testing.jpg'; 
            conVer.Title = 'Testing Files'; 
            conVer.VersionData = EncodingUtil.base64Decode(file); 
            insert conVer;    
            
            
            Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:conVer.Id].ContentDocumentId;
            ContentDocumentLink conDocLink = New ContentDocumentLink();
            conDocLink.LinkedEntityId = dataList[0].Id;
            conDocLink.ContentDocumentId = conDoc; 
            conDocLink.shareType = 'V';
            insert conDocLink;
        }
        system.debug('Data after update : '+dataList);
        return dataList;
    }
    
    @AuraEnabled
    public static void deleteEmployee(string recordId){
        system.debug('recordId : '+recordId);
        delete[select id from Employee__c where Id = : recordId ];
    }
    
}

Test Class=============(Percentage- 95%, Wanted percentage- 100)

@isTest
public class EmployeeControllerTest {
    
    @TestSetup
    static void makeData(){
        Employee__c emp = new Employee__c();
        emp.Name = 'Lokesh';
        emp.Blood_Group__c = 'B+';
        emp.Department__c = 'All';
        emp.Date_of_Birth__c = Date.today();
        insert emp;
        
        ContentVersion conVer = new ContentVersion();
        conVer.ContentLocation = 'S'; 
        conVer.PathOnClient = 'testing.text'; 
        conVer.Title = 'Testing Files'; 
        conVer.VersionData = EncodingUtil.base64Decode('file'); 
        insert conVer;    
        
        
        Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:conVer.Id].ContentDocumentId;
        ContentDocumentLink conDocLink = New ContentDocumentLink();
        conDocLink.LinkedEntityId = emp.Id;
        conDocLink.ContentDocumentId = conDoc; 
        conDocLink.shareType = 'V';
        insert conDocLink;
    }
    
    @IsTest
    static void testMethod1(){
        EmployeeController.getLightningPickListValues('Department__c', 'Employee__c');
        EmployeeController.getEmployee('All');
        Employee__c emp = new Employee__c();
        emp.Name = 'Lokesh';
        emp.Blood_Group__c = 'B+';
        emp.Date_of_Birth__c = Date.today();
        String file = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATQAAACkCAMAAAAuTiJaAAAAolBMVEX39/fNAADRAAD5///NAwP4+/vPAADJAADNBAT39vbNCQn4/Pv28fH5//7OGBjOExP17Oz05+fij4/QKCjPHh7y3d3SERHTGBjVLi7SDQ3UIyPXPT3w19fuzc3y4uLswsLYTU3qs7PffHzSPz/RMzPrvb3edXXbWlrZamrYX1/hlJTRLy/mo6Por6/ZU1PWOTnghYXlnp7TRkbYZWXggYHhenq2EDuzAAAYI0lEQVR4nO1dC3uiSLNOdduNggEFREBRFOUiiorm//+1U9Ukk8xszJDv7Gw0Y+0+szMTyUKlLu9bl+bh4S53uctd7nKXu9zlLne5y13ucpe73OUuNyMC5avv4cZE8Nl6se3f1dZaBO8tMiZZEAzvWmsnwhgdAhl2mOfsva++mZsQwR92W2AsDh3GAsbWxlff0dWL4FOboXhsL7NoMwlYwb/6nq5bBO/vEtKYx5i7G3LBI8bk9B7VLovgw9QPY7Izlq17BumKo9nZd1O7IJgut5vTYRsyFjJ7xp+tSwxlOO5/7a1dq6AfntnYjHOTmdVa8FeH5JXHFnf//IdgJNv6JmMlRv/QHvGfVCTWoVPd/fMXMcTUnki2j9k4iBc9/qtVGSVjo7upvRE0smPlsxojmcMOo8d3lCMwgdqP//2tXatgJLPPjKWYLWX9jpE9f6ob3v3zWQQf7MKJnCD0D5zD6ILGUHjM5PrunwpgRNkT21fjYiXj+SUjaz67DmV+NzU0Mrui2B+wVWBPjd+Z0YHB4O82NWE8rJ8qFpSnZOwWu/5HRvZ8xYCx7d/M2pEq2ZnP2NgZ+/JXTHbxIlue//SNXa1gJFtXQcDGbDxmyYL/1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bnUP3t4rgvTfjt2IKbDKxp/fI/xnpr+dDftfYJ+Urztu6y13ucpe73OUud7nLXe5yl7vc5S53uctn5P8A9RPNftqy6HMAAAAASUVORK5CYII=';
        EmployeeController.updateEmployee(new List<Employee__c>{emp}, EncodingUtil.base64Encode(Blob.valueOf(file)));
        EmployeeController.deleteEmployee([select id from Employee__c limit 1].Id);
    }
}
How to add an image functionality in Lightning Component

Hi,
I'm doing a task on aura components in which employees will be available in different Departments. I'm fetching the data and can edit but only thing left is functionalities like adding New record, Delete and adding image functionality.
User-added image
Please help me in this. Below is my code

EmployeeComponent.cmp

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" Controller="EmployeeController">
    <aura:attribute name="employeeOptions" type="List" default="[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"></aura:handler>
    <aura:attribute name="spinner" type="boolean" default="true"/>
    <aura:attribute name="isEdit" type="boolean" default="true"/>
    <aura:attribute name="employeeList" type="List" default="[]"/>
    <aura:if isTrue="{!v.spinner}">
        <div class="exampleHolder">
            <lightning:spinner alternativeText="Loading" size="large" />
        </div>
    </aura:if>
    <div style="background:white">
        <div class="demo-only demo-only--sizing slds-grid slds-wrap" >
            <div class="slds-size_2-of-4">
                <lightning:combobox name="Employee__c" label="Select Department" value="All" placeholder="Select Type" options="{! v.employeeOptions }" onchange="{! c.handleChange }"/>
            </div>
            <div class="slds-size_1-of-2 slds-p-left_x-small" style="margin-top:20px">
                <lightning:button variant="brand" label="Delete" title="Brand action" onclick="{!c.handleClick}" />
                <lightning:button variant="brand" label="Save" title="Brand action" onclick="{!c.handleSave}" />
                <lightning:button variant="brand" label="Edit" title="Brand action" onclick="{!c.handleEdit}" />
                <lightning:button variant="brand" label="Cancel" title="Brand action" onclick="{!c.handleCancel}" />
            </div>
            
        </div>
        <div class="slds-p-top_large">
            <div class="demo-only demo-only--sizing slds-grid slds-wrap">
                <aura:iteration items="{!v.employeeList}" var="item">
                    <aura:if isTrue="{!v.isEdit}">
                        <div class="slds-size_1-of-4">
                            <lightning:card>
                                <p class="slds-p-horizontal_small">
                                    {!item.Name}<br></br>
                                     {!item.Date_of_Birth__c}<br></br>
                                    {!item.Blood_Group__c}<br></br>
                                     {!item.Mobile__c}<br></br>
                                </p>
                            </lightning:card>
                        </div>
                        <aura:set attribute="else">
                            <lightning:card>
                                <p class="slds-p-horizontal_small">
                                   <lightning:input type="text" name="input1" label="Name" value="{!item.Name}"/>
                                    <lightning:input type="date" name="input1" label="Date Of Birth" value="{!item.Date_of_Birth__c}"/>
                                    <lightning:input type="text" name="input1" label="Blood Group" value="{!item.Blood_Group__c}"/>
                                    <lightning:input type="text" name="input1" label="Mobile__c" value="{!item.Mobile__c}"/>
                                </p>
                            </lightning:card>
                        </aura:set>
                    </aura:if>
                    
                </aura:iteration>
            </div>
        </div>
    </div>
</aura:component>

EmployeeController.apxc

public class EmployeeController {
    
    @AuraEnabled
    public static list<Map<String,Object>> getLightningPickListValues(String fieldName, string objectName) {
        list<Map<String,Object>> returnList = new list<Map<String,Object>>();
        try {
            returnList.add(new Map<String,Object>{'label'=>'--Select--','value'=>'--Select--'});
            Map<String, schema.SObjectField> feildMap = Schema.getGlobalDescribe().get(objectName.trim()).getDescribe().fields.getMap();
            list<Schema.PicklistEntry> values = feildMap.get(fieldName.trim()).getDescribe().getPickListValues();
            for (Schema.PicklistEntry obj : values) {
                returnList.add(new Map<String,Object>{'label'=>obj.getLabel(),'value'=>obj.getValue().remove('\'').escapeUnicode()});
            }
            System.debug('MAP with FEILD TYPE : '+returnList);
        } catch (Exception e) {
            System.debug('Error in lightning picklist values : '+e.getMessage()+' at line no :'+e.getLineNumber());
            // return null;
        }
        return returnList;
    }
    
    @AuraEnabled
    public static List<employee__c> getEmployee(string typeEmployee){
        if(typeEmployee == 'All'){
            return [select id, name,Date_of_Birth__c,Mobile__c,Blood_Group__c from employee__c];
        }else{
             return [select id, name,Date_of_Birth__c,Mobile__c,Blood_Group__c from employee__c where Department__c =:typeEmployee ];           
        }
    }
    
     @AuraEnabled
    public static List<employee__c> updateEmployee(List<employee__c> dataList){
        system.debug('Data before update : '+dataList);
        update dataList;
        system.debug('Data after update : '+dataList);
        return dataList;
    }
    
}

EmployeeComponentController.js

({
    doInit : function(component, event, helper) {
        console.log('In Doint');
        var action = component.get("c.getLightningPickListValues");
        action.setParams({
            "fieldName":'Department__c',
            "objectName":'Employee__c'
        });
        action.setCallback(this,function(response){
            console.log('response of picklist : ',response.getReturnValue());
            component.set("v.employeeOptions",response.getReturnValue());
            var actionTwo = component.get("c.getEmployee");
            actionTwo.setParams({
                "typeEmployee":"All"
            });
            actionTwo.setCallback(this,function(response){
                component.set("v.spinner",false);
                console.log('data : ',response.getReturnValue());
                component.set("v.employeeList",response.getReturnValue());
            })
            $A.enqueueAction(actionTwo);
        });
        
        $A.enqueueAction(action);
    },
    
    handleChange : function(component,event,helper){
        component.set("v.spinner",true);
        const type = event.getSource().get("v.value"); 
        var actionTwo = component.get("c.getEmployee");
        actionTwo.setParams({
            "typeEmployee":type
        });
        actionTwo.setCallback(this,function(response){
            component.set("v.spinner",false);
            console.log('data : ',response.getReturnValue());
            component.set("v.employeeList",response.getReturnValue());
            component.set("v.spinner",false);
        })
        $A.enqueueAction(actionTwo);
    },
    
    handleEdit : function(component,event,helper){
        console.log('edit');
        component.set("v.isEdit",false);
    },
    handleCancel : function(component,event,helper){
        console.log('cancel');
        component.set("v.isEdit",true);
    },
    handleSave : function(component,event,helper){
        var list = component.get("v.employeeList");
        console.log('Data : ',list[0]);
         component.set("v.spinner",true);
        var actionTwo = component.get("c.updateEmployee");
        actionTwo.setParams({
            "dataList":list
        });
        actionTwo.setCallback(this,function(response){
            console.log('data : ',response.getReturnValue());
            component.set("v.employeeList",response.getReturnValue());
            component.set("v.spinner",false);
             component.set("v.isEdit",true);
             $A.get('e.force:refreshView').fire();
        })
        $A.enqueueAction(actionTwo);
        
    }
})
 
Hi,
I created check box for fullday,Half day and Mixed day. So, I was trying to write this with the help of radio buttons because in check box i can select all three checkboxes at once.
<h1><b>Select Leave</b></h1>
<lightning:input type="checkbox" label="Full Day" name="Full Day" aura:id="apps" value="fullDay" onchange="{! c.handleChange }" />
<lightning:input type="checkbox" label="Half Day" name="Half Day" aura:id="product" value="halfDay" onchange="{! c.handleChange }" />
<lightning:input type="checkbox" label="Mixed Day" name="Mixed Day" aura:id="service" value="mixedDay" onchange="{! c.handleChange }" />

Thanks in advance
 
Hi,

I'm new to Aura components. I'm trying to build a lightning quick action for a employee to apply leave. Employee should be able to apply leave in 3 categories casual, privileged and medical, and if he has none of the leaves left in that type it should be added to leaves without pay.He can apply for full day, half day and mixed leave.

Also if a holiday is coming in between the date he has applied  for leave that no of days should be deducted from the total no of days he has applied for leave. Make a custom setting to mark name of week you give your weekly holidays example: sunday, monday  or saturday sunday. please help me in this.

Thanks in advance.


For eg if a person applied leave from friday to monday then only 2 days of full leave should be counted . i.e friday and monday.
 
The leave record should also be saved in a object and the quick action should be on contact record page
Hi, 
 I'm new to Aura components concept. Iam trying to Create a form to insert account withoutt record forms using Aura component. Please help me in solving this.

Thank you in advance
Hi,
 
I'm struggling to complete this trigger.If the lead status is ' Open-Not Contacted ' then the record should be added to campaign record (Create one Record Name- abc) and also if the status is changed from ' Open-Not Contacted ' to something else then the record (abc) in campaign should be removed.

I firstly tried to created junction object  by adding 2 master detail that is Lead and campaign but, When creating relationship Lead is not appearing to select. My idea is that we can do this with campaign member object. please help me in solving this trigger which involves
relationship.

Thanks in advance.
 
Hi,

I'm new to developement. I want to do batch class by using to build a text field on account named "Todays execution".This fields needs to be updated daily wth todays date + account name for all the account in the org.

Thanks in advance
 
Hi,
 I want to style my pdf. I want to get the record fields in a box and with good appearence.please help me in this.

User-added image

Below is my code...

========
ShowContactDetail.vfp

<apex:page controller="UpdateContactDetail">
 <style type="text/css">
  #title {
  font-size: 150%;
  margin-left: 30%;
  }
 </style>
  
  <h2 id="title">Contact</h2><br/><br/>
    <apex:form >
     <apex:pageBlock >
        <apex:pageBlockTable value="{!con}" var="b">
             <apex:column headervalue="Title">
                <apex:OutputText value="{!b.Title}" /> 
            </apex:column>   
            <apex:column headervalue="First Name">
                <apex:OutputText value="{!b.FirstName}" /> 
            </apex:column>            
            <apex:column headervalue="Last Name">
                <apex:OutputText value="{!b.LastName}" />
            </apex:column>
            <apex:column headervalue="Email">
                <apex:inputText value="{!b.Email}" />
            </apex:column>
            <apex:column headervalue="Phone">
                <apex:inputText value="{!b.Phone}" />
            </apex:column>
            
            <apex:column >
                <apex:commandLink action="{!updateRecord}" value="Update"/>                            
            </apex:column>                                                                                   
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form> 
         
</apex:page>

===============
UpdateContactDetail.apxc

public class UpdateContactDetail {

  public Contact con {get;set;}
  public Id recId;

    public UpdateContactDetail ()
    {
      recId = ApexPages.CurrentPage().getparameters().get('recordId');
        getRecord();
    }
   public void getRecord() {
   
      con = [select Id, Name,FirstName, LastName, Title, Email, Phone from contact where id =:recId];   

   }    
    
    public PageReference updateRecord(){      
        try{ 
            update con;
            
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
        }
        return null;
    }
}

=============
GeneratePDFOfContactTrigger


trigger GeneratePDFOfContactTrigger on Contact (after update) {
    
    GeneratePDFController.generateContactPDF(Trigger.new);
    
}

==============
GeneratePDFController.apxc


public class GeneratePDFController{ 
    public static final String FORM_HTML_START = '<HTML><BODY>';
    public static final String FORM_HTML_END = '</BODY></HTML>';
    
    public static void generateContactPDF(list<contact> contactList){
        String pdfContent = '' + FORM_HTML_START;
        for(contact con : contactList){
            try
            {
                pdfContent = '' + FORM_HTML_START;
                pdfContent = pdfContent + '<H2>Contact Information</H2>';
                
                //Dynamically grab all the fields to store in the PDF
                Map<String, Schema.SObjectType> sobjectSchemaMap = Schema.getGlobalDescribe();
                Schema.DescribeSObjectResult objDescribe = sobjectSchemaMap.get('Contact').getDescribe();
                Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
                
                //Append each Field to the PDF
                
                for(Schema.SObjectField fieldDef : fieldMap.values()){
                    Schema.Describefieldresult fieldDescResult = fieldDef.getDescribe();
                    String name = fieldDescResult.getName();
                    if(name == 'Title' || name == 'FirstName' || name == 'LastName' || name == 'Email' || name == 'Phone'){
                        pdfContent = pdfContent + '<P>' + name + ': ' + con.get(name) + '</P>';
                    }
                }
                pdfContent = pdfContent + FORM_HTML_END;
            }catch(Exception e){
                pdfContent = '' + FORM_HTML_START;
                pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>';
                pdfContent = pdfContent + FORM_HTML_END;
            }
            attachPDF(con,pdfContent);
        }
    }
    
    public static void attachPDF(Contact con, String pdfContent){
        try{
            Attachment attachmentPDF = new Attachment();
            attachmentPDF.parentId = con.Id;
            attachmentPDF.Name = con.FirstName+' '+con.LastName+ '.pdf';
            attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content
            insert attachmentPDF;
        }catch(Exception e){
            con.addError(e.getMessage());
        }
    }
    
}

Thank you in advance 
public with sharing class Auracsv {
    @AuraEnabled
    public static void processData(String fileData,String sobjectName,List<String> fields) {
        
        Schema.SObjectType targetType = Schema.getGlobalDescribe().get(sobjectName);
        try{
            if(fileData!=null){ 
                String[] fileLines = new String[]{};
                    fileLines = fileData.split('\n');
                    
                List<sObject> myList = new List<sObject>();
                for (Integer i=1,j=fileLines.size();i<j;i++){
                    String[] inputvalues = new String[]{};
                        inputvalues = fileLines[i].split(',');
                    sObject obj = targetType.newSObject();
                    integer rowsize=inputvalues.size();
                    
                    for(integer l=0;l<rowsize-1;l++){
                        system.debug('fields.get(l)'+fields.get(l)); 
                        if(String.isNotBlank(inputvalues[l]) )
                        {
                            String value= inputvalues[l].length()>255 ? inputvalues[l].substring(0,254) : inputvalues[l];
                            obj.put(fields.get(l),value);
                        }else{
                            obj.put(fields.get(l),'');
                        }
                           
                    }
                    myList.add(obj);   
                }
                insert myList;
            
            }
            
        }catch(Exception e){
            System.debug('exception'+e);   
        }  
    }
    
    @AuraEnabled
    public static List<Map<string,string>> getObjectList()
    {
        List<Map<string,string>> SObjectList = new List<Map<string,string>>();
        
        for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
            String name = objTyp.getDescribe().getName();
            SObjectList.add(new Map<string,string>{'label'=>name,'value'=>name});
            System.debug('name'+name);
            
        }
        return SObjectList;  
        
    }
    
    @AuraEnabled
    public static List<Sobject> updateData(string objectName, string file){
        system.debug('Json : '+file+'----------'+objectName);
        Blob json = EncodingUtil.base64Decode(file);
        system.debug('Json file : '+json.tostring());
        String[] fileLines = json.tostring().split('\n');
        string[] headers = fileLines[0].split(',');
        List<Sobject> objectList = new List<Sobject>();
        for(integer i=1; i<fileLines.size() ;i++){
            string[] rows = fileLines[i].split(',');
            sObject sObj = Schema.getGlobalDescribe().get(objectName).newSObject();
            for(integer j=0;j<headers.size();j++){
                sObj.put(headers[j].trim(), rows[j].trim());
            }
            objectList.add(sObj);
            
        }
        system.debug('Object : '+objectList);
        insert objectList;
        return objectList;
    }
}

Heres my WIP test class code====

@isTest
public class TestAuracsv {
    public static String[] csvFileLines;
    public static Blob csvFileBody;
    
     @TestSetup
    static void Accountdata(){
        Account acc = new Account();
        acc.Name = 'Lokesh';
        acc.AccountNumber = '56293723';
        acc.Type = 'Other';
        acc.Industry = 'Chemicals';
        insert acc; 
    }
    @IsTest
    static void testmethod1(){
        Account acc = new Account();
        acc.Name = 'Lokesh';
        insert acc;
        
        Test.startTest();       
        csvFileBody = Blob.valueOf(str);
        String csvAsString = csvFileBody.toString();
     
        AccountListController.updateData('Account', EncodingUtil.base64Encode(Blob.valueOf(str)));
        AccountListController.getObjectList();
         
    }
}

As I'm newbiee.There are some errors in test class and I'm trying to clear that.

 
Hi, 
 I'm new to Aura components concept. Iam trying to Create a form to insert account withoutt record forms using Aura component. Please help me in solving this.

Thank you in advance
Hi,

I'm new to developement. I want to do batch class by using to build a text field on account named "Todays execution".This fields needs to be updated daily wth todays date + account name for all the account in the org.

Thanks in advance