• Nasir
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 31
    Replies

Hi 

 

I have created a button on Account which is a Custom object'SendInvitation'.When i click that button a page appear where the user have to fill the 'To' and 'Subject' and 'body' of the Invitation.I have used Standardcontroller and two visualforce page.One contain the 'mail' section and other contain the 'PDF' page.In my PDF page i am using {!Account__c.Name} and {!Account__c.Visit_Date__c} which is not getting populated, because of the following error.VisualforceException: SObject row was retrieved via SOQL without querying the requested field: Account__c.Name

 

I am able to send email with the Attachments.But when i click the View button on the mail to see the PDF.The PDF page dosen't open.

 

In system log i am getting this Error:System.VisualforceException: SObject row was retrieved via SOQL without querying the requested field: Account__c.Name  and this error is comin in the line which is Bold( b= pdf.getContent();) in the controller.

 

All i want now that Account name and visit date should display

 

 

 

Below is the code

public  class SendInvitationByMail {
    public String subject { get; set; }
    public String body { get; set; }
    public Account__c acc{ get; set; }
    public Id idacc;
   
    
    public SendInvitationByMail(ApexPages.StandardController controller) {
    idacc =controller.getRecord().id;
    acc = [Select Name,Email__c,Subject__c,EmailBody__c,Visit_Date__c from Account__c where id=:idacc];
    System.debug('record:'+acc);

    }
 

    public PageReference send() {
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    // Reference the attachment page and pass in the account ID
    PageReference pdf = Page.attachmentPDF;
    pdf.getParameters().put('id',(String)acc.id);
  
    pdf.setRedirect(true);
    // Take the PDF content
     Blob b ;
     String n;
      try
      {
        
        b= pdf.getContent();
       
        system.debug('Blob'+b);
        }
        catch(VisualforceException e)
        {
         b=Blob.valueOf('SObject row was retrieved via SOQL without querying the requested field: Account__c.Name');
        
        }
    // Create the email attachment
    Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
    efa.setFileName('attachment.pdf');
    efa.setBody(b);

    if(acc.Email__c == null){
     acc.Email__c.addError('Please fill the To with an email address');

    }
     String addresses;
    if(acc.Email__c!=null){
    addresses=acc.Email__c;
    }
    String[] toAddresses = addresses.split(':', 0);
  
    email.setSubject( subject );    
    email.setToAddresses(toAddresses);
    email.setPlainTextBody( body );
    
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

    // Sends the email
    Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

    

        return null;
    }


}

 

 

 

 

 

 

 

 

Actually In my PDF visualforce page i am using {!Account__c.Name} and {!Account__c.Visit_Date__c} .

<apex:page standardController="Account__c" extensions="SendInvitationByMail" sidebar="false">

<apex:pageBlock tabStyle="Account" title="Send Invitation">

<apex:panelGrid columns="2">
<apex:form >
<apex:outputLabel value="To :"></apex:outputLabel> &nbsp;
<apex:inputField value="{!acc.Email__c}"/><br/><br />
<apex:outputLabel value="Subject :"></apex:outputLabel>&nbsp;
<apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
<br /><br />
<apex:outputLabel value="Body" for="Body"/>:<br />
<apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/>
<br /><br /><br />
<apex:commandButton value="Send Invitation" action="{!send}"/>
          

</apex:form>
</apex:panelGrid>

</apex:pageBlock>

</apex:page>
<apex:page standardController="Account__c"  extensions="SendInvitationByMail" renderAs="PDF" id="SendInvitationByMail">

Dear {!Account__c.Name},<br/>


You are cordially invited to the Visitors Day Meeting of the BNI Gems Chapter at The Royal Orchid
Hotel Spring Hall (Adjoining KGA Golf Course), HAL Airport Road on Friday {!Account__c.Visit_Date__c} . The
meeting will start promptly at 7:45AM and finish at 9.45AM. We will be sharing BNI's Secrets to
Success through "Word-of-Mouth" Marketing.<br/><br/>

BNI is a business and professional networking organisation whose primary purpose is to exchange
qualified business referrals. It is the most successful organisation of its type in the world today, with
over 5,800 chapters in operation world-wide (including the UK, USA, Malaysia, Singapore, Germany,
South Africa and Australia). Last year, members of BNI passed more than 6.5 million referrals which
generated more than Rs. 12,600 Crores worth of business for its members.<br/><br/>

What makes BNI unique is that it allows only one person per profession to join a chapter. Thus, once
you've joined, there is no conflict in passing leads, and none of your competitors can participate! BNI
is currently looking for IT PLM Consulting company to refer your business to. I would like to invite you

to the Visitors Day Meeting so you can learn more about the organisation, and find out if you would be
interested in generating a steady source of referrals for your business.<br/><br/>

Seating is limited, so please RSVP by calling me on +919342837640. There will be a nominal Rs.350/-
Meeting Fee, which includes breakfast. If you have any questions, please contact me. Remember to bring
plenty of business cards (at least 100 numbers) to pass around, as you will meet a lot of local business
people.<br/>

Venue<br/>
Seasons 1<br/>
The Royal Orchid Hotel<br/>
No 1, Golf Avenue, Adjoining KGA Golf Course<br/>
Old Airport Road, Bangalore 560008<br/>

Program<br/>
7:15AM-7:45AM – Open Networking<br/>
7:45AM – Meeting Starts<br/>
10:00AM – Onwards – Breakfast<br/>

Register here:<br/>
https://spreadsheets.google.com/a/rixyncs.co.in/spreadsheet/viewform?formkey=dHcwZmw5MnJtUWxHVGo0b0ZuajViZWc6MA#gid=0



Yours Sincerely,<br/>

P Ramesh Chander<br/>
Rixyncs India Inc<br/>
Core Group Member, BNI Gems Chapter<br/>

P.S: Please feel free to bring any business associate(s) with you who may also be interested in finding out how to generate more business through word of mouth referrals - this is a unique and really exciting opportunity for any individual or
 organisation to increase their business!<br/>

</apex:page>

 Please help.I will Appriciate your concer.

 

Thanks

 

Nasir

 

 

 

 

  • June 20, 2011
  • Like
  • 0

Hi ,

 

I have a controller through which i want to display all the fields in a page.My method "surveyform" is not working.I want to display all the fields value so that a user can input some value in it and save it.

 

 

<apex:page standardController="Case" extensions="Survey" sidebar="false">
 <apex:form style="background-color:#FFFFFF;"> 
    <style type="text/css">
        body {font-family:Arial Unicode MS;font-size:12px;}
        P{background-color:#006400;HEIGHT:20PX;font-size:12px;font-weight:bold;color:#FFFFFF;}
    </style>

 <apex:pageBlock title="Survey Form">
 <apex:pageBlockSection title="Please enter the details" collapsible="true"  columns="2" showHeader="true" 

onmouseover="hover">
  <apex:dataTable value="{!surveyform}" var="line"  width="50%">
 <apex:column >
 <apex:outputText value="Survey Name:" style="width:50px"/><br/>
 <apex:outputText value="How was the Case handling power:" style="width:50px"/><br/>
 <apex:outputText value="How was the feedback:" style="width:50px"/><br/>
 <apex:outputText value="Case:" style="width:50px"/><br/>
 </apex:column>
 <apex:column >
 <apex:inputField value="{!line.Name}"/><br/>
 <apex:inputField value="{!line.How_was_the_Case_handling_power__c}"/><br/>
 <apex:inputField value="{!line.How_was_the_feedback__c}"/><br/>
 <apex:outputField value="{!line.Case__c}"/><br/>
 </apex:column>

 
 </apex:dataTable>
 </apex:pageBlockSection>
 <center><apex:commandButton value="Save" action="{!Survey}"/>
 <apex:commandButton value="Cancel" action="{!Cancel}"/> </center>
 </apex:pageBlock> 

 </apex:form> 
</apex:page>
                  

 

 

My Controller

 

public  class Survey {

  public List<Survey__c> sur{get;set;}
  public Id srid;
  public Case cs;
  public Id cid;
  public ApexPages.StandardController a;

     public Survey(ApexPages.StandardController
                                      stdController) {
       cs = (Case)stdController.getRecord();
       system.debug('menon:'+ cs);
       a = stdController;
       cid = a.getRecord().id;
       system.debug('Survey:'+ cid);
         }
         
         
     public List<Survey__c> getSurveyform() {
         sur= [Select Name,How_was_the_Case_handling_power__c,How_was_the_feedback__c,Case__c from Survey__c where Case__c=:cid ];
         System.debug('sana:' + sur);
       
       
         return sur;
          }
    
     Public PageReference Survey(){
     insert(sur);
     return null;
          }
       
}

 

 

  • April 28, 2011
  • Like
  • 0

Hi

 

I had written a code for email to lead which creates a lead in salesforce.This is working currently and the email address comes who is sending the mail.but the requirement got changed.

 

Suppose a "student" (jawed@gmail.com)send a mail to Nasir whose email id is(nasir@gmail.com) ,and Nasir forward this email to email service in salesforce.A lead should create in salesforce with email of the student(jawed@gmail.com).Currently it is creating a lead with email of Nasir(nasir@gmail.com).

 

Below is my code

Global class unsubscribe implements Messaging.inboundEmailHandler{
    Lead lead;
    Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope env)
    {

    // Create an inboundEmailResult object for returning
    //the result of the Apex Email Service
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    String strEmailId = email.fromAddress;
    String strSubject = email.subject;
    String myText=email.plainTextBody;
    String myFromName = email.fromName;
   // TextBody = email.plainTextBody,
     //String HtmlBody = email.htmlBody;
   
    //Create a new test Lead and insert it in the Test Method 
    integer iCount;
    iCount = [select count() from Lead where Email=:email.fromAddress];
    system.debug('icount'+icount);
    if (iCount==0)
    {   
        lead = new Lead(lastName=myFromName,Company=myFromName,Email=strEmailId,LeadSource='OnlineEnquiry',Description=strSubject+'\n'+myText,OwnerId='00590000000OJ0w'); //Change this id with user's id to whome you want to assign this lead.
        insert lead;    
       
    }
    if (email.binaryAttachments!=null && email.binaryAttachments.size() > 0) {
        for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
            
                    Attachment newAttachment = new Attachment();
                      newAttachment.ParentId =lead.id;
                    //system.debug('AttachmentIDDDDDDDDDDDDd'+newAttachment.ParentId);
                     newAttachment.Name = email.binaryAttachments[i].filename;
                     newAttachment.Body = email.binaryAttachments[i].body;
                    insert newAttachment;
                }
    }
    
    
    result.success = true;
    return result;
    
    }  


    /* Only for test case */

    // Test method to ensure you have enough code coverage
    // Have created two methods, one that does the testing
    // with a valid "unsubcribe" in the subject line
    // and one the does not contain "unsubscribe" in the
    // subject line
  static testMethod void testUnsubscribe() {

   // Create a new email and envelope object
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
        Messaging.InboundEmail.BinaryAttachment inAtt = new Messaging.InboundEmail.BinaryAttachment();


        email.subject = 'test unsubscribe test';
       email.fromName = 'abhi k';
       email.fromAddress = 'abhilash@rixyncs.co.in';
       // email.subject='test';
       email.plainTextBody='zsdzdf';

       
      Lead l = new lead(firstName='Rasmus',
                lastName='abc',
                Company='Salesforce',
                Email='rmencke@salesforce.com',LeadSource='OnlineEnquiry',Description='dsdfdgf'
                );
         insert l;
       Id aid=l.id;
    // Create a new test Contact and insert it in the Test Method 
       Contact c = new Contact(firstName='Rasmus',
                    lastName='Mencke',
                    Email='rmencke@salesforce.com');
       insert c;
      Attachment att=new Attachment(ParentId=aid,name='test',body=blob.valueof('test'));
      system.debug('attachgment'+ att.ParentId);
      insert att;
      // test with subject that matches the unsubscribe statement
  
    if(inAtt!=null){

      inAtt.body = blob.valueOf('test');
      inAtt.fileName = 'my attachment name';
      inAtt.mimeTypeSubType = 'plain/txt';
   
       email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] {inAtt}; 
        }
       // call the class and test it with the data in the testMethod
       unsubscribe unsubscribeObj = new unsubscribe();
       unsubscribeObj.handleInboundEmail(email, env);
                           
       }
       
      

}

 

 

