+ Start a Discussion
nandacnandac 

Updating a formula field using a workflow

Hi,

 

I working on a billing application where I have bill custom object that contains a balance custom field.

 

I want to set the balance custom field to the total amount on the bill on save when the bill is created. Should this be done through a trigger or a formula field?

 

i also need to update the balance field whenever a payment is made, and would like to know if a formula field can be updated, through  a workflow where a payment is made against a bill?

 

If there are better ways to do this please let me know.

 

Cheers

Best Answer chosen by Admin (Salesforce Developers) 
Shannon HaleShannon Hale

Generally speaking, if you want a value that is going to show the latest value every time you view the record, and you don't want the field to be editable, you'll want a formula field. If you want the update only to occur under certain circumstances -- like when you're creating the record -- or you want the field to be editable after, you'll want a workflow rule field update.

 

I think you can use a formula field on your billing object for Balance, and also create a roll-up summary field -- say it's called Payments Applied -- that sums the amounts of each child payment amount. Then your Balance field formula would be Amount__c - Payments_Applied__c. The Payments Applied field doesn't need to be on the detail page.

All Answers

Prady01Prady01

Hi there,

 

      I don think you can update/write to a formual field.

 

Thanks

Prady

Madhan Raja MMadhan Raja M

HI Nandac

 

1. I want to set the balance custom field to the total amount on the bill on save when the bill is created. Should this be done through a trigger or a formula field?

- Use formula field

 

2. i also need to update the balance field whenever a payment is made, and would like to know if a formula field can be updated, through  a workflow where a payment is made against a bill?

- You don't need to update the formula field because the formula field will automatically calculates and updates itself.

 

Ex: Formula total field = field1+field2+field3

                  2                           1   +    0   +   1

-----------------------------------------------------------

                  5                           1   +     5  +   1

 

if field2 is updated with value 5 then automatically the total formula field will be updated with the new value 7.

 

Click on KUDOS button if the post helps you!

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 

Regards,

Madhan Raja M

nandacnandac

Thank you for your reply.

 

Your reply would work if I was updating the field always based on the same field. This is not what is happening in my case. I want to set the balance of the bill to the total amount initially when the bill is created. In this case the formula field does the job.

 

However, when I make payments on the bill I want the balance to reduce by the amount paid on the payment. The payments are tracked by another custom object which has a master-detail relationship with the bill.

 

So my problem is I have a field that needs to be updated but cannot because it is a formula field. If the field is not a formula field I cannot set it to the total amount on the bill initially.

 

I believe there must be alternatives but may be I am just looking at this the wrong way.

 

I would appreciate any pointers.

 

Cheers.

Madhan Raja MMadhan Raja M

Create a Balance custom field to capture the Balance amount.

 

Formula:

 

Total Amount (Formula field) = field1__c+field2__c+field3__c-Balance__c

 

Regards,

Madhan Raja M

 

 

Shannon HaleShannon Hale

Generally speaking, if you want a value that is going to show the latest value every time you view the record, and you don't want the field to be editable, you'll want a formula field. If you want the update only to occur under certain circumstances -- like when you're creating the record -- or you want the field to be editable after, you'll want a workflow rule field update.

 

I think you can use a formula field on your billing object for Balance, and also create a roll-up summary field -- say it's called Payments Applied -- that sums the amounts of each child payment amount. Then your Balance field formula would be Amount__c - Payments_Applied__c. The Payments Applied field doesn't need to be on the detail page.

This was selected as the best answer
nandacnandac

Thank you for your reply.

 

I ended up implementing this using a workflow as per your post after some experimentation.

 

Cheers