• BALAJI CH
  • PRO
  • 2119 Points
  • Member since 2015
  • Salesforce Developer
  • Solunus Inc.

  • Chatter
    Feed
  • 69
    Best Answers
  • 0
    Likes Received
  • 8
    Likes Given
  • 0
    Questions
  • 252
    Replies
Hii...I am new in Salesforce.Please help me to solve this.

I have a custom field 'NS_ID__c'(Text) on Product and Error_Message__c(Text Area) is custom field on Opportunity. These products are in OpportunityLineItem.
My requirement is if NS_ID__c is blank then these Product Names show on 'Error_Message__c' on Opportunity.
I get a list 'proid' which contains product Names...but i stuck, how to show this list in 'Error_Message__c' field.

 
List<string> proid = new List<string>(); 
Map<Id,List<String>> prodMap= new Map<Id,List<String>>();
List<Product2> prodList= [SELECT Id,Name,NS_ID__c FROM Product2 WHERE Id=:o.Product2Id];
               
if(prodList.size() > 0)
{
   Product2 prd = prodList[0]; 
   string pnsid = prd.NS_ID__c;
   System.debug('pnsid : '+pnsid);
   if(pnsid == null)
   {
       proid.add(prd.Name);
       System.debug('final product List : '+proid);
       string allstring = string.join(proid,',');
       for(Product2 pro: prodList)
       {
           prodMap.put(o.OpportunityId,proid);
           System.debug('prodMap==' +prodMap);
       }
        prodMap.get(Id).Error_Message__c = allstring;
        update prodMap.values();
    }
}
can anyone help me on this task .

public with sharing class TrainingCasefilter {

    public id accRecId;
    private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
   

    public TrainingCasefilter(ApexPages.StandardController controller) {

    accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
    totalRecs = [select count() from case where accountID= :accRecId];

    }

    List<case> trainingCases;

    public List<case> getTrainingCases() {
        if(accRecId != null) {
        trainingCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
                        FROM Case
                        WHERE RecordType.Name ='Training' AND account.id=:accRecId LIMIT :LimitSize OFFSET :OffsetSize];
        }
    return trainingCases;
    }    
    
    public void FirstPage()
{
OffsetSize = 0;
}
public void previous()
{
OffsetSize = OffsetSize – LimitSize;
}public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs – math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}

}
Hi. It worked some hours ago. Suddenly it do abnormally..
Could you please check it for me? why is this happened?

Here is visualforce page form
<apex:page showHeader="true" sidebar="true" controller="Test">
	<apex:form id="fr1">
		<apex:inputTextarea id="text" value="{!text}" cols="4" style="width:100%; height:80px"/><br/>
		From : &nbsp;<apex:outputText value="+565656"/><br/>
		To : &nbsp;<apex:inputText id="to" value="{!to}" style="width:80%"/>
		<apex:commandButton onClick="{!sendSMS}" value="Send Message" immediate="false"/>
	</apex:form>
</apex:page>

and controller
public with sharing class Test {
	public TwilioTest() {}
	public String text {get; set;}
	public String to {get; set;}

	public void getsendSMS(){
		String ACCOUNT_SID = 'AAA';
		String AUTH_TOKEN = 'VVV';
		if( to != null ){ <------ what I added to avoid the error.
			String phone_to = '+82'+to.leftPad(1);

			TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

			Map<String,String> properties = new Map<String,String> {
		        'To'   => phone_to,
		        'From' => '+AAAA,
		        'Body' => text
			};

			TwilioMessage message = client.getAccount().getMessages().create(properties);	
		}
		
	}
}

When I loaded visualforce page, getsendSMS function is called right away.
I'm not click commandbutton..
For avoiding this error, I insert If statement...

Is there any clue?

Please help.

Hi All,

I need a Batchable class that will update the lead Status as 'Open' when no actvities logged under Lead Object

Step1: We have 2 lead status 'Contacted Attempt Made' and 'Discovery'. When these status set, I update the stage date (Custom field Stage_date__c). 
Step2: If stage date is more than 30 days and no actvity logged under lead object from stage date then we need to update the Lead status as 'Open'

Can you please provide the class to update the stage 

Thanks in advanced
 

.

 

 

