Skip to main content

New answers tagged

0 votes

How to remove child lookup which is populated on parent when the associated child is deleted

Here's how you can implement it: Create an Apex Trigger on the Contact Object: The trigger will be fired after a contact record is deleted or updated. It will update the account record to remove the ...
vikash kumar's user avatar
-2 votes

Triggers on contact to update decsiption field of its parent account

Trigger Contacttest on contact (After Update) { if(trigger.isafter && trigger.isupdate){ Set<Id> IDS = new set<Id>(); List<Account> ACC = new List<...
Jagadeesh Pachipala's user avatar
0 votes

Update Existing Historical Bulk Records to fire a trigger

New solution based on same idea as SFDC Noob. Download Salesforce Inspector plug-in. Perform and Update operation, but only give the list of record Ids you want to trigger update for. I just did this ...
Bill Lessard's user avatar
2 votes

Trigger to update mailing address of contact record when billing street of account record is updated no compilation error but contact not updating

There are multiple things wrong with your code. NewSet is empty (you initialize it to a new list, which is empty) As a result, your query on Account is going to return no records (and you won't get ...
Derek F's user avatar
  • 62.7k
1 vote

Trigger to update mailing address of contact record when billing street of account record is updated no compilation error but contact not updating

list<account> ListOfNewlyUpdatedAccounts = [SELECT id, BillingStreet FROM account WHERE id IN :NewSet]; NewSet is empty, therefore no records will be queried. The rest of your code has nothing ...
sfdcfox's user avatar
  • 497k
2 votes
Accepted

Does Salesforce Pro Suite allows you to do apex?

The answer is probably "No, you can't create apex classes/triggers" tl;dr: Salesforce continues to make a mess of their offerings. You may want to reach out to the Salesforce Sales Team to ...
Derek F's user avatar
  • 62.7k
2 votes

Test Class for the Apex Class? In above I am calculating time spent by record in each stage? I tried writing test class but unable do test coverage?

The golden rule of unit testing is: you only gain coverage for code that is executed as part of running the test method(s) Since you currently only have a single test method, and are only working with ...
Derek F's user avatar
  • 62.7k
1 vote

Bypass flow and apex triggers when executing DML on batch apex

As you've observed, Custom Settings have to be updated. What you want is an in-memory solution. Here's a sample implementation to get started. public class SystemFlags { // Example flag public ...
sfdcfox's user avatar
  • 497k
0 votes

Bypass flow and apex triggers when executing DML on batch apex

You can assign a custom permission to the running user and skip the flow and triggers if the running user has this custom permission. I would recommend to use a trigger framework where you can bypass ...
Vamsi Krishna Mopievi's user avatar
0 votes
Accepted

Creating a trigger that throws error if any contain email is used in lead record. Getting iisues in code

In an Apex class, the Trigger variables are always a generic sObject, rather than a specific type, because the compiler does not know how you intend to use this code. Instead, you should iterate over ...
sfdcfox's user avatar
  • 497k
0 votes

I am trying to write a trigger on opportunity that will create order and order item on opportunity update event but facing issue

Your problem lies here for (Opportunity opp : [SELECT Id, AccountId, ContractId FROM Opportunity WHERE Id IN :opportunityIds]) { Order newOrder = new Order(); newOrder.AccountId = opp.AccountId; ...
cropredy's user avatar
  • 72.1k
1 vote
Accepted

Duplicate Job (or Apex or Flow) - before Merging records, Archive original records as Historical Data

You could call FindDuplicates methods in Apex to find possible duplicates. In your flow, first collect the user input, then call an InvocableMethod that finds any duplicates, and if duplicates are ...
sfdcfox's user avatar
  • 497k
0 votes
Accepted

Why Rich-Text Image URL not getting updated in record?

Got following update from salesforce support, Hope it will be helpful. Hi Ragul, I am XXXX from Salesforce Development Support Team. I have taken ownership of your case and I will be your point of ...
Ragul's user avatar
  • 541
4 votes

How to find the max amount of an opportunity without using aggregate result in apex trigger?

You're approaching this from the wrong direction. You can actually make this easy enough by using a subquery: public static void updateoppName(Opportunity[] afterSave, Opportunity[] beforeSave) Set&...
sfdcfox's user avatar
  • 497k
0 votes

How to Deactivate Trigger using Apex code

If you need to deactivate an Apex trigger in Salesforce programmatically, using the Tooling API can be a powerful approach. The following code demonstrates how to deactivate a trigger through a series ...
Deepak Mali's user avatar
0 votes

How to find the max amount of an opportunity without using aggregate result in apex trigger?

For Account and Opportunities, if you could ignore the requirement to get particular Opportunity ID and Name, you can use RollUp field on the Account as there is Master-Detail relationship. If you ...
zanstaszek9's user avatar
0 votes
Accepted

How to find the max amount of an opportunity without using aggregate result in apex trigger?

You can achieve this by querying all opportunities related to the account and then iterating all opportunities through the loop and getting the MAX Amount of opportunities for a specific Account. ...
Tushar Jadav's user avatar
  • 2,148
-1 votes

I have written a apex trigger on task and want a test class code

You may use this sample code to cover your apex trigger code. https://www.decodeforce.com/code/-O-iLf4LtAsb0C0fXIFO
george thomas's user avatar
1 vote
Accepted

Variable does not exist compile error

You can't mix formula functions and Apex, they're mutually exclusive. So ISPICKVAL() isn't a thing in Apex, and that's the source of your error. In Apex, picklists are effectively strings. Also, as ...
Derek F's user avatar
  • 62.7k

Top 50 recent answers are included