You need to sign in to do that
Don't have an account?
AArza
Method does not exist or incorrect signature: void replace(String, Datetime) from the type String
Error: Method does not exist or incorrect signature: void replace(String, Datetime) from the type String
also, i noticed that even when i comment out the this line of code it is still returning the same error. please suggest.
also, i noticed that even when i comment out the this line of code it is still returning the same error. please suggest.
for(ContentDocumentLink clIterator : trigger.new) { string strObjPrefix = String.valueOf(clIterator.LinkedEntityId).substring(0, 3); if(strObjPrefix == Appointment__c.sObjectType.getDescribe().getKeyPrefix()) { setCntDocIds.add(clIterator.ContentDocumentId); setAccIds.add(clIterator.LinkedEntityId); //Id str =setAccIds[0]; Set<Id> str = new set<Id>(setAccIds); Appointment__c app= [select id from Appointment__c where id =:str limit 1] ; system.debug('Email Body');//debug appointment string filename =filestitlemaps.get(clIterator.ContentDocumentId); string accountname = accnamemaps.get(clIterator.LinkedEntityId); Set<String> KeywordSet = new Set<String>(); Program_Setting__mdt[] programs = [SELECT Email_Body__c, Keyword__c, Keyword1__c FROM Program_Setting__mdt]; //if(filename.containsAny(programs[0].Keyword__c)){ if((programs[0].keyword__c).containsAny(Filename)){ Contact c = [Select id, name from contact where name='Ultragenyx PV']; // List<string> toAddress = new List<string>(); // toAddress.add('iamaarza@gmail.com'); EmailTemplate emailTemplate = [select Id, Subject, HtmlValue, Body from EmailTemplate where Id ='00X0i000000PGf1']; String subject = emailTemplate.Subject; //query appointment record pass values to replace the merge fields String plainBody = emailTemplate.Body; plainBody = plainBody.replace('{!app.Name}', app.Name); string s = string.valueOfGmt(app.Appointment_Start_Date__c); //plainBody = plainBody.replace('{!app.Appointment_Start_Date__c}', app.Appointment_Start_Date__c); plainBody = plainBody.replace('{!app.Appointment_Start_Date__c}', s); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTemplateId('00X0i000000PGf1'); // mail.setToAddresses(toAddress); //mail.setSubject('test subject'); mail.setTargetObjectId(c.Id); //mail.setWhatId(c.Id); mail.setSaveAsActivity(false); mail.setUseSignature(false); List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>(); allmsg.add(mail); } } } }
Your error says "incorrect signature: void replace(String, Datetime)" notice that the second parameter is the "DateTime" here which i don`t see any where in your code except the line 35 which you have commented. The line 36 has string as the parameter so i don`t think the error is in line 36.
Please try to save the code once again and then try to run it as i don`t see this error anywhere in the code.
All Answers
The issue is encountering due to the following line:
Here you are replacing DateTime value with a String value.
Instead of the above line, you can use: Hope this will help you. If does then please mark it as best answer so it can also help others.
Many Thanks,
Sunil Rathore
Your error says "incorrect signature: void replace(String, Datetime)" notice that the second parameter is the "DateTime" here which i don`t see any where in your code except the line 35 which you have commented. The line 36 has string as the parameter so i don`t think the error is in line 36.
Please try to save the code once again and then try to run it as i don`t see this error anywhere in the code.
Error: There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger sfdctest caused an unexpected exception, contact your administrator: sfdctest: execution of BeforeInsert caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Appointment__c.Name: Trigger.sfdctest: line 54, column 1".
line 54:
plainBody = plainBody.replace('{!app.Name}', app.Name);
string s = string.valueOfGmt(app.Appointment_Start_Date__c);
//plainBody = plainBody.replace('{!app.Appointment_Start_Date__c}', app.Appointment_Start_Date__c);
plainBody = plainBody.replace('{!app.Appointment_Start_Date__c}', s);
Any idea What the error means.
You are using the fields of Appointment without retrieving in the query.
Replace the query
with the following query:
Let me know if it solves your problem.
Many Thanks,
Sunil Rathore
This error occurs when you try to use Sobject Fields without retrieving it in your query.
In your case you have used "app.Name" and "app.Appointment_Start_Date__c " without retrieving it in your query.
if you just put these fields in your query then it should work. Hope this helps. Do let me know if you have any further queries.
P.S: Please marks this as the best answer if this helped.
Regards
Shubham Kumar