public class LeadDuplicateFinder_AC {
    public List<WraperClass> Summaries { get; set; }
    Integer recordLimit = 25;
     Integer offSetLimit = 0;
    public Integer totalRecords=0;
    public LeadDuplicateFinder_AC(){
        totalRecords=[select count() from Lead];
        Set<String> emails=new Set<String>();
      List<AggregateResult> results = [select count(id)name,email from lead where email!=null group by email having count(id)>2 Limit :recordLimit OFFSET :offSetLimit ];
             //System.debug(results);
             for (AggregateResult ar : results) {
               Integer count=0;
                 count=(Integer)ar.get('Name');
                 if(count>2){
                emails.add((String)ar.get('Email'));
   
                 }
                 }
        List<String> dupEmails=new List<String>();
        Summaries = new List<WraperClass>();
        for(Lead l:[select name,email from Lead where email in:emails]){                  
                //here before adding to Summaries list if any existing email record is there check first if it is ther dont add to the list
                  if not ther add to the list plz provide me logic how to do  


               Summaries.add(new WraperClass(l));
                
            }
        
            } 
             Public void Next(){
                offSetLimit = offSetLimit + 25;
                 System.debug(offSetLimit);
                 
                  }
     
             Public void Previous(){
                if(offSetLimit > 0)
                   offSetLimit = offSetLimit - 25;
                  
                  }
    public Boolean getPrev(){
        if(offSetLimit==0)
           return true; 
           else
           return false;
    }
    public Boolean getNxt(){
        if((offSetLimit+recordLimit)<totalRecords)
            return false;
            else
            return true;
    }
           public class WraperClass{
              public String Name { get;set;} 
              public String Email { get;set; }
               public WraperClass(Lead l){
                   Name=l.Name;
                   Email=l.Email;
               }
   }
}


 
Hi All,

below i have a piece of code where i  need to sort the items correctly but sort is not happenning correctly. please help me how to achieve in this case. Thanks


List < string > testList = new List < string >();
testList.add('12 hours');
testList.add('48 hours');
testList.add('24 hours');
testList.add('6 hours');
testList.add('72 hours');
testList.add('720 hours');
system.debug('before sort is '+testList); //before sort is (12 hours, 48 hours, 24 hours, 6 hours, 72 hours, 720 hours)
testList.sort();
system.debug('after sort is '+testList); // after sort is (12 hours, 24 hours, 48 hours, 6 hours, 72 hours, 720 hours

Hi All,

I have created a trigger in my Sandbox to play around with Apex Trigger. 

My purpose of this code is to check few field in Account from Task, whether they met a certain requirement. The trigger works but I'm stuck with my test class with 71%.
 

New to apex coding, need help to make it at least 80% above.

APEX TRIGGER

trigger checkAccountAge on Task (before insert) {

    Set<Id> accountIds = new Set<Id>();
    Set<Id> invalidacc = new Set<Id>();  
    
    for (Task t : trigger.new)
    {
        accountIds.add(t.WhatId);
    }
    
    List<Account> accounts = [SELECT Id,Name,Market_Share_Count__c,Owner_Profile_Name__c,No_of_Operating_Rooms__c FROM Account WHERE Id IN :accountIds];

    //validation
    if(accounts.size() > 0)
    {
        for(Account acc : accounts){
            if(acc.Market_Share_Count__c == 0 &&  acc.Owner_Profile_Name__c == 'System Admin'){
                invalidacc.add(acc.Id);
            }
        }
    }
    
    System.debug('invalidacc A '+invalidacc);

    if(invalidacc.size() > 0)
    {
        for (Task t : trigger.new){
            if(invalidacc.contains(t.WhatId)){
                t.addError('Please create Market Share information and fill in No. Operating Room in Account before create a task/log a call.');
            }
        }
    }
}
TEST CLASS
@istest
public class checkAccountAge_test{
    static testMethod void testmethod1() 
    {   
        Account acc = new Account(name='test');
        acc.RecordTypeId = '01290000001M1v3';
        acc.OwnerId = '005900000013z6x';
        acc.No_of_Operating_Rooms__c = 50;
        insert acc;
        
        Share_of_Space__c sos = new Share_of_Space__c();
        sos.Account__c = acc.id;
        sos.Record_Date__c = system.Today();
        sos.Share__c = 1;
        sos.Type__c = 'EXAM';
        insert sos;
        
        Task tk = new Task();
        tk.OwnerId = '005O0000003gIAz';
        tk.Subject = 'Call:';
        tk.ActivityDate = system.Today();
        tk.Activity_Bucket__c = 'FTF End User';
        tk.Activity_Type__c = 'Inservice';
        tk.whatId = acc.id;
        tk.Priority = 'Normal';
        tk.Status = 'Not Started';
        tk.RecordTypeId = '01290000001BRWo';
        tk.Time_Spent_Minutes__c = 120;
        insert tk;
        
        tk.Status ='Completed';
        update tk;
    }
}

 
When i update zipcode matches i need to update field value as Category1, Category2, Category3