Thanks

 

Plz help

  • March 17, 2011
  • Like
  • 0

Hi,

 

I am trying to create  an Email to lead.i mean when i use the email service link to send the mail to SF, a lead is generated.As this is working ,but when i am trying to attach a file with the Email.The file is not comin as attachments.My code is under.Can any one try to solve my problem.

Global class unsubscribe implements Messaging.inboundEmailHandler{

    Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope env )
    {

    // Create an inboundEmailResult object for returning
    //the result of the Apex Email Service
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    
 
    String strEmailId = email.fromAddress;
    String strSubject = email.subject;
    String myText=email.plainTextBody;
    String myFromName = email.fromName;
    Lead l;
    
       

    //Create a new test Lead and insert it in the Test Method 
    integer iCount;
    iCount = [select count() from Lead where Email=:email.fromAddress];
    if (iCount==0)
    {   
        l = new Lead(
        lastName= myFromName, //strEmailId,
        Company=myFromName,
        Email=strEmailId,
        LeadSource='OnlineEnquiry',
        Description=strSubject+'\n'+myText,
        OwnerId='00590000000OJ0w'); //Change this id with user's id to whome you want to assign this lead.
        insert l;    
       
    }
   
   
    result.success = true;
    return result;
    for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
     Attachment attachment = new Attachment();
     
    attachment.Name = tAttachment.fileName;
     attachment.Body = Blob.valueOf(tAttachment.body);
     attachment.ParentId = l.Id;
     insert attachment;
    }
    for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
     Attachment attachment = new Attachment();
     
    attachment.Name = bAttachment.fileName;
     attachment.Body = bAttachment.body;
      attachment.ParentId =l.Id;
     insert attachment;
   
    }
     result.success = true;
    return result;
    }  


    /* Only for test case */

    // Test method to ensure you have enough code coverage
    // Have created two methods, one that does the testing
    // with a valid "unsubcribe" in the subject line
    // and one the does not contain "unsubscribe" in the
    // subject line
   static testMethod void testUnsubscribe() {

   // Create a new email and envelope object
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
      
        // Create a new test Lead and insert it in the Test Method       
       Lead l = new lead(firstName='Rasmus',
                lastName='abc',
                Company='Salesforce',
                Email='rmencke@salesforce.com',LeadSource='OnlineEnquiry',Description='dsdfdgf'
                );
       insert l;
    
    // Create a new test Contact and insert it in the Test Method 
       Contact c = new Contact(firstName='Rasmus',
                    lastName='Mencke',
                    Email='rmencke@salesforce.com');
       insert c;
      
       // test with subject that matches the unsubscribe statement
       email.subject = 'test unsubscribe test';
       email.fromName = 'abhi k';
       email.fromAddress = 'abhilash@rixyncs.co.in';
        email.subject='test';
       email.plainTextBody='zsdzdf';
        
       
       
  
       // call the class and test it with the data in the testMethod
       unsubscribe unsubscribeObj = new unsubscribe();
       unsubscribeObj.handleInboundEmail(email, env );
                           
       }
       
      /* static testMethod void testTrigger() {
        Lead l = new Lead(lastName='testTrigger',Status='Qualified',Email='abhi@rixyncs.co.in',
                          Company='Rixyncs',MobilePhone='919901379361');
        insert l;
      //  SMS__c s = new SMS__c(To_Lead__c=l.Id,Message__c='Test');
      //  insert s; 
        
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(l.Id);
        lc.setConvertedStatus('Qualified');
        Database.LeadConvertResult lcr = Database.convertLead(lc);
    }*/

}

 Please help me.

 

Thanks

 

Nasir

 

  • February 24, 2011
  • Like
  • 0

Hi All,

 

I am not able to execute if statement.It is giving me null pointer exception.below is the code

public class SingleSmsController {
 
    private ApexPages.StandardController con;
    private PageReference smsPR=null;
    public String msg {get; set;}
    private String url;
    private String mobileNo;
    private String status;
    private String msgStatus;
    private SMS__c smsObj;
    private SMSHttpRequestResponse shrr;
     
    public SingleSmsController(ApexPages.StandardController controller) {
        con = controller;
        shrr = new SMSHttpRequestResponse();
        smsObj = new SMS__c();
        smsObj = (SMS__c) con.getRecord();
        if((ApexPages.currentPage().getParameters().get('sms')).equals('lead'))
            smsObj.To_Lead__c = ApexPages.currentPage().getParameters().get('CF00NO0000000GAGe_lkId');
        else if((ApexPages.currentPage().getParameters().get('sms')).equals('contact'))
            smsObj.To_Contact__c = ApexPages.currentPage().getParameters().get('CF00NO0000000GAGa_lkId');
    }
  
    public PageReference sendAction() {
    try{
        if(smsObj.To_Lead__c != null) 
            mobileNo = [select Id,MobilePhone from Lead where id=:smsObj.To_Lead__c][0].MobilePhone;
        else if(smsObj.To_Contact__c != null) 
            mobileNo = [select Id,MobilePhone from Contact where id=:smsObj.To_Contact__c][0].MobilePhone;
        
        //System.debug('### MobileNo: '+ mobileNo);
        if(mobileNo.startsWith('60') || mobileNo.startsWith('+60')) {
            url='http://www.onewaysms.com.my/api2.aspx?apiusername=xxAPIU6QF39AOLY&apipassword=APIU6QF39AOLY8UXUB'+
            '&mobileno='+mobileNo+'&senderid=NilaiUni.&languagetype=1&message=RM0.00 '+ 
            EncodingUtil.urlEncode(msg, 'UTF-8') +'';
        }
        else {
            url='http://www.onewaysms.com.my/api2.aspx?apiusername=xxAPIU6QF39AOLY&apipassword=APIU6QF39AOLY8UXUB'+
            '&mobileno='+mobileNo+'&senderid=NilaiUni.&languagetype=1&message='+ 
            EncodingUtil.urlEncode(msg, 'UTF-8') +'';
        }
        //System.debug('### URL: '+ url);
        
        status = shrr.getContent(url);
        System.debug('### res.getBody() '+status);
        
        if(status.equals('-600'))
            msgStatus = 'Failed-Insufficient balance';
        else if(status.equals('-300'))
            msgStatus = 'Failed-Invalid mobile number';
        else if(status.equals('-100'))
            msgStatus = 'Failed-Invalid credentials';
        else if(status.contains('-'))
            msgStatus = 'Failed';
        else
            msgStatus = 'Success-Sent';
        
        //System.debug('### Status Number: '+ status);
        //System.debug('### Status String: '+ msgStatus);
        
       }
       catch(Exception e) {
           msgStatus = 'Failed';
           //msgStatus = 'Failed-'+ e.getTypeName();
          // System.debug('### Exception: '+e.getMessage());
       }
       
       smsObj.Message__c = msg;
       smsObj.Message_Status__c = msgStatus;
       smsObj.Mobile_No__c = mobileNo;
       smsObj.MessageID__c = status;
       smsObj.RecordTypeId = '012O000000008OB';
       insert(smsObj);
       
       System.debug('### SMS ID: '+ smsObj.Id);      
       smsPR = new PageReference('/'+ smsObj.Id);
       smsPR.setRedirect(true);
       return smsPR;
     }
     public static testMethod void smsTest(){
        SMS__c smsOb = new SMS__c(Message__c ='i am interested',To_Lead__c ='00QO0000000ydUa');
        insert smsOb;
        Lead l = new Lead();
        Contact co = new Contact();
        ApexPages.StandardController apexpag = new ApexPages.StandardController(smsOb);
     
        SingleSmsController smsCont = new SingleSmsController(apexpag);
        System.debug('nasir:'+ smsCont );
        
        SMSHttpRequestResponse shrr = new SMSHttpRequestResponse();
        smsCont.sendAction();
        
     }
     
}

 the line below is giving me null pointer exception.Please help me to make this code 75 % covetage.

 

