• AnjithKumar
  • NEWBIE
  • 385 Points
  • Member since 2015
  • Salesforce Consultant
  • Tecom Group,Dubai


  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 0
    Questions
  • 72
    Replies
Hi, i'm trying to record the start of day date/time value for a given Business Hour as part of an Apex trigger but not sure of the way to do this.  Can someone help me try and achieve this please? The basic logc is to check what day it is today and then record the Start of Day date/time in to a field  (Start_of_Day__c) for that same day defined for the Business Hour.

Thanks
  • March 07, 2016
  • Like
  • 0
Hi

I am very new to Apex and this is my first code so bound to have school boy errors, would appreciate help and direction:

Need to create a trigger on Contact, on create and update, where Number_Field__c is greater than 30 (This is a formula field that is created to accumulate the days passed since a certain form was submitted , which is a date field.

Task need to be created with some data; Subject, Priority, Status, Contact Name, Task to be assigned to Contact Owner

Here is the code which does create a task, but doesnt check the condition and docesnt insert the Contact Name in the Related to field:

1
2
3
4
5
6
7
8
9
10
11
trigger QM on Contact (after insert, after update) {
for (Contact Con : Trigger.New) {
List <Contact> DBSCheck = new List<Contact>();
DBSCheck = [SELECT Id, Name FROM Contact WHERE Number_Field__c > 30];
Task DBStask = New Task ();
DBSTask.Subject = 'Overdue DBS';
DBSTask.Priority = 'Normal';
DBSTask.Status = 'In Pogress';
DBStask.WhoId = (Con.Name);
Insert DBSTask;
}}


Thanks a lot for your help.


 




 
  • March 06, 2016
  • Like
  • 0
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class

@isTest
public class Leadtestss{  
    static testMethod void runTest1() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
              
       Lead lead = new Lead();
       lead.FirstName = 'test';
       lead.LastName = 'foo'; 
       lead.company='Acc3';      
       insert lead; 
            
        test.startTest();
        PageReference pageRef = Page.Leadpage;
        pageRef.getParameters().put('Id', String.valueOf(lead.Id));
        Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
        ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object
        Leadpage testDObj = new Leadpage();
        testDObj.getperformcallout();
        test.stopTest();  
            
    }    
}
 
Page MOCK Class

@IsTest(seeAllData = false)
global class Leadpagemock implements HttpCalloutMock 
{    
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

public class Leadpage{
    public Leadpage(ApexPages.StandardController controller) {
    }    
    public  Leadpage()
        {}        
     public   String MySessionID = UserInfo.getSessionID();
     public   String conId = ApexPages.currentPage().getParameters().get('Id');
     public   String EmailCon=[Select email from Lead where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode='00530000000rLMxAAM';
     public   String Oid = UserInfo.getOrganizationId();  
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);   
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');   
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode (b64Data5,  'UTF-8');
  
    public List<LeadVideoViewAllWrap> ConsoleWrapperList{get;set;}
    public List<LeadVideoViewAllWrap> getperformcallout(){
        ConsoleWrapperList = new List<LeadVideoViewAllWrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
        req.setEndpoint(url);
        req.setMethod('GET');        
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<LeadVideoViewAllWrap>)json.deserialize(res.getbody(),List<LeadVideoViewAllWrap>.class); 
        }
        return consolewrapperlist;
    }  
}

 
IF( CloseDate >= Date(2015, 07, 01) && IsClosed == TRUE , Amount , NULL)

I would like to update this so that there is no need for me to update this formula yearly... can anyone help?
  • January 12, 2016
  • Like
  • 0
Hi all

I want to write a trigger on chatter group members. It will work when a new member will be added to the group and everyone will be notified through email. How can I write a trigger for this?
senario is that, if we create a new event on a account object then it should update the description field of account.  But it is not wokring. 
 