Category 1:
800,810,820,828,832,2000,2011,2015,2234,2250,2265,2267,2278,2280,2308,2315,2323,2327,2340,2444,2450,2452,2477,2489,2500,2534,2555,2579,2600,2618,2619,2621,2640,2641,2650,2651,2745,2774,2776,2785,2795,2830,2900,2914,3000,3207,3211,3216,3218,3228,3232,3234,3335,3341,3429,3690,3750,3752,3754,3755,3765,3767,3781,3796,3802,3810,3812,3910,3919,3926,3944,3975,3978,4000,4022,4030,4179,4205,4221,4223,4229,4280,4300,4306,4350,4500,4512,4516,4520,4550,4567,4572,4573,4575,4700,4701,4711,4740,4750,4751,4810,4815,4817,4818,4865,4868,4870,4878,4879,5000,5174,5231,5234,5240,5251,6000,6214,6229,6230,6232,6233,6280,6282,6284,6285,6330,6530,7000,7019,7021,7050,7055,7170,7172,7248,7250,7258,7277,7290,7300
Category 2:
835,836,870,2324,2326,2330,2333,2335,2350,2428,2430,2443,2445,2446,2456,2460,2464,2490,2535,2538,2541,2580,2680,2731,2738,2739,2800,3217,3230,3280,3350,3355,3356,3437,3438,3460,3461,3500,3501,3550,3556,3564,3630,3631,3691,3756,3757,3759,3761,3770,3775,3777,3840,3842,3844,4270,4272,4352,4370,4514,4521,4568,4570,4655,4670,4680,4703,4710,4720,4753,4802,4819,4877,4881,4883,5211,5214,5290,5355,5600,5608,5609,5719,6290,6450,6725,6726,7025,7173,7307,7310,7315
Category 3:
2360,2380,2400,2427,2431,2440,2447,2448,2454,2455,2463,2466,2470,2536,2537,2546,2548,2551,2582,2583,2594,2628,2630,2642,2643,2647,2710,2720,2790,2794,2850,2870,2880,3231,3249,3250,3300,3305,3331,3352,3357,3363,3377,3400,3431,3440,3442,3444,3450,3465,3585,3616,3620,3629,3636,3660,3672,3677,3730,3758,3764,3814,3816,3818,3820,3823,3825,3850,3875,3880,3909,3922,3980,3981,3995,3996,4285,4343,4405,4610,4650,4737,4800,4805,4807,4808,4816,4820,4821,4823,4825,4850,4860,4880,5201,5204,5252,5253,5255,5280,5291,5333,5341,5343,5345,5351,5354,5453,5501,5540,5554,5556,5558,5606,5607,5700,6225,6333,6401,6430,6432,6713,6714,6721,6722

I have tried this formaula


CASE(Zip_Code__c,800,810,820,828,832,2000,2011,2015,2234,2250,2265,2267,2278,2280,2308,2315,2323,2327,2340,2444,2450,2452,2477,2489,2500,2534,2555,2579,2600,2618,2619,2621,2640,2641,2650,2651,2745,2774,2776,2785,2795,2830,2900,2914,3000,3207,3211,3216,3218,3228,3232,3234,3335,3341,3429,3690,3750,3752,3754,3755,3765,3767,3781,3796,3802,3810,3812,3910,3919,3926,3944,3975,3978,4000,4022,4030,4179,4205,4221,4223,4229,4280,4300,4306,4350,4500,4512,4516,4520,4550,4567,4572,4573,4575,4700,4701,4711,4740,4750,4751,4810,4815,4817,4818,4865,4868,4870,4878,4879,5000,5174,5231,5234,5240,5251,6000,6214,6229,6230,6232,6233,6280,6282,6284,6285,6330,6530,7000,7019,7021,7050,7055,7170,7172,7248,7250,7258,7277,7290,7300,“Category1”,800,810,820,828,832,2000,2011,2015,2234,2250,2265,2267,2278,2280,2308,2315,2323,2327,2340,2444,2450,2452,2477,2489,2500,2534,2555,2579,2600,2618,2619,2621,2640,2641,2650,2651,2745,2774,2776,2785,2795,2830,2900,2914,3000,3207,3211,3216,3218,3228,3232,3234,3335,3341,3429,3690,3750,3752,3754,3755,3765,3767,3781,3796,3802,3810,3812,3910,3919,3926,3944,3975,3978,4000,4022,4030,4179,4205,4221,4223,4229,4280,4300,4306,4350,4500,4512,4516,4520,4550,4567,4572,4573,4575,4700,4701,4711,4740,4750,4751,4810,4815,4817,4818,4865,4868,4870,4878,4879,5000,5174,5231,5234,5240,5251,6000,6214,6229,6230,6232,6233,6280,6282,6284,6285,6330,6530,7000,7019,7021,7050,7055,7170,7172,7248,7250,7258,7277,7290,7300,“Category2”,2360,2380,2400,2427,2431,2440,2447,2448,2454,2455,2463,2466,2470,2536,2537,2546,2548,2551,2582,2583,2594,2628,2630,2642,2643,2647,2710,2720,2790,2794,2850,2870,2880,3231,3249,3250,3300,3305,3331,3352,3357,3363,3377,3400,3431,3440,3442,3444,3450,3465,3585,3616,3620,3629,3636,3660,3672,3677,3730,3758,3764,3814,3816,3818,3820,3823,3825,3850,3875,3880,3909,3922,3980,3981,3995,3996,4285,4343,4405,4610,4650,4737,4800,4805,4807,4808,4816,4820,4821,4823,4825,4850,4860,4880,5201,5204,5252,5253,5255,5280,5291,5333,5341,5343,5345,5351,5354,5453,5501,5540,5554,5556,5558,5606,5607,5700,6225,6333,6401,6430,6432,6713,6714,6721,6722,“Category3”,NULL)
But it showing synatx error, Please help me
Hi Expert, 

I am using a trigger that will fire to delete any record but when  record delete then new screen appears
"The record you attempted to access has been deleted. The user who deleted this record may be able to recover it from the Recycle Bin. Deleted data is stored in the Recycle Bin for 15 days."

But here i don't need this message.
Can any one plesae suggest.

Thanks
Mukesh 
i mm trying to create vf page search field 
when i search with name should get opportunities with that name 
and we should get option to edit their it self
Hi Friends,
 I want to display help symbol after my custom Field .  I am adding screen shot also. In this screen shot there is symbols after fields : Pass Data & Validated , & TitleUser-added image
Dear All
I have a need where , i dont want an error message and not allowing the user to save ( which can be done with a validation rule) , but just to prompt a warning and allowing to save the record.
As per my below screenshot, The " Main Driver" field is coming from the above " Account Name" field. Once i have a new quote, The Main Driver field automatically takes the account name plus all the details ( age , gender, MS, etc ). But say, if the user want to change the fields marital status, driving exp, acc in last 12 months, occupation. they should able to do that, but with a warning that it differs from the account. Can anybody plz suggest how to do this, in standard page. thnx

User-added image
I want a Apex code to add product from lookup list to my account.
Any idea??
Hi team,

I'm working on a flow on a specific field that will only accept 0.00 format of number. Any number from 0-9 is fine as long as the format is a 3 numbers that has a decimal after first number followed by a 2 numbers format (0.00). 

I'm using the code below but it seems like it doesn't work the way I expected it to be:
REGEX(Text({!ACCEL_OPEN_ANGLE}),"\\b\\d{1}[.]\\d{2}$")

Any help is greatly appreciated.




Any help will be appreciated. Thanks.
How to cover below lines in testclass???

 List<Fee_Table__c> feeList = database.query(feeQueryStr);
if(feeList.size()>0)
                {
                    //RY:
                    for(Fee_Table__c fee: feeList)
                    {
                       feeRecordTypeMap.put(fee.RecordTypeId, fee);
                    } 
                    system.debug('### feerecordtypemap is created ###');                    
                    return feeRecordTypeMap;  
                 }
 Set<Id> prodIds = new Set<Id>();
                for (Product2 svc : lstProd)
                {                       
                    prodIds.add(svc.Id); 
                }
 Map<Id, Id> prodPEMap = new Map<Id, Id>();
                if(prodIds.size() > 0)
                {
                 
                    List<PriceBookEntry> peList = [select Id, Product2Id from PriceBookEntry where Product2Id IN: prodIds];
                    for(PriceBookEntry pe: peList)
                    {
                        prodPEMap.put(pe.Product2Id, pe.Id);
                    }
                }
                Map<String, Id> rtMapFee = rtMap('Fee_Table__c');

thank you
  • January 11, 2017
  • Like
  • 0