if((ApexPages.currentPage().getParameters().get('sms')).equals('lead'))
            smsObj.To_Lead__c = ApexPages.currentPage().getParameters().get('CF00NO0000000GAGe_lkId');

 

  • February 06, 2011
  • Like
  • 0

Hi

 

I am trying to write the test method for the class below.but i am not abloe to cover "if" statements.

//    Description: This is the controller for checking delivery of
//                 both Single SMS as well as Bulk SMS to Leads/Contacts.
//    Author: Abhilash K

public class DeliveryController {

private String mtId;
private String[] mtArray;
private Integer iter;
private String myId;
private String response;
private String storeResponse;
private SMSHttpRequestResponse shrr;
private String smsType;
private SMS__c smsObj;
private Bulk_SMS__c bulkObj;
private PageReference pr;
public String credit;

    public PageReference checkDelivery() {
        ApexPages.Message myPageErrMsg;
        storeResponse = '';
        shrr = new SMSHttpRequestResponse();
        try {
            mtId = ApexPages.currentPage().getParameters().get('mtid');
            myId = ApexPages.currentPage().getParameters().get('id');
            smsType = ApexPages.currentPage().getParameters().get('type');
            System.debug('### '+mtId+' '+myId+' '+smsType);
            if(smsType.equals('bulk')) {
                mtArray = mtId.split(',');
                iter = mtArray.size();
                System.debug('### mtArray: ' + mtArray); 
                System.debug('### iter: '+ iter);
            }
            else {
                mtArray = new String[] {mtId};
                iter = 1;
            }
            for(Integer i=0; i<iter; i++) {
                System.debug('### Inside for loop:' + i); 
                response = shrr.getContent('http://www.onewaysms.com.my/bulktrx.aspx?mtid='+ mtArray[i]);
            
                if(response.equals('0')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Message Delivered');
                    storeResponse = storeResponse  + 'Delivered';
                }
                else if(response.equals('100')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM,'Waiting');
                    storeResponse = 'Waiting';
                }
                else if(response.equals('-100')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Invalid ID/not found');
                    storeResponse = 'Invalid ID';
                }
                else if(response.equals('-200')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Sending Failed');
                    storeResponse = 'Sending Failed';
                }
                else {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Checking Failed');
                    //storeResponse = 'Checking Failed';
                }
            }
            
            // Check SMS Credit balance
            credit = shrr.getContent('http://www.onewaysms.com.my/bulkcredit.aspx?apiusername=APIU6QF39AOLY&apipassword=APIU6QF39AOLY8UXUB');
            try {
                Integer x = Integer.valueOf(credit);
            }
            catch(Exception e) {
                credit = 'Checking Failed';
            }
            
            if(smsType.equals('single')) {
                smsObj = [select Id,Message_Status__c from SMS__c where Id=:myId][0];
                if(storeResponse != '')
                    smsObj.Message_Status__c = storeResponse;
                update smsObj;
            }
            else if(smsType.equals('bulk')) {
                bulkObj = [select Id,Message_Status__c from Bulk_SMS__c where Id=:myId][0];
                if(storeResponse != null)
                    bulkObj.Message_Status__c = storeResponse;
                update bulkObj;
            }        
        }
        catch(Exception e) {
           myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
        }
        ApexPages.addMessage(myPageErrMsg);    
        return null;
    }
    
     public PageReference goBack() {
         pr = new PageReference('/' + myId);
         pr.setRedirect(true);
         return pr;
    }

    public String getCredit() {
        return credit;
    }
    public static testMethod void redirect(){
     	SMS__c smsObj =new SMS__c();
     	Bulk_SMS__c bul = new Bulk_SMS__c();
     	
     	DeliveryController delCon = new DeliveryController();
     	delCon.checkDelivery();
     	
     	delCon.getCredit();
     	delCon.goBack();
     	 
     	
     	
     }
}

 

Please help

 

  • February 04, 2011
  • Like
  • 0

Hi 

 

I have  object called "Sales order" and "week management".Week management have some records.i have created a button on week management called "create sales order".When a user  select a record in weekmanagement by clicking it,and then click "Create sales order"  then record in a sales order record is created in sales order object.

 

I have to do this by using java script coz i had choosed use javascript to create that button. and i have to use web services.

 

How can i do that.

 

Plz help

 

Nasir

  • December 22, 2010
  • Like
  • 0

Hi

 

I am facing problem in updating a field from TMS__Time__c  to Sales_Order_Item__c

 

I had written this code,but this is not working.

trigger updatesalesorderitem on TMS__Time__c (before insert, before update)
{List<Sales_Order_Item__c> updateList = new List<Sales_Order_Item__c>();
for(TMS__Time__c co : Trigger.new){
Sales_Order_Item__c sa = [SELECT Comments__c FROM Sales_Order_Item__c WHERE Id = :co.TMS__Comments__c];

if(sa.Comments__c == null || sa.Comments__c ==''){
sa.Comments__c = co.TMS__Comments__c;

updateList.add(sa);
}
}
if (updateList.size() > 0) update updateList;
}

 As this code worked for to update field.But i am facing problem in SOQL query .Plz check and update me.

 

Thanks

 

Nasir

 

  • December 21, 2010
  • Like
  • 0

Hi

 

i am trying to write a trigger which will update an email field from contact to customer emailfield in account.But this is not working.

 

 

trigger updatecontact on Contact (before insert, before update) {
Account acc = [SELECT Customer_Email__c FROM Account Limit 1];
  Contact con = [SELECT Email FROM Contact limit 1 ];
  
for(Contact co : Trigger.new){
if(acc.Customer_Email__c == null || acc.Customer_Email__c =='')
   { acc.Customer_Email__c = co.Email;
    }
  }
}
Please help me on this
Thanks
Nasir

 

  • December 01, 2010
  • Like
  • 0

I would like you to set up a new Two stage approval process for me please.

Whenever the USER equals NASIR and the STAGE is changed from
CLOSE WON to REJECTED or CLOSE LOST POST WON an task or email is
triggered to AVINASH to verify and when Gillian has verified it
it will then trigger an email or task to me to APPROVE the change

 

I am using the "When formula evaluates to true" and putting the following condition but this is not getting saved

 

