9
votes
Accepted
2 workflows vs Process builder. Which one is better?
You should go with Process Builder. The beauty of process builder is one process can handle multiple criteria updates and all of them will be in a single process like the one you have now.
Process ...
- 4,011
9
votes
Accepted
How do processes consume SOQL queries?
It's one DML and SOQL per 200 records or a single DML "chunk."
To illustrate this, consider the following code:
contact[] c = [select id from contact limit 5];
id accountid = [select id from account ...
- 463k
7
votes
Accepted
Date Formula to Calculate date excluding weekends
Here is a link with similar solution.
Requirement: Calculate Due Date from Start Date and Number Of Business Days
Due Date = Start Date + Number of Days [excluding Saturdays and Sundays]
An apex ...
- 14.3k
7
votes
Truncate first five digits of postal zip codes
Assuming you want to take the first 5 digits from the zipcode field to use in the validation rule, you can use the LEFT function to do that. As per the Salesforce documentation, the LEFT(text, ...
- 14.3k
6
votes
Accepted
Invalid field OwnerID for SObject
With the comments you answered, the reason is because your contact__c is on the detail side of a master-detail relationship. In that case, the owner of your contact__c object will be the owner of the ...
- 12.9k
6
votes
Accepted
Workflow Rule (Ischanged) - Field is not updated when the record is created
Well, aside from the AND being extraneous, you need to add an ISNEW check to your OR clause if you want it to fire on create. The ISCHANGED formula returns false on create.
OR(ISNEW(), ISCHANGED(...
- 147k
6
votes
Accepted
Sum of fields in a field update when some of the fields are null
Your friend is the BLANKVALUE function that if the first argument is null, will use the second argument as the value of the expression
BLANKVALUE(Field__c,0) + BLANKVALUE(Field1__c,0) + ...
- 67k
6
votes
Accepted
How to get parent data in a before insert context?
You can just query the PricebookEntry records instead:
Set<Id> entryIds = new Set<Id>();
for (QuoteLineItem item : trigger.new) entryIds.add(item.PricebookEntryId);
Map<Id, ...
- 147k
6
votes
Accepted
Optimistic locking when working via REST API
If the Ruby script updates a record between the time the user loads the edit page and clicks Save, they'll get a "record has been modified" error to prevent them from overwriting data.
If the user ...
- 463k
6
votes
Accepted
How to update picklist using REST API
As the other answer says, you can do this via the Tooling API if you want to use a REST call. You can find the details on their answer. The other option is to use the Metadata API which is a SOAP API. ...
- 1,160
6
votes
Fire Journey Builder when Contact Object is Updated
The documentation is a little misleading when it states: "The rule does not run when a record that previously met rule criteria is updated". Makes it sound like a record can't qualify again.
So for ...
- 1,166
5
votes
Accepted
Formula that return the date when the checkbox was selected
Instead of a formula, create a new Date or Datetime field, and update it to NOW() via a Workflow Field Update or via a trigger, whenever you detect that the Checkbox value has been changed from False ...
- 2,018
5
votes
Updating 50 checkboxes on picklist change with Trigger?
I am not sure how to interpret your trigger, but here is how I would find all Checkbox fields in Execute Anonymous:
Set<Schema.SObjectField> checkboxFields = new Set<Schema.SObjectField>()...
- 147k
5
votes
Accepted
How to update a field with Lightning Components?
I think the error lies in these lines
var action = component.get("c.account");
action.setParams({ "account": account });
try changing it to
var action = component.get("c.saveAccount");
var account ...
- 2,700
5
votes
Convert Trigger to use Dynamic Apex
I agree with @crop1645 that DLRS is a good option here, but if you must roll your own it would look something like:
Utilities
Getting Parent Ids
I consider the following utility essential. It is ...
- 147k
5
votes
Accepted
Before Insert Trigger not updating field
well, one issue is with your testmethod - you need to requery the Contact to get the value set in the trigger
Contact c = new Contact(LastName='x',MailingCountry='Angola');
insert c;
...
- 67k
5
votes
Accepted
Adding One Year to Date Field Value Through Custom Button
It would look something like this:
{!requireScript("/soap/ajax/37.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Invoice_Statement__c");
c.id = "{!Invoice_Statement__c.Id}";
c....
- 463k
5
votes
Accepted
help with trigger business logic
I advise you to implement this functionality declaratively. In this case, you simply need a Workflow Rule and a Validation Rule.
I highly recommend you read Visual Development – When to Click Instead ...
- 147k
5
votes
Accepted
why the trigger is executing only once after workflow is fired?
The trigger(s) (and it is both Trigger 'A' and Trigger 'B' in your example) are only being executed once after the workflow field update because that's how Salesforce has decided to make things work.
...
- 54.9k
5
votes
Accepted
priorvalue is blank or --None-- update internal status "In-progress" workflow
Try this.
AND(
ISBLANK(TEXT(PRIORVALUE(InternalStatus__c))),
NOT(ISNEW())
)
- 3,909
5
votes
Accepted
Why does __r result in a null value?
You need to perform a separate query to retrieve names. Salesforce doesn't return values from related object's fields, though it will not give you the error rather it returns null.
Here is an ...
- 35.7k
5
votes
Making updates to mass records using batch apex faster
Based on your code, it's clear that there's not much you're going to do to improve performance. However, one major improvement would be to increase the scope size, assuming it does not cause you to ...
- 463k
5
votes
Accepted
PrePopulate Task with related data even before creating a Task
Triggers are supposed to work that way. They do not pre-populate data on the screens but only update it during the transaction.
Out of the box, you will not be able to pre-populate data. If you can ...
- 29.9k
5
votes
Accepted
Send only udpated fields instead of all the field information
You can use the CDC (Change Data Capture) to get updates only on updated fields. You could also write manual code (Apex) to create a change delta, although this might require a lot of CPU time ...
- 463k
5
votes
How would you use Schema.SObjectField to dynamically get the values of each field for the object?
You're looking for getPopulatedFieldsAsMap. This gives you a Map where the key is each populated field, and the value is each value stored in the record. Unpopulated values won't be present.
- 463k
5
votes
Accepted
What is the order of execution for the final approval actions in a standard approval process?
They will not be guaranteed to fire in the order you see listed, however this will still work out for you.
In Considerations for Field Update Actions that covers creating field updates for workflow ...
- 20.7k
4
votes
Accepted
Updating 50 checkboxes on picklist change with Trigger?
Question : Is trigger the best approach?
Answer: not as per my humble opinion after process builder was introduced with update records feature
Process builder has its limitations, but in your case ...
- 16.6k
4
votes
Workflow that executes any time a record is changed or page is accessed
Change the Evaluation criteria to "Every time a record is created or edited". Then just use a formula of TRUE. This will run every time the record is created or edited, no matter what.
Important to ...
- 24k
4
votes
Accepted
Text field to Picklist
You should use Process Builder.
Create a process for your object and select Start the process- "when a record is created or edited"
Set criteria to check if your text field Is Changed = true or Was ...
- 147k
4
votes
Accepted
Calculating date/time x working hours from now
The easiest way to do this via trigger would be to use Business hours. In this case it would be:
BusinessHours bh = [select Id from BusinessHours where IsDefault=true];
obj.SLA_deadline__c = ...
- 1,856
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
field-update × 439workflow × 103
trigger × 101
apex × 97
formula × 38
process-builder × 37
formula-field × 27
update × 24
visual-workflow × 23
custom-field × 16
date × 14
before-trigger × 14
approval-process × 13
custom-object × 12
batch × 11
picklist × 11
lookup × 11
datetime × 11
lightning × 10
workflowrule × 10
visualforce × 9
javascript × 9
account × 9
marketing-cloud × 8
case × 8