Hi,
In my class i have a method: (Bold-Italic lines are not covered)
public PageReference sendBulkSMSToLeads(){
        //debug = leadStatus + ':' + intakeMonth + ':' + intakeYear + ':' + message;
        List<Lead> matchingLeadsList = [Select MobilePhone from Lead where Status =:leadStatus and Intake_Month__c =:intakeMonth
                                        and Intake_Year__c =:intakeYear];
        Set<String> uniquePhoneNumberList = new Set<String>();                                
        if(matchingLeadsList != null && matchingLeadsList.size() > 0){
            String commaSeparatedMobileNumbers = '';
            for(Lead lead : matchingLeadsList){
                
                if(lead.MobilePhone != null && lead.MobilePhone != ''){
                    if(!uniquePhoneNumberList.contains(lead.MobilePhone)){
                        uniquePhoneNumberList.add(lead.MobilePhone);
                        commaSeparatedMobileNumbers = commaSeparatedMobileNumbers + ',' + lead.MobilePhone;
                    }
                }
            }
            
            if(commaSeparatedMobileNumbers.length() > 0){
                commaSeparatedMobileNumbers = commaSeparatedMobileNumbers.substring(1, commaSeparatedMobileNumbers.length());
            }
            
            //debug = commaSeparatedMobileNumbers;
            
           
            
            String payLoad = 'username=global&password=muzztech&mobile=' +commaSeparatedMobileNumbers + '&sendername=SPJAIN&message='+message;
            Http h = new Http();
            HttpRequest req = new HttpRequest();
            req.setEndpoint('http://priority.muzztech.in/sms_api/sendsms.php'); 
            req.setMethod('POST');
            req.setBody(payLoad);
            HttpResponse res = h.send(req);
            
            ApexPages.Message myMsg = new  ApexPages.Message(ApexPages.Severity.INFO,'Bulk SMS initiated for ' + matchingLeadsList.size() + ' leads');
            ApexPages.addMessage(myMsg); 
            
        }else{
            ApexPages.Message myMsg = new  ApexPages.Message(ApexPages.Severity.ERROR,'No matching leads found to send SMS');
            ApexPages.addMessage(myMsg); 
        }
        return null;
    }
For which i have written this test class method:
@isTest 
      global class SMSControllerTest {
      global class MockHttpResponseGenerator implements HttpCalloutMock
        {
          global HTTPResponse respond(HTTPRequest req) {
            // Optionally, only send a mock response for a specific endpoint and method.
            System.assertEquals('http://priority.muzztech.in/sms_api/sendsms.php', req.getEndpoint());
            System.assertEquals('POST', req.getMethod());
            
            HttpResponse res = new HttpResponse();
            res.setHeader('Content-Type', 'application/json');
            res.setBody('{"username":"global","password":"muzztech","mobile":"7854945777","message":"test message"}');//add your fake JSON here
            res.setStatusCode(200);
            return res;
            } 
         }  
         
        static testMethod void sendBulkSMSToLeadsTest() {
          Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
          Test.startTest();
          SMSController ctrl = new SMSController();        
          ctrl.leadStatus = 'Hot';
          ctrl.intakeMonth = 'January';
          ctrl.intakeYear = '2017';
          ctrl.sendBulkSMSToLeads();
          //Assert the response here
          Test.stopTest();
        }
        
       
      }
How can i increase the code coverage of this method? Thanks a ton for suggestions!
 
Hi,
I am trying to insert the record using Action Function,
I am getting the below error:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account Number should be Numeric.: []
Error is in expression '{!Saverec}' in page action_function_demo: Class.ActionFunctionCLS.Saverec: line 11, column 1
Class.ActionFunctionCLS.Saverec: line 11, column 1

Below is my Code:
<apex:page controller="ActionFunctionCLS" id="pg" >
  <script>
   function recSave(){
    var accountType = document.getElementById('pg:fm:pb:pbs:actType').value;
   // alert('accountType -->'+accountType);
    if(accountType != 'Prospect'){
     alert("You Should Select Prospect to Save the Record");
     return false;
    }
    else{
     saveAccount(); //this is the function name which calls our action function from java Script.
     return true;
    }
   }
 
  </script>

 <apex:form id="fm">
  <apex:actionfunction name="saveAccount" action="{!Saverec}" />
   <apex:pageBlock id="pb">
     <apex:pagemessages ></apex:pagemessages>
     <apex:pageblockButtons >
      <apex:commandButton value="Save" onclick="recSave(); return false;" />    
      
      
     </apex:pageblockButtons>
    
     <apex:pageblockSection id="pbs">
       <apex:inputField value="{!actobj.Name}" id="actName"/>
       <apex:inputField value="{!actobj.type}" id="actType"/>
     </apex:pageblockSection>
   </apex:pageBlock>
 </apex:form>
