July 15, 2014
So how’s everyone doing on their journey to become a Salesforce developer by the end of Summer?
You should be at least on Chapter 5 to stay on track!
If you’re not there yet, there’s still time to catch up! Spend an extra hour or two per week and you’ll be right back on top of things!
Running into any difficulties? Write a comment and I’ll help you out!

David
Hi David,
Hope you are doing well.
Case: I have written a trigger for which code coverage is 87% in sandbox and also i have successfully deployed the trigger and its test class into the production.
Issue: After the deployment trigger shows the 0% code coverage. I have tried few things to rectify the possible error(whatever!) but unsuccessfully.
Trigger code:
/* Purpose: This trigger will fire when user creates a new Distribution Product
* create:Distribution Product Request of “Check out Request” Record type for the product
* Update “WebDPR field as checked under Distribution Product Request
* Developed by : Gaurav Rao
* Development Date: 02 July 2014 */
trigger CreateDPR on Distribution_Product__c (after insert) {
List DPR = new list();
List rtypes = [Select id, Name, DeveloperName from RecordType where DeveloperName=’Check_Out_Request’];
For (Distribution_Product__c newDP: trigger.New)
{
if(newDP.Name !=null)
{
DPR.add(new Report_Copy_Request__c(
RecordTypeId=rtypes[0].Id,
Distribution_Product__c=newDP.Id,
webDPR__c =True));
}
}
try {
insert DPR;
} catch (Exception e) {
System.debug(‘An error happened, as predicted!’);
}
}
Test Class code:
@isTest
public class TestCreateDPR {
//List DPR = new List();
//List RT = [Select Id, Name, DeveloperName from RecordType where DeveloperName=’Check_Out_Request’];
static testMethod void CreateDP()
{
Dissemination_Project__c Baap = new Dissemination_Project__c(Name = ‘test1’, Themes__c = ‘CSR’);
insert Baap;
//List Rtype = New List([Select Id,Name,DeveloperName,Description From RecordType where SobjectType =’Research_Project__c’ and DeveloperName = ‘Research_Project’]);
Research_Project__c ResP = new Research_Project__c(Name = ‘Kuch bhi’, Related_Dissemination_Project__c = Baap.Id);
//RecordTypeId =Rtype[0].Id,
insert ResP;
Distribution_Product__c DP = new Distribution_Product__c(Name = ‘test_distribution product’, Dissemination_Project__c = Baap.Id, Research_Project__c = ResP.Id, Product_Type__c = ‘Vers’);
//DP.Product_Type__c=’Report’;
insert DP;
}
}
Can you please help me on this issue?
Thanks,
Ankit
An error is happening in your test class before the record gets inserted =) Try adding System.debug() lines to find out why!
Hi David,
Thank you, thank you, thank you for building this site! I am a SF admin and I’ve been wanting to learn code for a while now and after months of searching I stumbled across your site! Yay! I ordered Head First Java today and started listening to the webinars for the summer series you’re doing.
I just set up my developer org and ran into snag. I am running SF Enterprise with the nonprofit starter pack. I was trying to test the simple trigger ForceForecasting trigger on the User object, only there is no User object in my Dev Org. Please advise?
Try a fresh dev org by signing up here:
https://developer.salesforce.com/en/signup?d=70130000000td6N
Non-profit orgs don’t have access to code unfortunately!
Hi David
I am having issues with Regex on apex.
I am trying to have a method to dynamically replace place holders in a string, example of placeholder : [COW_NAME] and an example of string(message) :
“Cow [COW_NAME] Signs of heat: Check cows vulva for clear discharge and change of colour of vulva lips from pink to red. Check every day of heat week.”
My first issue was that even if I found a match instead of having the placeholder replaced by a cow name, the whole string would get replaced.
the first Regex: \\b.*[COW_NAME]\\b.*
the second rege: \\[COW_NAME\\] didn’t work no match was found at all.
I have only used Regex on Javascript a few times.
Method below:
public String replacePromptPlaceholder(ServiceData serviceData) {
String livestockValue;
String replacedMessage = serviceData.message;
if (serviceData.hasAPromptThatRequiresSubstitution()) {
String message = serviceData.message;
List promptTemplateMatcherList = getPromptTemplateMatchers();
if (promptTemplateMatcherList != null) {
for (Template_Matcher__c promptTemplate : promptTemplateMatcherList) {
Pattern regexPattern = Pattern.compile(promptTemplate.Prompt_Regex__c);
Matcher regexMatcher = regexPattern.matcher(message);
if (regexMatcher.matches() == true) {
livestockValue = getLivestockPlaceholderValue(promptTemplate, serviceData.livestock);
replacedMessage = message.replaceAll(promptTemplate.Prompt_Regex__c, livestockValue);
}
}
}
}
return replacedMessage;
}
private static String getLivestockPlaceholderValue(Template_Matcher__c template, Livestock__c livestock ) {
String livestockFieldValue = null;
Object value = livestock.get(template.Field_Name__c);
if (value != null) {
livestockFieldValue = String.valueOf(value);
}
return livestockFieldValue;
}
Please help and thanks for your time.
hahaha Regex is a whole other story! Luckily it’s not Apex specific so you can find a lot of info on that stuff online. I definitely don’t know enough to help you out, sorry!!
Hey David!
I am new to Apex and Salesforce. I am trying to “embed” Vimeo videos in a Salesforce custom object. I want the video to show on the object and be able to be streamed for Magentrix portal users. I need it to be dynamic, so that I can create a new record or instance of the object for each different video.
I have been able to do it for a Youtube video but I haven’t figured out the Vimeo video. I have a custom object (YouTube_Player__c) with a custom field for inputting the various video IDs (YouTube_Video__c). I created a Visualforce page with code to dynamically call upon the video ID from the YouTube_Video__c field. The VF page can then be put in the page layout for the custom object (Vimeo_Player__c) which allows me to “embed” the video on the object.
Here is the VF page code that works for the Youtube video:
The video id goes in each instance of the object in the YouTube_Video__c text field. This one works showing the video there on the instance of the object.
The Vimeo one hasn’t been working with many variations attempted.
I also tried these variations for the src line of code
Any ideas on how to get these Vimeo videos working with the embed like the You Tube video?
I know that I can use a url field on the object to reference an external site of each video, but I am hoping to be able to embed the video on the object instead.
Thanks for any insights you can give me into this!
The code doesn’t come through in the comments but the main thing is this works as the source for the You Tube and I don’t know what the format for the source should be for the Vimeo videos. src=”https://www.youtube.com/v/{!YouTube_Player__c.YouTube_Video__c}”
I tried apex:flash src=”//video/vimeo.com/{!Vimeo_Player__c.Vimeo_Video__c}” and “https://www.vimeo.com/{!Vimeo_Player__c.Vimeo_Video__c}” I also tried iframe src and apex:iframe src
Try using __r here instead:
Vimeo_Player__r.Vimeo_Video__c
Technically it must be __r there, which is strange because the YouTube version works without the __r. Perhaps it’s just luck!
You can also right click then View Source of the failed widget to see what URL it’s actually pointing to!
Hi David,
You have ben truly inspiring and I look forward to you whenever I need motivation. You are doing a great job to the salesforce community and I truly appreciate it. I have been recommending your blog to many Salesforce enthusiasts.
I am eagerly awaiting you chapters on Visual Force and Integration. Meanwhile any references you could provide on these would be very valuable.
Many Thanks
Janardhanan
=*)
Planning a wedding right now so wayyyy behind on posts!
Hey David,
I just started going through the toturials over the weekend. Right now I’m on chapter 3. So far so good.
Awesome, great progress Dean!
Hey Dave,
Thanks for getting back. Well I have completed till chapter 7 quiz and waiting eagerly for remaining chapters and more videos tutorials and quizzes.
Also please suggest me that which sites or study material should I refer to learn more from the SFDC developer perspective as I am sure that a Salesforce Developer performs several responsibilities other than creating test classes and triggers. After going through all the chapters/videos posted on your site I am falling short of good learning resource and not sure how to proceed further. I am also interested to learn things about Salesforce admin. Please guide.
Nitin I know you’re making great progress!
Take this opportunity to really learn the admin side. Every good developer must be a good admin, which is why DEV 401 covers admin only topics!
Check out these resources if you haven’t already!
https://www.udacity.com/course/ud162
http://www.salesforce.com/us/developer/docs/fundamentals/index_Left.htm#CSHID=adg_app_arch.htm|StartTopic=Content%2Fadg_app_arch.htm|SkinName=webhelp
David
Thanks for your kind & encouraging words David :)
I will surely check out these resources.