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
Money Care 7Money Care 7 

Function REQUIRESCRIPT may not be used in this type of formula

Hi Guys

I am facing this issue now when i am calling class uisng javascript like 

Error: Function REQUIRESCRIPT may not be used in this type of formula
 
global class SendTigerTuesday
{
public static blob b;
    
    WebService static string Tuesday(string id)
    {
     try
     {
              
          TigerTuesday__c qt=[Select id,Mail_Id__c,CreatedBy.name,Name, Issue_Date__c,Issue__c from TigerTuesday__c where id=:id];
        
        
            PageReference pdf =new PageReference('/apex/TigerTuesDayPDF?scontrolCaching=1&id='+Id);
            
            pdf.setRedirect(true);
           
          if(Test.isRunningTest() == false){
       b = pdf.getContent();
}
        
        //--------create a mail object to send a single email.--------
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
         
         string[] toaddress =String.valueOf(qt.Mail_Id__c).Split(',');

            mail.setToAddresses(toaddress);
          //  mail.setToAddresses(new string[] {qt.email__c}); // Internal_Email_User_Id__c text fied
          
            mail.setBccAddresses(new String[] {'maheswar@globalnest.com'});
            mail.setBccSender(true);
          
        
            mail.setSenderDisplayName(qt.CreatedBy.name);
            
           
            //mail.setSubject('News Flash For'+' '+qt.Company_Name__c);
            mail.setSubject('TigerTuesDay,'+' '+'Issue'+' '+qt.Issue__c +' '+'Dated '+' '+qt.Issue_Date__c);
            
        //------------- Create the email attachment-----------------
         
            
            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
            efa.setFileName('TigerTuesDay.pdf');
            efa.setBody(b);
        //-----------------------------------------------------------
            mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
            //mail.setPlainTextBody('Hi Sir/Madam, Please find the News Flash for '+qt.Company_Name__c +'\n'+'\n'+'Thanks & Regards'+'\n'+qt.CreatedBy.name);
      mail.setPlainTextBody('Dear Tiger Friend ,' + '\n' + '\n' + 'USAID’s Bagh Activity would like to share its weekly bulletin- TigerTuesday,'+' '+'Issue'+' '+qt.Issue__c +' '+'Dated '+' '+qt.Issue_Date__c+'.'+'\n'+'\n'+'Thanks & Regards'+'\n'+'\n'+qt.CreatedBy.name);
       
        //------------------------Attach sales order to a contract--------------------
         Attachment formAttach = new Attachment();
         formAttach.Name = 'TigerTuesday'+qt.Name+'.pdf';
         formAttach.body = b;
         formAttach.ContentType='application/pdf';
         formAttach.parentId =id;
         if (!Test.isRunningTest())
         {
          
           insert formAttach;
         }
        
            //send the email
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } );
           
            return 'TigerTuesDay PDF  has been sent';
        }
        catch(exception ex)
        {
           
          string ex1=string.valueof(ex);
          return ex1;
            
        }

    }
    
}
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var msg =sforce.apex.execute("SendTigerTuesday","Tuesday", {id:"{!TigerTuesday__c.Id}"}); 
window.alert(msg); 
window.location.href=location.href;


 
SandhyaSandhya (Salesforce Developers) 
Hi,

Please try to use below one.

 
<apex:includeScript value="/soap/ajax/15.0/connection.js"/>
<apex:includeScript value="/soap/ajax/15.0/apex.js"/>

Please let us know if this helps you!

Thanks and Regards
Sandhya
Money Care 7Money Care 7
I have tried like this var msg =sforce.apex.execute("SendTigerTuesday","Tuesday", {id:"{!TigerTuesday__c.Id}"}); window.alert(msg); window.location.href=location.href; but its again showing *Error:* Enter a URL that is valid and well-formed
SandhyaSandhya (Salesforce Developers) 
Hi,
 
You need to place all your javascript code inside the script tag.

Please refer below link you can get more information.

http://salesforce.stackexchange.com/questions/105692/function-requirescript-may-not-be-used-in-this-type-of-formula

Thanks and Regards
Sandhya