I have created the following Apex trigger that will create, update and delete Opportunity Contact Roles based on a Contact Lookup field placed on the Opportunity. Everything works great currently. I am just trying to figure out one final scenario. If John Doe already has a Contact Role but is not the Primary Contact Role and I want him to be. I want to be able to change my look up field to him and then have that check him as the primary. Currently it just creates a new one and checks them both as primary. So what I need to do is check the current Contact Roles and if there is already one with the same name as in the Lookup field then just check that one as primary, but if there isn't then create a new one. Below is the code. Please let me know if you need further description.

I am trying to delete an Apex Class, and its associated Test Class from my production instance. I am changing the status to Deleted and then doing the deploy to server from Force.com IDE. But it is failing due to code coverage issues, but the only class/trigger that is less than 75% CC is the class that I am trying to delete. Am I missing something?

I was trying to deploy some code this morning from sandbox to production, and I received this error on a test class that was written by someone else at my company. They copied it from somewhere online and have no idea what this error is. I am curious if someone can help me figure out what is wrong with this test class that is causing the following error:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301310000008shZ. Contact your administrator for help.: [] Stack Trace: Class.MyProfilePageControllerTest.testSave: line 34, column 1

I have an Apex Trigger that takes the list of Tasks that meet a certain criteria and finds the one with the Max Date and then populates a field on the Account with that date. The trigger works great, but I would like it so that if the list size = 0 then the field will return to null. Currently the previous value will just stay in there. Any help would be greatly appreciated.

I have a custom object called Project, and a subordinate custom object called CRM Hour Tracker, what i would like to do is create a scheduled Apex Class to create a new CRM Hour Tracker every month on the first day of that month for every Project in the system.(Only About 110). I know how to do the scheduling of the Apex Class, my problem is i need each of these CRM Hour Trackers to relate to a different Project. Anyone have any ideas?

I would like to write an Apex Trigger on the Task Object that will populate a date field on the Account Object with the Created Date of the Last Activity With a Status of Completed and a Subject of Completed Call.

Okay so I have a Trigger that fires after insert of Task. The Trigger works perfectly, I wrote the following Test Class and I'm only getting 75% code Coverage and I need more than that because my org average is only at 57%. Any help would be greatly appreciated.

I have an Apex Trigger losted below. It counts the number of tasks on an account, and it works perfectly, but i want it to only count Attempted and Completed Call, I currently have it counting only Attempted Calls because everytime i try and add Completed Call it doesnt work at all. Any Ideas?

So I have a custom object called Airport which is a lookup to the Account object, and it literally is just all of the Airports in America. And what i would like to do is create a formula field on the Account that Displays the closest Airport to that address. Does anyone know how this is possible? I would like to be able to just compare them by city and state.

So for instance lets say that the account is for Quicken Loans Arena in Ohio, then I want it to take Cleveland, Ohio and find the airport that is the closest to that location which would be Cleveland-Hopkins International. I can explain this alittle better if I'm not being clear enough.

I am trying to create a Formula Field that displays the name of the nearest Airport to the Account's Billing address.

I was handed this task about a week ago, and have triede everything that I can think of and have researched it thouroughly and have come up dry. I am really hoping that one of you lovely developers on here will have some advice for me as to how i should attempt to accomplish this task.

I have an Apex Trigger that counts the number of Projects that have been created on an Account, and i realized today that if you create the first Project on an Account the field displays 1, but then if you delete that Project the field still displays 1. I need it to go back to zero if there are no Projects on the Account anymore.

I have an Apex Trigger listed below, what it does is it shows a count of how many Projects are linked to an Account, it works perfectly but I added a checkbox to the Project object and I would like to now only count Projects that have that checkbox checked. Can anyone help me with this?

I have a custom object called "Project" that looks up to the object "Account" and I would like to create a Trigger that simply tells me how many "Projects" are linked to that specific "Account". Im just looking for someone to point me in the right direction.

I have created the following Apex trigger that will create, update and delete Opportunity Contact Roles based on a Contact Lookup field placed on the Opportunity. Everything works great currently. I am just trying to figure out one final scenario. If John Doe already has a Contact Role but is not the Primary Contact Role and I want him to be. I want to be able to change my look up field to him and then have that check him as the primary. Currently it just creates a new one and checks them both as primary. So what I need to do is check the current Contact Roles and if there is already one with the same name as in the Lookup field then just check that one as primary, but if there isn't then create a new one. Below is the code. Please let me know if you need further description.

I am trying to delete an Apex Class, and its associated Test Class from my production instance. I am changing the status to Deleted and then doing the deploy to server from Force.com IDE. But it is failing due to code coverage issues, but the only class/trigger that is less than 75% CC is the class that I am trying to delete. Am I missing something?

I was trying to deploy some code this morning from sandbox to production, and I received this error on a test class that was written by someone else at my company. They copied it from somewhere online and have no idea what this error is. I am curious if someone can help me figure out what is wrong with this test class that is causing the following error:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301310000008shZ. Contact your administrator for help.: [] Stack Trace: Class.MyProfilePageControllerTest.testSave: line 34, column 1

I have an Apex Trigger that takes the list of Tasks that meet a certain criteria and finds the one with the Max Date and then populates a field on the Account with that date. The trigger works great, but I would like it so that if the list size = 0 then the field will return to null. Currently the previous value will just stay in there. Any help would be greatly appreciated.

I would like to write an Apex Trigger on the Task Object that will populate a date field on the Account Object with the Created Date of the Last Activity With a Status of Completed and a Subject of Completed Call.