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
BrenzoBrenzo 

Custom Javascript Button that Run (Edits Record) on Behalf of Designated User?

I have a basic javascript button that when clicked updates a datefield on the opportunity object. I'd like to know if it's possible to edit the code in this button so that any user can click it and it will appear as if the record was updated by me, the system admin. 

Here is the code:
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}

var opp = new sforce.SObject("Opportunity");
opp.Id = '{!Opportunity.Id}';
opp.Dataloader_Update_Date__c = '{!Opportunity.Dataloader_Update_Date__c}';
opp.Manager_Followed_Opportunity__c = '{!Opportunity.Manager_Followed_Opportunity__c}';

// assign values to fields on opportunity object
opp.Dataloader_Update_Date__c = new Date();
opp.Manager_Followed_Opportunity__c = true;

//save the change 
result = sforce.connection.update([opp]);

//refresh the page 
window.location.reload();

I was thinking of designating the user as the system admin (using my user ID), but I couldn't get it working. Ultimately, I want it to work so that after the page refreshes, it shows the record as being last modified by myself and not the user who clicked the button.

Thanks in advance!
BrenzoBrenzo
Really hopeful that someone out there can help me with this request? Thanks again...!