• SRK
  • SMARTIE
  • 1090 Points
  • Member since 2010

  • Chatter
    Feed
  • 32
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 550
    Replies
I'm getting this error in the Visual force page but i have all the <td> tag ends with <./td>
Not sure why its triggering this error.

Please suggest.
Hi there,

The issue I am having is email tracking is counting activities on the Opportunities level, but not the Lead level when checking the Activities Report.

User-added image


The number you see in the screenshot (55) is all opportunities, but no leads. How do I get it to count both leads and opportunities?

Thanks.
Hey Everyone,

I'm trying to extract information via the Data Loader for a trailhead exercise. I've downloaded the application, and attempted to run the steps provided: 

The next step is to select the Account object, rename the file to be extracted and save it to your desktop. Note: All file names default to extract.csv. Renaming files prevents losing or overwriting them.
From the Select Salesforce Object list, select Account (Account).
In the Choose a target for extraction text box, enter Accounts Export.csv.
Click Browse…
Navigate to the desktop, click Save, then click Next.
Now create the necessary SOQL query.
Choose the query fields below:
Id
Name
Site
To complete the where clause to your query, type (or copy and paste) WHERE Type LIKE '%Customer%' in the text box so your query looks like this:
Select Id, Name, Site FROM Account WHERE Type LIKE '%Customer%'
Click Finish, then click Yes. The Operation Finished window appears, reporting the number of successful extractions. Note: The resulting export file should contain 11 records.

I get this message as a result: 
Site FROM Account WHERE Type LIKE ‘%Customer%’                                  ^ ERROR at Row:1:Column:51 line 1:51 no viable alternative at character '‘'
Can anyone provide some insight into how to fix this issue or how to proceed? 

Thanks for any help you could provide!
I want to input mobile number in Text field after saving the record the mobile number should display in (999) 999-9999 format..

I've tried creating a formula field of text and gave the below formula
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE( Phone__c ,
 '.', NULL),
 ' ', NULL), 
'-', NULL), 
')', NULL),
 '(', NULL)

But it doesn't worked for me.Can anyone help me doing this..
Hi,

I have a time-based workflow on the account which is updating a checkbox field to true when this action is executed I want my custom code to fire (after update) and make some updates on the object. Currently, the scheduled time-based action is changing to the future time when it comes to schedule execution time.

Thanks

Hello, I have a Contracts object where we keep track of company's contracts data. I want to create a field that keeps track of what number renewal cycle we are in. For example, if the original contracts ends on 2/2/20, so the renewal period begins on 2/3/20, once 2/3/20 hits, I want the "Renewal cycle #" field to automatically change from 0 to 1. Then when the next renewal cycle begins, I want "Renewal cycle #" to automatically change from 1 to 2. I am open to doing this through a formula field or workflow action or Apex-- whatever works. Any help is greatly appreciated. 

What I have so far covers 26% of the batch class. I'm not able to cover the execute portion of the batch class.

batch.cls
public class Batch implements Database.Batchable<sObject> {