trigger event on Event (after insert) {
set<id> ids=trigger.newmap.keyset();

map<id,event> newevents =new map<id,event>();

 for(event e1:trigger.new)
 {
 if(((String)e1.whatid).startsWith('001')) {
 newevents.put(e1.id,e1);
  }
 }
// account acc=[select id,name,description from account where id in:newevents.keyset()];
 
 for(account a1:[select id,name,description from account where id in:newevents.keyset()])
 {

a1.description=newevents.get(a1.id).location;
update a1;
 
}
}

 
Am rendering vfp as PDF. I want to show sections and subsections Numbering dynamically to the paragraph for example
1. First Section
   1.1 First Subsection for first section
       1.1.1 child for first subsection
       1.1.2 child for first subsection
   1.2 Second Subsection for first section
       1.2.1 child for first subsection
       1.2.2 child for first subsection
2. Second Section
   2.1 First subsection for second section
       2.1.1 child for first subsection
   2.2 second subsection for second section
       2.2.1 child for second subsection

While typing paragraph in field i'll mention h1# or h2# or h3# before starting paragraph, the meaning of that is,
      h1# ----> first section
      h2# ----> Sub section of first section
      h3# ----> child for sub section
so am typing like,

       h1# This is First Section
           h2# This is Sub section for first section
                h3# This is child for sub section
       h1# This is Second section
            h2# This is Sub section for Second section
                h3# This is child for sub section.

I tried with below extension,
 
public class Apex_Class_Name {
    public string str{get;set;}
//  public integer temp=0;
    public integer i,j,k;
    public integer h1Hash = 0, h2Hash = 0, h3Hash = 0;
    public string Level1, Level2, Level3;
    public Patient__c sal;
    public Apex_Class_Name(ApexPages.StandardController controller){
        sal = [SELECT Paragraph__c from Patient__c where id=:Apexpages.currentpage().getParameters().get('id') limit 1];
        str = sal.Paragraph__c;
        Pattern p1 = Pattern.compile('h1#');
        Pattern p2 = Pattern.compile('h2#');
        Pattern p3 = Pattern.compile('h3#');
        Matcher m1 = p1.matcher(str);
        Matcher m2 = p2.matcher(str);
        Matcher m3 = p3.matcher(str);
        while (m1.find()) {
            h1Hash++;
        }
        while (m2.find()) {
            h2Hash++;
        }
        while (m3.find()) {
            h3Hash++;
        }
        system.debug('==============>'+h1Hash);
        system.debug('==============>'+h2Hash);
        system.debug('==============>'+h3Hash);


 CallMethod(str);
    }
    public string CallMethod(string substr){
        if(h1Hash != 0){
            for(i = 1; i <= h1Hash; i++){
                Level1 = string.valueOf(i);
                str = str.replaceFirst('h1#',Level1);
                for(j = 1; j <= h2Hash; j++){
                    Level2 = Level1+'.'+string.valueOf(j);
                    str = str.replaceFirst('h2#',Level2);
                    for(k = 1; k <= h3Hash; k++){
                        Level3 = Level2+'.'+string.valueOf(k);
                        str = str.replaceFirst('h3#',Level3);
                    }
                }
            }
        }
        return str;
    }
}

My present output is,
1. First Section
   1.1 Sub section one
        1.1.1 child for sub section
        1.1.2 child for sub section
   1.2 Sub section two 
         1.1.3 child for sub section **(coming 1.1.3 instead of 1.2.1)**
         1.1.4 child for sub section **(coming 1.1.4 instead of 1.2.2)**
 2. Second Section
    1.3 Sub section one **(coming 1.3 instead of 2.1)**
        1.1.5 child for sub section **(coming 1.1.5 instead of 1.3.1)**
    1.4 Sub section two **(coming 1.4 instead of 2.2)**
        1.1.6 child for sub section **(coming 1.1.6 instead of 1.4.1)**
Please see the errors above, I mentioned in brackets.

What is the error I did?

How can I overcome this?