AND(
    ($User.Id  = 00520000000nkR1),
    (ISCHANGED( StageName )), (
    (ISPICKVAL( StageName , Closed Lost(Post Won)), 
    (ISPICKVAL( StageName , Processing Rejection))
)

 

The user id is mine.

 

Please help...or is there any way to code it.

 

Thanks

  • November 25, 2010
  • Like
  • 0

Hi 

 

I am trying to built a Managed package and the visual force page i had created comes fine in the UI when i type /apex/zone , but when i go through the sites and click the URL it dosen't shows me the page what  comes from the UI.Even when i click next it goes to the next page but the page is not proper.

 

Can you please help me so i can do the need full thing and why this problem is comin.

 

Thanks

 

Nasir

  • November 04, 2010
  • Like
  • 0

Hi ,

 

I want to make a field required in VF page and it uses Selectlist.As there is one more condition for which the required is working on.Please see the code below.

<apex:pageBlockSectionItem labelStyle="width: 300px" dataStyle="width: 200px" > 
                         <apex:outputLabel value="Gas Commission Type"  /> 
                         <apex:selectList value="{!SaleRec.Commission_Type_Gas__c}" size="1"  id="NewSupplierGasCommissionType" required="{!SaleRec.Status__c == 'Submited Sale'}">
                                <apex:selectOptions value="{!GasCommissionType}"/> 
                                <apex:actionSupport event="onchange" oncomplete="GasCommissionType('{!$Component.NewSupplierGasCommissionType}');" rerender="NewSupplierProductGasTypeTemp"/>
                            </apex:selectList> 
                      </apex:pageBlockSectionItem>

 All i want to do is to make the field "Commission_type_gas__C" required and to display it in the red mark in UI.As required field is used there but it is on a condition.

 

Please help

Nasir

 

  • October 18, 2010
  • Like
  • 0

Hi

 

I want to create an Approval processes when anyone of this Profile user  (except where the role is System Admin, General Manager, Finance Manager) changes the Stage from Closed Won to ANY OTHER Stage like close lost or rejected.

 

Thanks

 

I had creted this process by using formula

 

AND(NOT(OR( $Profile.Name  =='System Administrator' ,$Profile.Name =='General Manager' ,$Profile.Name=='Finance Manager')),OR( ISCHANGED(StageName) ),OR(ISPICKVAL(PRIORVALUE(StageName),"Closed Won")))

 

But this says"

Function ISCHANGED may not be used in this type of formula

 

  

"

  • October 15, 2010
  • Like
  • 0
Hi , I am writing a testmethod.But i am not able to cover the lines under try catch statement.Please advice me.
  • October 14, 2010
  • Like
  • 0

 

public class Store {
public Store__c str;

    public store(ApexPages.StandardController controller) {
this.str = (Store__c)Controller.getRecord();

 }
    public Store__c getStr(){
    return str;
    }
    
    Public PageReference save(){
     
Store__c str =[Select id,Name__c,Address__c,Phone__c,Email__c from Store__c ];
    upsert str;
    return null;
    }

}

 

Hi 

 

 

I have created an object called store and there are some fields in that object which is defind in the VF page as under.I just want to write a controller which uses the save action and can save the record directly from controller.

 

As i am new in Apex.Please help me in writing this save method.

<apex:page standardController="Store__c" extensions="Store">
<apex:form id="nasir">
<apex:pageMessages />
<apex:pageBlock title="ApexCloudStore" mode="edit">
  <apex:pageBlockButtons >
     <apex:commandButton action="{!save}" value="save" >
     <apex:commandButton action="{!cancel}" value="Cancel"/>
    </apex:commandButton>
  </apex:pageBlockButtons>
 <!--This is the first section-->
<apex:pageBlockSection Title="Store Information" columns="2">

<apex:pageBlockSectionItem >
<apex:outputText value="Name"/>
<apex:inputField value="{!Store__c.Name__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Address"/>
<apex:inputField value="{!Store__c.Address__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Email"/>
<apex:inputField value="{!Store__c.Email__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Phone"/>
<apex:inputField value="{!Store__c.Phone__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Website"/>
<apex:inputField value="{!Store__c.Website__c}"/>
</apex:pageBlockSectionItem>

</apex:pageBlockSection>  

<apex:pageBlockSection title="Snacks" columns="2">
<apex:pageBlockSectionItem >
<apex:outputText value="Chips"/>
<apex:inputField value="{!Store__c.Chips__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Cold Drinks"/>
<apex:inputField value="{!Store__c.Cold_Drinks__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Biscuits"/>
<apex:inputField value="{!Store__c.Biscuits__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Juice"/>
<apex:inputField value="{!Store__c.Juice__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="Pop Corn"/>
<apex:inputField value="{!Store__c.Pop_Corn__c}"/>
</apex:pageBlockSectionItem>

</apex:pageBlockSection>
  

</apex:pageBlock>
</apex:form>
</apex:page>

 When i am saving this from UI.My code is not getting saved and some times it give "id not defind and some times attempt to dereferance a null object,

 

Please help me in resolving the errors

 

Thanks

 

Nasir

 

  • October 11, 2010
  • Like
  • 0

Hi

 

I have created a class called "credit check" and i have a visual force page for this.I want to create a condition under which if the fields are empty and when i try to save it,should through an error for that condition.

 

As i have written the condition in  class credit check  and i have VF page and connect it to the controller creditcheck.cls.But here i am facing the issue,that the record is saving  and at the top of Save button the error comes up and when i edit it, then it shows me the field which all i have not filled.What should i do to through the error before the record is saved.

 

I know it can be done by the trigger(before insert, before update).But i want this to be done in the class.

 

Help me

 

Thanks

 

Nasir

  • September 24, 2010
  • Like
  • 0

Hi

 

I am getting this error in the production.

 

System.DmlException: ConvertLead failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ConvertLead: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0062000000F3KnAAAV; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Profile Class allowed on this Record Type is 00. Your MPAN should start with 00.: [MPAN_1_Top_Line__c] Trigger.ConvertLead: line 206, column 5

 

This is a validation rule which was implemented in the production.Due to this there is a code breakage.

 

The related class is

 public static testMethod void testConvertLead(){
            Lead newLead = new Lead();
            newLead = setupLead();
            newLead.Status = 'Qualified';
            System.assertNotEquals(newLead, null);
            newLead.Status = 'Qualified';
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(newLead.id);
            lc.setOwnerId(UserInfo.getUserId());

            LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
            lc.setConvertedStatus(convertStatus.MasterLabel);
            Database.LeadConvertResult lcr = Database.convertLead(lc); 
            System.assert(lcr.isSuccess());
    }

 

 

and the related trigger is

 

trigger ConvertLead on Lead (after update) {
    List<Account> Accs = new List<Account>();
    List<Opportunity> oppors = new List<Opportunity>();
    List<Opportunity> updateOprs = new List<Opportunity>();
    Id UserProfileId = [Select Name, Id From Profile where Name = 'Sub Broker'].Id;
    List<Task> tsks = new List<Task>();
    List<Contact> decisionMakerContacts = new List<Contact>();
    for(Lead ConvertedLead : Trigger.new){
          if(ConvertedLead.IsConverted == true){   
             Account Acc = [SELECT Id, Name FROM Account WHERE Id = :ConvertedLead.ConvertedAccountId];
             Contact cnt = [Select Id, Name, Email from Contact WHERE Id = :ConvertedLead.ConvertedContactId];
             tsks = [Select WhatId, Subject From Task where WhatId = : ConvertedLead.ConvertedAccountId or WhatId = : ConvertedLead.ConvertedOpportunityId limit 1];
         /*      Acc.Channel_Source__c = ConvertedLead.Channel_Source__c;
             Acc.Channel_Type__c = ConvertedLead.Channel_Type__c;
             Acc.Channel_Partner__c = ConvertedLead.Channel_Partner__c;
             Date formatDate = date.newInstance(ConvertedLead.CreatedDate.dayOfYear(), ConvertedLead.CreatedDate.month(), ConvertedLead.CreatedDate.day());
             Double Closedays = formatDate.daysBetween(System.Today());
             
             Acc.ShippingStreet = ConvertedLead.Site_Street__c;
             Acc.Site_Building_Number__c = ConvertedLead.Site_Buiilding_Number__c;
             Acc.Site_Building_Name__c = ConvertedLead.Site_Buiilding_Name__c;
             Acc.ShippingState = ConvertedLead.Site_County__c;
             Acc.ShippingPostalCode = ConvertedLead.Site_Postal_Code__c;
             Acc.ShippingCountry = ConvertedLead.Site_Country__c;
             Acc.ShippingCity  = ConvertedLead.Site_City__c; 
             Acc.days_between_the_LEAD_and_Acc_Creat_Date__c = Closedays;
             Acc.RA_Building_Name__c = ConvertedLead.RA_Building_Name__c;
             Acc.RA_Building_Number__c = ConvertedLead.RA_Building_Number__c;
             Acc.RA_Street__c  = ConvertedLead.RA_Street__c;
             Acc.RA_Postal_Code__c  = ConvertedLead.RA_Postal_Code__c; 
             Acc.RA_County__c  = ConvertedLead.RA_County__c; 
             Acc.RA_Country__c  = ConvertedLead.RA_Country__c;
             Acc.RA_City__c  = ConvertedLead.RA_City__c; 
             Acc.Company_Reg_No__c =  ConvertedLead.Company_Reg_Number__c;
             Acc.Date_LOA_Obtained__c =ConvertedLead.Date_LOA_Obtained__c;
             Acc.LOA_Obtained__c =ConvertedLead.LOA_Obtained__c;
             Acc.Current_Electric_Supplier_Meter1__c = ConvertedLead.New_Supplier__c; */
             
                                 
              if(ConvertedLead.Related_Utility__c == 'Gas & Electricity' || ConvertedLead.Related_Utility__c == 'Gas' || ConvertedLead.Related_Utility__c == 'Electricity'){
                Opportunity updateopr = leadOpportunity.setOpportunityRecordType(ConvertedLead, UserProfileId);
                updateopr.Channel_Source__c = ConvertedLead.Channel_Source__c;
                updateopr.Channel_Type__c = ConvertedLead.Channel_Type__c;
                updateopr.Channel_Partner__c = ConvertedLead.Channel_Partner__c;
                updateopr.Description = ConvertedLead.Description;
            /*    updateopr.Site_Building_Number__c = ConvertedLead.Site_Buiilding_Number__c;
                updateopr.Site_Building_Name__c = ConvertedLead.Site_Buiilding_Name__c;
                updateopr.Site_Street__c = ConvertedLead.Site_Street__c;
                updateopr.Site_Postal_Code__c = ConvertedLead.Site_Postal_Code__c;
                updateopr.Site_County__c = ConvertedLead.Site_County__c;
                updateopr.Site_Country__c = ConvertedLead.Site_Country__c;
                updateopr.Site_City__c = ConvertedLead.Site_City__c;
                
                updateopr.New_Supplier_Renewal_Opt_Out__c = ConvertedLead.New_Supplier_Renewal_Opt_Out__c;
                updateopr.Partner_Reference__c = ConvertedLead.Partner_Reference_Number__c;
            
             */
                //if(ConvertedLead.Current_Supplier__c != null) updateopr.Current_Supplier__c = ConvertedLead.Current_Supplier__c;
                if(ConvertedLead.Related_Utility__c == 'Gas'){
              /*        Acc.HasGas__c =  true;
                    if(ConvertedLead.MPR_2__c != null)Acc.MPR_2_Account_2__c =  ConvertedLead.MPR_2__c;
                    Acc.MPR_1_Account_2__c =  ConvertedLead.MPR_1__c;
                    
                    updateopr.Name = 'Gas';
                    updateopr.Related_Utility__c = 'Gas';
                    //updateopr.Current_Supplier__c = ConvertedLead.Current_Supplier_Electricity__c;
                    updateopr.Current_Supplier__c = ConvertedLead.Current_Supplier_Gas__c;
                    //updateopr.Current_Supplier__c = ConvertedLead.Current_Supplier__c;
                    updateopr.Current_Gas_Unit_Price_2__c = ConvertedLead.Current_Gas_Unit_Price_2__c;
                    updateopr.Current_Gas_Unit_Price_1__c = ConvertedLead.Current_Gas_Unit_Price_1__c;
                     
                    updateopr.Annual_Spend__c = ConvertedLead.Annual_Spend_Gas__c;
                    updateopr.Current_Gas_Unit_Price_1__c = ConvertedLead.Current_Gas_Unit_Price_1__c;
                    
                    updateopr.Contract_Status__c = ConvertedLead.Contract_Status_Gas__c;
                    
                    if(ConvertedLead.MPR_2__c != null)updateopr.MPR_2__c = ConvertedLead.MPR_2__c ; 
                    updateopr.MPR_2_AQ__c = ConvertedLead.MPR_2_AQ__c; 
                    updateopr.MPR_1__c = ConvertedLead.MPR_1__c; 
                    updateopr.MPR_1_AQ__c = ConvertedLead.MPR_1_AQ__c;
                    
                         
                */
                    if(ConvertedLead.Actual_Expiry_Date_Gas__c != null){updateopr.Actual_Expiry_Date__c = ConvertedLead.Actual_Expiry_Date_Gas__c;} 
                    
                     if(ConvertedLead.Contract_Status_Gas__c == 'In Contract'){
                        updateopr.StageName = 'Prospecting';
                    } 
                    
                }
                 if(ConvertedLead.Current_Supplier_Gas__c == ConvertedLead.New_Supplier__c){
                //   updateopr.Current_Supplier__c = ConvertedLead.New_Supplier__c;
                 }
                 
                  if(ConvertedLead.Current_Supplier_Electricity__c == ConvertedLead.New_Supplier__c){
                    // updateopr.Current_Supplier__c = ConvertedLead.New_Supplier__c;
                 }
                   
                    //updateopr.Contract_Term_Months__c = ConvertedLead.Contract_Term_Months_FL__c ;
                    
                    if(ConvertedLead.Related_Utility__c == 'Electricity' || ConvertedLead.Related_Utility__c == 'Gas & Electricity'){
                     // Acc.HasElectricity__c = true;
                     
                    /*updateopr.Name = 'Electricity';
                    updateopr.Related_Utility__c = 'Electricity';
                    updateopr.KVA__c = ConvertedLead.KVA__c;
                    /*updateopr.MPAN_1_Top_Line__c = ConvertedLead.MPAN_Profile__c+ConvertedLead.MTC__c+ConvertedLead.LLF__c;
                    updateopr.MPAN_1_Bottom_Line__c = ConvertedLead.MPAN_Dis_Id__c+ConvertedLead.MPANLeft__c+ConvertedLead.MPANMid__c+ConvertedLead.MPANRight__c;
                    if( ConvertedLead.Rel_MPAN_Profile__c != null )updateopr.MPAN_2_Top_Line__c = ConvertedLead.Rel_MPAN_Profile__c;
                    if(ConvertedLead.Rel_MTC__c != null) updateopr.MPAN_2_Top_Line__c += ConvertedLead.Rel_MTC__c+ConvertedLead.Rel_LLF__c;
                    if(ConvertedLead.Rel_LLF__c != null) updateopr.MPAN_2_Top_Line__c += ConvertedLead.Rel_LLF__c;
                    if(ConvertedLead.Rel_MPAN_Dis_Id__c != null) updateopr.MPAN_2_Bottom_Line__c = ConvertedLead.Rel_MPAN_Dis_Id__c+ConvertedLead.Rel_MPANLeft__c+ConvertedLead.Rel_MPANMid__c+ConvertedLead.Rel_MPANRight__c;
                    if(ConvertedLead.Rel_MPANLeft__c != null) updateopr.MPAN_2_Bottom_Line__c += ConvertedLead.Rel_MPANLeft__c;
                    if(ConvertedLead.Rel_MPANMid__c != null) updateopr.MPAN_2_Bottom_Line__c += ConvertedLead.Rel_MPANMid__c;
                    if(ConvertedLead.Rel_MPANRight__c != null) updateopr.MPAN_2_Bottom_Line__c += ConvertedLead.Rel_MPANRight__c;

                    updateopr.LLF__c = ConvertedLead.LLF__c;
                    updateopr.MPAN_Profile__c = ConvertedLead.MPAN_Profile__c;
                    updateopr.MPAN_Dis_Id__c = ConvertedLead.MPAN_Dis_Id__c;
                    updateopr.MPANLeft__c = ConvertedLead.MPANLeft__c; */
                    if(ConvertedLead.Actual_Expiry_Date_Electricity__c != null){updateopr.Actual_Expiry_Date__c = ConvertedLead.Actual_Expiry_Date_Electricity__c;}
                //  updateopr.MPANMid__c = ConvertedLead.MPANMid__c;
                //  updateopr.MPANRight__c = ConvertedLead.MPANRight__c;
                //  updateopr.Related_MPAN__c = ConvertedLead.Related_MPAN__c;
                    
                    //updateopr.Contract_Status__c = ConvertedLead.Contract_Status_Electricity__c;
                    
                    //if(ConvertedLead.Rel_MPAN_Profile__c!= null)updateopr.Related_MPAN_Profile__c = ConvertedLead.Rel_MPAN_Profile__c;
                    
                    //if(ConvertedLead.Rel_MTC__c != null)updateopr.Related_MTC__c = ConvertedLead.Rel_MTC__c;
                    //if(ConvertedLead.Rel_LLF__c != null) updateopr.Rel_LLF__c = ConvertedLead.Rel_LLF__c;
                    //if(ConvertedLead.Rel_MPANLeft__c != null) updateopr.Rel_MPANLeft__c = ConvertedLead.Rel_MPANLeft__c;
                    //if(ConvertedLead.Rel_MPANMid__c != null) updateopr.Rel_MPANMid__c = ConvertedLead.Rel_MPANMid__c;
                    //if(ConvertedLead.Rel_MPANRight__c != null) updateopr.Rel_MPANRight__c = ConvertedLead.Rel_MPANRight__c;
                    //updateopr.MTC__c = ConvertedLead.MTC__c;
                    //updateopr.Voltage__c = ConvertedLead.Voltage__c;
                    //updateopr.Current_Supplier__c = ConvertedLead.Current_Supplier_Electricity__c;
                    //updateopr.Email_Contact_del__c = cnt.Id;
                    
                    //updateopr.Electric_AQ_Day__c = ConvertedLead.Electric_AQ_Day__c;
                    //updateopr.Electric_AQ_Eve_W_end__c = ConvertedLead.Electric_AQ_Eve_W_end__c;
                    //updateopr.Electric_AQ_Night__c = ConvertedLead.Electric_AQ_Night__c;
                    //updateopr.Annual_Spend__c  = ConvertedLead.Annual_Spend_Electricity__c;
                    
                    //updateopr.Site_Building_Number__c = ConvertedLead.Site_Buiilding_Number__c;
                     //updateopr.Site_Building_Name__c = ConvertedLead.Site_Buiilding_Name__c;
                     //updateopr.Site_Street__c = ConvertedLead.Site_Street__c;
                     //updateopr.Site_Postal_Code__c = ConvertedLead.Site_Postal_Code__c;
                     //updateopr.Site_County__c = ConvertedLead.Site_County__c;
                     //updateopr.Site_Country__c = ConvertedLead.Site_Country__c;
                     //updateopr.Site_City__c = ConvertedLead.Site_City__c; 
                     
                }
                                
                if(ConvertedLead.Related_Utility__c == 'Gas & Electricity'){
                    //Opportunity oppr = CreateGasOpportunity.createOpportunity(ConvertedLead, UserProfileId, Acc, cnt); 
                 // oppr.Lead_Created__c = formatDate;
                    //Acc.HasGas__c =  true;
                //  Acc.MPR_2_Account_2__c =  ConvertedLead.MPR_2__c;
                    //Acc.MPR_1_Account_2__c =  ConvertedLead.MPR_1__c;
                    //oppr.Customer_Type__c = 'New Customer';
                    //oppr.Type = 'New Business';
                    //oppors.add(oppr);
                   // ConvertedLead.addError('Lead cannot be converted');
                }
                
                if(updateopr.Name == 'Electricity'){
                   if(ConvertedLead.Related_Utility_Type__c == 'Non Half Hourly'){
                      //    updateopr.KVA__c = ConvertedLead.KVA__c ;
                       //   updateopr.Voltage__c = ConvertedLead.Voltage__c;
                   }    
                }
                 if(ConvertedLead.Contract_Status__c == 'In Contract'){
                    updateopr.Type = 'Future Business';
           }
                if(ConvertedLead.Related_Utility__c == 'Gas'){
                //updateopr.Current_Supplier__c = ConvertedLead.Current_Supplier_Gas__c;
                }
                // Create Opportunity Task
                // Create Task for the Opportunity
                if(ConvertedLead.Name_of_Decision_Maker__c != null){
                   List<String> Str = ConvertedLead.Name_of_Decision_Maker__c.split(' ',-2);
                   String FirstName = '';
                   String LastName = '';
                   if(Str.size() == 1)LastName = Str.get(0);
                   if(Str.size() > 1){
                        FirstName = Str.get(0);
                        LastName = Str.get(1);
                   }
                   Contact decisionMakerContact = new Contact(AccountId = Acc.Id, FirstName = FirstName, LastName = LastName,Phone=ConvertedLead.Phone,Email=ConvertedLead.Email,MailingCity=ConvertedLead.RA_City__c,MailingPostalCode=ConvertedLead.RA_Postal_Code__c,MailingStreet=ConvertedLead.RA_Street__c,Title=ConvertedLead.Title);
                   decisionMakerContacts.add(decisionMakerContact);
                } 
                //updateopr.Customer_Type__c = 'New Customer';
                //updateopr.Type = 'New Business';
                updateopr.Opportunity_Contact_Name__c = cnt.Name;
                updateopr.Email_Contact_del__c = cnt.Id;
                updateopr.Lead_Created__c = ConvertedLead.createdDate.date();
                Acc.Lead_Created_Date__c = ConvertedLead.createdDate.date();
                Accs.add(Acc); 
                updateOprs.add(updateopr);
              }
          } 
    }
    
    update Accs;
    update updateOprs;
//  if(oppors.size() > 0){insert oppors;}
    if(decisionMakerContacts.size() > 0){insert decisionMakerContacts;}
}

 

I am getting error in the 3 last line 

 

 

update updateOprs;

 

Please help

  • September 23, 2010
  • Like
  • 0

Hi

 

I am getting an error.I know i have to use list for opportunity but the record is not getting saved.Please help me out

 

The related trigger is

 

 

trigger OpportunityCreditCheck on Credit_Check__c (before insert, before update) {

 

 

  for(Credit_Check__c CCheck : Trigger.new){
            
    if(CCheck.RecordtypeId == '012200000009PMEAA2'){
          Opportunity oppr = [Select Account.Business_Type__c,Account.Name,Account.Registered_Charity_Number__c,Product_Name__c, New_Supplier__c, AccountId From Opportunity where Id =:CCheck.Opportunity__c];
     
      if(Oppr.Account.Business_Type__c == 'Limited Company' || Oppr.Account.Business_Type__c == 'Plc' || Oppr.Account.Business_Type__c == 'Charity'){
     
         if(oppr.New_Supplier__c == 'Eon' && oppr.Product_Name__c != 'Bespoke Price'){ 
         
        
         
             if(CCheck.Limited_Company_Account__c == null ){
            CCheck.Limited_Company_Account__c.addError('Please Enter the Account Name');
            }
            if(CCheck.Registered_Address__c == null){
            CCheck.Registered_Address__c.addError('Please Enter the Full Registered Address');
            }
            
            if(CCheck.Date_of_Incorporation__c == null){
            CCheck.Date_of_Incorporation__c.addError('Please Enter the Date of Incorporation');
            }
            
             if(CCheck.Company_Registered_Number__c == null){
            CCheck.Company_Registered_Number__c.addError('Please Enter the Full Company Registered Number');
            }
             
            if(CCheck.Phone_Number__c == null){
            CCheck.Phone_Number__c.addError('Please Enter the Full Phone Number');
            }
            if(CCheck.Billing_Address__c == null){
            CCheck.Billing_Address__c.addError('Please Enter the Full Billing Address');
            }
            }
            
      }
       if(CCheck.Date_of_Incorporation__c < system.Today()-730){
       
           if(CCheck.Full_Company_Name__c == null){
           CCheck.Full_Company_Name__c.addError('Please Enter the Full company name');
           }
             
            if(CCheck.Registered_Address__c == null){
            CCheck.Registered_Address__c.addError('Please Enter the Full Registered Address');
            }
             if(CCheck.Company_Registered_Number__c == null){
            CCheck.Company_Registered_Number__c.addError('Please Enter the Company Registered Number');
            }
             
            if(CCheck.Phone_Number__c == null){
            CCheck.Phone_Number__c.addError('Please Enter the Full Phone Number');
            }
            if(CCheck.Billing_Address__c == null){
            CCheck.Billing_Address__c.addError('Please Enter the Full Billing Address');
            }
            if(CCheck.Director_First_Name__c == null){
            CCheck.Director_First_Name__c.addError('Please Enter the Director First Name');
            }
            if(CCheck.Director_Last_Name__c == null){
            CCheck.Director_Last_Name__c.addError('Please Enter Director Last Name');
            }
             if(CCheck.Directors_DOB__c == null){
            CCheck.Directors_DOB__c.addError('Please Enter Director Date of Birth');
            }
            
            if(CCheck.Building_Name__c == null && CCheck.Building_Number__c == null){
            CCheck.Building_Name__c.addError('Please Enter Building number or Building name');
             CCheck.Building_Number__c.addError('Please Enter Building number or Building name');
            
            }
           
            if(CCheck.Building_PostCode__c == null){
            CCheck.Building_PostCode__c.addError('Please Enter Building Post Code');
            }
            if(CCheck.CC_Consent__c == null){
            CCheck.CC_Consent__c.addError('Please Enter the Full CC Consent');
            }
            if(CCheck.Building_Town__c == null){
            CCheck.Building_Town__c.addError('Please Enter the Town'); 
            }
       }
       
       /*if date of incorporation is greater than 2 years, new supplier is equal to Eon and product name is not equal to bespoke,
        than contact firstname,contact last name,billing building number,billing building name ,billing address,billing town,
        billing post code and date field must be filled.*/
        
          if(CCheck.Date_of_Incorporation__c > system.Today() + 730 && oppr.New_Supplier__c == 'Eon' && oppr.Product_Name__c != 'Bespoke Price'){
           
           if(CCheck.Director_First_Name__c == null){
           CCheck.Director_First_Name__c.addError('Please enter contact First name');
           }
           if(CCheck.Director_Last_Name__c == null){
           CCheck.Director_Last_Name__c.addError('Please enter contact Last name');
           }
            if(CCheck.Building_Name__c == null && CCheck.Building_Number__c == null){
            CCheck.Building_Name__c.addError('Please Enter Building number or Building name');
             CCheck.Building_Number__c.addError('Please Enter Building number or Building name');
            
            }
           if(CCheck.Building_Street_Address__c== null){
           CCheck.Building_Street_Address__c.addError('Please enter Billing Street Address');
           }
           if(CCheck.Building_Town__c== null){
           CCheck.Building_Town__c.addError('Please enter Billing Town');
           }
           if(CCheck.Building_PostCode__c== null){
           CCheck.Building_PostCode__c.addError('Please enter Billing Post Code');
           }
           if(CCheck.Directors_DOB__c== null){
           CCheck.Directors_DOB__c.addError('Please enter Date of Birth');
           }
          }
        }
         if(CCheck.RecordtypeId == '012200000009PMJAA2'){
            
            Opportunity oppr = [Select Account.Business_Type__c,  AccountId From Opportunity where Id =:CCheck.Opportunity__c];
           
          if(Oppr.Account.Business_Type__c == 'Sole Trader' || Oppr.Account.Business_Type__c == 'Trusteeships' ||  Oppr.Account.Business_Type__c == 'Partnership' ){
            
            if(CCheck.Business_Name__c == null){
             CCheck.Business_Name__c.addError('Please enter business name');
            }
            if(CCheck.Bussiness_owner_name__c == null){
                CCheck.Bussiness_owner_name__c.addError('Please enter business owner name');
            }
           if(CCheck.Current_Address_Home_Address__c == null){
            CCheck.Current_Address_Home_Address__c.addError('Please enter current address');
           }
           if(CCheck.Date_of_Occupancy_of_Home__c == null){
            CCheck.Date_of_Occupancy_of_Home__c.addError('Please enter date of occupancy at Home');
           }
           if(CCheck.Previous_Address__c == null){
            CCheck.Previous_Address__c.addError('Please enter previous address if it less than 2 years Or mention SAME AS ABOVE');
           }
           if(CCheck.Bussiness_Owner_DOB__c == null){
           CCheck.Bussiness_Owner_DOB__c.addError('Please enter Bussiness owner date of birth');  
           }
           
          }
        }
    }   
    }

Thanks

 

Nasir

  • September 22, 2010
  • Like
  • 0

i have a object called member  in SF.In its page layout there are many fields and amoung those fields there is a field called "username "and "password".now i had created a record in that member object with "username =member1" and password='112345'.

 

Now i want to create a web site.from where  a member enter his user  enter the usename and password it should hit the date base and member could see his record and edit it also. i had created a vf page

 

<apex:page standardController="Member__c" extensions="members" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Login page">
Please enter user name and Password

<apex:inputField value="{!Member__c.User_Name__c}" /><br/>
<apex:inputField value="{!Member__c.Password__c}"/>

</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!login}" value="login"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
  
</apex:page>
public class members {
public string username {get; set;}
public string password {get; set;}
    public members(ApexPages.StandardController controller) {

    }
    public Pagereference login(){
    String startUrl = System.currentPageReference().getParameters().get('startURL');
        return Site.login(username, password, startUrl);
    
    }
    public members(){}
    public static testMethod void testmembers(){
    members mem = new members();
    mem.username = 'member1';
    mem.password = '12345';
    
    System.assertEquals(mem.login(),null); 
    
    }

}

but this code is not working.

Please help me out.

  • August 30, 2010
  • Like
  • 0

Hi,

 

Please  find the solution.

 

Actually there are two custom fields

1:payment date

2:invoice status

 

where payment date is a date field and invoice status is a picklist field which has the picklist values 'approved,onhold and paid.'

When invoice status=paid 

then payment date should be editable 

but when invoice status =onhold or approved.

payment date should not be editable

 

what i had done in this,i had created a new record type for which payment date is editable,and i had created a new page layout .then i had written a workflow for this.but this is not working.

 

Please advice

 

Thanks

 

  • August 30, 2010
  • Like
  • 0

Hi All,

 

I have created a Visualforce page with input fields.When user clicks on save button a logic executes in the controller and need to show up a pop message to user saying fill the values in the fields.

 

Can you please let me know how this could be acheived.

 

 

 

Thanks,

Srilakshmi B

Hi 

 

I have created a button on Account which is a Custom object'SendInvitation'.When i click that button a page appear where the user have to fill the 'To' and 'Subject' and 'body' of the Invitation.I have used Standardcontroller and two visualforce page.One contain the 'mail' section and other contain the 'PDF' page.In my PDF page i am using {!Account__c.Name} and {!Account__c.Visit_Date__c} which is not getting populated, because of the following error.VisualforceException: SObject row was retrieved via SOQL without querying the requested field: Account__c.Name

 

I am able to send email with the Attachments.But when i click the View button on the mail to see the PDF.The PDF page dosen't open.

 

In system log i am getting this Error:System.VisualforceException: SObject row was retrieved via SOQL without querying the requested field: Account__c.Name  and this error is comin in the line which is Bold( b= pdf.getContent();) in the controller.

 

All i want now that Account name and visit date should display

 

 

 

Below is the code

public  class SendInvitationByMail {
    public String subject { get; set; }
    public String body { get; set; }
    public Account__c acc{ get; set; }
    public Id idacc;
   
    
    public SendInvitationByMail(ApexPages.StandardController controller) {
    idacc =controller.getRecord().id;
    acc = [Select Name,Email__c,Subject__c,EmailBody__c,Visit_Date__c from Account__c where id=:idacc];
    System.debug('record:'+acc);

    }
 

    public PageReference send() {
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    // Reference the attachment page and pass in the account ID
    PageReference pdf = Page.attachmentPDF;
    pdf.getParameters().put('id',(String)acc.id);
  
    pdf.setRedirect(true);
    // Take the PDF content
     Blob b ;
     String n;
      try
      {
        
        b= pdf.getContent();
       
        system.debug('Blob'+b);
        }
        catch(VisualforceException e)
        {
         b=Blob.valueOf('SObject row was retrieved via SOQL without querying the requested field: Account__c.Name');
        
        }
    // Create the email attachment
    Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
    efa.setFileName('attachment.pdf');
    efa.setBody(b);

    if(acc.Email__c == null){
     acc.Email__c.addError('Please fill the To with an email address');

    }
     String addresses;
    if(acc.Email__c!=null){
    addresses=acc.Email__c;
    }
    String[] toAddresses = addresses.split(':', 0);
  
    email.setSubject( subject );    
    email.setToAddresses(toAddresses);
    email.setPlainTextBody( body );
    
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

    // Sends the email
    Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

    

        return null;
    }


}

 

 

 

 

 

 

 

 

Actually In my PDF visualforce page i am using {!Account__c.Name} and {!Account__c.Visit_Date__c} .

<apex:page standardController="Account__c" extensions="SendInvitationByMail" sidebar="false">

<apex:pageBlock tabStyle="Account" title="Send Invitation">

<apex:panelGrid columns="2">
<apex:form >
<apex:outputLabel value="To :"></apex:outputLabel> &nbsp;
<apex:inputField value="{!acc.Email__c}"/><br/><br />
<apex:outputLabel value="Subject :"></apex:outputLabel>&nbsp;
<apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
<br /><br />
<apex:outputLabel value="Body" for="Body"/>:<br />
<apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/>
<br /><br /><br />
<apex:commandButton value="Send Invitation" action="{!send}"/>
          

</apex:form>
</apex:panelGrid>

</apex:pageBlock>

</apex:page>
<apex:page standardController="Account__c"  extensions="SendInvitationByMail" renderAs="PDF" id="SendInvitationByMail">

Dear {!Account__c.Name},<br/>


You are cordially invited to the Visitors Day Meeting of the BNI Gems Chapter at The Royal Orchid
Hotel Spring Hall (Adjoining KGA Golf Course), HAL Airport Road on Friday {!Account__c.Visit_Date__c} . The
meeting will start promptly at 7:45AM and finish at 9.45AM. We will be sharing BNI's Secrets to
Success through "Word-of-Mouth" Marketing.<br/><br/>

BNI is a business and professional networking organisation whose primary purpose is to exchange
qualified business referrals. It is the most successful organisation of its type in the world today, with
over 5,800 chapters in operation world-wide (including the UK, USA, Malaysia, Singapore, Germany,
South Africa and Australia). Last year, members of BNI passed more than 6.5 million referrals which
generated more than Rs. 12,600 Crores worth of business for its members.<br/><br/>

What makes BNI unique is that it allows only one person per profession to join a chapter. Thus, once
you've joined, there is no conflict in passing leads, and none of your competitors can participate! BNI
is currently looking for IT PLM Consulting company to refer your business to. I would like to invite you

to the Visitors Day Meeting so you can learn more about the organisation, and find out if you would be
interested in generating a steady source of referrals for your business.<br/><br/>

Seating is limited, so please RSVP by calling me on +919342837640. There will be a nominal Rs.350/-
Meeting Fee, which includes breakfast. If you have any questions, please contact me. Remember to bring
plenty of business cards (at least 100 numbers) to pass around, as you will meet a lot of local business
people.<br/>

Venue<br/>
Seasons 1<br/>
The Royal Orchid Hotel<br/>
No 1, Golf Avenue, Adjoining KGA Golf Course<br/>
Old Airport Road, Bangalore 560008<br/>

Program<br/>
7:15AM-7:45AM – Open Networking<br/>
7:45AM – Meeting Starts<br/>
10:00AM – Onwards – Breakfast<br/>

Register here:<br/>
https://spreadsheets.google.com/a/rixyncs.co.in/spreadsheet/viewform?formkey=dHcwZmw5MnJtUWxHVGo0b0ZuajViZWc6MA#gid=0



Yours Sincerely,<br/>

P Ramesh Chander<br/>
Rixyncs India Inc<br/>
Core Group Member, BNI Gems Chapter<br/>

P.S: Please feel free to bring any business associate(s) with you who may also be interested in finding out how to generate more business through word of mouth referrals - this is a unique and really exciting opportunity for any individual or
 organisation to increase their business!<br/>

</apex:page>

 Please help.I will Appriciate your concer.

 

Thanks

 

Nasir

 

 

 

 

  • June 20, 2011
  • Like
  • 0

Hi ,

 

I have a controller through which i want to display all the fields in a page.My method "surveyform" is not working.I want to display all the fields value so that a user can input some value in it and save it.

 

 

<apex:page standardController="Case" extensions="Survey" sidebar="false">
 <apex:form style="background-color:#FFFFFF;"> 
    <style type="text/css">
        body {font-family:Arial Unicode MS;font-size:12px;}
        P{background-color:#006400;HEIGHT:20PX;font-size:12px;font-weight:bold;color:#FFFFFF;}
    </style>

 <apex:pageBlock title="Survey Form">
 <apex:pageBlockSection title="Please enter the details" collapsible="true"  columns="2" showHeader="true" 

onmouseover="hover">
  <apex:dataTable value="{!surveyform}" var="line"  width="50%">
 <apex:column >
 <apex:outputText value="Survey Name:" style="width:50px"/><br/>
 <apex:outputText value="How was the Case handling power:" style="width:50px"/><br/>
 <apex:outputText value="How was the feedback:" style="width:50px"/><br/>
 <apex:outputText value="Case:" style="width:50px"/><br/>
 </apex:column>
 <apex:column >
 <apex:inputField value="{!line.Name}"/><br/>
 <apex:inputField value="{!line.How_was_the_Case_handling_power__c}"/><br/>
 <apex:inputField value="{!line.How_was_the_feedback__c}"/><br/>
 <apex:outputField value="{!line.Case__c}"/><br/>
 </apex:column>

 
 </apex:dataTable>
 </apex:pageBlockSection>
 <center><apex:commandButton value="Save" action="{!Survey}"/>
 <apex:commandButton value="Cancel" action="{!Cancel}"/> </center>
 </apex:pageBlock> 

 </apex:form> 
</apex:page>
                  

 

 

My Controller

 

public  class Survey {

  public List<Survey__c> sur{get;set;}
  public Id srid;
  public Case cs;
  public Id cid;
  public ApexPages.StandardController a;

     public Survey(ApexPages.StandardController
                                      stdController) {
       cs = (Case)stdController.getRecord();
       system.debug('menon:'+ cs);
       a = stdController;
       cid = a.getRecord().id;
       system.debug('Survey:'+ cid);
         }
         
         
     public List<Survey__c> getSurveyform() {
         sur= [Select Name,How_was_the_Case_handling_power__c,How_was_the_feedback__c,Case__c from Survey__c where Case__c=:cid ];
         System.debug('sana:' + sur);
       
       
         return sur;
          }
    
     Public PageReference Survey(){
     insert(sur);
     return null;
          }
       
}

 

 

  • April 28, 2011
  • Like
  • 0

Hi,

 

I am trying to create  an Email to lead.i mean when i use the email service link to send the mail to SF, a lead is generated.As this is working ,but when i am trying to attach a file with the Email.The file is not comin as attachments.My code is under.Can any one try to solve my problem.

Global class unsubscribe implements Messaging.inboundEmailHandler{

    Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope env )
    {

    // Create an inboundEmailResult object for returning
    //the result of the Apex Email Service
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    
 
    String strEmailId = email.fromAddress;
    String strSubject = email.subject;
    String myText=email.plainTextBody;
    String myFromName = email.fromName;
    Lead l;
    
       

    //Create a new test Lead and insert it in the Test Method 
    integer iCount;
    iCount = [select count() from Lead where Email=:email.fromAddress];
    if (iCount==0)
    {   
        l = new Lead(
        lastName= myFromName, //strEmailId,
        Company=myFromName,
        Email=strEmailId,
        LeadSource='OnlineEnquiry',
        Description=strSubject+'\n'+myText,
        OwnerId='00590000000OJ0w'); //Change this id with user's id to whome you want to assign this lead.
        insert l;    
       
    }
   
   
    result.success = true;
    return result;
    for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
     Attachment attachment = new Attachment();
     
    attachment.Name = tAttachment.fileName;
     attachment.Body = Blob.valueOf(tAttachment.body);
     attachment.ParentId = l.Id;
     insert attachment;
    }
    for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
     Attachment attachment = new Attachment();
     
    attachment.Name = bAttachment.fileName;
     attachment.Body = bAttachment.body;
      attachment.ParentId =l.Id;
     insert attachment;
   
    }
     result.success = true;
    return result;
    }  


    /* Only for test case */

    // Test method to ensure you have enough code coverage
    // Have created two methods, one that does the testing
    // with a valid "unsubcribe" in the subject line
    // and one the does not contain "unsubscribe" in the
    // subject line
   static testMethod void testUnsubscribe() {

   // Create a new email and envelope object
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
      
        // Create a new test Lead and insert it in the Test Method       
       Lead l = new lead(firstName='Rasmus',
                lastName='abc',
                Company='Salesforce',
                Email='rmencke@salesforce.com',LeadSource='OnlineEnquiry',Description='dsdfdgf'
                );
       insert l;
    
    // Create a new test Contact and insert it in the Test Method 
       Contact c = new Contact(firstName='Rasmus',
                    lastName='Mencke',
                    Email='rmencke@salesforce.com');
       insert c;
      
       // test with subject that matches the unsubscribe statement
       email.subject = 'test unsubscribe test';
       email.fromName = 'abhi k';
       email.fromAddress = 'abhilash@rixyncs.co.in';
        email.subject='test';
       email.plainTextBody='zsdzdf';
        
       
       
  
       // call the class and test it with the data in the testMethod
       unsubscribe unsubscribeObj = new unsubscribe();
       unsubscribeObj.handleInboundEmail(email, env );
                           
       }
       
      /* static testMethod void testTrigger() {
        Lead l = new Lead(lastName='testTrigger',Status='Qualified',Email='abhi@rixyncs.co.in',
                          Company='Rixyncs',MobilePhone='919901379361');
        insert l;
      //  SMS__c s = new SMS__c(To_Lead__c=l.Id,Message__c='Test');
      //  insert s; 
        
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(l.Id);
        lc.setConvertedStatus('Qualified');
        Database.LeadConvertResult lcr = Database.convertLead(lc);
    }*/

}

 Please help me.

 

