You need to sign in to do that
Don't have an account?
Nelly78
Javascript button with password help!
Not sure where I am going wrong but I need a javascript button to make a checkbox true...easy enough and Ive done it loads....but here I want the user to be prompted for a password which they enter and then the checkbox is marked true if they have the password correct. I have been trying the code below but I keep getting Error: The Name field is required
var ans=prompt("Please enter password","");
if(ans=="123"){
var newRecords=[];
var q=new sforce.SObject("Quote");
q.id="{!Quote.Id}";
if({!Quote.Override_Docusign__c}==false){
q.Override_Docusign__c=true;
newRecords.push(q);
result=sforce.connection.update(newRecords);
window.location.reload();
}
else
{alert
("Override already marked true");
}
else{
alert("Incorrect Password")
}
var ans=prompt("Please enter password","");
if(ans=="123"){
var newRecords=[];
var q=new sforce.SObject("Quote");
q.id="{!Quote.Id}";
if({!Quote.Override_Docusign__c}==false){
q.Override_Docusign__c=true;
newRecords.push(q);
result=sforce.connection.update(newRecords);
window.location.reload();
}
else
{alert
("Override already marked true");
}
else{
alert("Incorrect Password")
}
Try the below code snippet as reference:
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")}
sforce.connection.sessionId = "{!$Api.Session_ID}"
var ans = prompt("Please enter password", "");
if (ans == "123")
{
var newRecords = [];
var q = new sforce.SObject("Quote");
q.id = "{!Quote.Id}";
if ({!Quote.Override_Docusign__c} == false)
{
q.Override_Docusign__c = true;
newRecords.push(q);
result = sforce.connection.update(newRecords);
window.location.reload();
}
else
{
alert("Override already marked true");
}
}
else
{
alert("Incorrect Password")
}
Regards
Ankit Gupta
All Answers
Try the below code snippet as reference:
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")}
sforce.connection.sessionId = "{!$Api.Session_ID}"
var ans = prompt("Please enter password", "");
if (ans == "123")
{
var newRecords = [];
var q = new sforce.SObject("Quote");
q.id = "{!Quote.Id}";
if ({!Quote.Override_Docusign__c} == false)
{
q.Override_Docusign__c = true;
newRecords.push(q);
result = sforce.connection.update(newRecords);
window.location.reload();
}
else
{
alert("Override already marked true");
}
}
else
{
alert("Incorrect Password")
}
Regards
Ankit Gupta
Many thanks it works perfectly!!!