- Arthur Lockrem
- NEWBIE
- 150 Points
- Member since 2012
- ProCore Resources
-
ChatterFeed
-
5Best Answers
-
0Likes Received
-
0Likes Given
-
2Questions
-
20Replies
Deployment Unit Tests cause autonumber on case to increment
This means that we now have big gaps in the numbers in our production environment..
Can anyone please confirm whether this is what is probably happening and if so is there anyway to stop it?
Thanks,
- GC_00001
- October 29, 2014
- Like
- 0
- Continue reading or reply
Populate values in Child records with information from parent records.
A client of mine is trying to send out an email template from an object that lookups to another. I need to pull all of the information down to the children to send off multiple email alerts with all of the information on the parent. There are more than 15 fields that I need to populate in the child record from the parent so formula fields are out of the question along with field updates. Does anybody have some code or know how to create a trigger that basically triggers an update to a child record when the parent is saved? I also need the fields to populate at the time of the save so when the workflow rule triggers to send out the email alert we have all of the information that we need.
The objects are Work Order and ServiceMax Event. The ServiceMax Event object is the child to the Work Order object. ServiceMax Events are created when dispatching Work Orders to technicians and each technician is associated to a ServiceMax Event, but only one is associated directly to the Work Order. We need an email alert to trigger to each technician upon confirmation, but only one is directly related to the Work Order. So, when confirming the work order I need a trigger to edit all of the children to bring over the information on the Work Order object to the ServiceMax Event records that are related and upon the save an email alert will go out to each of them.
Does anyone know a way to do this? Please help!
- Scott.Bub
- October 29, 2014
- Like
- 0
- Continue reading or reply
User ID convert to Username in Trigger
Can you guys help on my simple trigger experiment please. What I am trying to do is to find the name of the UserID.
I have object (TestObject__c) and Fields (txtField__c, WhoUser__c).
My goal is to return the name of the UserID that is in the txtField under my TestObject. Say for example, my user is Bob and his user ID is 0053000000AtjAhAAJ.
So, if the txtField value is 0053000000AtjAhAAJ, the WhoUser field will return Bob when I save the Record.
I've tried experimenting on this but it seems my codes does not make any sense.. I'm always getting that "Unexpected Token" error when trying to query.. (I'm still learning the syntax though) :D
Thanks a lot!
- Irvine Delacroix
- October 29, 2014
- Like
- 0
- Continue reading or reply
Custom Account update button on contacts
<apex:page StandardController="Contact" recordSetVar="contacts">
<apex:form >
<apex:pageblock >
<apex:inputText value="{!Contact.AccountId}"/>
</apex:pageblock>
<apex:pageBlock >
<apex:pageBlockTable value="{!selected}" var="c">
<apex:column value="{!c.firstname}"/>
<apex:column value="{!c.lastname}"/>
<apex:column value="{!c.Account.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
- Mallik Vemugunta
- October 28, 2014
- Like
- 0
- Continue reading or reply
Pick field names from custom setting
List<Field_Name__c> mycustomsetting = Field_Name__c.getAll().values();
system.debug('List of custom setting' + mycustomsetting.size());
List<contact> mycontacts = [select id, name,birthdate, Languages__c, Level__c from contact];
string fieldname = '';
for(contact Con : mycontacts)
{
for(integer i=0; i<mycustomsetting.size();i++)
{
system.debug(i+ ' :custom setting : ' + mycustomsetting[i].Field__c);
fieldname = mycustomsetting[i].Field__c;
Con. + fieldname = null; - This is what i'm trying to do but it does not works
Con.birthdate = null; -- This is what needs to be done via custom setting
}
update Con;
}
I have created custom setting as "Field_Name__c" and this contains field as "Field__c" which contains contact field API names.
Any help will be appreciated
- Sunny Mohla
- October 27, 2014
- Like
- 0
- Continue reading or reply
Code coverage is frozen
- I have added additional methods to my utility class and test methods to one of my test classes. The test method is never executed, and the utility method is ignored. The number of lines tested does not reflect the presence of the new method. When I review the results in Developer Console, the method is there, and not highlighted at all. (see code below)
- A different class has been greatly reduced. It changed from 258 lines of code to 16. The code coverage still shows 258 lines, with 88 lines untested, even though the file only has 16 lines of code. Same as the previously stated method, the Developer Console summary shows 258 lines of code, while the details of the class show only the 16 lines available.
Example of newly added methods not reflected in test coverage.
In utility class:
public static String getTestResults(String origValue) { String a = origValue; String b = a; return b; }
In test class:
testMethod static void testTestResults() { String a = Utility.getTestResults('Test'); System.assertEquals(a, 'Test'); }
- Arthur Lockrem
- January 05, 2015
- Like
- 0
- Continue reading or reply
Passing a generic SObject to a SOAP web service via Ajax Toolkit
I need the ability to pass a generic SObject to a SOAP web service. When I specify the SObject type (ie. Account) it works fine.
The following works:
webService static String testUpsert(Account o) { try { upsert o; return o.Id; } catch (Exception e) { return e.getMessage(); } }
When I change it to an SObject it fails. In fact, it acts like the method doesn't exist (nothing gets returned).
The following does not work:
webService static String testUpsert(SObject o) { try { upsert o; return o.Id; } catch (Exception e) { return e.getMessage(); } }
Here is the JavaScript code I'm using to execute the SOAP methods.
function doTest() { sforce.connection.init("{!$API.Session_ID}"); var acc = new sforce.SObject("Account"); acc.Name = "a - JS Test Account 1"; var result = sforce.apex.execute("ws_Test", "testUpsert", {o:acc}); alert('result - ' + result); }
Any help is appreciated.
- Arthur Lockrem
- July 19, 2012
- Like
- 0
- Continue reading or reply
Code coverage is frozen
- I have added additional methods to my utility class and test methods to one of my test classes. The test method is never executed, and the utility method is ignored. The number of lines tested does not reflect the presence of the new method. When I review the results in Developer Console, the method is there, and not highlighted at all. (see code below)
- A different class has been greatly reduced. It changed from 258 lines of code to 16. The code coverage still shows 258 lines, with 88 lines untested, even though the file only has 16 lines of code. Same as the previously stated method, the Developer Console summary shows 258 lines of code, while the details of the class show only the 16 lines available.
Example of newly added methods not reflected in test coverage.
In utility class:
public static String getTestResults(String origValue) { String a = origValue; String b = a; return b; }
In test class:
testMethod static void testTestResults() { String a = Utility.getTestResults('Test'); System.assertEquals(a, 'Test'); }
- Arthur Lockrem
- January 05, 2015
- Like
- 0
- Continue reading or reply
Test class for a simple trigger
My Trigger:
trigger ArticleFeedbackAfterTrigger on Article_Feedback__c (after insert, after update) {
List<FeedItem> lstFeeds = new List<FeedItem>();
for(Article_Feedback__c af : Trigger.new) {
FeedItem fi = new FeedItem();
fi.Type = 'TextPost';
fi.Title= af.Name;
fi.ParentId = af.Article_ID__c;
fi.Body = af.Comments__c;
fi.CreatedById=af.CreatedById;
lstFeeds.add(fi);
}
if(lstFeeds.size() > 0) { insert lstFeeds; }
}
My Test Class:
@isTest
private class ArticleFeedbackTrigger_test {
static testmethod void test_trigger(){
Article_Feedback__c af =new Article_Feedback__c(Article_ID__c='kac236789045672000',Comments__c='Body for the feed');
//insert af;
List<FeedItem> lstFeeds = new List<FeedItem>();
FeedItem fi = new FeedItem();
fi.Type = 'TextPost';
fi.Title= 'test article';
//fi.ParentId = af.Article_ID__c;
fi.Body = af.Comments__c;
//Name='test_article',,CreatedById='kac895643289456000'
lstFeeds.add(fi);
system.assertEquals(fi.Body ,'Body for the feed');
}
}
- rebvijkum
- October 29, 2014
- Like
- 0
- Continue reading or reply
Deployment Unit Tests cause autonumber on case to increment
This means that we now have big gaps in the numbers in our production environment..
Can anyone please confirm whether this is what is probably happening and if so is there anyway to stop it?
Thanks,
- GC_00001
- October 29, 2014
- Like
- 0
- Continue reading or reply
Populate values in Child records with information from parent records.
A client of mine is trying to send out an email template from an object that lookups to another. I need to pull all of the information down to the children to send off multiple email alerts with all of the information on the parent. There are more than 15 fields that I need to populate in the child record from the parent so formula fields are out of the question along with field updates. Does anybody have some code or know how to create a trigger that basically triggers an update to a child record when the parent is saved? I also need the fields to populate at the time of the save so when the workflow rule triggers to send out the email alert we have all of the information that we need.
The objects are Work Order and ServiceMax Event. The ServiceMax Event object is the child to the Work Order object. ServiceMax Events are created when dispatching Work Orders to technicians and each technician is associated to a ServiceMax Event, but only one is associated directly to the Work Order. We need an email alert to trigger to each technician upon confirmation, but only one is directly related to the Work Order. So, when confirming the work order I need a trigger to edit all of the children to bring over the information on the Work Order object to the ServiceMax Event records that are related and upon the save an email alert will go out to each of them.
Does anyone know a way to do this? Please help!
- Scott.Bub
- October 29, 2014
- Like
- 0
- Continue reading or reply
User ID convert to Username in Trigger
Can you guys help on my simple trigger experiment please. What I am trying to do is to find the name of the UserID.
I have object (TestObject__c) and Fields (txtField__c, WhoUser__c).
My goal is to return the name of the UserID that is in the txtField under my TestObject. Say for example, my user is Bob and his user ID is 0053000000AtjAhAAJ.
So, if the txtField value is 0053000000AtjAhAAJ, the WhoUser field will return Bob when I save the Record.
I've tried experimenting on this but it seems my codes does not make any sense.. I'm always getting that "Unexpected Token" error when trying to query.. (I'm still learning the syntax though) :D
Thanks a lot!
- Irvine Delacroix
- October 29, 2014
- Like
- 0
- Continue reading or reply
18 Digit ID to Data
We are trying to integrate SFDC with our system and while trying to fetch an information from a field in SFDC through API , the values are getting fetched in 18 digits instead of hte actual name.
The filed which we are trying is called as Projects which should have names like RBC , Royal Bank of Scotland etc but it shows like this 006w000000XweAaAAJ ( 18 digits) in my application instead of the actual data.
How do we get this sorted.
Kindly help.
- Meetesh Jain
- October 29, 2014
- Like
- 0
- Continue reading or reply
Before Trigger Referencing Custom Setting Not Updating Properly
When I run my trigger, the bolded system.debug show that the Contact Owner values is being set correctly (i.e. the User Id is the User Id mapped to the Billing Country in the Custom Setting), but the field is ulitmately not updated with the correct User Id. Based on field history tracking, it does not look like its being updated at all.
Am I missing something on this trigger?
trigger AssignContact on Contact (before insert, before update) {
Set<String> accountSet = new Set<String>();
Set<Id> contactIdSet = new Set<Id>();
List<Lead_Assignment__c> lstBillingOwner = [Select ID,Country__c, New_Owner_ID__c FROM Lead_Assignment__c];
Map<String,String> mpCountryOwner = new Map<String,String>();
for(Lead_Assignment__c l1 : lstBillingOwner) {
mpCountryOwner.put(l1.Country__c, l1.New_Owner_ID__c);
}
Map<Id,User> mpUser = new Map<Id,User>([Select ID FROM User Where ID IN :mpCountryOwner.values()]);
Set<Id> accIds = new Set<Id>();
for(Contact con : trigger.new){
accIds.add(con.AccountId);
}
Map<Id,Account> mpAcc = new Map<Id,Account>([Select ID, Name, BillingCountry FROM Account Where ID IN :accIds]);
for(Contact con : trigger.new){
Account act = mpAcc.get(con.AccountId);
if(con.AccountId != null && act.BillingCountry != null){
if(mpCountryOwner.get(act.BillingCountry) != null){
con.owner = mpUser.get(mpCountryOwner.get(act.BillingCountry) );
System.debug('***** - Updating Owner - New Owner - '+con.owner);
}
}
}
}
- Marie Kagay
- October 28, 2014
- Like
- 0
- Continue reading or reply
View Google Site from Tab
Thanks
- Jack Volkov
- October 28, 2014
- Like
- 0
- Continue reading or reply
Custom Account update button on contacts
<apex:page StandardController="Contact" recordSetVar="contacts">
<apex:form >
<apex:pageblock >
<apex:inputText value="{!Contact.AccountId}"/>
</apex:pageblock>
<apex:pageBlock >
<apex:pageBlockTable value="{!selected}" var="c">
<apex:column value="{!c.firstname}"/>
<apex:column value="{!c.lastname}"/>
<apex:column value="{!c.Account.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
- Mallik Vemugunta
- October 28, 2014
- Like
- 0
- Continue reading or reply
Pick field names from custom setting
List<Field_Name__c> mycustomsetting = Field_Name__c.getAll().values();
system.debug('List of custom setting' + mycustomsetting.size());
List<contact> mycontacts = [select id, name,birthdate, Languages__c, Level__c from contact];
string fieldname = '';
for(contact Con : mycontacts)
{
for(integer i=0; i<mycustomsetting.size();i++)
{
system.debug(i+ ' :custom setting : ' + mycustomsetting[i].Field__c);
fieldname = mycustomsetting[i].Field__c;
Con. + fieldname = null; - This is what i'm trying to do but it does not works
Con.birthdate = null; -- This is what needs to be done via custom setting
}
update Con;
}
I have created custom setting as "Field_Name__c" and this contains field as "Field__c" which contains contact field API names.
Any help will be appreciated
- Sunny Mohla
- October 27, 2014
- Like
- 0
- Continue reading or reply
AsyncApexExecutions Limit exceeded error for my batch apex on custom object.
I wrote a batch apex that selects all the records from updated events object. When ever this batch apex is scheduled it throwing the forrlowing error:
AsyncApexExecutions Limit exceeded.
Following is my batch apex code.
global class SyncCalendarsUpdates implements Database.Batchable<sObject>, Database.AllowsCallouts {
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT Id, Event_ID__c, Description__c, Event_Owner__r.Id, Subject__c, Start_Datetime__c, End_Datetime__c, Click_Key__c FROM Updated_Event__c';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Updated_Event__c> scope) {
Map<String, String> clickKeyMap = new Map<String, String>();
for (Updated_Event__c e : scope) {
Boolean doUpdate = true;
if (e.Subject__c != null) {
if (e.Subject__c.left(2) == 'SV' && e.Click_Key__c != null && e.Click_Key__c != '') {
doUpdate = false;
}
}
if (doUpdate) {
ClickCalendar cal = new ClickCalendar(e.Event_Owner__r.Id, e.Start_Datetime__c, e.End_Datetime__c, e.Subject__c, e.Click_Key__c);
cal.buildUpdateRequest();
if (!Test.isRunningTest()) {
HttpResponse resp = cal.getResponse();
if (e.Click_Key__c == null) {
String key = cal.getKeyFromResponse(resp);
if (e.Event_ID__c != null) {
clickKeyMap.put(e.Event_ID__c, key);
}
}
}
}
e.Is_Synced__c = true;
}
update scope;
List<Event> eventsToUpdate = [SELECT Id, Click_Key__c FROM Event WHERE Id IN :clickKeyMap.keySet()];
for (Event e : eventsToUpdate) {
e.Click_Key__c = clickKeyMap.get(e.Id);
}
update eventsToUpdate;
}
global void finish(Database.BatchableContext BC) { }
}
We have 1,500,000 records in that object.
- Vishnu Yadavalli
- October 17, 2013
- Like
- 0
- Continue reading or reply