Thanks

 

Nasir

 

  • February 24, 2011
  • Like
  • 0

Hi

 

I am trying to write the test method for the class below.but i am not abloe to cover "if" statements.

//    Description: This is the controller for checking delivery of
//                 both Single SMS as well as Bulk SMS to Leads/Contacts.
//    Author: Abhilash K

public class DeliveryController {

private String mtId;
private String[] mtArray;
private Integer iter;
private String myId;
private String response;
private String storeResponse;
private SMSHttpRequestResponse shrr;
private String smsType;
private SMS__c smsObj;
private Bulk_SMS__c bulkObj;
private PageReference pr;
public String credit;

    public PageReference checkDelivery() {
        ApexPages.Message myPageErrMsg;
        storeResponse = '';
        shrr = new SMSHttpRequestResponse();
        try {
            mtId = ApexPages.currentPage().getParameters().get('mtid');
            myId = ApexPages.currentPage().getParameters().get('id');
            smsType = ApexPages.currentPage().getParameters().get('type');
            System.debug('### '+mtId+' '+myId+' '+smsType);
            if(smsType.equals('bulk')) {
                mtArray = mtId.split(',');
                iter = mtArray.size();
                System.debug('### mtArray: ' + mtArray); 
                System.debug('### iter: '+ iter);
            }
            else {
                mtArray = new String[] {mtId};
                iter = 1;
            }
            for(Integer i=0; i<iter; i++) {
                System.debug('### Inside for loop:' + i); 
                response = shrr.getContent('http://www.onewaysms.com.my/bulktrx.aspx?mtid='+ mtArray[i]);
            
                if(response.equals('0')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Message Delivered');
                    storeResponse = storeResponse  + 'Delivered';
                }
                else if(response.equals('100')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM,'Waiting');
                    storeResponse = 'Waiting';
                }
                else if(response.equals('-100')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Invalid ID/not found');
                    storeResponse = 'Invalid ID';
                }
                else if(response.equals('-200')) {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Sending Failed');
                    storeResponse = 'Sending Failed';
                }
                else {
                    myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Checking Failed');
                    //storeResponse = 'Checking Failed';
                }
            }
            
            // Check SMS Credit balance
            credit = shrr.getContent('http://www.onewaysms.com.my/bulkcredit.aspx?apiusername=APIU6QF39AOLY&apipassword=APIU6QF39AOLY8UXUB');
            try {
                Integer x = Integer.valueOf(credit);
            }
            catch(Exception e) {
                credit = 'Checking Failed';
            }
            
            if(smsType.equals('single')) {
                smsObj = [select Id,Message_Status__c from SMS__c where Id=:myId][0];
                if(storeResponse != '')
                    smsObj.Message_Status__c = storeResponse;
                update smsObj;
            }
            else if(smsType.equals('bulk')) {
                bulkObj = [select Id,Message_Status__c from Bulk_SMS__c where Id=:myId][0];
                if(storeResponse != null)
                    bulkObj.Message_Status__c = storeResponse;
                update bulkObj;
            }        
        }
        catch(Exception e) {
           myPageErrMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
        }
        ApexPages.addMessage(myPageErrMsg);    
        return null;
    }
    
     public PageReference goBack() {
         pr = new PageReference('/' + myId);
         pr.setRedirect(true);
         return pr;
    }

    public String getCredit() {
        return credit;
    }
    public static testMethod void redirect(){
     	SMS__c smsObj =new SMS__c();
     	Bulk_SMS__c bul = new Bulk_SMS__c();
     	
     	DeliveryController delCon = new DeliveryController();
     	delCon.checkDelivery();
     	
     	delCon.getCredit();
     	delCon.goBack();
     	 
     	
     	
     }
}

 

