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 ...
sfdcFanBoy's user avatar
  • 4,045
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 ...
sfdcfox's user avatar
  • 481k
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, ...
Saroj Bera's user avatar
  • 14.6k
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(...
Adrian Larson's user avatar
  • 149k
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) + ...
cropredy's user avatar
  • 69.8k
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, ...
Adrian Larson's user avatar
  • 149k
6 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 ...
Santanu Boral's user avatar
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 ...
sfdcfox's user avatar
  • 481k
6 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 ...
sfdcfox's user avatar
  • 481k
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. ...
Kyle's user avatar
  • 1,170
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 ...
Josh de Blank's user avatar
6 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.
sfdcfox's user avatar
  • 481k
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; ...
cropredy's user avatar
  • 69.8k
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 ...
Adrian Larson's user avatar
  • 149k
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 ...
George S.'s user avatar
  • 2,720
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....
sfdcfox's user avatar
  • 481k
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 ...
Adrian Larson's user avatar
  • 149k
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. ...
Derek F's user avatar
  • 59.3k
5 votes
Accepted

priorvalue is blank or --None-- update internal status "In-progress" workflow

Try this. AND( ISBLANK(TEXT(PRIORVALUE(InternalStatus__c))), NOT(ISNEW()) )
Reshma's user avatar
  • 3,969
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 ...
Jayant Das's user avatar
  • 30.3k
5 votes

Refresh the page after the flow completes

Unfortunately, the UnofficialSF solution didn't work for me, but was able to get a similar solution working. Similar to the UnofficialSF component, add the following aura component to your flow where ...
Charles Naccio's user avatar
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 ...
sfdcfox's user avatar
  • 481k
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 ...
Kris Goncalves's user avatar
4 votes

Update check box using workflow

Go to Setup Menu->Create->Workflows->Process Builder->New-> NameYourProcess Save Add Object You wanna make this workflow work On Mark "when a record is created or edited" Save Add Criteria -> ...
Alexander Aeons Torn's user avatar
4 votes
Accepted

Workflow Rule Execution criteria

There's a limit of 5 recursions (e.g. five successive field updates that cause further rule evaluation), and a limit of 50 active workflow rules per object. In order for, e.g. WF2 to trigger WF3, it ...
sfdcfox's user avatar
  • 481k
4 votes
Accepted

How to set a value multiple times within same update

Not sure I fully understand, but I suggest: for (Revenue_Pipeline_Schedule__c s : scope) { Revenue_Pipeline__c p = pipelines.get(s.Revenue_Pipeline__c); // First clear all for (...
Keith C's user avatar
  • 135k
4 votes

How to do a batch job to update a field in a parent object from multiple child object fields?

If you want to persist your changes in the database, you have to perform a DML Operation (in this case update): for (MyObject__c record : scope) { // manipulate data } update scope; I would also ...
Adrian Larson's user avatar
  • 149k
4 votes
Accepted

apex:inputField not binding value to controller

You have multiple forms on your page. You button is in a separate form so when you submit it does not grab the value from the input fields in the other form. Wrap you entire code in the form as ...
Eric's user avatar
  • 54k
4 votes

how to pass prior and current value to apex when record changes through process builder?

This can be achieved using below Class and Process Builder: public class PrintInvocable { public class MyInvocableVariable { @InvocableVariable(label='Id' required=true) public Id recId; ...
Bhoopender Pal Singh's user avatar
4 votes
Accepted

How can I update a text field on a child object with a value from it's parent without using a formula field?

This can be achieved by Workflow rule field update which will be executed on Product Rating object. Workflow Evaluation criteria: Evaluate the rule when a record is created, and every time it's ...
Santanu Boral's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible