• testrest97
  • NEWBIE
  • 350 Points
  • Member since 2013

  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 62
    Replies

Hi everyone

 

My first trigger in salesforce, is working in sandbox but I'm having a problem with the coverage.

 

I was already reading about it and couldn't find a solution, can anyone help?

 

I'm a new at salesforce so any help will be more than welcome.

 

The code is:

 

trigger AccountTrigger on Account (before insert) {
    
    List<Account> lst_in = trigger.new;
      for(Account acc:lst_in){
      
         
         acc.ShippingCity = acc.BillingCity;
         acc.PersonMailingCity = acc.BillingCity;
         acc.PersonOtherCity = acc.BillingCity;
    
         acc.ShippingStreet = acc.BillingStreet;
         acc.PersonMailingStreet = acc.BillingStreet;
         acc.PersonOtherStreet = acc.BillingStreet;
   
         acc.ShippingState = acc.BillingStreet;
         acc.PersonMailingState = acc.BillingState;
         acc.PersonOtherState = acc.BillingState;
       
         acc.ShippingPostalcode = acc.BillingPostalcode;
         acc.PersonMailingPostalcode = acc.BillingPostalcode;
         acc.PersonOtherPostalcode = acc.BillingPostalcode;
 
         acc.ShippingCountry = acc.BillingCountry;
         acc.PersonMailingCountry = acc.BillingCountry;
         acc.PersonOtherCountry = acc.BillingCountry;
    
   }
}

 

The errors are:

 

AccountTrigger

      Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required Deploy Error      

      Average test coverage across all Apex Classes and Triggers is 66%, at least 75% test coverage is required.

 

I can understand that I will have to tweak the code to have more than the minimum expected, but how?

 

Thank you

  • November 20, 2013
  • Like
  • 0

I found this on a blog that used it for Opportunities,  I massaged it to use in Cases, but I cannot get it to pop up the message.

<apex:page standardController="Case" rendered="{!Case.Impact__c = 'Site Production Down'}">

<script type="text/javascript">
{
    window.alert{"This is an alert");
}

</script>

</apex:page>

 I added the VF Page to my page layout, created a case to meet the criteria and saved the case, no pop up.  Am I missing something?

  • November 20, 2013
  • Like
  • 0

Hi,

 

I am trying to create Workflow rule where Target Date greater than Today()

 

but it is giving me an error  Error: Invalid date (Valid date format 11/14/2013)

 

Target Date is the field with Date Type.

 

Can anyone tell me how to resolve this error

 

 

Hi,

I want to implement a tree structure in visualforce page some thing like the structure from this link http://ludo.cubicphuse.nl/jquery-treetable/

 

Is it possible to implement like above.If yes can any one please provide any simple example to implement this.

Thanks in Advance.

 

 

Raj.

  • November 08, 2013
  • Like
  • 0

In my Contact object, I have a lookup field to the User table.  Every user has a corresponding contact record.

I have a trigger, that pulls in the Contact ID of the current User and passes that information to the Case Contact field.

 

