• JesseA
  • NEWBIE
  • 105 Points
  • Member since 2010

  • Chatter
    Feed
  • 4
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 47
    Replies

I'm trying to create an 'after update' trigger on a custom object (billing_event__c).

 

It needs to set the value of a lookup field (Account) on the billing event whenever the billing event is updated. The twist is that the Account field needs to be set to the same Account that another lookup field on the billing event object is already pointing to.   For example, the billing event has a lookup to a project called 'Project X'. If you look at Project X, it has a lookup to an Account called 'ABC Company'. I need to set the Acocunt field on the billing event object to 'ABC Company' whenever the billing event is updated.

 

Here's what I wrote, but it is not working. As I'm new at this, I'm obviously doing something wrong:

 

trigger BE_Trigger on pse__Billing_Event__c (before update) {

pse__Billing_Event__c myBillingEvent = trigger.old[0];

myBillingEvent.Account__c = myBillingEvent.pse__Project__r.pse__Account__c;

update myBillingEvent;

}

 

Any ideas ?

 

Thanks,

Darrell

Have a public site whose actions I would like to, through a trigger, create a chatter post. I know people have come to this issue before, i'm looking for good workarounds.

The first one I think of is having a batch to find the record of something the site user can update and having that batch schedule itself at the end. But I've seen this get very messy. The list of scheduled jobs gets very big and at some point you have the issue of a phantom job that prevents you from deploying code even in sandboxes. 

Another possible is to have an email service that accepts email sent from the site controller with the information of what post to create. I've never tried this before so not sure about any pitfalls asides from using email limit and it just being not nice.

Any other ideas/work arounds? Thanks.

What are some good solutions people have found to maximize their data storage usage? Our biggest culprate is Tasks because we use them across teams for multiple steps that occur for each sale. 

I'm sure somebody if not a lot of people have gone through this before. I need to run a simple method to update an Opportunity after a OpportunityContactaRole has been inserted. How have people gotten around not being able to make an OppContactRole trigger? I saw some suggestions about making a custom object to replicate that object, thats not going to happen in my situation. 

 

I see that Opportunity LastModifiedDate is updated when an OpportunityContactRole is created but the actual Opportunity or even Contact triggers do not run after that. There has to be a way to do this. 

I have an After Update trigger which calls 4 different handler functions. Before the first function runs the value of a field between the trigger.new and trigger.old are different, that was the field being updates. But after the first function runs both the trigger.new and trigger.old value are the same. So I can't detect the chaned in another class.

 

So in that first function there are a few things that are done and it can update some child objects. After that the trigger.new and trigger.old list values for this field are the same. So is updating a child record updating the parent such that the new/old value for the next handlers are then based off that child update?

This is a simplified version of my issue, if it doesnt make sense I may have to explain complete scenario. But basically I am having problems  where the value I have is a field of type email, and there is a map whose key's are of type string. The map's value are of type string because the map was build from parsing a JSON response to a webservice call. And the JSON parser only has a getText() value, there is nothing specific to pull out an email value. The map returns false if i perform a containsKey on it, even though if I print the keySet out I see it in there.

 

But I am able to query for records like Leads by looking for those where the email field is contained in a set of strings.

 

I wrote a test and it seems to prove my issue:

Lead l = new Lead(lastName = 'last', Company = 'company', email = 'email@emailTest.com', Country = 'US');
insert l;

Map<String, String> emailsAsStringsMap = new Map<String, String>();
emailsAsStringsMap.put('email@emailTest.com', 'test');

system.debug('THIS IS emailsAsStringsMap.keySet(): ' + emailsAsStringsMap.keySet());


for(Lead insertedLead : [SELECT Id, Email FROM Lead WHERE Email IN : emailsAsStringsMap.keySet()]){
	system.debug('THIS IS insertedLead.Email: ' + insertedLead.Email);
	system.debug('THIS IS emailsAsStringsMap.containsKey(insertedLead.Email): ' + emailsAsStringsMap.containsKey(insertedLead.Email));   
}

 

 

This is the output:

