1

I've got a custom object called Attribution_Event__c that has a lookup to both Contact and Account.

As a contact takes specific actions we create attribution events(goes to website, answers a call, responds to email, etc.)

What I'm ultimately trying to do is to demonstrate which attribution events are driving opportunities.

So, let's say a Contact came to the website on 4/30 we'd log an attribution event for that action. Then, we email and he/she responds on 5/1. We'd have two attribution events, one for the website visit and one for the email response.

On 5/3 we generate an opportunity and tie the contact via a Contact Role to the oppty.

Is there any way to demonstrate that

  • an attribution event took place within X days

or

  • what the last attribution event was on a contact prior to the opportunity being created

At this point I'm just looking to do a SOQL query to get this data, is it possible to do without code or is apex required to identify those relationships? Adding new workflows or process builder isn't going to work for me in this case. I'm trying to export the data to prove value to customers that have installed my app.

  • Will a report work for you? – Mahmood May 3 '17 at 3:07
  • Report would work but it seems like making those connections is a little more than SFDC can handle, even with custom report types – shartshooter May 3 '17 at 3:07
  • Well, you can achieve that using workflows(WF) or process builder(PB) as well. Have a field on Account and Contact and call, Last_Attibution_date. So, every time an Attribution record gets created, you update that field using WF/PB. And finally you can have a simple report on Contact and Account to show the last attirbution date. For your first requirement you can implement similar solution, but this time with formula field to calculate the number of days. – Mahmood May 3 '17 at 3:18
  • It won't be possible to query everything in a single query, so you would need a class to query all different information. You could simply write a REST service to filter out the Last attribution date based on the opportunity creation date and return it as a response. – Salesforcesmarty May 3 '17 at 3:51
0

Well, you can achieve that using workflows(WF) or process builder(PB).

  • Have a field on Account and Contact and call, Last_Attibution_date. So, every time an Attribution record gets created, you update that field using WF/PB.
  • And finally you can have a simple report on Contact and Account to show the last attirbution date.

For your first requirement you can implement similar solution, but this time with formula field to calculate the number of days.

  • I should have been more explicit. I'm trying to get this data out from many of my customers that have installed a package that tracks attribution. Getting them all to update the package and/or create workflows isn't going to work. My goal was to export this info using REST calls – shartshooter May 3 '17 at 3:22
  • hmm... Im totally lost here. Your comment changes the whole picture, but your question doesn't reflect what you just commented. Do you mind updating the question to have relevant info and requirements, plz? – Mahmood May 3 '17 at 3:28
  • I just need to build a SOQL query to pull out opportunities and any attribution_event__c associated with contacts tied to a given opportunity – shartshooter May 3 '17 at 3:36
  • Im just going to consider your last comment. In the case of Opps with Contacts, you can create a simple report. As for the contacts to have the attribution record attached to them; my answer should do, that is, a custom field on Contact and update that field by WF or PB. Should be simple. But if you talk REST and getting the information from all your customers who are using your package. Then the question needs change. – Mahmood May 3 '17 at 3:47
0

You may write a class to get data. See if this work for you.

  1. Get all the the attribution of opportunity contact
  2. Get the latest one attribution of the contacts
  3. Compare the date with opportunity date and last attribution date.
Set<id> Conid = New Set<id>();
For(Opportunity opp : oppList){

Conid.add(contatid);

}
//Get the last created attribution

List<Attribution_Event__c> attri = [SELECT ID, CONTACT FROM Attribution_Event__c WHERE CONTACT =: Conid ORDER BY CREATEDDATE DESC];


For(Opportunity opp : oppList){

//Compare the data and output the result.


}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.