The trigger works, as I'm able to create cases with this information being populated correctly.  I'm having problems figuring out how to write the test code as the system user wouldn't have a contact or user to match up against.

    sObject s = [SELECT ID FROM CONTACT WHERE user__c =: Userinfo.getUserId()];
    ID myid = s.id;

 

            if((caseObj.Type == 'Drupal Site Launch' || caseObj.Type == 'Classic Site Launch') && caseObj.ParentId == NULL){
                Case JDLaunchCase = new Case();
                JDLaunchCase.Subject = caseObj.Subject + ' JD Launch Work';
                JDLaunchCase.RecordTypeId = '012A000000177IL';
                JDLaunchCase.ParentId = caseObj.ID;
                JDLaunchCase.Type = caseObj.Type;
                JDLaunchCase.Request_Type__c = 'Request New Development';
                JDLaunchCase.Requested_Deliver_Date__c = caseObj.Estimated_Launch_Date__c;
                JDLaunchCase.ContactId = myid;
                relatedCases.add(JDLaunchCase);

 

Hi ,

Am creating a VF Page for New/Edit page for my CustomObject and With the Following Controller am getting:

Visualforce Error

System.QueryException: List has no rows for assignment to SObject 

 

Class :

public class NewColorPaletteController{

  public Color_Palette_To_Color__c record;    
  public string b{get; set;} 

  public NewColorPaletteController() {
      record= [select id,Name,Color_Palette__c,Color__c FROM Color_Palette_To_Color__c where id=:ApexPages.currentPage().getParameters().get('Id')];
    }

  Public Color_Palette_To_Color__c  getRecord()
  { return record;
  }
    
  Public PageReference SaveMethod(){
       try{
            update record;
        }
       catch(exception e){
      //      // handle the exception
      }
        return new PageReference('/apex/relatedListColorPalette?id='+record.Color_palette__c);
  }

  Public PageReference cancelMethod() {
        return null;
    }

}

 Please provide Solution for this Error.

 

-Thank you.

I'm trying to do a select for data for the currently logged in user with the global variable {!$User.id} in a trigger.
This statement runs fine:
[SELECT j.id, j.Subject, j.CallDurationInSeconds, j.CreatedDate, j.status, j.Description, j.CreatedByID  
FROM Task  j  WHERE (j.CreatedDate = today AND CreatedByID = '00540000001Gii5AAC' AND j.Status = 'Completed')
But when I replace the hard coded ID with {!User.id} I get an error.
Thanks, Michele
@isTest
public class testContactServices{
    
    static testMethod void testTaskOnInsertHandler()
    {
        //Test.StartTest();
        // test Lead
        
       // Lead l = new Lead();
        
        
       // insert l;
        
        
        
        //Contact nc = new Contact();
        
    //insert nc;

        // test contact
          Task test = new Task();
    
          test.Type = 'Unqualified';
          test.Status = 'Completed';              
          test.WhoId = [select Id from Contact limit 1].Id; // to get an existing one.
          insert test;
            Map<ID,Task> contactmap = new Map<ID,Task>();
          contactmap.put(test.Id,test);
          
          ContactServices.taskOnInsertHandler(contactmap);
      
            // test lead
             Task test2 = new Task();

          test2.Type = 'Unqualified';
          test2.Status = 'Completed';              
          test2.WhoId = [select Id from Lead limit 1].Id; // to get an existing one.
          insert test2;
            Map<ID,Task> leadmap = new Map<ID,Task>();
          leadmap.put(test2.Id,test2);
      LeadServices.taskOnInsertHandler(leadmap);
     
        //Test.StopTest();
    }

}

 I'm probably missing something obvious, sorry. The referenced classes just push the "Type" field from a Task onto a "Task Type" field on the contact/lead. 

Hello,

 

I am new to Apex triggers and need help on creating one.  My organization has a custom object called product subscriptions.  I would like to run a trigger to checks if a field called quantity on my custom object is equal to 0.  If the quantity is equal to 0 I would like the trigger to delete that record.  Below is the trigger I have started(it may be completely wrong):

 

trigger DeleteZeroQtySubscriptions on Product_Subscription__c (after update, after insert) {
//This trigger deletes any product subscription that has a quantity of 0
//Created by Bennett 1082013

Product_Subscription__c[] toBeDeleted = new list<Product_Subscriptions__c>();

for (Product_Subscription__c sub : Trigger.Old)
{
if (sub.Quantity__c == '0')
{
toBeDeleted.add(sub);
}
}
delete toBeDeleted;
}

 

Also, how can I test this trigger?

 

Thanks,

So i have the attached trigger on my case object. When trying to do a mahor upload we received the following errror:

 

System.LimitException: Too many SOQL queries: 101 Trigger.pullSE: line 5, column 1".

 

From reading other post it seems that i have to take the select statement out of the for loop. But my issue is that when i try its not pulling the information as it was. I tried <list> and <map> functions and nothing works so i have put it back to normal and now the code works again. Can anyone help me figure the best approach to get rid of the error.

 

Code:

trigger pullSE on Case (before update, before insert) {
    for (case t: trigger.new) {
        try {
            if (t.SE__c == null) {
                t.SE__c = [select User__c from Site__c where Id = :t.Site__c].User__c; //t.Site__r.User__c;
            }
        }
        catch (Exception e) {
        }
    }
}

 

Thanks....

public with sharing class NewNAISearchController {
    public Comp__c compSearch {get;set;}
    public Comp__c compSearch2 {get;set;}
    public Comp__c compSearch3 {get;set;}
    public Comp__c compSearch4 {get;set;}
    
    //List of Comp
    private List <Comp__c> comps;
    public List <Comp__c> getComps() {
        List<Comp__c> listComps = (List<Comp__c>) setCon.getRecords();
        return listComps;
    }
    
    //Sort Expression
    private String sortExp = 'Name';
    public String sortExpression {
        get {
            return sortExp;
        }
        set {
            if (value == sortExp)
                sortDirection = (sortDirection == 'ASC') ? 'DESC' : 'ASC';
            else
                sortDirection = 'ASC';
            sortExp = value;
        }
    }
    
    //Sort Direction
    private String sortDirection = 'ASC';
    public String getSortDirection() {
        if (sortExpression == null || sortExpression == '')
            return 'ASC';
        else
            return sortDirection;
    }
    public void setSortDirection(String value) {
        sortDirection = value;
    }
    
    //Constructor
    public NewNAISearchController(ApexPages.StandardController controller) {
        compSearch = new Comp__c();
        compSearch2 = new Comp__c();
        compSearch3 = new Comp__c();
        compSearch4 = new Comp__c();
        whereClause();
    }
    
    //Standard set Controller
    public ApexPages.StandardSetController setCon {
        get{
            try {
                if(setCon == null) {
                    String qtQuery;
                    if(whereCondition != ''){
                        qtQuery = 'SELECT Name,Rethink2_Actual_Rate_type__c,Address__c,Average_Rental_Rate__c,Building_Class__c,Closed_Deal_Date__c,Comp_Type__c,Deal_type__c,Gross_SF__c,Zip_Code__c, SubMarket__c, Property_Type__c '
                                  +' FROM Comp__c WHERE '+ whereCondition
                                  +' ORDER BY ' + sortExpression + ' ' + sortDirection;
                    }else{
                        qtQuery = 'SELECT Name,Rethink2_Actual_Rate_type__c,Address__c,Average_Rental_Rate__c,Building_Class__c,Closed_Deal_Date__c,Comp_Type__c,Deal_type__c,Gross_SF__c,Zip_Code__c, SubMarket__c, Property_Type__c FROM Comp__c ORDER BY ' + sortExpression + ' ' + sortDirection;
                    }
                    system.debug('****'+qtQuery);
                    setCon = new ApexPages.StandardSetController(Database.Query(qtQuery));
                    setCon.setPageSize(20);   
                }
            }
            catch(Exception e) {
                Apexpages.addMessages(e);
            }
            return setCon;
        }set;
    }
    
    //Search Method
    public PageReference searchComp() {
        whereCondition = '';
        whereClause();
        setCon = null;
        return null;
    }
    

    //Method to call Next 
    public PageReference next() {
        if(setCon.getHasNext()){
            setCon.next();
        } 
        return null;
    }
    
    public Boolean hasNext {
        get {
            return setCon.getHasNext();
        }
    }
    
    //Method to call Previous 
    public Boolean hasPrevious {
        get {
            return setCon.getHasPrevious();
        }
        set;
    }
    
    public PageReference previous() {
        if(setCon.getHasPrevious()){
            setCon.previous();  
        }        
        return null;  
    }
    
    //Method to get where clause
    private string whereCondition = '';
    private Date sfClosedDate;
    private Date thruClosedDate;
    private void whereClause(){
        sfClosedDate = compSearch.Closed_Deal_Date__c;
        thruClosedDate = compSearch2.Closed_Deal_Date__c;
        if(compSearch.recordTypeId != null){
            whereCondition += ' recordTypeId =\'' + compSearch.recordTypeId +'\'';
        }
        if(compSearch.Property_Type__c != null){
            whereCondition += ' AND Property_Type__c =\'' + compSearch.Property_Type__c +'\'';
        }
        if(compSearch.Comp_Type__c != null){
            whereCondition += ' AND Comp_Type__c =\'' + compSearch.Comp_Type__c +'\'';
        }
        if(compSearch.Deal_type__c != null){
            whereCondition += ' AND Deal_type__c =\'' + compSearch.Deal_type__c +'\'';
        }
        if(compSearch.Building_Class__c != null){
            whereCondition += ' AND Building_Class__c =\'' + compSearch.Building_Class__c +'\'';
        }
        if(compSearch.Rethink2_Actual_Rate_type__c != null){
            whereCondition += ' AND Rethink2_Actual_Rate_type__c =\'' + compSearch.Rethink2_Actual_Rate_type__c +'\'';
        }
        if(compSearch.SubMarket__c != null || compSearch2.SubMarket__c != null || compSearch3.SubMarket__c != null || compSearch4.SubMarket__c != null){
            String subMarket = '';
            if(compSearch.SubMarket__c != null)
                subMarket += ' SubMarket__c =\'' + compSearch.SubMarket__c +'\'';
            if(compSearch2.SubMarket__c != null)
                subMarket += (subMarket == '' ? ' SubMarket__c =\'' + compSearch2.SubMarket__c +'\'' : ' OR SubMarket__c =\'' + compSearch2.SubMarket__c +'\'');
            if(compSearch3.SubMarket__c != null)
                subMarket += (subMarket == '' ? ' SubMarket__c =\'' + compSearch3.SubMarket__c +'\'' : ' OR SubMarket__c =\'' + compSearch3.SubMarket__c +'\'');
            if(compSearch4.SubMarket__c != null)
                subMarket += (subMarket == '' ? ' SubMarket__c =\'' + compSearch4.SubMarket__c +'\'' : ' OR SubMarket__c =\'' + compSearch4.SubMarket__c +'\'');    
            whereCondition += (subMarket == '' ? '' : ' AND (' + subMarket +')');
        }
        
        if(compSearch.Zip_Code__c != null || compSearch2.Zip_Code__c != null || compSearch3.Zip_Code__c != null || compSearch4.Zip_Code__c != null){
            String zipCode = '';
            if(compSearch.Zip_Code__c != null)
                zipCode += ' Zip_Code__c =' + compSearch.Zip_Code__c ;
            if(compSearch2.Zip_Code__c != null)
                zipCode += (zipCode == '' ? ' Zip_Code__c =' + compSearch2.Zip_Code__c  : ' OR Zip_Code__c =' + compSearch2.Zip_Code__c );
            if(compSearch3.Zip_Code__c != null)
                zipCode += (zipCode == '' ? ' Zip_Code__c =' + compSearch3.Zip_Code__c  : ' OR Zip_Code__c =' + compSearch3.Zip_Code__c );
            if(compSearch4.Zip_Code__c != null)
                zipCode += (zipCode == '' ? ' Zip_Code__c =' + compSearch4.Zip_Code__c  : ' OR Zip_Code__c =' + compSearch4.Zip_Code__c );  
            whereCondition += (zipCode == '' ? '' : ' AND (' + zipCode +')');
        }
        
        if(compSearch.Gross_SF__c != null && compSearch2.Gross_SF__c != null){
            whereCondition += ' AND ( Gross_SF__c >= '+ compSearch.Gross_SF__c +' AND Gross_SF__c <= '+compSearch2.Gross_SF__c +')';
        }else if(compSearch.Gross_SF__c != null || compSearch.Gross_SF__c != null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.severity.INFO, 'You must enter Gross between SF & Thru'));
        }
        
        if(sfClosedDate != null && thruClosedDate != null){
            whereCondition += ' AND ( Closed_Deal_Date__c >= : sfClosedDate AND Closed_Deal_Date__c <= : thruClosedDate)';
        }else if(sfClosedDate != null || thruClosedDate != null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.severity.INFO, 'You must enter Closed Deal Date between two Dates'));
        }
        
        if(compSearch.Address__c != null){
            whereCondition += ' AND Address__c =\'' + compSearch.Address__c +'\'';
        }
        
        if(compSearch.Average_Rental_Rate__c != null && compSearch2.Average_Rental_Rate__c != null){
            whereCondition += ' AND ( Average_Rental_Rate__c >= '+ compSearch.Average_Rental_Rate__c +' AND Average_Rental_Rate__c <= '+compSearch2.Average_Rental_Rate__c +')';
        }else if(compSearch.Average_Rental_Rate__c != null || compSearch2.Average_Rental_Rate__c != null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.severity.INFO, 'You must enter Min & Max Average Rental Rate'));
        }
    }
}

 HOw would i write a test class for this search controller? I am new to test classes... 