	public Database.QueryLocator start(Database.BatchableContext bc) {
        String query = 'SELECT Id, jstcl__Consultant__r.Previous_Timesheet_Status__c FROM jstcl__TG_Timesheet__c WHERE jstcl__Placement__r.ts2__Status__c =\'Active\' AND jstcl__Placement__r.VMS__c = \'\' AND jstcl__Week_Ending__c = LAST_N_DAYS:4 AND jstcl__Status__c = \'Pending\'';
          return Database.getQueryLocator(query);
    }
   public void execute(Database.BatchableContext BC, List<jstcl__TG_Timesheet__c> timesheets){
       List<Contact> consultants = new List<Contact>();
       List<Contact> consultants2 = new List<Contact>();

       for(jstcl__TG_Timesheet__c timesheet : timesheets){
           Contact consultant = timesheet.jstcl__Consultant__r; 
           if (consultant == null) continue;
           consultant.Previous_Timesheet_Status__c = 'Pending';
           if(consultants.contains(consultant)){
               consultants2.add(consultant);
           }else{consultants.add(consultant);}
           }
           update consultants;
        }
   public void finish(Database.BatchableContext BC){}
}
test.cls
@istest 
private class Test {

static TestMethod void hfTest() {
     Profile prof = [select id from profile where name='system Administrator'];
     User usr = new User(alias = 'usr', email='us.name@vmail.com',
                emailencodingkey='UTF-8', lastname='lstname',
                timezonesidkey='America/Los_Angeles',
                languagelocalekey='en_US',
                localesidkey='en_US', profileid = prof.Id,
                username='testuser128@testorg.com');
                insert usr;
    Id idRecordId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Candidate').getRecordTypeId();

    	ts2__Source__c source = new ts2__Source__c(Name = 'LinkedIn.com - Resume Search');
    	Account acc = new Account(Name = 'Express Scripts Holding Company');
        insert acc;
  		Account acc2 = new Account(Name = 'Candidates- 10-2018');
        insert acc2;
    	Contact con = new Contact(FirstName='fnadmes', LastName = 'lnamdes', Email = 'emadils@gmail.com', Phone = '9744800300', AccountId = acc2.Id, ts2__Source__c = source.Id, ts2__People_Status__c = 'Placed');
        Contact con2=new Contact(FirstName='fnames', LastName = 'lnames', Email = 'emails@gmail.com', Phone = '9743800300', AccountId=acc.Id, Relationship_Status__c = 'Lunch'); 
    	insert con; insert con2;
        ADP_Department__c adp = new ADP_Department__c(Name = 'Georgia');
        insert adp;
        ts2__Job__c job = new ts2__Job__c(Name = 'Software Engineer',Hiring_Manager_Contact__c = con2.Id);
        insert job;
        ts2__HolidayCalendar__c hcal = new ts2__HolidayCalendar__c(Name= 'Holiday Calendar');
        insert hcal;
        Labor_Category__c lcat = new Labor_Category__c(Name='Software Engineer 1');  
        insert lcat;
        ts2__Placement__c plc = new ts2__Placement__c(ts2__Job__c = job.Id, Contractor_Type__c = 'Technical Youth', Onboarding_Method__c= 'Staff Augmentation', ts2__Start_Date__c= Date.newInstance(2019, 1, 7), ts2__End_Date__c= Date.newInstance(2019, 2, 15),
        jstcl__HireType__c= 'W2', ADP_Department__c= adp.Id, ts2__Bill_Rate__c= 60.00, ts2__Pay_Rate__c= 30.00, jstcl__Invoice_Batch__c= 'Placement', ts2__Client__c= acc.Id, ts2__Hiring_Manager__c= con2.Id, jstcl__TimecardApprover__c= con2.Id, jstcl__HolidayCalendar__c= hcal.Id,
		State_Worked_In_Non_TFI_Placements__c= 'GA - Georgia', jstcl__Overtime_Bill_Rate__c= 60, jstcl__Burden__c= 0.20, jstcl__Accounts_Receivable_U__c= '00537000005d7F2AAI', jstcl__Terms__c= 'Net 60', ts2__Employee__c= con.Id, Labor_Category__c= lcat.Id);
		insert plc;
     	List<jstcl__TG_Timesheet__c> tsList = new List<jstcl__TG_Timesheet__c>();
    	 jstcl__TG_Timesheet__c ts = new jstcl__TG_Timesheet__c(jstcl__Consultant__c = con2.Id, jstcl__Placement__c = plc.Id, jstcl__Week_Ending__c = Date.newInstance(2019, 2, 15));
    tsList.add(ts);

	Test.startTest(); 
     Batch abcd = new Batch();
     ID batchprocessid = Database.executeBatch(abcd);
	Test.stopTest();
 }    
}

 

Good day,

On below trigger, my Insert and Update works. Please assist in an after delete trigger:

