You need to sign in to do that
Don't have an account?
Peter Russell 9
Custom button to clear field data
Hi,
I would like to create a jscript button to clear two fields in an opportunity when pressed.
Above is the code I am trying but I just get error messages. The Task_Due and Task_Notes are the custom fields I am trying to reset to empty. Task Due is a date field and Task Notes is a long text field.
Anyone have any ideas on what is wrong or what needs correcting?
Thanks,
Pete
I would like to create a jscript button to clear two fields in an opportunity when pressed.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} var newRecords = []; var c = new sforce.SObject("Opportunity"); c.id ="{!Opportunity.Id}"; c.Task_Due__c = " "; c.Task_Notes__c = " "; newRecords.push(c); result = sforce.connection.update(newRecords); window.location.reload();
Above is the code I am trying but I just get error messages. The Task_Due and Task_Notes are the custom fields I am trying to reset to empty. Task Due is a date field and Task Notes is a long text field.
Anyone have any ideas on what is wrong or what needs correcting?
Thanks,
Pete
Please use the below code in the button.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Opportunity");
c.id ="{!Opportunity.Id}";
c.Task_Due__c = null;
c.Task_Notes__c = " ";
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
Thanks,
Sarav
Sweet Potato tec
Just that null that was missing!
Please mark it as best answer if it's resolved.
So that it will be helpful to others.
Thanks,
Sarav
Sweet Potato Tec
Just to follow up - the button is working great.
Just wondeting if there is a way for SF to take the data that is in the fields (Date/time & Text) and either input it into a post on the opportunity page or create a completed task with that info.
Just to give context, the fields are a method of setting tasks, once the task is complete, the button will clear the fields but I would like a trail of what was input into the fields.
Thanks,
Pete
Yes, you can create a proces builder to achieve this.
Step 1 : Select 'Opportunity' as object with 2nd condition.
Step 2: Create the criteria as ISCHANGED([Opportunity].Task_Due_Date__c) && ISBLANK([Opportunity].Task_Due_Date__c)
&& ISCHANGED([Opportunity].Task_Notes__c) && ISBLANK([Opportunity].Task_Notes__c)
Step 3: Immediate Action with Task object and fill the mandatory fields.To get the Task_Due_Date__c and Task_Notes__c in Task object use the PRIORVALUE fuction and use the related to ID field to relate the task to Opportuity.
Please let me know if you can able to follow the steps.
Thanks,
Sarav
Sweet Potato Tec
Yes I can follow these steps, I am a complete novice when it comes to coding so I have no idea what formulae are supposed to go in the field in Step 3, could you please let me know?
Thanks,
Pete
Thank you for your help.
In step 3 if you select Due Date and Select Formula as the value and paste the below line.
PRIORVALUE([Opportunity].Task_Due_Date__c )
Paste the beow line for Subject and Select Formula as the value and paste the below line.
PRIORVALUE([Opportunity].Task_Notes__c )
Please let me know if you can't follow the steps.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Thanks,
Sarav
Sweet Potato Tec
Thanks
You could using PRIORVALUE(DATEVALUE([Opportunity].Task_Due_Date__c ) )
If your field is date and time and you need to get only date.
Thanks,
Sarav
Sweet Potato Tec
I get the following error:
The formula expression is invalid: Incorrect argument type for function 'PRIORVALUE()'.
Thanks,
Pete
DATEVALUE(PRIORVALUE([Opportunity].Due_Date_Time__c ) )
Thanks,
Sarav
Sweet Potato Tec
Please mark this thread as solved if it was helped.
So that others will be able to get help from this.
Thanks,
Sarav
Sweet Potato Tec
The fields are populated to be able to show a what-if scenario if additional costs were to hit our project. I'd like to have the ability to set them back to $0 once the user has checked the addition costs or deductions. This is on a custom object 'Proj Sales Distribution' ID a1c4u000003WfVHAA0