-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
4Questions
-
5Replies
Getting an EOF Error on Trigger, and Would like to only fire Trigger when Case Subject meets criteria
trigger Populate_Case on Case (before insert) {
}trigger WorkOnStrings on Case (before insert) {
for(Case C:trigger.new){
if(C.Description!='' && C.Description.length()>0){
String data=C.Description;
C. First_Name__c=data.substringBetween('First Name:', 'Last Name:'); // value between the two substrings specified is considered as first name.
C.Last_Name__c=data.substringBetween('Last Name:', 'Email:');
C.Email__c=data.substringBetween('Email:', 'Phone:');
// Add your other fields
}
}
}
}trigger WorkOnStrings on Case (before insert) {
for(Case C:trigger.new){
if(C.Description!='' && C.Description.length()>0){
String data=C.Description;
C. First_Name__c=data.substringBetween('First Name:', 'Last Name:'); // value between the two substrings specified is considered as first name.
C.Last_Name__c=data.substringBetween('Last Name:', 'Email:');
C.Email__c=data.substringBetween('Email:', 'Phone:');
// Add your other fields
}
}
}
- Wendy Tanner 11
- February 09, 2020
- Like
- 0
- Continue reading or reply
I have Email to Case set up, Detail coming in to body of email. Need to Parse that Info in to fields in Case. Apex Trigger? Any Examples?
Email to case is set up. Detail comes in to the description:
First Name: xxxxx
Last Name: Test
Email: test@gmail.com
Phone: xxxxxxxx
Country: US
Comment: Last Test!
TextAlertsOptIn: Yes
I ahve Fields for each option and I need to pass the information in to those fields. the format is the same every time.
Any suggestions or examples of how this can be done, Trigger? New to apex and any detail is appreciated.
First Name: xxxxx
Last Name: Test
Email: test@gmail.com
Phone: xxxxxxxx
Country: US
Comment: Last Test!
TextAlertsOptIn: Yes
I ahve Fields for each option and I need to pass the information in to those fields. the format is the same every time.
Any suggestions or examples of how this can be done, Trigger? New to apex and any detail is appreciated.
- Wendy Tanner 11
- February 07, 2020
- Like
- 0
- Continue reading or reply
Test Class for Lead Convert. Unable to push Apex Class to production
Hello! I have an apex class that was working great in sandbox.
Using it in a process builder. Any one doing this, can you provide guidance?
Public class AutoConvertLeads
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
When trying to push to prod, it states i need a test class. Tried the example below and i am not able to get it to work. Any input appreciated. When i run test it says lead already converted?
@isTest
public class TestAutoConvertLeads{
static testMethod void createnewlead() {
User userToCreate = [Select id from user where profile.name='System Administrator' Limit 1];
Test.startTest();
Lead leadToCreate =new Lead();
List<id> Ids= New List<Id>();
leadToCreate.ownerid= userToCreate.id;
leadToCreate.LastName ='Test1';
leadToCreate.LeadSource='Employee Referral';
leadToCreate.Rating='';
leadToCreate.Status='';
insert leadToCreate;
Ids.add(leadToCreate.id);
AutoConvertLeads.LeadAssign(Ids);
Test.stopTest();
}
}
Using it in a process builder. Any one doing this, can you provide guidance?
Public class AutoConvertLeads
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
When trying to push to prod, it states i need a test class. Tried the example below and i am not able to get it to work. Any input appreciated. When i run test it says lead already converted?
@isTest
public class TestAutoConvertLeads{
static testMethod void createnewlead() {
User userToCreate = [Select id from user where profile.name='System Administrator' Limit 1];
Test.startTest();
Lead leadToCreate =new Lead();
List<id> Ids= New List<Id>();
leadToCreate.ownerid= userToCreate.id;
leadToCreate.LastName ='Test1';
leadToCreate.LeadSource='Employee Referral';
leadToCreate.Rating='';
leadToCreate.Status='';
insert leadToCreate;
Ids.add(leadToCreate.id);
AutoConvertLeads.LeadAssign(Ids);
Test.stopTest();
}
}
- Wendy Tanner 11
- January 31, 2020
- Like
- 0
- Continue reading or reply
SHOW A WEB TO LEAD FORM ON VISUAL FORCE PAGE
I AM trying to just take my web to lead form and make it a component on a home page.
I think I am close but keep getting errors.
Latest Errors are :
Error: New_Lead_Submit2 line 107, column 3: The element type "br" must be terminated by the matching end-tag "</br>"
Error: The element type "br" must be terminated by the matching end-tag "</br>".
Code so far...
apex:page>
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <META> element to your page <HEAD>. -->
<!-- If necessary, please modify the charset parameter to specify the -->
<!-- character set of your HTML page. -->
<!-- ---------------------------------------------------------------------- -->
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type="hidden" name="oid" value="00DP00000003qyC"/>
<input type="hidden" name="retURL" value="http://"/>
<!-- ---------------------------------------------------------------------- -->
<!-- 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="wendy.tanner@rollick.io"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
Mobile Phone:<input id="00NP0000003FU6P" maxlength="40" name="00NP0000003FU6P" onkeydown="formatPhoneOnEnter(this, event);" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
<label for="state">State/Province</label><input id="state" maxlength="20" name="state" size="20" type="text" /><br>
Trade In?:<select id="00NP0000003FUzf" name="00NP0000003FUzf" title="Trade In?"><option value="">--None--</option><option value="Yes">Yes</option>
<option value="No">No</option>
</select><br>
Vehicle Year:<select id="00NP0000003FM3U" name="00NP0000003FM3U" title="Vehicle Year"><option value="">--None--</option><option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
</select><br>
Vehicle Make:<select id="00NP0000003FM3Z" name="00NP0000003FM3Z" title="Vehicle Make"><option value="">--None--</option><option value="Acura">Acura</option>
<option value="Alfa Romeo">Alfa Romeo</option>
<option value="Aston Martin">Aston Martin</option>
<option value="Audi">Audi</option>
<option value="Bentley">Bentley</option>
<option value="BMW">BMW</option>
<option value="Bugati">Bugati</option>
<option value="Buick">Buick</option>
<option value="Cadillac">Cadillac</option>
<option value="Chevrolet">Chevrolet</option>
<option value="Chrysler">Chrysler</option>
<option value="Dodge">Dodge</option>
<option value="Ferrari">Ferrari</option>
<option value="Fiat">Fiat</option>
<option value="Ford">Ford</option>
<option value="General Motors">General Motors</option>
<option value="GMC">GMC</option>
<option value="Honda">Honda</option>
<option value="Hyundai">Hyundai</option>
<option value="Infiniti">Infiniti</option>
<option value="Jaguar">Jaguar</option>
<option value="Jeep">Jeep</option>
<option value="Kia">Kia</option>
<option value="Lamborghini">Lamborghini</option>
<option value="Land Rover">Land Rover</option>
<option value="Lexus">Lexus</option>
<option value="Maserati">Maserati</option>
<option value="Mazda">Mazda</option>
<option value="McClaren">McClaren</option>
<option value="Mercedes-Benz">Mercedes-Benz</option>
<option value="Mini">Mini</option>
<option value="Porsche">Porsche</option>
<option value="Ram">Ram</option>
<option value="Subaru">Subaru</option>
<option value="Suzuki">Suzuki</option>
<option value="Tesla">Tesla</option>
<option value="Toyota">Toyota</option>
<option value="Volkswagen">Volkswagen</option>
<option value="Volvo">Volvo</option>
</select><br>
Vehicle Model:<input id="00NP0000003FM3e" maxlength="255" name="00NP0000003FM3e" size="20" type="text" /><br>
Time to Purchase:<select id="00NP0000003FM3y" name="00NP0000003FM3y" title="Time to Purchase"><option value="">--None--</option><option value="As soon as Possible">As soon as Possible</option>
<option value="1 to 3 months">1 to 3 months</option>
<option value="3_to_6_months">3 to 6 Months</option>
<option value="9 to 12 Months">9 to 12 Months</option>
<option value="Not Sure">Not Sure</option>
</select><br>
<label for="zip">Zip</label><input id="zip" maxlength="20" name="zip" size="20" type="text" /><br>
Create Opportunity:<input id="00NP0000003FTk8" name="00NP0000003FTk8" type="checkbox" value="1" /><br>
<input type="submit" name="submit"/>
</form>
</apex:page>
I think I am close but keep getting errors.
Latest Errors are :
Error: New_Lead_Submit2 line 107, column 3: The element type "br" must be terminated by the matching end-tag "</br>"
Error: The element type "br" must be terminated by the matching end-tag "</br>".
Code so far...
apex:page>
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <META> element to your page <HEAD>. -->
<!-- If necessary, please modify the charset parameter to specify the -->
<!-- character set of your HTML page. -->
<!-- ---------------------------------------------------------------------- -->
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type="hidden" name="oid" value="00DP00000003qyC"/>
<input type="hidden" name="retURL" value="http://"/>
<!-- ---------------------------------------------------------------------- -->
<!-- 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="wendy.tanner@rollick.io"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
Mobile Phone:<input id="00NP0000003FU6P" maxlength="40" name="00NP0000003FU6P" onkeydown="formatPhoneOnEnter(this, event);" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
<label for="state">State/Province</label><input id="state" maxlength="20" name="state" size="20" type="text" /><br>
Trade In?:<select id="00NP0000003FUzf" name="00NP0000003FUzf" title="Trade In?"><option value="">--None--</option><option value="Yes">Yes</option>
<option value="No">No</option>
</select><br>
Vehicle Year:<select id="00NP0000003FM3U" name="00NP0000003FM3U" title="Vehicle Year"><option value="">--None--</option><option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
</select><br>
Vehicle Make:<select id="00NP0000003FM3Z" name="00NP0000003FM3Z" title="Vehicle Make"><option value="">--None--</option><option value="Acura">Acura</option>
<option value="Alfa Romeo">Alfa Romeo</option>
<option value="Aston Martin">Aston Martin</option>
<option value="Audi">Audi</option>
<option value="Bentley">Bentley</option>
<option value="BMW">BMW</option>
<option value="Bugati">Bugati</option>
<option value="Buick">Buick</option>
<option value="Cadillac">Cadillac</option>
<option value="Chevrolet">Chevrolet</option>
<option value="Chrysler">Chrysler</option>
<option value="Dodge">Dodge</option>
<option value="Ferrari">Ferrari</option>
<option value="Fiat">Fiat</option>
<option value="Ford">Ford</option>
<option value="General Motors">General Motors</option>
<option value="GMC">GMC</option>
<option value="Honda">Honda</option>
<option value="Hyundai">Hyundai</option>
<option value="Infiniti">Infiniti</option>
<option value="Jaguar">Jaguar</option>
<option value="Jeep">Jeep</option>
<option value="Kia">Kia</option>
<option value="Lamborghini">Lamborghini</option>
<option value="Land Rover">Land Rover</option>
<option value="Lexus">Lexus</option>
<option value="Maserati">Maserati</option>
<option value="Mazda">Mazda</option>
<option value="McClaren">McClaren</option>
<option value="Mercedes-Benz">Mercedes-Benz</option>
<option value="Mini">Mini</option>
<option value="Porsche">Porsche</option>
<option value="Ram">Ram</option>
<option value="Subaru">Subaru</option>
<option value="Suzuki">Suzuki</option>
<option value="Tesla">Tesla</option>
<option value="Toyota">Toyota</option>
<option value="Volkswagen">Volkswagen</option>
<option value="Volvo">Volvo</option>
</select><br>
Vehicle Model:<input id="00NP0000003FM3e" maxlength="255" name="00NP0000003FM3e" size="20" type="text" /><br>
Time to Purchase:<select id="00NP0000003FM3y" name="00NP0000003FM3y" title="Time to Purchase"><option value="">--None--</option><option value="As soon as Possible">As soon as Possible</option>
<option value="1 to 3 months">1 to 3 months</option>
<option value="3_to_6_months">3 to 6 Months</option>
<option value="9 to 12 Months">9 to 12 Months</option>
<option value="Not Sure">Not Sure</option>
</select><br>
<label for="zip">Zip</label><input id="zip" maxlength="20" name="zip" size="20" type="text" /><br>
Create Opportunity:<input id="00NP0000003FTk8" name="00NP0000003FTk8" type="checkbox" value="1" /><br>
<input type="submit" name="submit"/>
</form>
</apex:page>
- Wendy Tanner 11
- December 04, 2019
- Like
- 0
- Continue reading or reply
I have Email to Case set up, Detail coming in to body of email. Need to Parse that Info in to fields in Case. Apex Trigger? Any Examples?
Email to case is set up. Detail comes in to the description:
First Name: xxxxx
Last Name: Test
Email: test@gmail.com
Phone: xxxxxxxx
Country: US
Comment: Last Test!
TextAlertsOptIn: Yes
I ahve Fields for each option and I need to pass the information in to those fields. the format is the same every time.
Any suggestions or examples of how this can be done, Trigger? New to apex and any detail is appreciated.
First Name: xxxxx
Last Name: Test
Email: test@gmail.com
Phone: xxxxxxxx
Country: US
Comment: Last Test!
TextAlertsOptIn: Yes
I ahve Fields for each option and I need to pass the information in to those fields. the format is the same every time.
Any suggestions or examples of how this can be done, Trigger? New to apex and any detail is appreciated.
- Wendy Tanner 11
- February 07, 2020
- Like
- 0
- Continue reading or reply
Test Class for Lead Convert. Unable to push Apex Class to production
Hello! I have an apex class that was working great in sandbox.
Using it in a process builder. Any one doing this, can you provide guidance?
Public class AutoConvertLeads
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
When trying to push to prod, it states i need a test class. Tried the example below and i am not able to get it to work. Any input appreciated. When i run test it says lead already converted?
@isTest
public class TestAutoConvertLeads{
static testMethod void createnewlead() {
User userToCreate = [Select id from user where profile.name='System Administrator' Limit 1];
Test.startTest();
Lead leadToCreate =new Lead();
List<id> Ids= New List<Id>();
leadToCreate.ownerid= userToCreate.id;
leadToCreate.LastName ='Test1';
leadToCreate.LeadSource='Employee Referral';
leadToCreate.Rating='';
leadToCreate.Status='';
insert leadToCreate;
Ids.add(leadToCreate.id);
AutoConvertLeads.LeadAssign(Ids);
Test.stopTest();
}
}
Using it in a process builder. Any one doing this, can you provide guidance?
Public class AutoConvertLeads
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
When trying to push to prod, it states i need a test class. Tried the example below and i am not able to get it to work. Any input appreciated. When i run test it says lead already converted?
@isTest
public class TestAutoConvertLeads{
static testMethod void createnewlead() {
User userToCreate = [Select id from user where profile.name='System Administrator' Limit 1];
Test.startTest();
Lead leadToCreate =new Lead();
List<id> Ids= New List<Id>();
leadToCreate.ownerid= userToCreate.id;
leadToCreate.LastName ='Test1';
leadToCreate.LeadSource='Employee Referral';
leadToCreate.Rating='';
leadToCreate.Status='';
insert leadToCreate;
Ids.add(leadToCreate.id);
AutoConvertLeads.LeadAssign(Ids);
Test.stopTest();
}
}
- Wendy Tanner 11
- January 31, 2020
- Like
- 0
- Continue reading or reply