trigger calcClaim on Claim__c (after Insert, after Update, after Delete){
    
    set<Id> OccIds = new set<Id>();
    integer count = 0;
    for(Claim__c cl: Trigger.new)
    {    
        decimal temp = 0.0;
        try{temp = Trigger.old[count].Initial_Estimate__c;}
        Catch(exception e)
        {}
        if(cl.Initial_Estimate__c != temp)
        {
            OccIds.add(cl.Occurrence__c);
        } else
            if(Trigger.isDelete){
            /*{for(Claim__c c : trigger.old)
                system.debug(trigger.old);
                OccIds.add(cl.Occurrence__c);}*/
              count++;        
    }
    List<RK_Occurrence__c> occs  = ([SELECT id FROM RK_Occurrence__c where Id in :OccIds]);
    system.debug(occs);
    
    OccurenceClaimCalculator.calculateOcc(occs);
    
    }

Hi All,
I am struggling to find best way to create a lightning component which lists Accounts as well as Person Account records created within a time range ordered by distance from a certain location (lat/lng) along with pagination.

I already have a working components which lists all accounts created within time specified ordered by distance with Offset value for 10 records each time. But now to include all Person accounts in that list with ordering to work together on (Account+Person Accounts), is it possible to achieve with one query?
 
Hello,

I am quering a Prive book Entry, and i made sure that there are no fuplicates,

but still i have below error
 
Line: 122, Column: 1
System.DmlException: Insert failed. First exception on row 7; first error: FIELD_INTEGRITY_EXCEPTION, This price definition already exists in this price book: []

Any suggestions
i have written a increment trigger, where there are 5 custom field(India,ME,US,SEA,EU),all these fields are Incremented based on a formula field(PraticeLWC__Region__c), now if i update for ME the record should increment for 1 and 2, and if i delete a record related to ME and again add the record the record for ME it should take as 2 itself and not 3, how do i achive this

so basically when i add the records based on the region it should get incremented and if i delete a record it should get decremented

Region1
 
trigger Increment on Lead (before insert,Before Update) {
    if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate || Trigger.IsUnDelete))  {
        List<Lead> leadList = [Select Id,PraticeLWC__Lead_No_Region_IN__c From Lead Where PraticeLWC__Region__c = 'India'];
        For(Lead l : trigger.New ) {
            if(l.PraticeLWC__Region__c == 'India') {
                if(leadList.size() > 0){
                    l.PraticeLWC__Lead_No_Region_IN__c = leadList.size()+0;   
                } else {
                    l.PraticeLWC__Lead_No_Region_IN__c = 1;
                }
            }
        }
        List<Lead> leadListt = [Select Id,PraticeLWC__Lead_No_Region_USA__c From Lead Where PraticeLWC__Region__c = 'US'];
        For(Lead m : trigger.New) {
            if(m.PraticeLWC__Region__c == 'US') {
                if(leadListt.size() > 0){
                    m.PraticeLWC__Lead_No_Region_USA__c = leadListt.size()+0;   
                } else {
                    m.PraticeLWC__Lead_No_Region_USA__c = 1;
                }
            }
        } 
        List<Lead> leadListm = [Select Id,PraticeLWC__Lead_No_Region_EU__c From Lead Where PraticeLWC__Region__c = 'EU'];
        For(Lead n : trigger.New) {
            if(n.PraticeLWC__Region__c == 'EU') {
                if(leadListm.size() > 0){
                    n.PraticeLWC__Lead_No_Region_EU__c = leadListm.size()+0;   
                } else {
                    n.PraticeLWC__Lead_No_Region_EU__c = 1;
                }
            }
        } 
        List<Lead> leadListo = [Select Id,PraticeLWC__Lead_No_Region_SEA__c From Lead Where PraticeLWC__Region__c = 'SEA'];
        For(Lead o : trigger.New) {
            if(o.PraticeLWC__Region__c == 'SEA') {
                if(leadListo.size() > 0){
                    o.PraticeLWC__Lead_No_Region_SEA__c = leadListo.size()+0;   
                } else {
                    o.PraticeLWC__Lead_No_Region_SEA__c = 1;
                }
            }
        }
        List<Lead> leadListp = [Select Id,PraticeLWC__Lead_No_Region_ME__c From Lead Where PraticeLWC__Region__c = 'ME'];
        For(Lead p : trigger.New) {
            if(p.PraticeLWC__Region__c == 'ME') {
                if(leadListp.size() > 0){
                    p.PraticeLWC__Lead_No_Region_ME__c = leadListp.size()+0;   
                } else {
                    p.PraticeLWC__Lead_No_Region_ME__c = 1;
                }
            }
        } 
        
    }                   
}

 
Start Method : 

 global APTS_UsageInput_ValidateDataBatch(APTS_UsageInputWrapper uirecordsfromloadfile)
    {
        workid=uirecordsfromloadfile.EQ_WorkId;
        inputrecord = uirecordsfromloadfile;
    }