Any help is appreciable!! Thanks.

 
I would like to creat a Workflow that updates a Custom picklist Field (MRR Territory) based on the Standard State/Province Field. I will have all 50 states to accommodate for in the formula and three territories (East, Central, West). Here is how I started the Rule:
IF(ISPICKVAL(State/Province, "AL"), 
IF(ISPICKVAL(State/Province, "SC"),
(MRR_Territory, (Central))

I keep getting an error message.
Hi, 

I found the following code for a tooltip in combination with a component.

How can I add a linebreak into this text. <br/> is not working.
<c:helpicon helpText="
Example: 1215551212.
No dashes, please
"/>


Thanks,
Sascha


 
<apex:component selfClosing="true">
<apex:attribute name="helpText" description="Help Text." type="String" required="true"/>
<div class="mouseOverInfoOuter" id="searchInvoiceHelper" onfocus="addMouseOver(this)" onmouseover="addMouseOver(this)" tabindex="0">
    <img src="/s.gif" alt="" class="infoIcon" title="" />
    <div class="mouseOverInfo" id="searchInvoiceHelperText" style="display: none; opacity: -0.19999999999999996; left: 16px;">
        <div class="body">{!helpText}</div>
    </div>
</div>
</apex:component>
 
<apex:page >
    <apex:sectionHeader title="Help Icon Test" />
    <apex:form>
        <apex:pageBlock>
            <apex:outputText value="enter your phone number" />
            <apex:inputText /><c:helpicon helpText="Example: 1215551212. No dashes, please"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
I am new to force app development.  I have an custom object which any user can access. That means any user, who has access to my  app can create new records, view all records but edit or delete his own entries. 

Please suggest steps for acheiving this.
I am new to force app development. I have a datetime field called schdule.
i have put formula Schedule__c  >  now() + XXX (any number)
the syntax check shows ok. what i a trying to achieve is the that this datetime field should contain anything from tomorrow onwards.
Please suggest. Currently, even this validation Schedule__c  >  now()  is not working
how can we make the callouts in batch apex?
hi, everyone
I have developed a visualforce page which have "selectCheckboxes" as Account "Rating" field.
what need to do is. make "selectCheckboxes"  not multiselected. only one checkbox is selected.
User-added image
Hi all,
writing my first trigger and can't seem to get it to work, can you take a look and see what I am doing wrong? Should it be after insert, before update?
It's just not putting the test text in the custom field...
What i am trying to do is eventually put a template in the description field for my users to fill out.
Thanks!

trigger insertText on Case (before insert, before update) {

            for (case c : trigger.new) {
            
                        If (c.triggertest__c == null)
                                    c.triggertest__c = 'Text here';

                        else {
                                    System.debug ('field is already filled in');
                        }
           
            }
}
// student__c is child, college__c is parent. The below code to get the child record when parent information is given works
    {
          student__c [] a = [select id, name, date_of_birth__c, phone__c, email__c, address__c from student__c where     college_name__r.name = 'PEC College'];
          for(student__c s:a)
          system.debug(s);    
    }

//The code below to get parent record when child information does not.
    {
          college__c a = [select id, name, address__c, courses_offered__c, dean_name__c, number_of_students__c, year_started__c
                        from college__c where id in (select student__r where student__c.name = 'Claire Hale') ];
      }

 
Experts
In my opportunity screen i have Opportunity type and Sales stage two list fields. I am tying to build a  logic like a Opporuntiy record with type value as "lost" stays more than 30 days from the create date, set the sales stage as "Cancelled".   some logic steps would be appreciate.

Thanks
Matt
Hi everyone,

I have a requirement to post a chatter feed on case feed stream and chatter tab, when a specific task was created under a case.

I know how to post a txt msg from apex code, but I am wondering how to post a chatter feed with auxiliary body as below

User-added image

Appreciate if you have any idea.

Regards,
Thomas
Hi Everyone,

Can you please let me know whether we can Integrate salesforce with external applications by using a Professional Edition or not.

Thanks.
Hi, i'm trying to record the start of day date/time value for a given Business Hour as part of an Apex trigger but not sure of the way to do this.  Can someone help me try and achieve this please? The basic logc is to check what day it is today and then record the Start of Day date/time in to a field  (Start_of_Day__c) for that same day defined for the Business Hour.

Thanks
  • March 07, 2016
  • Like
  • 0
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1  
                      &
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
 
Test Class

@isTest
public class sendmailcontacttest{  
    static testMethod void runTest1() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
            
         test.startTest();
         PageReference pageRef = Page.sendmail; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.sendpost();
           test.stopTest();  
            
    }   
    static testMethod void runTest3() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
            
         test.startTest();
         PageReference pageRef = Page.Leadpage; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.callapi2();
           test.stopTest();  
            
    }
    static testMethod void runTest4() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         
       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
	   test.startTest();
         PageReference pageRef = Page.Leadpage; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.getperformcallout();
           test.stopTest();              
    }  
}
 
