function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michele ToscanoMichele Toscano 

Extra 'OR' in workflow formula

How can I fix this syntax?  I want the first two lines evaluated first followed by the last two lines....another pair of eyes would be greatly appreciated.

ISCHANGED((AccountId) = True || (AccountId) <> '' ) &&
Address_Line_1__c <> '' OR
ISCHANGED((Account.LCL_Account_Name__c) = True || (Account.LCL_Account_Name__c) <> '')
&& LCL_Address_Line_1__c <> ''
Pankaj MehraPankaj Mehra
Hi Michele Toscano

First of all you cannot apply ISCHANGED method to a related field Account.LCL_Account_Name__c, I have updated the formula but you need to update it because of the restriction I mentioned
      AND(ISCHANGED(AccountId ) , AccountId <> '' , Address_Line_1__c <> '') ,
      AND(ISCHANGED(Account.LCL_Account_Name__c) , Account.LCL_Account_Name__c <> '' , LCL_Address_Line_1__c <> '')

Michele ToscanoMichele Toscano
Thank you. But then how can one account for the lookup change on those fields if the IsChanged function (or PriorValue) isn’t supported? Is there another way to accommodate this upon new record creation only? In other words, the user is creating a new contact – but he accidentally chooses the wrong account from the lookup and wants to change it prior to ‘saving’ the record….. Regards, Michele Toscano Senior Applications Specialist Cabot Corporation Office: (678) 297-1455
Pankaj MehraPankaj Mehra
Hi Michele Toscano,

For such complex validation I would suggest to add validation in trigger

trigger CustomActivityTrigger on CustomActivity__c (after insert, after update, after undelete, after delete, before insert, before update, before delete) {

        if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)){
            map<Id,Study__c> studyMap = new map<Id,Study__c>();
         for(CustomActivity__c cAct : val){
            studyMap.put(cAct.Study__c, null);
         studyMap.putAll([Select Id, Name From Study Where Id In : studyMap.keyset()]);

         list<StudyTeam__c> sTeamList = [Select Id, Name, Study__c, User__c From StudyTeam__c Where Study__c in : studyMap.keyset()];

         map<Id,set<Id>> study2IdsMap = new map<Id,set<Id>>();
         for(StudyTeam__c sTeam : sTeamList){
               study2IdsMap.put(sTeam.Study__c, new set<Id>();

         for(CustomActivity__c cAct : val){
                cAct.addError('YOU CANNOT DO THAT!!');


Here is a sample example, where we are querying data from objects and adding a validation