• Alisha Mehta 9
  • NEWBIE
  • 114 Points
  • Member since 2016

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 13
    Replies
Hi All 

I have a batch class as follows 
 
Integer FiscalYear = getCurrentFY();
    Integer FYPlusOne = FiscalYear - 1;

    global database.querylocator start(Database.BatchableContext BC){   
        Integer lmt = Limits.getLimitQueryRows();
        String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';     
        query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
        query += ' FROM Account_Org_Relationship__c';
        query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National';

I need to add a condition to the query like Inte__key__c like 'FYPlusOne%' 

Intekey field value will be in the format of 2017|39238shdshdhkjsoskok. I have to fetch the records of the previous fiscal year so the inteley should contain 2017(Currentfiscalyear - 1) 

Please help me how to achieve this in where condition. I have a declared a variable on top 

Thanks 
Sangeetha T

Hi People,
I am writing a simple code to refrain the user from deleting a record if it's active but getting the below error:

 Error: There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Cannot Delete".

Here is my code:
trigger DontDeleteIfActive on Position__c (before delete) {

if(trigger.isdelete)
{
for (Position__c pos : trigger.old)

{   

    if(pos.Active__c != null || pos.Active__c == True)
        pos.addError('Cannot Delete');
    
}
}

}
 

AggregateResult[] groupedResults = [SELECT AVG(Amount)aver FROM Opportunity]; Object avgAmount = groupedResults[0].get('aver');
in this code why aver from groupedResult is not accessed directly as
avgAmount = groupedResult.get('aver');

and what is the purpose of casting aggregateresult values.
Hi, 

Following error is coming when JS function performing some calculations. 
User-added image


and I have following JS code 
User-added image

Where the value of unitprice is coming as undefined which nothing but a currency type of field. 

can anyone please help me out with this. ? 

Thanks & Regards,
Ashvin
Hi,
While saving the below code, Following Error Occurs: "Variable does not exist: DeveloperName"
 
List<Dashboard> listAllDashboards = [SELECT DeveloperName,Type,FolderName,Folder.DeveoperName FROM Dashboard];
for(Dashboard d1 : listAllDashboards){
 System.debug(d1.Folder.DeveloperName);
}

 
Hi all,

I am trying to save controller.js file,then i am getting the following error.Can any one help me to solve this.User-added image
Any valuble suggestions.
Why I am getting this error--
"Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account."
my code--

public class AccountHandler {

     public static Account insertNewAccount(String name){
        
          Account a = new Account();
          a.Name = 'name';
        
        try{
            insert a;
        }
        catch(Exception e){
            return null;
        }    
       return a;
    }
}
<apex:page standardController="Business_Contract_to_Account__c"  standardStylesheets="false"> 
<apex:sectionHeader title="Account Hierarchy" subtitle="{!Business_Contract_to_Account__c.Name}"/> 
        <!--<c:HierarchyTreeDragAndDrop currentRecId="{!Account.id}" sObjectTypeName="Account" sObjectFieldsAPINames="Type,Industry" parentIdFieldAPI="parentId" numOfLevels="5"/>
        --->     "{!Business_Contract_to_Account__c.AccountId__c}"
            <apex:pageBlock >
       <c:HeirarchyJBTreeV2 currentRecId="{!Business_Contract_to_Account__c.Customer__c}" sObjectTypeName="Business_Contract_to_Account__c" sObjectFieldsAPINames="Customer__r.AccountNumber,Customer__r.SAP_Partner_Functions__c,Customer__r.Store_Number__c,Customer__r.State_City_Country__c,Customer__r.Customer_Reporting_Group__c,Customer__r.Customer_Facing_Parent_Type__c" parentIdFieldAPI="Customer_Facing_Parent__c" displayListSize="700" numOfLevels="5"/> 
        </apex:pageBlock>
</apex:page>

and the component line is

<apex:attribute name="currentRecId" description="This is the Record Id for displaying Hierarchy" type="String" required="true" assignTo="{!currentId}"/>
Error in Data Import Wizard Trailhead Challenge
trigger validationPrimarycontact1 on Contact (after insert,after update) {
List<Contact> acclist = new List<Contact>();
set<Id> accIdSet = new set<Id>();
Set<Id> ContactIds = new Set<Id>();
if(Trigger.IsUpdate){
for ( Contact s : trigger.new ){
        if(s.AccountId != null)
        accIdSet.add(s.AccountId);   
        Contact oldcon = Trigger.oldMap.get(s.Id);       
        if(oldcon.id != null)
        ContactIds.add(oldcon.id);
       
                                }

acclist=[select id, name,Account.name,Primary_Contact__c from Contact where AccountId IN : accIdSet AND Id NOT IN : ContactIds];

system.debug('*******Runish'+acclist);

List<Contact> conlist=new List<Contact>();
Contact c1=new Contact();
 if(checkRecursive.runOnce()){
        for ( Contact s : Trigger.new)

             {         
            if(s.Primary_Contact__c ==true)
                {
                  for(Contact a :acclist)
                      {
                         a.Primary_Contact__c =false;
                         c1=a;            
                      }
          
                    update c1; 
                }  
              }
           update acclist;
                       }
     }
        if(Trigger.isInsert){
                for ( Contact s : trigger.new ){
                        if(s.AccountId != null)
                        accIdSet.add(s.AccountId);   
                        Contact oldcon = Trigger.newMap.get(s.Id);       
                        if(oldcon.id != null)
                        ContactIds.add(oldcon.id);
       
                                                }

acclist=[select id, name,Account.name,Primary_Contact__c from Contact where AccountId IN : accIdSet AND Id NOT IN : ContactIds];

system.debug('*******Runish'+acclist);

List<Contact> conlist=new List<Contact>();
Contact c1=new Contact();

 if(checkRecursive.runOnce()){
for ( Contact s : Trigger.new)
         {      
            if(s.Primary_Contact__c ==true)
                {
                  for(Contact a :acclist)
                          {
                             a.Primary_Contact__c =false;
                              c1=a;            
                          }
                     update c1; 
        
        }  
        
       }
       update acclist;
       }
        
        }
         }


I am getting error that "Variable does not exist: checkRecursive",how to fix
Hi All 

I have a batch class as follows 
 
Integer FiscalYear = getCurrentFY();
    Integer FYPlusOne = FiscalYear - 1;

    global database.querylocator start(Database.BatchableContext BC){   
        Integer lmt = Limits.getLimitQueryRows();
        String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';     
        query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
        query += ' FROM Account_Org_Relationship__c';
        query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National';

I need to add a condition to the query like Inte__key__c like 'FYPlusOne%' 

Intekey field value will be in the format of 2017|39238shdshdhkjsoskok. I have to fetch the records of the previous fiscal year so the inteley should contain 2017(Currentfiscalyear - 1) 

Please help me how to achieve this in where condition. I have a declared a variable on top 

Thanks 
Sangeetha T
Controller class.

 public class SetVFPage {
   public Set<Group__c>acc { get; set; }
     public string keyword{get;set;}
     List<Group__c > accList{get;set;}
      Set<Group__c > accSET = new Set<Group__c >();                
     public pagereference Search(){    
       accList =[SELECT Name, id,Course_Name__c FROM Group__c where Name Like: '%'+keyword+'%'];
       for(Group_c gp : accList){
       gp.name;
       }         
           return null;
     }
}

VF Page
<apex:page controller="SetVFPage ">
    <apex:form >
        <apex:pageBlock >
            <!--<apex:inputField value="{!keyword}"/>-->
            <apex:commandButton value="Search" action="{!Search}" />
            <apex:pageBlockTable value="{!acc}" var="s">
                <apex:column value="{!s.name}"/>
                <apex:column value="{!s.Course_Name__c} "/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Error: Task08 Compile Error: Invalid type: Group_c at line 12 column 12
Request your comments for solution.
Thanks

Hi People,
I am writing a simple code to refrain the user from deleting a record if it's active but getting the below error:

 Error: There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Cannot Delete".

Here is my code:
trigger DontDeleteIfActive on Position__c (before delete) {

if(trigger.isdelete)
{
for (Position__c pos : trigger.old)

{   

    if(pos.Active__c != null || pos.Active__c == True)
        pos.addError('Cannot Delete');
    
}
}

}
 

Can anyone please tell me that how can we display a visualforce page on clicking a button that is on accounts object's detail page?
AggregateResult[] groupedResults = [SELECT AVG(Amount)aver FROM Opportunity]; Object avgAmount = groupedResults[0].get('aver');
in this code why aver from groupedResult is not accessed directly as
avgAmount = groupedResult.get('aver');

and what is the purpose of casting aggregateresult values.
Hi, 

Following error is coming when JS function performing some calculations. 
User-added image


and I have following JS code 
User-added image

Where the value of unitprice is coming as undefined which nothing but a currency type of field. 

can anyone please help me out with this. ? 

Thanks & Regards,
Ashvin
I am not able to see Challenge section under Admin Beginner > Lightning Experience Customization > Create and Customize List Views.
Please take a look.
Thank you in advance !

User-added image