Mock Class

@IsTest(seeAllData = false)
global class sendmailcontactmock implements HttpCalloutMock 
{   
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

Public  class sendmailp{

    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
    public String table3{get; set;}
     public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public String  conId = ApexPages.currentPage().getParameters().get('Id');
     public  String  EmailCon =[Select email from Contact where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );

    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
 
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');

    public sendmailp(ApexPages.StandardController controller) {
    AddRecep = '';
    body=apexpages.currentpage().getparameters().get('att');   
           
    }
    
   public void sendpost(){
    String MySessionID = UserInfo.getSessionID();
      String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
        String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
        string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
        String Acode= Userinfo.getuserid();
        String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
   Blob data6 = Blob.valueOf(to);
   Blob data7 = Blob.valueOf(AddRecep);
  Blob data8 = Blob.valueOf(subject);
   Blob data9 = Blob.valueOf(body);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
    Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 );
    Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 );
   Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 );
        String b64Data = EncodingUtil.base64Encode(encryptedData);
        String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
        String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
        String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
        String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
        String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
       String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
       String b64Data7 = EncodingUtil.base64Encode(encryptedData7);
        String b64Data8 = EncodingUtil.base64Encode(encryptedData8);
       String b64Data9 = EncodingUtil.base64Encode(encryptedData9);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
     String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
     String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
     String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');
     String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8');
     String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8');
    String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8');
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost');
        
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');        req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); 
system.debug('???'+aucode);
        try {
                res = http.send(req);
                if (res.getBody() != null) {
                    System.debug('#Success!');
                } else {
                    System.debug('HTTP error: ' + res.getStatusCode());
                }
                System.debug(res.getBody());
            } 
        catch(System.CalloutException e) 
            {
                System.debug('Callout error: '+ e);
            }
   }
        
    public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailp(){
        body = apexpages.currentpage().getparameters().get('att');
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        normalList = true;
        selectedList = false;
        body = ''; 
       to = EmailCon; 
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    } 
    
    public List<video> ConsoleWrapperList1{get;set;}
    public String consolewrap{get;set;}
    public String  SessionId = '';
    public void callapi2(){
    String  SessionId = '';
    string testSessionId = '';
    for( consolewrap cwt : ConsoleWrapperList){
        testSessionId += cwt.sid;
        if(cwt.selected){
            if(SessionId == ''){
                SessionId += cwt.SessionId;
            }else{
                SessionId += ','+ cwt.SessionId;
            }
        }
    } 
    system.debug('testSessionId+++'+testSessionId);
    List<video> ConsoleWrapperList1 = new List<video>();
    HttpRequest req = new HttpRequest(); 
    HttpResponse res = new HttpResponse();
    Http http = new Http(); 
    system.debug('SessionId+++'+SessionId);
   string url = 'https://www.demomail.net/sf/api/SendVideoContactPreview?AUCode='+aucode+'&SOrgID='+ocode+'&SessionIds='+SessionId;
      req.setEndpoint(url); 
    req.setMethod('GET');
    res = http.send(req);
    if(res.getstatusCode() == 200 && res.getbody() != null){ 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
        ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);
        system.debug('ConsoleWrapperList1+++'+ConsoleWrapperList1);
        body = ConsoleWrapperList1.get(0).bodyT;
    }
}
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;} 
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
     string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&id='+SessionId;
        System.debug('##: '+ SessionId);
      req.setEndpoint(url);
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
        return consolewrapperlist;
    }
    
}

 
Hi

I am very new to Apex and this is my first code so bound to have school boy errors, would appreciate help and direction:

