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
StaciStaci 

​Button click to always update in case history

I have a Take Case button on cases, when clicked is to change the case owner, status and substatus accordingly, fill in some dates, mark all this in case history as well as mark that the button was clicked.

We're finding that when the button is clicked the first time, everything works great, I can see in history that the button was clicked.  But if the button is clicked a second time, it doesn't show that.  It only shows that it updated the user.

How can I get it to fill in EVERYTIME its clicked?
 
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject("Case");

caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$User.Id}';
caseObj.Status = 'In Progress';
caseObj.Take_Case_button_clicked__c = "Take Case";
var roleName = '{!$UserRole.Name}';
if((roleName.indexOf("Tier 3") != -1) || (roleName.indexOf("CW NPI") != -1) || (roleName.indexOf("CW CPI") != -1) || (roleName.indexOf("Field Operation") != -1) || (roleName.indexOf("Service Engineer") != -1))
{
caseObj.Substatus__c = 'Open with Product Specialists';
if('{!Case.CW_T3_First_Reponse__c}'=='')
{
caseObj.CW_T3_First_Reponse__c=new Date().toJSON();
}
if('{!Case.Incident_First_Response__c}'=='')
{
caseObj.Incident_First_Response__c=new Date().toJSON();
}
if('{!Case.CW_Advance_Support_Needed__c}' == false)
{
caseObj.CW_Advance_Support_Needed__c = true;
}
}
else
{
caseObj.Substatus__c = 'Open with Support Advocates';
if('{!Case.Incident_First_Response__c}'=='')
{
caseObj.Incident_First_Response__c=new Date().toJSON();
}
}
var result = sforce.connection.update([caseObj]);

if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
window.parent.location.href="/{!Case.Id}";
}

 
Best Answer chosen by Staci
StephenKennyStephenKenny
Hi Staci,

The standard history is only updated if one of the fields currently being tracked is changed. So for your example above, when the owner is changed for the first time, you will see this in the history, but for the second time, as the owner does not change, there is notihng to display in the history. There is no way around this unfortunatly and you are unable to modify the standard history short of choosing what fields to track

In order to capturef every time a record has been updated, you would have to create a new custom object, and a trigger to populate it everytime the parent object is updated.

Hope this makes sense let me know if anything is unclear.

Regards
Stephen