</apex:page>
---------------------------------------------
public class ActionFunctionCLS {
  public Account actObj{get;set;}
   PageReference prf= null;
    public ActionFunctionCLS(){
      actObj = new Account();
    }
 
   
    public pagereference Saverec(){
   if(actobj.Name !=''){
    insert actobj;
   
   }
   else{
     ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please Enter Name.');
     ApexPages.addMessage(myMsg);
   //return prf;
   }
   if(actobj.id !=null){
 
      // Send the user to the detail page for the new account.
      prf = new PageReference('/'+actobj.id);
      prf.setRedirect(true);
   
   }
   return prf;
    
}
}
Can anyone help me to solve this error.
Thanks in avance
what is the merge statement in DML 
 
  • December 01, 2016
  • Like
  • 0
Hii...I am new in Salesforce.Please help me to solve this.

I have a custom field 'NS_ID__c'(Text) on Product and Error_Message__c(Text Area) is custom field on Opportunity. These products are in OpportunityLineItem.
My requirement is if NS_ID__c is blank then these Product Names show on 'Error_Message__c' on Opportunity.
I get a list 'proid' which contains product Names...but i stuck, how to show this list in 'Error_Message__c' field.

 
List<string> proid = new List<string>(); 
Map<Id,List<String>> prodMap= new Map<Id,List<String>>();
List<Product2> prodList= [SELECT Id,Name,NS_ID__c FROM Product2 WHERE Id=:o.Product2Id];
               
if(prodList.size() > 0)
{
   Product2 prd = prodList[0]; 
   string pnsid = prd.NS_ID__c;
   System.debug('pnsid : '+pnsid);
   if(pnsid == null)
   {
       proid.add(prd.Name);
       System.debug('final product List : '+proid);
       string allstring = string.join(proid,',');
       for(Product2 pro: prodList)
       {
           prodMap.put(o.OpportunityId,proid);
           System.debug('prodMap==' +prodMap);
       }
        prodMap.get(Id).Error_Message__c = allstring;
        update prodMap.values();
    }
}
Hello,

I've made an Apex class that runs through the current weeks active leads and creates an Excel (.csv) report on the lead data + history data (looking for the dates when the status of the lead has changed from one to the next).

The code works nicely, but now when I got into the test coverage part, I was quickly surprised to see that the LeadHistory object is not working in the test classes.

The test coverage starts to be red on the following line, and I actually think that it goes into the catch(Exception) part.
 
list<LeadHistory> leadHistory = [SELECT LeadId, CreatedDate, Field, toLabel(OldValue), toLabel(NewValue) FROM LeadHistory WHERE LeadId =: l.Id AND Field = 'Status' order by CreatedDate asc];

My test class looks like this:
@isTest

public class CreateAutomaticLeadReportTest {
    static testMethod void testMethod1() {

        //create test leads
        Lead l = new Lead();
        l.LastName = 'Test John';
        l.Company = 'Testing Company';
        l.Email = 'test@email.com';
        l.Date__c = Date.newInstance(2019, 3, 1);
        l.Country__c = 'Germany';
        INSERT l;
        
        Leadhistory lh = new Leadhistory(Field='Status', LeadId=l.id);
        INSERT lh;

        Test.startTest();
            CreateAutomaticLeadReport CALR = new CreateAutomaticLeadReport();
            Database.QueryLocator ql = CALR.start(null);
            List<Lead> listOfLeads = [SELECT Id FROM Lead];
            CALR.execute(null, listOfLeads);
            CALR.Finish(null);
        Test.stopTest();
        
    }
}

I tried adding the (SeeAllData=true) annotation to my test class, but it didn't help. (Then I removed the test data insertion)​​​​​​​
Hello,

I am creating the html template in Salesforce and below is value i am fetching from one field that is building address. However, i just need the building number from the entire address. Below is the scenario.
“Václavské náměstí 785/28, P1 - Alfa Building”, this is the text and I want to extract the only the number i.e 785/28. But the thing is the numbers before and after the ‘/’ varies it can be more than 3 or 2 digits. Trim Left and Right work but can't seem to specify the values dynamically. 

