You need to sign in to do that
Don't have an account?

Custom button and a formula
Hello,
I have a question, I am making a custom button which need to generate data from certain formula and after that put the data in given field, the formula was the easy pars, and as I am new to salesforce, I can't get a way to put the data into the given field, I am having this formula code:
{!PayedSum__c.Payed_Sum__c} = {!Account.Compensation_Sum__c} - {!Account.Payed_Compensation_Sum__c} AND {!PayedSum__c.Payed_Date__c} = {!TODAY()}
As you can see from the code I need to put the data in sObject PayedSum__c field Payed_Sum__c, can someone help me how to put the result from this formula into the Payed_Sum__c field ?
Thank you in advance,
Bozidar
All Answers
Your question is confusing, could you elaborate on what you wanted to do.
Create custom button on detail page calculate all in apex controller and call that apex controller on button click and put data in given field in same controller.Button should be ajax type.It is one of the way.
Alternative,
Create formula field do calculation in that field using formula
{!PayedSum__c.Payed_Sum__c} = {!Account.Compensation_Sum__c} - {!Account.Payed_Compensation_Sum__c} AND {!PayedSum__c.Payed_Date__c} = {!TODAY()}
and update Payed_Sum__c field using workflow field update or trigger
Thanks,
Amit Trivedi
But if need a ajax example, refer below:
I get this error:
Can you tell me what is my mistake ?
Thank you
Have a look at the example which was provided earlier.
Elaborate on whats not working.
I get this error, even though all fields included in equation are Currency:
Can someone point me how I suppose to create new record of type PayedSum__c and write the result in field Payed_Sum__c.
Thanks
Currently it is just refreshing the Account page.
Try the code below: