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

IF condition expression in workflow

I was adding a workflow in my application like this :


IF( ISNULL(Credit__c) ,
Account__r.Available_Balance__c = Account__r.Available_Balance__c - debit__c,
Account__r.Available_Balance__c = Account__r.Available_Balance__c + Credit__c


means if credit filed is not null it will add it to available belence field in the related object 

else will deduct debit from available balance.


But its giving sysntax error : Error: Formula result is data type (Boolean), incompatible with expected data type (Currency).


How to achieve it.


Best Answer chosen by Admin (Salesforce Developers) 
Rise AnalyticsRise Analytics

Is this your Field Update formula?


A proper IF statement returns a value, but can't execute an assignment as you are doing. Here's an example of what it should look like:


IF( ISBLANK(Credit__c) ,
 Account__r.Available_Balance__c - debit__c,
Account__r.Available_Balance__c + Credit__c


The Field to Update would be Account: Available_Balance__c


I'd need more details to know if this is the only issue, though, as I can't tell how you've set up the workflow from what you've written.


You also need to consider how to handle when both debit and credit are blank, and when both are filled. Could you give me a better idea of what you're trying to accomplish? Only testing if credit is blank likely isn't your best approach.