Thanks, Shweta
Hello, 
I am trying to rollup a custom field "Product_Alert_Message" from the OpportunityItemLine to an Opportunity field "Product_Alerts_Roll_up__c".
I have the below Apex Class:
global with sharing class OppProductReqRollupTriggerHandler 
{
    global static void MainProcess(set<id> OpportunityIds)
    {
        //Create List to hold final concatenated result
        List<Opportunity> OpportunityList = new List<Opportunity>();
        
         //Create list to Children that have Parents within Parent Set.
        List<Opportunity> Opportunity = [Select Id,Product_Alerts_Roll_up__c, (SELECT Id,   OpportunityLineItem.Product_Alert_Message__c from OpportunityLineItem) from Opportunity where Id in :OpportunityIds];
 
        //Loop through List result to build concatenated string and add to sampleList
        for (Opportunity s:Opportunity)
        {
           String concatenateString = '';
              for (OpportunityLineItem sp: s.OpportunityLineItem)
              {
                if(sp.OpportunityLineItem__r.Product_Alert_Message__c <> null)
                {
                    concatenateString += sp.OpportunityLineItem__r.Product_Alert_Message__c + ';';
                }
              }
              s.Product_Alerts_Roll_up__c = concatenateString.replace('null','').removeEnd(';');
              OpportunityList.add(s);
        }
 
        //Update Parent object with concatenated string
        update OpportunityList;
    }
}
 but it's giving me the below errors:
Error: Compile Error:
OpportunityLineItem.Product_Alert_Message__c from OpportunityLineItem) from Opportunity
^
ERROR at Row:1:Column:102
Didn't understand relationship 'OpportunityLineItem' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 9 column 41.
Can someone help me with this?
Thanks,
acc= (id == '1' || id== '2') ? 'a: ' : ((id == '3' ) ? 'b: ' : '');
Hi All,
Here my situation is, in Opportunity object we are having a field closed date and in product level their is a field Date field 
my requriment is when we will change opportunity closed date field by 3 days then in product level date field should be added by 3 days.
for example: Opportunity closed date is 6/1/2017 i will change it to 6/3/2017 then in opportunity product if it is 5/31/2017 it should become 6/2/2017.
 we can achieve it by trigger but we need workflow because some other reqiurment are their based on this change in the UI
I need a help to write a workflow formula

Thanks in advance

Regards,
satya
 
ApexPages.currentPage().getParameters().get('action'); // 0- > New, 1 -> Reply, 2 -> Reply All, 3 -> Forward
can anyone help me on this task .

public with sharing class TrainingCasefilter {

    public id accRecId;
    private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
   

    public TrainingCasefilter(ApexPages.StandardController controller) {

    accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
    totalRecs = [select count() from case where accountID= :accRecId];

    }

    List<case> trainingCases;

    public List<case> getTrainingCases() {
        if(accRecId != null) {
        trainingCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
                        FROM Case
                        WHERE RecordType.Name ='Training' AND account.id=:accRecId LIMIT :LimitSize OFFSET :OffsetSize];
        }
    return trainingCases;
    }    
    
    public void FirstPage()
{
OffsetSize = 0;
}
public void previous()
{
OffsetSize = OffsetSize – LimitSize;
}public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs – math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}

}
How to create a custom column field in CaseUser-added image
[
   {
      "currentPage":"1",
      "totalPages":"37",
      "showingResults":"1-10 of 776"
   },
   {
      "rfqs":[
         {
            "opened":"04/17/2017",
            "clientId":"5004",
            "agentId":"724",
            "serialNumber":"4664641342",
            "opportunityId":"",
            "locReqs":[
               {
                  "1":{
                     "locReqId":"123456",
                     "product_type":"Internet",
                     "access_type":"20M FastE",
                     "SingleLineAddress1":"Street2, CA 92373",
                     "SingleLineAddress2":"",
                     "Term":"12"
                  },
                  "2":{
                     "locReqId":"123489",
                     "product_type":"Internet",
                     "access_type":"20M FastE",
                     "SingleLineAddress1":"Street3, CA 92373",
                     "SingleLineAddress2":"",
                     "Term":"12"
                  }
               }
            ]
         },
         {
            "opened":"04/17/2017",
            "clientId":"5005",
            "agentId":"725",
            "serialNumber":"4664641341",
            "opportunityId":"",
            "locReqs":[
               {
                  "1":{
                     "locReqId":"123412",
                     "product_type":"Internet",
                     "access_type":"20M FastE",
                     "SingleLineAddress1":"Street1, CA 92373",
                     "SingleLineAddress2":"",
                     "Term":"12"
                  }
               }
            ]
         }
      ]
   }
]

 

What I am trying to do is make a page where if i click on button then all accounts with type "prospect" to be shown. below is all my code :

 

Error: Formula expression is required for attribute value in in q4controller at line 7 column 58
VF code

<apex:pageblock title = "List of accounts">

                <apex:pageblocktable value="{! acts }" var="a">

                    <apex:column value="{ !a.Name } " /> 
                    <apex:column value="{ !a.Type }" />    
                    <apex:column value="{ !a.Industry }" />

                </apex:pageblocktable>


       </apex:pageblock>


</apex:page>



******Controller class******