String str='select id,EQ_UsageSchedule__c,EQ_ValidationError__c,EQ_ProcessStatus__c,APTS_Legacy_ExternalID__c, EQ_ServiceCode__c,EQ_Account__c,EQ_AssetLineItem__c ,EQ_AccountLocation__c, EQ_IssueNumber__c, EQ_SourceSystem__c,EQ_RecordKey__c, EQ_WorkId__c, EQ_QuantityID__c, EQ_LoadMonth__c, EQ_Quantity__c from EQ_TempSSP1Data__c where EQ_WorkId__c=:workid';
    global database.QueryLocator start(Database.BatchableContext BC)
    {
      return Database.getQueryLocator(str);
   }
Execute Method : 
 global void execute(Database.BatchableContext BC, List<EQ_TempSSP1Data__c> scope)
   {
     String key;
           set<String> distinctTempSsp1DataSourceSystems = new set<String>();
           set<String> issueNumbers = new set<String>();
           set<String> serviceCodes = new set<string>();
           set<String> areAllIssueNumbersPresent = new set<String>();
           list<string> errors=new list<string>();
           Set<String> pickListValuesList= new Set<String>();
           String SourceSystem='004:Invalid Source System';
           string IssueNumber = '001:IssueNumber Does not exists';
           string DuplicatesFound = '012:Duplicate issue number service code pair record found';
           string NotValidDateRange = '006:sageData Date is not in the valid(Effective) Date range';
           string ServiceCode = '002:Fee Code Does not exists';
           string ServiceCodeIssueNumberCombo = '007:Asset doesnot exists for the Account-Fee Code'; 
           string missingAssetData = '008: every record from the load file doesnot have existing Account or AccountLocation';
           string MultipleAssetsPerFeeCode = '013: Multiple Assets for Account or Acc Location per Fee Code';
           string InactiveAccount = '003:Account is Inactive';
           list<String> duplicateSourcecode= new list<String>();
           list<String> encounterSourcecode= new list<String>();
           list<String> duplicateIssue= new list<String>();
           list<String> encounterIssue= new list<String>();
           list<EQ_SSP1Data__c> ssp1Data =new list<EQ_SSP1Data__c>();
           list<EQ_SSP1Data__c> ssp1DataRef =new list<EQ_SSP1Data__c>();
           map<string,list<EQ_TempSSP1Data__c>> tempSsp1DataIssueFeeCodeKey = new map<string,list<EQ_TempSSP1Data__c>>();
           map<string,list<EQ_SSP1Data__c>> ssp1DataAccountIdKey = new map<string,list<EQ_SSP1Data__c>>();
           map<string,list<EQ_SSP1Data__c>> ssp1DataAccountLocationIdKey = new map<string,list<EQ_SSP1Data__c>>();
           list<String> encounterList= new list<String>();
           list<String> duplicateList= new List<String>();
           list<ErrorTempSSP1Data > errorTempSection   = new list<ErrorTempSSP1Data >();
           
          system.debug(': Heap size is-1 ' + limits.getHeapSize() + ' enforced is ' + limits.getLimitHeapSize()); 
          tempSsp1Data=scope;
         system.debug('Validate Batch -Scope list contains---->'+tempSsp1Data);
           //---------------------------validation 1---------------------------------------------------------------------
         // ErrorChecker with tempSsp1Data for valid values of the fields and check SourceSystem is existing in system
         
                
           // Blank Check on records
          list<ErrorTempSSP1Data> errorTempSection_1= new list<ErrorTempSSP1Data>();
          for(EQ_TempSSP1Data__c record : tempSsp1Data)
              {
                 distinctTempSsp1DataSourceSystems.Add(record.EQ_SourceSystem__c);
                serviceCodes.add(record.EQ_ServiceCode__c);
                 list<String> nullerrors= new list<String>();
                  map<ID,list<String>> nullCheckmap= new map<ID,list<String>>();
                 nullerrors = ErrorChecker.ValidateImportData(record);
                 system.debug('Null Errors List ->'+nullerrors);
                 if(nullerrors.size()!=0)
                 {
                    if (!errorTempData.ContainsKey(String.valueof(record)))
                        {
                            ErrorTempSSP1Data ins = new ErrorTempSSP1Data();
                            ins.TempData=record;
                            ins.Errors=nullerrors;
                             nullCheckmap.put(ins.TempData.id,ins.Errors);
                             ins.mapErrors=nullCheckmap;
                             errorTempSection_1.add(ins);
                             system.debug('Null Errors if any ->'+ins.mapErrors );
                         } 
                 }
                  
              }
         if(errorTempSection_1.size()!= 0)
                {
                    for(ErrorTempSSP1Data errorTemp:errorTempSection_1)
                    {
                        key = string.valueof(errorTemp.TempData);

                        if (!errorTempData.ContainsKey(key))
                         {
                            errorTempData.put(key,errorTemp);
                         }
                    }
             }
        system.debug('errorTempData data1--->'+errorTempData.values());
       system.debug(': Heap size is--2 ' + limits.getHeapSize() + ' enforced is ' + limits.getLimitHeapSize());
       
       // Validation for duplicate IssueNumber-ServiceCode pairs in the load file
             for(EQ_TempSSP1Data__c x:tempSsp1Data)
             {
              list<String> error1= new list<String>();
              map<ID,list<String>> m1= new map<ID,list<String>>();
              if((x.EQ_IssueNumber__c!=null || x.EQ_IssueNumber__c!='')&& (x.EQ_ServiceCode__c!=null||x.EQ_ServiceCode__c!=''))
                
              {
                  String uniqueChecksum= x.EQ_IssueNumber__c + x.EQ_ServiceCode__c;
                  List<EQ_TempSSP1Data__c> entitiesForKey = tempSsp1DataIssueFeeCodeKey.get(uniqueChecksum);
                    if (entitiesForKey == null) 
                    {
                        entitiesForKey = new List<EQ_TempSSP1Data__c>();
                        tempSsp1DataIssueFeeCodeKey.put(uniqueChecksum, entitiesForKey);
                    }    
                  entitiesForKey.add(x);
                 tempSsp1DataIssueFeeCodeKey.put(uniqueChecksum,entitiesForKey);
                 if(!encounterList.contains(uniqueChecksum))
                 {
                    encounterList.add(uniqueChecksum);
                 }
                 else
                 {
                     ErrorTempSSP1Data ins = new ErrorTempSSP1Data();
                         ins.TempData=x;
                         error1.add(DuplicatesFound);
                         ins.Errors=error1;
                         m1.put(ins.TempData.id,ins.Errors);
                         ins.mapErrors=m1;
                         system.debug('Duplicate issue number service code error if any-->'+ ins.mapErrors);
                        errorTempSection.add(ins);
                 }
              }
           }       
             
           
             if(errorTempSection.size()!= 0)
                {
                    for(ErrorTempSSP1Data errorTemp :errorTempSection)
                    {
                        key = string.valueof(errorTemp.TempData);

                        if (!errorTempData.ContainsKey(key))
                        {
                            errorTempData.put(key, errorTemp);
                            
                         }

                    }
                }

  for(ErrorTempSSP1Data item:errorTempData.Values())
                {
                    for(String st:item.Errors)
                    {
                       errorsList.add(st);
                    }
                    
                }
         count=errorsList.size();
         system.debug('ErrorList^^^^^'+errorsList);
         system.debug('ErrorList count^^^^^'+count); 
          status = (count == 0)
                ? 'PegaCallbackStatus.Complete'
                : 'PegaCallbackStatus.Error';
       //-----------------------------
 //Update error field on tempssp1 records
        EQ_TempSSP1Data__c tempSsp1Record=new EQ_TempSSP1Data__c() ;
        String str='';
       list<EQ_TempSSP1Data__c> listtoupdate1 = new list<EQ_TempSSP1Data__c>();
       list<EQ_TempSSP1Data__c> tempSsp1Recordlist = new list<EQ_TempSSP1Data__c>();
       system.debug(': Heap size is--11 ' + limits.getHeapSize() + ' enforced is ' + limits.getLimitHeapSize());
        if(status=='PegaCallbackStatus.Error')
        {
           for(ErrorTempSSP1Data record:errorTempData.Values())
           {
               str='';
               list<String> listOferrors = record.mapErrors.get(record.Tempdata.id);
               if(listOferrors.size()>0)
               {
                for (integer i = 0; i < listOferrors.size() ;i++)
                    {
                        str=str+record.mapErrors.get(record.Tempdata.id);
                    }
                  
                    if(str!=null)
                    {
                         record.TempData.EQ_Errors__c =str;
                         record.TempData.EQ_ProcessStatus__c ='failure';
                         listtoupdate1.add(record.TempData);
                    }
                }
                
                
           }
            update listtoupdate1;
            
                
           }
  
   
   }