Please help

 

  • February 04, 2011
  • Like
  • 0

Hi 

 

I have  object called "Sales order" and "week management".Week management have some records.i have created a button on week management called "create sales order".When a user  select a record in weekmanagement by clicking it,and then click "Create sales order"  then record in a sales order record is created in sales order object.

 

I have to do this by using java script coz i had choosed use javascript to create that button. and i have to use web services.

 

How can i do that.

 

Plz help

 

Nasir

  • December 22, 2010
  • Like
  • 0

Hi

 

i am trying to write a trigger which will update an email field from contact to customer emailfield in account.But this is not working.

 

 

trigger updatecontact on Contact (before insert, before update) {
Account acc = [SELECT Customer_Email__c FROM Account Limit 1];
  Contact con = [SELECT Email FROM Contact limit 1 ];
  
for(Contact co : Trigger.new){
if(acc.Customer_Email__c == null || acc.Customer_Email__c =='')
   { acc.Customer_Email__c = co.Email;
    }
  }
}
Please help me on this
Thanks
Nasir

 

  • December 01, 2010
  • Like
  • 0

I would like you to set up a new Two stage approval process for me please.

Whenever the USER equals NASIR and the STAGE is changed from
CLOSE WON to REJECTED or CLOSE LOST POST WON an task or email is
triggered to AVINASH to verify and when Gillian has verified it
it will then trigger an email or task to me to APPROVE the change

 