Public class q4{

List<account> acts;

public list<account> getacts(){
acts = [Select name,type,industry from account where type = 'Prospect'];
return acts;
}



}
 




what is this error, i don't understand. i have tried googling but wasnt able to pin point what the issue is.also i am new to this so please scuse and silly mistake.
Thanks

Hi. It worked some hours ago. Suddenly it do abnormally..
Could you please check it for me? why is this happened?

Here is visualforce page form
<apex:page showHeader="true" sidebar="true" controller="Test">
	<apex:form id="fr1">
		<apex:inputTextarea id="text" value="{!text}" cols="4" style="width:100%; height:80px"/><br/>
		From : &nbsp;<apex:outputText value="+565656"/><br/>
		To : &nbsp;<apex:inputText id="to" value="{!to}" style="width:80%"/>
		<apex:commandButton onClick="{!sendSMS}" value="Send Message" immediate="false"/>
	</apex:form>
</apex:page>

and controller
public with sharing class Test {
	public TwilioTest() {}
	public String text {get; set;}
	public String to {get; set;}

	public void getsendSMS(){
		String ACCOUNT_SID = 'AAA';
		String AUTH_TOKEN = 'VVV';
		if( to != null ){ <------ what I added to avoid the error.
			String phone_to = '+82'+to.leftPad(1);

			TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

			Map<String,String> properties = new Map<String,String> {
		        'To'   => phone_to,
		        'From' => '+AAAA,
		        'Body' => text
			};

			TwilioMessage message = client.getAccount().getMessages().create(properties);	
		}
		
	}
}

When I loaded visualforce page, getsendSMS function is called right away.
I'm not click commandbutton..
For avoiding this error, I insert If statement...

Is there any clue?

Please help.

Hi All,

I need a Batchable class that will update the lead Status as 'Open' when no actvities logged under Lead Object

Step1: We have 2 lead status 'Contacted Attempt Made' and 'Discovery'. When these status set, I update the stage date (Custom field Stage_date__c). 
Step2: If stage date is more than 30 days and no actvity logged under lead object from stage date then we need to update the Lead status as 'Open'

Can you please provide the class to update the stage 

Thanks in advanced
 

.

 

 

Hi Friends,
I read in apex developer guide we can't deploy the email service address name. Can  any one help me how we deploy the email service address name?
Thank you
Hi,
I have a javascript button on click event on opportunity object...it works well..
Now i want if stagename = 'ABC', only then it gets enable ...otherwise it should be hidden or greyed out...
any help will be appreciated...
Thanks in advance!!!
 
Hi Experts,
What is the difference between Clone () and DeepClone() in Apex? When should we use what? Can someone explain with an example?

Thanks!
Hi,

I have a requirement where i need to reorder particular rows in VF page whenever user clicks a link on reorder column in VF page.

Delete                  Reorder                Time            Topic
<Checkbox>         <Arrowheads>      <time>         <Topics>

Thanks
Vivek
Hiii,
Can any one please help me out in generating report on task object, I am able to display only single object records but i need to display as shown below:.. 
User-added image
Thanks in Advance.
  • April 12, 2016
  • Like
  • 2
Formula to calculate the Age in Years,Months, Weeks and Days


IF(
NOT( ISNULL (Date_of_Birth__c)), /* Condition */

TEXT(FLOOR((TODAY()-Date_of_Birth__c)/365.2425)) & " Years " &
TEXT(FLOOR(MOD((TODAY()-Date_of_Birth__c),365.2425)/30)) & " Months " & 
Text(Floor(MOD(Floor(MOD((TODAY()-Date_of_Birth__c),365.2425)),30)/7)) & " Weeks "  & 
 TEXT( FLOOR( MOD( FLOOR( MOD( FLOOR( MOD(TODAY()-Date_of_Birth__c,365.2425) ) ,30) ) ,7) ) ) 
& " Days" ,  
/* Value IF True */
"Check your DOB " /* Value IF False */
)
Hi all,

When ever the button "Click" is clicked. The value should increment to 0,1,2,3,4,...etc,. Should not use JavaScript. Use only controller and vf page.

I have tried but, no value is incrementing. Once go through the below code.

VF Code:
<apex:page showHeader="false" controller="increment">
<apex:form >
 <apex:commandButton value="Click" action="{!display}"/>
</apex:form>
</apex:page>

Apex Class:
public class increment{

    integer numb;
    integer i;

    public void display(){
    
       numb = 100;
       
    for(i=0; i<numb; i++){
        i=i+1;
        System.debug(i);
        
    } 
    
    }

}

What is wrong in my code?
  • March 24, 2016
  • Like
  • 1

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.