Finish :

global void finish(Database.BatchableContext BC)
   {
       
         status = (count == 0)
                ? 'PegaCallbackStatus.Complete'
                : 'PegaCallbackStatus.Error';
       
       
       validationHelper1.PegaCallbackServiceCall(status,count,workid,errorTempData);
}
 
How to send Case Id,return Type as CSV file in apex class and method functinaulty?
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_system_remoteobjectcontroller.htm

RemoteObjectController
Use RemoteObjectController to access the standard Visualforce Remote Objects operations in your Remote Objects override methods.

RemoteObjectController Methods
The following are methods for RemoteObjectController. All methods are static.
create(type, fields) Create a record in the database.
del(type, recordIds) Delete records from the database.
retrieve(type, fields, criteria) Retrieve records from the database.
updat(type, recordIds, fields) Update records in the database.

retrieve(type, fields, criteria)
Retrieve records from the database.
Signature
public static Map<String,Object> retrieve(String type, List<String> fields, Map<String,Object> criteria)
Parameters
type
Type: String
The sObject type on which retrieve is being called.
fields
Type: List<String>
The fields to retrieve for each record.
criteria
Type: Map<String,Object>
The criteria to use when performing the query.


My question is: How do set the criteria like 'where' and 'orderby' (in the java script below) in the retrieve method for RemoteObjectController
<apex:remoteObjectsjsNamespace="RemoteObjectModel">    
    <apex:remoteObjectModel name="Contact" fields="FirstName,LastName"/>  
