• Rahul Kumar 151
  • NEWBIE
  • 160 Points
  • Member since 2016
  • Salesforce Developer
  • SaasFocus


  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 12
    Replies
Hey Guys,

i need to complete this trigger. It works like it is.. the problem is, everytime when i update the account, the trigger creates a new Case  ( i am not a Coder but i understand why ^^) The Trigger is simple and i hope you can see what i want. I want the trigger to stop if the last (newest) case is in progress (status = in progress). So the trigger should only fire when there is no Case in progress. How can i fix this ? I want to learn apex and i understand why the trigger is still running but i dont know how to fix it. Thanks for your help guys :)



User-added image


 
Case escalation checkbox revert back to false when user is changed.can anyone help me out why this things happened.In my org. no escalation rule defined.


 
Try to create report and ocurring error -Error: This Report Unique Name already exists or has been previously used. Please choose a different name.
actully i delete a report with same name and create a new report ' Opp Stage by Adventure ' for trailhead superbadge .
please help me.
Thank you
I have Created a lightning application , we don't have provision for lightning application Tab in both lightning and classic view so how can i make this app in use ....................
I have Created a lightning application , we don't have provision for lightning application Tab in both lightning and classic view so how can i make this app in use ....................
Try to create report and ocurring error -Error: This Report Unique Name already exists or has been previously used. Please choose a different name.
actully i delete a report with same name and create a new report ' Opp Stage by Adventure ' for trailhead superbadge .
please help me.
Thank you
Can any one help me in wriiting test class for below code?


public class picklistinVfCont 
{
public String state { get; set; }
public String city { get; set; }
    
    public List<SelectOption> getStates() {
        List<SelectOption> stOptions = new List<SelectOption>();
        stOptions.add(new SelectOption('None','--None--'));
        stOptions.add(new SelectOption('AP','Andhra Pradesh'));
        stOptions.add(new SelectOption('TN','Tamil Nadu'));
        stOptions.add(new SelectOption('KA','Karnataka'));
        return stOptions;
    }

    public List<SelectOption> getCities() {
        List<SelectOption> ciOptions = new List<SelectOption>();
        if(state=='AP'){
            ciOptions.add(new SelectOption('VSKP','Vishakapatnam'));
            ciOptions.add(new SelectOption('BZA','Vijayawada'));
            ciOptions.add(new SelectOption('TPTY','Tirupati'));
        }
        else if(state=='TN'){
            ciOptions.add(new SelectOption('CHE','Chennai'));
            ciOptions.add(new SelectOption('CBE','Coimbatore'));
        }
        else if(state=='KA'){
            ciOptions.add(new SelectOption('SBC','Bangalore'));
            ciOptions.add(new SelectOption('MAQ','Mangalore'));
        }
        else if(state=='None'){
            ciOptions.add(new SelectOption('None','--None--'));
        }
        return ciOptions;
    }
}



================================================================================

<apex:page controller="picklistinVfCont">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:outputLabel >State</apex:outputLabel>
                <apex:pageblockSectionItem >                
                    <apex:selectList size="1" value="{!state}">
                        <apex:selectOptions value="{!states}"/>
                            <apex:actionSupport event="onchange" reRender="a"/>
                    </apex:selectList>                
                </apex:pageblockSectionItem>
                
                <!--CITY--->
            <apex:outputLabel value="City"/>       
            <apex:pageblockSectionItem >
                <apex:selectList size="1" value="{!city}" id="a">
                    <apex:selectOptions value="{!cities}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>      
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>





 
Hi All,

I am new Salesforce Lightning experience. I am trying to call an external JavaScript by loading it as a Static resource and calling it in my Lightning application using the following syntax but I am unable to get it work.

<aura:application >
       <ltng:require scripts="{!$Resource.SDFCTestJS}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
</aura:application>

Please suggest how can I get it work.

P.S : I read a solution that we can load Javascript by creating a Helper class and call it from our Component. Can anyone suggest a way so that I don't need to create helper everytime I call a component as I am going to have many; a way that I can include the JS directly from the above.

Thanks in advance.

Warm Regards,
Shubham
SFDC
 
I have Created a lightning application , we don't have provision for lightning application Tab in both lightning and classic view so how can i make this app in use ....................
I have the following code: 
Account master = new Account(Name='Account1')
insert master;

But this is for inserting a new account. How can I get an existing account with the same structure?
Something like: 
Account acc = account(Where name = :myVariable);
Hi All,

I have written one Apex controller in that i wrote logic for delete and update. Problem here is am unable to delete records.
public class logView3Controller {

   
    public Boolean searched { get; set; }
   