19:02:51.329 (329237000)|USER_DEBUG|[7]|DEBUG|THIS IS emailsAsStringsMap.keySet(): {email@emailTest.com}
19:02:51.329 (329848000)|SOQL_EXECUTE_BEGIN|[10]|Aggregations:0|select Id, Email from Lead 
19:02:51.352 (352823000)|SOQL_EXECUTE_END|[10]|Rows:1
19:02:51.353 (353150000)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator()
19:02:51.353 (353170000)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator
19:02:51.353 (353561000)|USER_DEBUG|[11]|DEBUG|THIS IS insertedLead.Email: email@emailtest.com
19:02:51.353 (353694000)|USER_DEBUG|[12]|DEBUG|THIS IS emailsAsStringsMap.containsKey(insertedLead.Email): false

 

See how the email is in the keySet as a String, but the map containsKey value doesn't seem to be able to equate the email field to the string value.

 

 

  • April 23, 2013
  • Like
  • 0

The last time I looked into using the build in approval process the automatic locking proved to be annoying but still usable. I'm now trying to implement an approval process that is really not dependent on the data in the master record. The process is being built for an opportunity, but all the information used to accept or reject would not really be in that opportunity so the locking is now actually just pointless in this scenario. 

 

Has anybody had success with appexchange apps that have a custom built approval process or maybe have built there own? 

 

Also if a non Administrator user has Modify All Data, does that preculde them from being unable to edit locked records?

  • January 24, 2013
  • Like
  • 0

Sorry if this has been covered before, but I think my question is slightly different than most. I have a visualforce page which is going to replace the Open Activities and Activity History related lists on Leads and Contacts with in-line visualforce pages. This is so I can seperate them bases on type and other factors. 

 

What I don't want to change is the standard buttons like New Task, New Event, Log A Call and so on. Is there an easy way to use those standard buttons but not recreate them as a custom button? I can recreate a button like New Task, but only if it points to a specific record type. When I try to recreate the exact nature of the standard button, taking use to record type selection first it doesnt seem to work out.

  • October 04, 2012
  • Like
  • 0

Understanding that its maybe removing a level of security but is there a way to get around the user having to authorize a new device for an iPad app? We have a internal app in development.  We want to try and avoid the device verification part of loggin in for the first time login since there will be many devices being enabled. The app is using OAuth2 for authentication. 

  • September 10, 2012
  • Like
  • 0

It looks like we are getting closer and closer to using Advanced Currency Management. One thing though is what date field is used on a record like an Opportunity to know which DatedConversionRate to use? I've only read it in a non-official post somewhere saying that it is based on Close Date. Is this true? Is there any way to use a different date?

  • September 05, 2012
  • Like
  • 0

From what I've read Activities are automatically archived based on criteria. 

 

Is there a way to archive other standard object records? How about custom object records? Our data space is used up a lot right now by custom object records that business is hesitant to remove even though they dont use them. So sounds like we want to archive them with critera much like that for activities. What are our options?

  • August 31, 2012
  • Like
  • 0

We are just started to play with the Streaming API, have succeffully created and been able to subscribe to a pushTopic. But for future reference how or where would one find out what topics have been created? 

  • August 29, 2012
  • Like
  • 0

Keep getting the error when trying to deploy to production via eclipse: "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required"

 

For some reason the test method I wrote today doesnt seem to run in production. At first I thought maybe it was the queries not returning anything, but I ran them in developer console and they all ran fine. 

 

Trigger:

trigger Contact on Contact (before delete) {
    if(trigger.isBefore && trigger.isDelete){
        Contact_Delete.beforeDelete(trigger.old);
    }
}

 Test Class:

@isTest(SeeAllData=true)
private class ContactMethodsTest {
	private static testmethod void beforeDeleteTEST(){
		User username = [SELECT Id, ProfileId FROM User WHERE Username LIKE 'editedUserName%' LIMIT 1];
		
		Account a = new Account(Name='beforeDeleteTEST');
		Contact c = new Contact(lastName='lastName', AccountId=a.Id);
		system.runAs(username){		
			insert a;
			insert c;
		}
		
		Profile sysAdminProfile = [SELECT Id FROM Profile WHERE Name = 'System Administrator' LIMIT 1];
		
		User notAdmin = [SELECT Id FROM User WHERE ProfileId !=: sysAdminProfile.Id AND ProfileId !=: username.ProfileId AND isActive = true LIMIT 1];
		
		Test.startTest();
			System.runAs(notAdmin){
				try{
					delete c;
				} catch(System.DMLException e){
					system.debug('THIS IS MESSAGE: ' + e.getMessage());
					 //System.assert( e.getMessage().contains('Cannot delete this Contact'));
				}
			}
		Test.stopTest();
	}
}

 

  • August 15, 2012
  • Like
  • 0