Hi Team,

 

when i click a custom button it will generates the PDF.

on the PDF I would like to generate page numbers.

I am putting below code

 

<head>
<style type="text/css">
@page
{

size:landscape;

@bottom-right {
content: "Page " counter(page);
}
}
</style>
</head>

 

But it is not showing numbers on pdf, please can any one suggest me how to display number on visualforce pdf.

 

Thanks

Hello All

I have a requirement of taking a csv and uploading records into a object, no validations required. Just parsing the csv and inserting records.
 Could anyone point me to any blog/website where I can find this stuff. Any help is appreciated.

Can I send a email at a particular time via apex. I know I can schedule a class to run at a given time, but can I send email at a particular time without using schedular class. Also without using external app

Have 7 years experience in IT, 4 years in salesforce. Willing to relocation anywhere in US. Email: testrest97@gmail.com

select id from account where name='123' or name='345' or name='456';

 

or

 

select id from account where name IN ('123','345','456');

 

Which one you all think is optimized more. Or both are same??

Hello All

I have a requirement of taking a csv and uploading records into a object, no validations required. Just parsing the csv and inserting records.
 Could anyone point me to any blog/website where I can find this stuff. Any help is appreciated.

Green Dot is looking for Salesforce Certified Developers in the Pasadena area to work on a large fast paced project ASAP.

 