    public List<Weeks__c> weekList = Weeks__c.getAll().values();
    public Map<Integer, Weeks__c> weekMap = new Map<Integer, Weeks__c>();
    public Map<String, Integer> weekMapGetIntWithWeek = new Map<String, Integer>();    
    public Map<String, Subjects_and_Levels__c> subjectLevelMap =  Subjects_and_Levels__c.getAll();
    public List<Subjects_and_Levels__c> subjectLevelList = subjectLevelMap.values();
    public Map<String, Subjects_and_Levels__c> levelMap = new Map<String, Subjects_and_Levels__c>();
       
    public Date StartDate {get;set;}
    public Date EndDate {get;set;}
    public String selectedLocation {get;set;}
    public String selectedDay {get;set;}
    public List<Log_Book__c> logBookEntries {get;set;}
    public List<studentsWithWeeks> studentsWithWeeksList {get;set;} 
    public studentsWithWeeks newSWW {get;set;}
    public String domain {get;set;}
    public List<integer> indexNums {get;set;}
    public List<String> weekTableHeader {get;set;}
    public List<String> subjectTableHeader {get;set;}
    
    public  List<Log_Book__c> relatedLogs{get;set;}
    
    //Jagadeesh
    public String selectedTeacher{get;set;}
    public String selectedDays{get;set;}
    
 
    public Id recordToUpdateId {get;set;} 
    public Id recordToUpdateIdStudent {get;set;} 
    
    
    public log_Book__c logObj {get;set;}
    public Student__c studentObj {get;set;}
    public boolean displayPopup {get; set;}
    public boolean displayPopupStudent {get; set;}
    public String exportToExcelURL {get;set;}
    public log_Book__c newLevel{get;set;}
    public log_Book__c newWeek{get;set;}
    List<Log_Book__c> lbjump{get;set;}
    // 2.  a,b,c,d - a,j,k,l,m - changing the complete series
    // Written by Jagadeesh(New code for skip records) 
    public List<Log_Book__c> jump{get;set;}
    public Log_Book__c jump1{get;set;}
    public List<Log_Book__c> lblist{get;set;}
    
     List<Log_Book__c> updateLogs = new List<Log_Book__c>();
     
     
      public logView3Controller () 
      {    
        domain = ApexPages.currentPage().getHeaders().get('Host'); 
        //exportToExcelURL = '/apex/logView3ExportToExcel?startDate='+startDate+'&endDate='+endDate+'&selectedLocation='+selectedLocation;
        exportToExcelURL = '/apex/logView3ExportToExcel?startDate='+startDate+'&endDate='+endDate+'&selectedLocation='+selectedLocation+'&selectedTeacher='+selectedTeacher;
        weekTableHeader = new List<String>();
        relatedLogs = new List<Log_book__c>();
        searched = false;
        
      
     }
      public String getEnglishColor() {
        return Colr;
      }
   
