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
tzuvytzuvy 

Date Function on Custom Case Button

Hi, I'm trying to create an escalation button in which a Level 2 analyst will use it to escalate his case to a level 3 analyst.

 

After doing so some fields should be updated, name, role and the date the escalation was done.

 

{!requireScript('/soap/ajax/20.0/connection.js')} 
try{ var update_Case = new sforce.SObject('Case'); update_Case.Id = '{!Case.Id}'; update_Case.Disable_Change_Owner_Validation__c = new Date(); update_Case.Escalated_By_Name__c = '{!$User.FirstName} {!$User.LastName}'; update_Case.Esclated_By_Role__c ='{!$UserRole.Name}';update_Case.Escalated_on__c ={!DATEVALUE(NOW())};update_Case.OwnerId = "00G00000006pPTc" ;var updateRecords = []; updateRecords.push(update_Case); var resultUpdate = sforce.connection.update(updateRecords); if (resultUpdate[0].getBoolean("success")) { parent.location.href = "/" + '{!Case.Id}'; }else{ alert(resultUpdate[0].errors.message); } }catch(err){ alert(err.description); }

 

As you can see, I created a javascript button but I'm having problems with the date field. The field is called Case.Escalated_on__c  and is a date one. How whould I insert the date of the moment the button was clicked? I tried Now, Today. Nothing worked. I get a weird number 0.11545444666

 

Can someone help?

 

Thanks

 

Tzuvy

 

 

Josephadm401Josephadm401

Create a hidden formula date field or date-time field on the page that returns Today() or Now() respectively. Then reference this in your button. I believe the reson that this is not working is because Salesforce thinks you are trying to reference a field that is not there. This is just a workaround that I believe will work for you as I do not know much coding.