I am using the "When formula evaluates to true" and putting the following condition but this is not getting saved

 

AND(
    ($User.Id  = 00520000000nkR1),
    (ISCHANGED( StageName )), (
    (ISPICKVAL( StageName , Closed Lost(Post Won)), 
    (ISPICKVAL( StageName , Processing Rejection))
)

 

The user id is mine.

 

Please help...or is there any way to code it.

 

Thanks

  • November 25, 2010
  • Like
  • 0

On a VF page, I have a pageBlockTable.  There are times where there are more than 1000 records in the collection to be rendered.  When this occurs, the Visualforce collection limit of 1000 is hit and the page doesn't load.  I need to figure out a creative solution for getting around this.  In the end...

 

  1. I need all records to render on the page. If I do any pagination, it'll happen client-side after the records are loaded in the HTML.  I know the first responses to this will be about whether I really need to have all those records on the page and how there is doubt about whether I need to, but for the purposes of this forum post, please work with me here.
  2. I want to keep the look and feel of a pageBlockTable if possible.

 

When not using pageBlockTables, I have used a construct similar to the following to get through a collection of more than 1000 items.

 

<apex:repeat value="{!myCollection}" var="item" rows="1000" first="0">
{!item.text}
</apex:repeat>
<apex:repeat value="{!myCollection}" var="item" rows="1000" first="1000">
{!item.text}
</apex:repeat>
<apex:repeat value="{!myCollection}" var="item" rows="1000" first="2000">
{!item.text}
</apex:repeat>

 

pageBlockTable has the rows and first parameters, but if I do that, I'd be getting a new pageBlockTable everytime.

 

The options I can think of are:

 

  • Get a creative solution from the forums to actually utilize the pageBlockTable (purpose of this post)
  • Use apex:dataTable and try to use style classes to mimix the pageBlockTable look and feel. This is a nice possibility I haven't tried yet.
  • Use apex:repeat tags and make up my own HTML styling

 

Any help is appreciated.

 

 

  • September 13, 2010
  • Like
  • 0