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
Cha YangCha Yang 

OnClick Javascript button to launch an url and update two fields

When users click on button, I want to it to launch an url in a new tab and populate the user's name on the a field call User_1__c and the current datetime on Logged_in_1__c. Object call Research_tools__c.

Please help!
Best Answer chosen by Cha Yang
Cha YangCha Yang
I got it to work how i wanted by this video tuturial. https://www.youtube.com/watch?v=zdtQtlzVR48

Below are my script. However, browser pop up blocker blocked when Java launch the url. How do I get around this?
I don't want to disable popup blocker for other safety. 
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")};


var p;
p = "You've been logged in to Accurint 1.  Please remember to log out when you're finished.";
alert(p);

var updateRecords= [];


var o = new sforce.SObject("Research_Tools__c");
o.id = "{!Research_Tools__c.Id}";
o.User_1__c ="{!User.Name}";
o.Logged_in_1__c = "{!Today}";


updateRecords.push(o);
result = sforce.connection.update(updateRecords);

window.location.reload();

window.open("https://secure.accurint.com/app/bps/main/");

 

All Answers

Cha YangCha Yang
I got it to work how i wanted by this video tuturial. https://www.youtube.com/watch?v=zdtQtlzVR48

Below are my script. However, browser pop up blocker blocked when Java launch the url. How do I get around this?
I don't want to disable popup blocker for other safety. 
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")};


var p;
p = "You've been logged in to Accurint 1.  Please remember to log out when you're finished.";
alert(p);

var updateRecords= [];


var o = new sforce.SObject("Research_Tools__c");
o.id = "{!Research_Tools__c.Id}";
o.User_1__c ="{!User.Name}";
o.Logged_in_1__c = "{!Today}";


updateRecords.push(o);
result = sforce.connection.update(updateRecords);

window.location.reload();

window.open("https://secure.accurint.com/app/bps/main/");

 
This was selected as the best answer