• Arthur Lockrem
  • NEWBIE
  • 150 Points
  • Member since 2012
  • ProCore Resources

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 20
    Replies
Having just been doing a number of unit tests whilst deploying various things, it would appear that the autonumber of cases has incrementd in line with the number of dummy cases that would have been temporarily inserted during the tests.

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,
Hello All,

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!
Hello,

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!
I had the below code to display the selected contacts from the account page related list, looks like my !selected is not working, can someone help on this.
<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>
I have a custom setting which saves three field names of lets say contact object. I want to update value of all those fields to null which are store in my custom setting. following is the code that i'm writing.

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
The code coverage in my managed package org is frozen.  No changes I make are reflected in the coverages.  Examples below:

- 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');
}

 

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.

The code coverage in my managed package org is frozen.  No changes I make are reflected in the coverages.  Examples below:

- 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');
}

 
The code coverage is still 0%, even though it is successfull. need some help plz
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');
    }
}
Having just been doing a number of unit tests whilst deploying various things, it would appear that the autonumber of cases has incrementd in line with the number of dummy cases that would have been temporarily inserted during the tests.

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,
Hello All,

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!
Hello,

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!
Hi All,
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.
I'm attempting to set the Contact Owner based on the Account Billing Country using a Custom Setting, Lead_Assignment__c, that maps Country to a User Id. When a Contact is created or updated, the trigger pulls the mapped Country and User Id values from the Custom Setting, finds the Billing Country value from the Account associated with the Contact, and sets the Contact Owner with the User Id that correlates with the Country value that matches the Billing Country.

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);
            }
        }
    }
 }



 
How can a Google Site be viewed from a tab in SFDC?  The goal here is to create a new Tab in SFDC.  Then when a user clicks on that tab an internal Google Site is shown within the page with the sidebar displayed.

Thanks
I had the below code to display the selected contacts from the account page related list, looks like my !selected is not working, can someone help on this.
<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>
I have a custom setting which saves three field names of lets say contact object. I want to update value of all those fields to null which are store in my custom setting. following is the code that i'm writing.

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

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.