• Nelly78
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi all hope you can help me!!
I have used the methods described in this post: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008r4xIAA&language=en 
to create a custom PDF that attaches to the quote. Now I am stuck and dont know where to start to write a test class for the attachmentgenerator web service class below! Can anyone help?

global class AttachmentGeneratorCustomUK{
webService static String AttachPDFToQuote(string Id) {
        string retRes = '';
        try
        {
         PageReference pageRef = new PageReference('/apex/Quote_No_T_C_UK?Id='+Id);
         Blob content = pageRef.getContent();
         QuoteDocument doc = new QuoteDocument(Document = content, QuoteId = Id);
         insert doc;

         retRes='SUCCESS';
         return retRes;
       } catch(exception ex) {
           System.debug('--- Error ----------'+ ex);
           retRes= ex.getMessage();
           return retRes;
       }
   }
}
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")
}
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")
}