We are developing a iPad app for retail employees to collect lead data. The idea though of users having to deal with SFDC security token, or storing a token within the app is not appealing. How can we keep up security between the mobile app and our SFDC instance when using a exposed apex webservice? It will be my first time developing a webservice for mobile use so any detail would be greatly appreciated.

  • August 03, 2012
  • Like
  • 0

Is it possible to have a custom javascript button which can create and insert a Contact and OpportunityContact Role records, then make a page callout to a visualforce page which will use those OpportunityContactRoles and then lastly delete the Contacts?

 

If so does anybody have any examples of something like this? Creating a Contact from a javascript button? 

 

Maybe it would be easier to create a visualforce page/controller that did the work in apex. 

Is there a way to to compeltely hide a contact record type from view? Simply declaring a recordType and restricting it to only the profile that needs it does not seem to mean that other profiles cannot see the records.  The Account sharing model is public, hence the Contacts are public also. So trying to seperate via role wont work.  

 

I could create my own Contacts Related List custom visualforce page to use on Account page layout. But then users would still be able to search and find records of that type. So thats not a full solution. 

 

 

We have a partner which we would like to use web2lead to post a lead to their instance. I was able to setup the http post in apex and create a lead to one of my own sandboxes but when i point it to the partners org then I get this error:

 

System.CalloutException: Unexpected end of file from server

 Any thoughts? I asked them to whitelist all the SFDC IP ranges because I think they are trying to exercise some strict Ip Login security but not sure if that even makes sense. Whitelisting SFDC IP ranges within SFDC. 

I have created a custom "New" button for Case so that we can have it on the Opportunity page layout Case related list. If I specify the record type in the URL I can pass in values via URL parameters. But If I try to have the button call recordTypeSelect then I can't seem to get past the record type selection screen. I want to be able to fill in some fields but still allow user to select record type. Can this be done?

Looking for some help in using a "classic asmx (net 2.0) based webservice". Was able to use wsdl2apex in SFDC so I hace the apex class now. One note from developer who saw the output was that it generated class with protocol http instead of https. Anybody have any input on this?

 

I am more interested in just how to get it to work. I can call the method via apex but i get the following response:

 

System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'

 

So I believe I need to construct an SOAP envelope to make the call in but I'm not sure how. My searches online keep pointing to the same pages and its just not clicking for me. Can somebody point me in the right direction?

If I have an API session open with my integration user, and I use the same user to login via a browser. Will both share the same session Id? 

 

We are seeing some weird random timeouts happen and are not sure if it is because are using the user account via the browser at the same time. 

We have 7 different approvers. Three of them though are independent and either one may not be required which I believe gives me 8 different possible buckets of approvers. My question is whether it is better to setup 8 different approval processes each with just 1 step or 1 approval process with 8 different steps that each have criteria matching one of the 8 combinations. 

 

Follow Up Question: If there are multiple approvers on a single step and two of them point to the same user will this mean that the user only has to approve once?

  • January 19, 2012
  • Like
  • 0

We are looking to create a Contract approval process but want it to be in parallel steps. I know we can have multiple approvers for a single step but that doesnt give any diferention for those users. At least with seperate steps we can name them and people can easily know what segment (financial, legal...) they are approving,

 

Has anybody been able to do this?

  • October 03, 2011
  • Like
  • 2
Have a public site whose actions I would like to, through a trigger, create a chatter post. I know people have come to this issue before, i'm looking for good workarounds.

The first one I think of is having a batch to find the record of something the site user can update and having that batch schedule itself at the end. But I've seen this get very messy. The list of scheduled jobs gets very big and at some point you have the issue of a phantom job that prevents you from deploying code even in sandboxes. 

Another possible is to have an email service that accepts email sent from the site controller with the information of what post to create. I've never tried this before so not sure about any pitfalls asides from using email limit and it just being not nice.

Any other ideas/work arounds? Thanks.

I have an After Update trigger which calls 4 different handler functions. Before the first function runs the value of a field between the trigger.new and trigger.old are different, that was the field being updates. But after the first function runs both the trigger.new and trigger.old value are the same. So I can't detect the chaned in another class.

 