    public PageReference doUpdateLogObj2()
    {  
      
        String lv =  logObj.Week__c.split('-')[0];
       if(logObj.Subject__c == 'Math' && logObj.Level__c == 'Level 5B' && Integer.valueOf(lv) > 17){
           
          logObj.Week__c.addError('For Math Level 5B week should not exceed 17');
            return null;
        }
        system.debug('hii');
      
        relatedLogs = [SELECT Id, Name, Color_Code__c, Comment_on_LogBook__c, Student__c, Student__r.Id, Student__r.Name, Student__r.Last_Name__c, Subject__c, Level__c, Week__c, Week_Day__c, Class_Scheduled_Date__c, Student__r.Location__r.Name FROM Log_Book__c WHERE Student__r.Id =: logObj.Student__r.Id AND Subject__c =: logObj.Subject__c AND Class_Scheduled_Date__c >=: logObj.Class_Scheduled_Date__c and isSkipped__c=false];
        System.debug(' relatedLogs.Size()'+ relatedLogs.Size());
       
        Log_Book__c lb = new Log_Book__c();
        
        Integer levelOrder = Integer.valueof(subjectLevelMap.get(logObj.Subject__c +':'+logObj.Level__c).Order__c);
        Integer weekOrder;
            System.Debug('levelOrder :' + levelOrder);
            System.Debug('weekList :' + weekList);
            for(Weeks__c week : weekList)
            {
                weekMap.put((Integer)week.Order__c, week);
                weekMapGetIntWithWeek.put(week.Name, (Integer)week.Order__c);
            }
            System.Debug('weekMap :' + weekMap);
            System.Debug('weekMapGetIntWithWeek :'+ weekMapGetIntWithWeek);
            for(Subjects_and_Levels__c level: subjectLevelList)
            {
                levelMap.put(level.subject__c+Integer.valueof(level.Order__c), level);
            }
            System.Debug('levelMap :' + levelMap);
          Integer totalLevels = 0;
          if(logObj.Subject__c == 'English')
            totalLevels = 16;
          else if(logObj.Subject__c == 'Abacus')
            totalLevels = 11;
          else if(logObj.Subject__c == 'Math')
            totalLevels = 14;
          else if(logObj.Subject__c == 'G.K')
            totalLevels = 3;
         
        System.Debug('Total Logs :'+ relatedLogs.Size());
        lb = logObj.clone(false, true, false, false);
        updateLogs.add(lb);
        
        for(Integer i=1; i<relatedLogs.Size(); i++)
        {
                lb = new Log_Book__c();
                
                System.Debug('lblblblblblblb :' + lb);
                
                lb = updateLogs[i-1].clone(false, true, false, false);
                weekOrder = Integer.ValueOf(weekMapGetIntWithWeek.get(lb.Week__c));
                System.Debug('weekOrder : ' + weekOrder);                
                lb.Class_Scheduled_Date__c = lb.Class_Scheduled_Date__c.addDays(7);
                
                System.Debug('weekMapGetIntWithWeek.get(lb.Week__c) :'+ weekMapGetIntWithWeek.get(lb.Week__c));
                System.Debug('weekMapGetIntWithWeek.get(lb.Week__c)+i :'+ Integer.ValueOf(weekMapGetIntWithWeek.get(lb.Week__c))+i);
                if( weekOrder < 26 )
                {
                weekOrder = weekOrder+1;
                lb.Week__c = weekMap.get(weekOrder).Name;
                System.Debug('@@@@@@ lb.Week__c = ' + lb.Week__c);
                }
                else
                {
                  if(lb.week__c == '26-Z')
                  {
                    if(levelOrder < totalLevels)
                    {
                        levelOrder = levelOrder +1;
                        System.Debug('lb.Subject__c+levelOrder : '+ lb.Subject__c+levelOrder);
                        lb.level__c = levelMap.get(lb.Subject__c+levelOrder).Level__c;
                        lb.Week__c = '1-A';
                    
                    }
                  
                  }
                    else
                    if(lb.Subject__c == 'Math' && lb.Level__c == 'Level 5B' && lb.Week__c == '17-Q')
                    {
                        if(levelOrder != null && levelOrder < totalLevels){
                        
                            levelOrder = levelOrder +1;
                        
                         lb.level__c = levelMap.get(lb.Subject__c+levelOrder).Level__c;
                         lb.Week__c = '1-A';
                           
                        
                        
                        }
                    }
                    
                    else
                    {
                    i = relatedLogs.Size();
                    
                    }
                }
           
                 System.Debug('lblblblblblblb :' + lb);
                
                        
                updateLogs.add(lb);
                System.Debug('updateLogs : '+ updateLogs);        
        }
        
         delete relatedLogs;
         update updateLogs;
      
           
         //insertLogs();
              
        System.debug('@@@@@updated logs@@@'+updateLogs.size()+'----------->'+updateLogs[0]);
        
        displayPopup = false;
      
       return null;      
    }
}

Thanks,
A.Jagadeesh
Hi,
I am new to sales force development. I have question on the SOQL query and using it in the list. If it has the child reference need to check to make some actions.it is throwing the error "Invalid field Asset_Options__r for Customer_Asset__c". I am sending herewith the code snippet. Any pointers in this regards is highly appreciated.

Regards,
Ravi

code snippet
==========
1) The SOQL query is something like this [ soql = select Id, Last_Maintenance_Date__c, (select Id, Value__c from Asset_Options__r where (Name = 'SOMETST')) from Customer_Asset__c  limit 1]
  
2) Building the list
    list<Customer_Asset__c> asset = database.query(soql);      

3) Action for the child objects
   for(sobject ca : asset) {
     ...
    ....
    sobject ao;
    system.debug(ca.get('Asset_Options__r'));
 //   ao = ca.get('Asset_Options__r');
 //   if(ao != null) {
//      ... do something
//    } else {  -- do something..
//   }
  ...
  ...
   }
 
Hey Guys,

i need to complete this trigger. It works like it is.. the problem is, everytime when i update the account, the trigger creates a new Case  ( i am not a Coder but i understand why ^^) The Trigger is simple and i hope you can see what i want. I want the trigger to stop if the last (newest) case is in progress (status = in progress). So the trigger should only fire when there is no Case in progress. How can i fix this ? I want to learn apex and i understand why the trigger is still running but i dont know how to fix it. Thanks for your help guys :)



User-added image


 
 public List<String> kamNa {
        get {
            if (kamNames == null) {                
                kamNames = new List<String>();
                Schema.DescribeFieldResult field1 = Brokerage__c.Control__c.getDescribe();                
                for (Schema.PicklistEntry f : field.getPicklistValues())
                    kamNa.add(f.getLabel());               
            }
            return kamNa;          
        }
        set;
    }