</apex:remoteObjects>

<script>
var ct = new RemoteObjectModel.Contact();
ct.retrieve( 
    { where: { 
        FirstName: {eq: 'Marc'}, 
        LastName: {eq: 'Benioff'} 
      }, 
      orderby: [ {LastName: 'ASC'}, {FirstName: 'ASC'} ],
      limit: 1 },  

    function(err, records) { 
        if (err) { 
            alert(err); 
        } else { 
            console.log(records.length); 
            console.log(records[0]); 
        } 
    } 
);
</script>
 
public class TestRemoteActionOverrideController{
    @RemoteAction
    public static Map<String,Object> retrieve(String type, List<String> fields, Map<String, Object> criteria) {
        fields.add('Name');

        //
        // place holder for converting criteria below in java script to apex
        //
        // { where: { 
        // FirstName: {eq: 'Marc'}, 
        // LastName: {eq: 'Benioff'} 
        // }, 
        // orderby: [ {LastName: 'ASC'}, {FirstName: 'ASC'} ],
        // limit: 1 }
        
        // call through to the default remote object controller with our modified field list.
        return RemoteObjectController.retrieve(type, fields, criteria);
    }
}

 
Hello Everyone,

I have observed a wired behavior with "Blob.toPDF(<string>)" Salesforce Apex API's , this method strips off Chinese characters and there is no option to set character encoding, please find below the sample code.


String targetString = 'Before - 測試中文字 - After';

Attachment attachmentPDF = new Attachment();
attachmentPDF.parentId = '<parent record id>';
attachmentPDF.Name = 'Test' + '.pdf';
attachmentPDF.ContentType = 'application/pdf; charset=UTF-8';
attachmentPDF.body = Blob.toPdf(targetString); //This creates the PDF content
insert attachmentPDF;

I have also tried encoding Chinese character content to UTF-8 but this displays all the encoded characters in PDF,

String targetString = 'Before - 測試中文字 - After';
String encodedString = EncodingUtil.urlEncode(targetString,'UTF-8');
System.debug('##encodedString:-'+encodedString);

Attachment attachmentPDF = new Attachment();
attachmentPDF.parentId = '<parent record id>';
attachmentPDF.Name = 'Test' + '.pdf';
attachmentPDF.ContentType = 'application/pdf; charset=UTF-8';
attachmentPDF.body = Blob.toPdf(encodedString); //This creates the PDF content
insert attachmentPDF;

Please help.

Thanks
-Tejas(+91 9663266726)