4

Since you're new to Salesforce, I'd recommend that you ditch this approach. It's highly inefficient and manual. Instead, you can use BusinessHours and Custom Metadata to provide a configurable setting for your trigger. BusinessHours In Setup, create a new Business Hours setting. You can just specify the start and end times as 12:00AM on each end to make ...


4

I was able to update the UnitPrice by first removing all its related OpportunityLineItemSchedule records, the code as follows: Id oliId = '00k1w000006SpWE'; List<OpportunityLineItemSchedule> olisList = [SELECT Id FROM OpportunityLineItemSchedule WHERE OpportunityLineItemId = :oliId]; delete olisList; OpportunityLineItem oli = [SELECT Id, UnitPrice ...


3

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 updated to work, the record needs to be updated from something different than the entry criteria condition, to something that equals the condition. For example, ...


3

The system is that "clever." It reevaluates the rules only for records that were changed (like a Set<Id>). There wouldn't be any point in checking the rules again if the records haven't changed. However, note that the checkbox doesn't go through the entire save process again; it simply reevaluates the rules and applies any further updates, and only ...


3

You need to change your code somewhat to get it to even compile. Beyond that, you should move your update out of the loop. public class UpdateContact implements Database.Batchable<sObject> { public Database.QueryLocator start(Database.BatchableContext BC) { return Database.getQueryLocator([Select id, Profil__c from Contact__c]; ...


2

You need to do a data clean up. Export the data set of the records you want to update using dataloader. This will create a CSV file Update the field values in Excel Upload the revised dataset Here is some docs on data loader: https://help.salesforce.com/articleView?id=data_loader.htm&type=5 Here is a trailhead for dataloader https://trailhead....


2

First, a note: working with DateTime fields in workflow field updates faces major hurdles, especially around time zones and Daylight Savings. If I understand correctly what you're after here, this is not really a good job for a workflow field update. IF all users are in the same time zone and you're willing to have your calculations be off by an hour during ...


2

Since they are all accounts you simply can use one list. But if there is same account with multiple update then a map is required. It would look like this: if(scope.size() != 0){ //size should not be 0 Map<Id, Account> accountsWithUpdatedAddress = new Map<Id, Account(); for (New_Account_Address__c ac : scope) { Account acc =...


2

As Kris is saying, you should be looking to the processes, workflows and any other declarative operation that may be firing on the same transaction. You can also try a couple of things to see if you can control a bit the transactions that are operating on this classes. I will suggest to make a clear cut between before update and before insert operation. ...


2

To send the list of records to your class, you should prepare a list of such records which satisfy your trigger criteria. Below is example: trigger UpdateLastActivitySubject_trigger on Lead (before update) { List<Lead> lead = Trigger.new; List <Lead> lstLead = new List <Lead> (); for (Lead ld : lead) { if (ld....


2

Yes,You can do that. You need an additional DML statement. You need to do like this:- Opportunity o = [Select Id, lookup__r.field__c, lookup__r.field2__c from Opportunity]; o.lookup__r.field__c = 'test'; o.lookup__r.field2__c ++; update o; //it will update opportunity update o.lookup__r; //it will update the relationship record


1

I would say, in the context that this is the only thing being done, this can be set via Workflow field update, or process builder, instead of a trigger which is a much better option. When possible always clicks over code... Few things: You are setting the value of the local variable in the else and not the value on the record I do not get where your ...


1

You could turn on Field History Tracking for the Status field and that would log not only when it changed, but who did it as well as current and prior values.


1

You can use a Process Builder/Workflow Rule/Trigger to achieve this. Just create a custom Date/Time field, choose the appropriate method you want to use (e.g. Process Builder), define the action to fire when it meets your criteria (e.g. ISCHANGED(StageName) && NOT(IsClosed)), and use an action to set the Date/Time field.


1

You could always update make a Map<Id, Account> from all three lists and then perform a single update: Map<Id, Account> toUpdate = new Map<Id, Account>(); for (New_Account_Address__c ac : scope) { // Update as needed toUpdate.put(ac.Account_c, acc) } update toUpdate.values();


1

I think there's an easier way to do this, if you're interested in avoiding Apex code. Client_Property__c is what's called a junction object; it has master-detail relationships to two other objects. Because it is the child, you have declarative tools that can help you traverse the relationship to the parent and make updates, or automatically roll-up child ...


1

Salesforce Data Entry Events are only triggered when a contact goes from a state of not meeting criteria to then meeting the criteria. Since the same contact that had already met criteria was updated, the event was not triggered. See link here: "When a record is updated, the rule runs only if the record meets rule criteria after the update. The rule does ...


1

You can use priorValue in workflow field update. NewField__c = PriorValue(OldField__c)


1

Normally, for client side validaiton of input fields/values in lighting:recordEditForm's, I add an aura:id to the fields, and or/do my "validation" on field change or blur. This is generally more intuitive than having to wait for clicking on next to see if any fields are not properly filled in. If for whatever reason you need to perform the validation all ...


1

Found this (not the Best) workaround to get Object/field values. Instead of Wizard page buttons, used Next/Back buttons on each Lightning:RecordEditForm (bottom of page). Made the Next button type="submit", handled navigation in onClick() of button, now it fires onSubmit of RecordEditForm onSumbit event flushes the edited field values to my own sobject ...


1

I believe you need to write an Apex Trigger to compare new and old value. I found a similar discussion here Trigger.new contains OLD value of edited Rich Text Area in come cases?


1

From your above comments, if you just want to update a field with errors and not throw errors, then you will need to use CASE function in your workflow instead of IF. IF function should be used to determine if expressions are true or false. Returns a given value if true and another value if false. Your formula should be CASE(OR(ISBLANK(Name), LEN(...


1

The update DML command on the CertificationObjects will not update the Contact lookup fields' data - it only updates fields on the Certification__c record itself. Try the following (EDIT - using Map to avoid duplicate Contact Id updates): List<Certification__c> CertificationObjects = new List<Certification__c>(); CertificationObjects = [SELECT ...


1

Change they type to whenever created or edited Use the ownerid part in the criteria. If you want to exclude insert add !isNew() to the criteria


1

In lieu of using a formula field, which would probably work in most cases, you can use a Process Builder on the Account to update the Customer of the Week record. The Process Builder has an option to update child records related to a parent record.


1

The report is a red herring here - it has nothing to do with the problem. Given that you have on Object 2 a field Customer_Type__c that is a formula reference to a field on another object (the Account), and you wish to construct another field on Object 2 that concatenates Customer_Type__c with other fields, you can't use Workflow Rules. As cropredy noted in ...


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