So in that first function there are a few things that are done and it can update some child objects. After that the trigger.new and trigger.old list values for this field are the same. So is updating a child record updating the parent such that the new/old value for the next handlers are then based off that child update?

This is a simplified version of my issue, if it doesnt make sense I may have to explain complete scenario. But basically I am having problems  where the value I have is a field of type email, and there is a map whose key's are of type string. The map's value are of type string because the map was build from parsing a JSON response to a webservice call. And the JSON parser only has a getText() value, there is nothing specific to pull out an email value. The map returns false if i perform a containsKey on it, even though if I print the keySet out I see it in there.

 

But I am able to query for records like Leads by looking for those where the email field is contained in a set of strings.

 

I wrote a test and it seems to prove my issue:

Lead l = new Lead(lastName = 'last', Company = 'company', email = 'email@emailTest.com', Country = 'US');
insert l;

Map<String, String> emailsAsStringsMap = new Map<String, String>();
emailsAsStringsMap.put('email@emailTest.com', 'test');

system.debug('THIS IS emailsAsStringsMap.keySet(): ' + emailsAsStringsMap.keySet());


for(Lead insertedLead : [SELECT Id, Email FROM Lead WHERE Email IN : emailsAsStringsMap.keySet()]){
	system.debug('THIS IS insertedLead.Email: ' + insertedLead.Email);
	system.debug('THIS IS emailsAsStringsMap.containsKey(insertedLead.Email): ' + emailsAsStringsMap.containsKey(insertedLead.Email));   
}

 

 

This is the output:

19:02:51.329 (329237000)|USER_DEBUG|[7]|DEBUG|THIS IS emailsAsStringsMap.keySet(): {email@emailTest.com}
19:02:51.329 (329848000)|SOQL_EXECUTE_BEGIN|[10]|Aggregations:0|select Id, Email from Lead 
19:02:51.352 (352823000)|SOQL_EXECUTE_END|[10]|Rows:1
19:02:51.353 (353150000)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator()
19:02:51.353 (353170000)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator
19:02:51.353 (353561000)|USER_DEBUG|[11]|DEBUG|THIS IS insertedLead.Email: email@emailtest.com
19:02:51.353 (353694000)|USER_DEBUG|[12]|DEBUG|THIS IS emailsAsStringsMap.containsKey(insertedLead.Email): false

 

See how the email is in the keySet as a String, but the map containsKey value doesn't seem to be able to equate the email field to the string value.

 

 

  • April 23, 2013
  • Like
  • 0

The last time I looked into using the build in approval process the automatic locking proved to be annoying but still usable. I'm now trying to implement an approval process that is really not dependent on the data in the master record. The process is being built for an opportunity, but all the information used to accept or reject would not really be in that opportunity so the locking is now actually just pointless in this scenario. 

 

Has anybody had success with appexchange apps that have a custom built approval process or maybe have built there own? 

 

Also if a non Administrator user has Modify All Data, does that preculde them from being unable to edit locked records?

  • January 24, 2013
  • Like
  • 0

Understanding that its maybe removing a level of security but is there a way to get around the user having to authorize a new device for an iPad app? We have a internal app in development.  We want to try and avoid the device verification part of loggin in for the first time login since there will be many devices being enabled. The app is using OAuth2 for authentication. 

  • September 10, 2012
  • Like
  • 0

From what I've read Activities are automatically archived based on criteria. 

 

Is there a way to archive other standard object records? How about custom object records? Our data space is used up a lot right now by custom object records that business is hesitant to remove even though they dont use them. So sounds like we want to archive them with critera much like that for activities. What are our options?

  • August 31, 2012
  • Like
  • 0

We are just started to play with the Streaming API, have succeffully created and been able to subscribe to a pushTopic. But for future reference how or where would one find out what topics have been created? 

  • August 29, 2012
  • Like
  • 0

Keep getting the error when trying to deploy to production via eclipse: "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required"

 

For some reason the test method I wrote today doesnt seem to run in production. At first I thought maybe it was the queries not returning anything, but I ran them in developer console and they all ran fine. 

 

Trigger:

trigger Contact on Contact (before delete) {
    if(trigger.isBefore && trigger.isDelete){
        Contact_Delete.beforeDelete(trigger.old);
    }
}

 Test Class:

@isTest(SeeAllData=true)
private class ContactMethodsTest {
	private static testmethod void beforeDeleteTEST(){
		User username = [SELECT Id, ProfileId FROM User WHERE Username LIKE 'editedUserName%' LIMIT 1];
		
		Account a = new Account(Name='beforeDeleteTEST');
		Contact c = new Contact(lastName='lastName', AccountId=a.Id);
		system.runAs(username){		
			insert a;
			insert c;
		}
		
		Profile sysAdminProfile = [SELECT Id FROM Profile WHERE Name = 'System Administrator' LIMIT 1];
		
		User notAdmin = [SELECT Id FROM User WHERE ProfileId !=: sysAdminProfile.Id AND ProfileId !=: username.ProfileId AND isActive = true LIMIT 1];
		
		Test.startTest();
			System.runAs(notAdmin){
				try{
					delete c;
				} catch(System.DMLException e){
					system.debug('THIS IS MESSAGE: ' + e.getMessage());
					 //System.assert( e.getMessage().contains('Cannot delete this Contact'));
				}
			}
		Test.stopTest();
	}
}

 

  • August 15, 2012
  • Like
  • 0

We are developing a iPad app for retail employees to collect lead data. The idea though of users having to deal with SFDC security token, or storing a token within the app is not appealing. How can we keep up security between the mobile app and our SFDC instance when using a exposed apex webservice? It will be my first time developing a webservice for mobile use so any detail would be greatly appreciated.

  • August 03, 2012
  • Like
  • 0

We have a partner which we would like to use web2lead to post a lead to their instance. I was able to setup the http post in apex and create a lead to one of my own sandboxes but when i point it to the partners org then I get this error:

 

System.CalloutException: Unexpected end of file from server

 Any thoughts? I asked them to whitelist all the SFDC IP ranges because I think they are trying to exercise some strict Ip Login security but not sure if that even makes sense. Whitelisting SFDC IP ranges within SFDC. 

I have created a custom "New" button for Case so that we can have it on the Opportunity page layout Case related list. If I specify the record type in the URL I can pass in values via URL parameters. But If I try to have the button call recordTypeSelect then I can't seem to get past the record type selection screen. I want to be able to fill in some fields but still allow user to select record type. Can this be done?

I need to have an apex-class which can close open Cases. 

I tried to update Case.status = "Closed", but the Case is not closed after this update. 
Case.isclosed is not writeable. Is there a possibility to close a case with apex? 

i.e. like Database.leadconvert() ? 

I've been having this issue for a while and just cannot seem to find what the problem is. Thought it started a few API versions back, there is a post that says update from api 18 to 19. Right now my controller and VF page are api version 20. 

 

It doesnt happen on page load. Rather seems to only happen after a controller function has been called. Before this function completes it tasks it runs some checks. If any of the checks fail it is an error and I set a Boolean to true and a String to the error message and then return null. I use the public Boolean to know whether or not to show the error page message, and the public string is holding the message.  I've checked the field permissions on each field that is being used and they are visible but read-only. Which should be fine as I am only using them to compare.

 

Any thoughts?

  • October 12, 2011
  • Like
  • 0

Hi,

I have a visualforce page from where the users can upload/fax documents.

the above two are radio buttons 

 

in my visualforce page they look like this 

 

<apex:selectRadio value="{!action}" onclick="YAHOO.force.com.showMe();" > 

         <apex:selectOptions value="{!listofactions}" />

</apex:selectRadio> 

 

the problem is the pop up is showing for both the radio buttons but i want to show the popup only when the action= "Upload"

 

is there a way i can put a IF statement in onclick or any other way 

Plz help

  • October 12, 2011
  • Like
  • 0

Hi all,

 

You are gonna like this one!

 

I am getting an error on Eclipse 3.4.2 that restricts me to save, synchronize and/or deploy my project. It reads:

 

"Unable to fetch and save Force.com components to project:

 The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later. (ALREADY_IN_PROCESS)"

 

Has anyone seen this error before? I have wait for 15 minutes (my max waiting capacity :( ), tried to refresh, deploy, save... but this error is not letting me go anywhere.

 

Suggestions are welcome

 

Alex

  • February 16, 2010
  • Like
  • 0