Need to create a trigger on Contact, on create and update, where Number_Field__c is greater than 30 (This is a formula field that is created to accumulate the days passed since a certain form was submitted , which is a date field.

Task need to be created with some data; Subject, Priority, Status, Contact Name, Task to be assigned to Contact Owner

Here is the code which does create a task, but doesnt check the condition and docesnt insert the Contact Name in the Related to field:

1
2
3
4
5
6
7
8
9
10
11
trigger QM on Contact (after insert, after update) {
for (Contact Con : Trigger.New) {
List <Contact> DBSCheck = new List<Contact>();
DBSCheck = [SELECT Id, Name FROM Contact WHERE Number_Field__c > 30];
Task DBStask = New Task ();
DBSTask.Subject = 'Overdue DBS';
DBSTask.Priority = 'Normal';
DBSTask.Status = 'In Pogress';
DBStask.WhoId = (Con.Name);
Insert DBSTask;
}}


Thanks a lot for your help.


 




 
  • March 06, 2016
  • Like
  • 0
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class

@isTest
public class Leadtestss{  
    static testMethod void runTest1() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
              
       Lead lead = new Lead();
       lead.FirstName = 'test';
       lead.LastName = 'foo'; 
       lead.company='Acc3';      
       insert lead; 
            
        test.startTest();
        PageReference pageRef = Page.Leadpage;
        pageRef.getParameters().put('Id', String.valueOf(lead.Id));
        Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
        ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object
        Leadpage testDObj = new Leadpage();
        testDObj.getperformcallout();
        test.stopTest();  
            
    }    
}
 
Page MOCK Class

@IsTest(seeAllData = false)
global class Leadpagemock implements HttpCalloutMock 
{    
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

public class Leadpage{
    public Leadpage(ApexPages.StandardController controller) {
    }    
    public  Leadpage()
        {}        
     public   String MySessionID = UserInfo.getSessionID();
     public   String conId = ApexPages.currentPage().getParameters().get('Id');
     public   String EmailCon=[Select email from Lead where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode='00530000000rLMxAAM';
     public   String Oid = UserInfo.getOrganizationId();  
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);   
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');   
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode (b64Data5,  'UTF-8');
  
    public List<LeadVideoViewAllWrap> ConsoleWrapperList{get;set;}
    public List<LeadVideoViewAllWrap> getperformcallout(){
        ConsoleWrapperList = new List<LeadVideoViewAllWrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
        req.setEndpoint(url);
        req.setMethod('GET');        
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<LeadVideoViewAllWrap>)json.deserialize(res.getbody(),List<LeadVideoViewAllWrap>.class); 
        }
        return consolewrapperlist;
    }  
}

 
Can Any One explain in which situation we have to use Wrapperclass ?
Hi
When I create a new developer SalesForce license it creates a professional SalesForce account
THis means I can't access the workflow and Approvals link
I used this link to register 
http://www.developerforce.com/events/regular/registration.php

And i'm trying to follow the instructions here
http://blogs.msdn.com/b/webdev/archive/2015/09/07/integrating-with-salesforce-using-asp-net-webhooks-preview.aspx

How can I upgrade my professional edition?

Cheers
Sam
I am new to force app development. I have a datetime field called schdule.
i have put formula Schedule__c  >  now() + XXX (any number)
the syntax check shows ok. what i a trying to achieve is the that this datetime field should contain anything from tomorrow onwards.
Please suggest. Currently, even this validation Schedule__c  >  now()  is not working
This trailhead is a great tool!

I just completed my second badge and had to re-read the challenge word for word.

If you find yourself struggling know that it took me 3 tries to pass the challenge.

Thanks to the community, looking forward to getting my certs.
This is my table Demo : these are my  fields
auto _Id (Auto number and unique ) 
Version : string (ex 8.3.1, 8.3.3)

 The user selects a version from the drpdown say 8.3.1. Now I want to retrieve the corresponding auto_id in the controller, which is not a list but just a number. How can I query this?

Please Help..
  • September 17, 2015
  • Like
  • 1
1. Organization ID of the sandbox: 00DS0000002SagE
 
2. I am the system administrator authorized on behalf of this organization to request this limit increase. 
https://cs1.salesforce.com/00DS0000002SagE 

3. The details about the business use case that the customer feels will benefit from having this limit increased are:
     
                A. New Projects, processes, integrations. 
                B. % Apex Code is high.

 
4. What is the duration that you would like to have this limit increased?Indefinitely