Note, I am not a recruiter I am a hiring Director. If you think you are a fit, I would love to see your resume.

Hi ,

 

I have a requirement just to send an email notification every day to a particular user.I have implemented this using schedular apex class, but

 

I am not recievieng any emails at the scheduled time.Here is my code:

 

 

Global class Schedularclass implements Schedulable{
global void execute (SchedulableContext SC){
 {   
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
  mail.setTemplateId('00Xi0000000ViBZ'); //email template id
  String[]   toAddresses = new String[]{'mygmailid@gmail.com'}; 

mail.setToAddresses(toAddresses);
 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}

 

Please let me know if anyone has any idea on this.

 

Thanks

SN

  • November 22, 2013
  • Like
  • 0

Voucher is parent object and treasure_chest_application__c is my child object ,the issue is i could not able to cover the code for this in test class.......can please help to me  in writing test class for this............

 

for(Treasure_Chest_Application__c TCA :queryvouchers.Treasure_Chest_Applications__r){
if(TCA.Date_of_the_Event__c != null ){

if((date.today().month() - TCA.Date_of_the_Event__c.month() <= 1) && (date.today().year() == TCA.Date_of_the_Event__c.year())){

RelatedVoucher.add(queryvouchers);
}
}
}
}
for(Voucher__c CalVouchers : RelatedVoucher ){
TotalRaffles = 0 ;
TotalEvents = 0 ;
NumberEventsBenefiting = 0;

for(Treasure_Chest_Application__c TCA1 :CalVouchers.Treasure_Chest_Applications__r){
if(TCA1.Date_of_the_Event__c != null && TCA1.Amount_Raised_for_Voucher__c != null && TCA1.Amount_Raised_for_Event__c != null ){

if((date.today().month() - TCA1.Date_of_the_Event__c.month() <= 1) && (date.today().year() == TCA1.Date_of_the_Event__c.year())){


// NumberEventsBenefiting += Integer.valueOf(TCA1.get('expr0'));
NumberEventsBenefiting++;
TotalRaffles += Integer.valueOf(TCA1.Amount_Raised_for_Voucher__c);
TotalEvents += Integer.valueOf(TCA1.Amount_Raised_for_Event__c);
system.debug('&&&&&&&&&&&&&&&&&&&&&&&&&&&'+ TotalRaffles);
}
}
}
}

Hi everyone

 

My first trigger in salesforce, is working in sandbox but I'm having a problem with the coverage.

 

I was already reading about it and couldn't find a solution, can anyone help?

 

I'm a new at salesforce so any help will be more than welcome.

 

The code is:

 

trigger AccountTrigger on Account (before insert) {
    
    List<Account> lst_in = trigger.new;
      for(Account acc:lst_in){
      
         
         acc.ShippingCity = acc.BillingCity;
         acc.PersonMailingCity = acc.BillingCity;
         acc.PersonOtherCity = acc.BillingCity;
    
         acc.ShippingStreet = acc.BillingStreet;
         acc.PersonMailingStreet = acc.BillingStreet;
         acc.PersonOtherStreet = acc.BillingStreet;
   
         acc.ShippingState = acc.BillingStreet;
         acc.PersonMailingState = acc.BillingState;
         acc.PersonOtherState = acc.BillingState;
       
         acc.ShippingPostalcode = acc.BillingPostalcode;
         acc.PersonMailingPostalcode = acc.BillingPostalcode;
         acc.PersonOtherPostalcode = acc.BillingPostalcode;
 
         acc.ShippingCountry = acc.BillingCountry;
         acc.PersonMailingCountry = acc.BillingCountry;
         acc.PersonOtherCountry = acc.BillingCountry;
    
   }
}

 

The errors are:

 

AccountTrigger

      Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required Deploy Error      

      Average test coverage across all Apex Classes and Triggers is 66%, at least 75% test coverage is required.

 

I can understand that I will have to tweak the code to have more than the minimum expected, but how?

 

Thank you

  • November 20, 2013
  • Like
  • 0

I found this on a blog that used it for Opportunities,  I massaged it to use in Cases, but I cannot get it to pop up the message.

<apex:page standardController="Case" rendered="{!Case.Impact__c = 'Site Production Down'}">

<script type="text/javascript">
{
    window.alert{"This is an alert");
}

</script>

</apex:page>

 I added the VF Page to my page layout, created a case to meet the criteria and saved the case, no pop up.  Am I missing something?

  • November 20, 2013
  • Like
  • 0

Hi,

 

I am trying to create Workflow rule where Target Date greater than Today()

 

but it is giving me an error  Error: Invalid date (Valid date format 11/14/2013)

 

Target Date is the field with Date Type.

 

Can anyone tell me how to resolve this error

 

 

I want to know how to write test classes to execute  the trigger code coverage? how should we write on what basis? for the trigger i have writtened some test classes but it wasnt giving code coverage for me. I almost executed all lines in trigger. where i am behind?

 

 

trigger createTaskForEmail on Task (before insert) {
   for (Task t : trigger.new) {
               if (t.status == 'Completed' && t.subject.startswith('Email:')) {
                          t.status = 'Completed';
                          t.description = t.description.substringAfter('Body:');
                          t.Activity_Direction__c = 'Email';
                          t.Activity_type__c='Email';
                }
     }
}

 

 

 

For this trigger I have writtened Test class some thing like below which gives code coverage up to 33 % only? what else i have left?

 

@isTest(SeeAllData = false)
private class Test_createTaskForEmail
{
static testMethod void UnitTestForException1()
{

  
Task ta = new task(Activity_type__c='Email'  , Activity_Direction__c='Email',status = 'completed');
insert ta ;
update ta ;

}
}

 

 

Like that i have other trigger i.e

 

trigger UpdateEventRating on Event (before insert, before update) {
for(Event E : Trigger.new){
if(E.Rating__c=='-Excellent Meeting (committed to business within 3 weeks)'){
E.Rating_Value__c=5;
}
else
if(E.Rating__c=='-Good Meeting (Resulted in client meeting agreed to/set or booked a seminar)'){
E.Rating_Value__c=4;
}
else
if(E.Rating__c=='-Productive Meeting (Client specific illustration requested or next meeting scheduled)'){
E.Rating_Value__c=3;
}
else
if(E.Rating__c=='-Average Meeting (Agreed to continued discussions, no client specific activity)'){
E.Rating_Value__c=2;
}
else
if(E.Rating__c=='-Poor Meeting (No potential for future business, no further activity needed)'){
E.Rating_Value__c=1;
}
}
}

 

 

Test Class For this trigger is this gives 53% code coverage only

 

@isTest(SeeAllData = false)

private class Test_UpdateEventRating 
{
static testMethod void UnitTestForException()
{
test.startTest();
Event e = new Event(ActivityDate = system.today(), ActivityDateTime = system.now(), DurationInMinutes = 2);
insert e ;
update e ;
test.stopTest();
}
}

 

  • November 14, 2013
  • Like
  • 0

Hi,

I want to implement a tree structure in visualforce page some thing like the structure from this link http://ludo.cubicphuse.nl/jquery-treetable/

 

Is it possible to implement like above.If yes can any one please provide any simple example to implement this.

Thanks in Advance.

 

 

Raj.

  • November 08, 2013
  • Like
  • 0

In my Contact object, I have a lookup field to the User table.  Every user has a corresponding contact record.

I have a trigger, that pulls in the Contact ID of the current User and passes that information to the Case Contact field.

 

The trigger works, as I'm able to create cases with this information being populated correctly.  I'm having problems figuring out how to write the test code as the system user wouldn't have a contact or user to match up against.

    sObject s = [SELECT ID FROM CONTACT WHERE user__c =: Userinfo.getUserId()];
    ID myid = s.id;

 

            if((caseObj.Type == 'Drupal Site Launch' || caseObj.Type == 'Classic Site Launch') && caseObj.ParentId == NULL){
                Case JDLaunchCase = new Case();
                JDLaunchCase.Subject = caseObj.Subject + ' JD Launch Work';
                JDLaunchCase.RecordTypeId = '012A000000177IL';
                JDLaunchCase.ParentId = caseObj.ID;
                JDLaunchCase.Type = caseObj.Type;
                JDLaunchCase.Request_Type__c = 'Request New Development';
                JDLaunchCase.Requested_Deliver_Date__c = caseObj.Estimated_Launch_Date__c;
                JDLaunchCase.ContactId = myid;
                relatedCases.add(JDLaunchCase);

 

Hi Team,

 

We need some technical help with addressing GEOLOCATION and distance based SOQL queries in one of our app. Currently the response is delayed for users. We are trying to explore our options to enhance the user experience.

 

Below is SOQL query in @RemoteAction Method in Controller Class, it is taking longer time to fetch the Accounts in full copy sandbox.

 

string q='SELECT BillingCountry,BillingCity,BillingStreet,Latitude__c, Longitude__c, Geolocation__latitude__s,Geolocation__longitude__s,BillingPostalCode,BillingState,'+valueField+','+EmployeeField+','+NameField+' FROM '+sObjVal+' WHERE '+NameField+' LIKE \'%'+param+'%\' AND geolocation__longitude__s!=null ';
             q+='AND DISTANCE(Geolocation__c,GEOLOCATION('+lat+','+longt+'),\'mi\')<50 ORDER BY DISTANCE(Geolocation__c,GEOLOCATION('+lat+','+longt+'),\'mi\') LIMIT 50'; 
             

 

Geolocation__c : This field stores the latitude and longitude of an account

Lat, longt: This variables store the latitude and longitude of current location.

 

Please let us know if we have any better approach to get Distance based search results.

 

Thanks,

Anil

Hi,

 How to auto enable a field as required based on other fields input data in visual force

Can anyone please help.Its urgent.

 

Thanks in advance.

 

 

What are the diferences between <Apex:ActionFunction> and Java Script Remoting....?

 

Hiya,

I have a question on Batch jobs.

 

Currently I was calling a Batch Job from Finish Method and I see the execution started immediately as soon as the first job finishes. And it took almost 4 to 5 minutes to start showing the SerialBatchApexRangeChunkHandler. Will it take that amount of time to process the second Batch or Will the Batch run Asynchronously!! Am I missing something? Please clarify.

 

To Understand more of what I am saying, see the time it shows when the batch executes. I profiled them from developer console.

 

10/25/2013 2:13:57AM Batch Apex
10/25/2013 2:14:05AM SerialBatchApexRangeChunkHandler
10/25/2013 2:14:05AM SerialBatchApexRangeChunkHandler
10/25/2013 2:14:13AM SerialBatchApexRangeChunkHandler
10/25/2013 2:14:16AM SerialBatchApexRangeChunkHandler
10/25/2013 2:14:21AM Batch Apex
10/25/2013 2:14:21AM Batch Apex
10/25/2013 2:19:03AM SerialBatchApexRangeChunkHandler
10/25/2013 2:19:03AM SerialBatchApexRangeChunkHandler
10/25/2013 2:19:05AM SerialBatchApexRangeChunkHandler
10/25/2013 2:19:07AM Batch Apex

 

It started at 2.14 and i took almost 5 min to show the next execution.

Did anybody faced this. Please post ur Ideas and Suggestions on how to make the batch execution in less time.

 

Thanks,

Raj.

 

 

  • October 25, 2013
  • Like
  • 0

I've created a simple trigger that will fire whenever a new case is created.  The trigger intent is to send case data to a custom object "Tickets".


I'm receiving an error on 5 - Unexpected Token: 'for'

 

Any ideas with what I'm doing wrong?

 

Thanks,

Greg

 

trigger createTicket on Case (after insert) {

    List <Ticket__c> tikToInsert = new List <Ticket__c> 
	
        for (Case c:Trigger.new) {
			//check if Case that is being inserted meets the criteria
            
		if (c.Type = "RMA") {  
            
            Ticket__c t = new Ticket__c (); 
            
           
            
            t.SAP_Return_Order__c = c.SAP_Return_Order__c; // map case fields to new ticket object that is being created with this case
            t.Subject__c = c.Subject; 
            
           	tikToInsert.add(t);
		
		
		}
		
	}
}

 

  • October 25, 2013
  • Like
  • 0

Attempt to de-reference a null object why this err coming.how to resolve this here below my class and VF page code....

please someone help me...

 

controller:

 

public PageReference Save()
{
List<level1s__c> selectLevel1 = new List<level1s__c>();
//this.stdController.save();

/////////// LEVEL1 ///////////////////
List<level1s__c> selectedLevel1 = new List<level1s__c>();

for(Level1sClass cCon: getList1Details() )
{
system.debug('cCon'+cCon.selected);
if(cCon.selected == true)
{
system.debug('firstCCCCCCCCCC:'+cCon.lev1);
selectedLevel1.add(cCon.lev1);
}
}

Level1__c[] levl1= [Select Id from Level1__c where Account__c=: ApexPages.currentPage().getParameters().get('id')];
delete levl1;
if(selectedLevel1 != null)
{
for(level1s__c con : selectedLevel1)
{
system.debug('CCCCCCCCCC:'+con+'\n');
string acctid =ApexPages.currentPage().getParameters().get('id');
List<Level1__c> lvl1obj= new Level1__c[0];
lvl1obj.add(new Level1__c(Name='Level1',Account__c=acctid,cLevel1__c=con.id));
insert lvl1obj;

}
}
///////////////// LEVEL2 //////////////////////
List<level2s__c> selectedLevel2 = new List<level2s__c>();

for(Level2sClass cCon: getList2Details() )
{
system.debug('cCon'+cCon.selected);
if(cCon.selected == true)
{
system.debug('firstCCCCCCCCCC:'+cCon.lev2);
selectedLevel2.add(cCon.lev2);
}
}

Level2__c[] levl2= [Select Id from Level2__c where Account__c=: ApexPages.currentPage().getParameters().get('id')];
delete levl1;
if(selectedLevel2 != null)
{
for(level2s__c con : selectedLevel2)
{
system.debug('CCCCCCCCCC:'+con+'\n');
string acctid =ApexPages.currentPage().getParameters().get('id');
List<Level2__c> lvl2obj= new Level2__c[0];
lvl2obj.add(new Level2__c(Name='Level2',Account__c=acctid,cLevel2__c=con.id));
insert lvl2obj;

}
}

return null;

}

 

 

VF Page:

<body id="classbody">
<apex:form id="form1">
<div class="main_wrapper">
<div class="container-fluid" >
<div class="row-fluid">
<div class="main">
<apex:inputHidden value="{!SearchText}" id="searchTextbox"/>

<div style="background:#fff; margin-left:13px; margin-right:15px; color:#FFF; border-bottom:2px solid #fff;">
<div style="padding-left:40px; padding-bottom:0px;background-image:url('/resource/1382341187000/gradient');"><br/>
<h2 style="color:#333;font-size:18px;">Landscape Details</h2>
<div align="right" style="margin-right:10px;">
<!-- <input type="button" id="btnsave" value="Save" onclick="clntsave();" style="border:0px solid #333; background:#6fb3e0;width:82px; padding:4px; color:#FFF; font-weight:600;border-radius:8px; " />
<input type="button" value="Back To Account" onclick="backtoAccount()" style="border:0px solid #333; background:#6fb3e0;width:142px; padding:4px; color:#FFF; font-weight:600;border-radius:8px; "/> -->
<apex:commandButton action="{!Save}" onclick="clntsave();" style="border:0px solid #333; background:#6fb3e0;width:100px; padding:8px; color:#FFF; font-weight:600;border-radius:16px; " value=" Save "/>
<apex:commandButton onclick="backtoAccount()" style="border:0px solid #333; background:#6fb3e0;width:100px; padding:8px; color:#FFF; font-weight:600;border-radius:16px; " value=" Back To Account"/>
<div style="display:none;" class="msg" id="savemsg">
<br/><b>processing.... </b>
</div>
</div>

can delete records in trigger by using delete statements ?

 

if possible what are the possible trigger events ?

 

if not possible , what is the reason behind that ?   ple tell me this is one of the interview question to me .   

 

 

thank u

Hi experts,

 

Please can anyone tell me how to send emails through batchapex . please write code by taking one example and sechudling that mails also please .