• salesforceMann
  • NEWBIE
  • 135 Points
  • Member since 2016


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 55
    Replies
Hi , Cann anyone plz help me urgenntly,
My below formula is showing a syntax error, Can anyone plz suggest where its gone wrong in syntax. I am using it in process builder.
When i tried it in formula editor, it showed the below error , But i dont think anywhere its wrong or couldnt able to figure it out. Thanks
Error: Syntax error. Missing '='
 
IF(
CASE( [Lead].Renewal_Month__c,
"January",1,
"February",2,
"March",3,
"April",4,     
"May",5,
"June", 6,
"July", 7,
"August", 8,
"September",9,
"October", 10,
"November", 11,
"December", 12,NULL)< MONTH(TODAY()),
IF(TEXT([Lead].Renewal_Month__c)="January",DATE(YEAR(TODAY()),12,1), 
DATE(YEAR(TODAY())+1,CASE([Lead].Renewal_Month__c,
"January",1,
"February",2,
"March",3,
"April",4, 
"May",5,
"June", 6,
"July", 7,
"August", 8,
"September",9,
"October", 10,
"November", 11,
"December", 12,NULL)-1,1)),
DATE(YEAR(TODAY()), MONTH(TODAY())-1, 1)

 
Hi,

i want to find out a class run on which box either sandbox/production how i identify easily ?

regards,
Bhanu

 
Im new to salesforce, im working on visualforce page to import Account and contacts to salesforce.

here is my requiremnt, please guide me to achive this. 
 
Give the customer ability to import Accounts from external csv file to salesforce with button on custom Visualforce page.
Read the csv file and display the content in the Tabular form in the same Visualforce page.
Verify the Duplicate records based on Phone number, if the phone number of the import record matches with existing Account record then verify for Email field match, if matches then populate error message as Duplicate record on Visualforce page Table under Status column for particular record. Otherwise insert record and update the status column on Visualforce page as Success.
Extend the functionality to multiple Objects (Account, Contact, and Opportunity) from single csv file.

here is my code: im getting error "common.apex.runtime.impl.ExecutionException: List index out of bounds: 5" and status is not getting updated. 

Please help me

VF:
<apex:page controller="importDataFromCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4">
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Account" action="{!importCSVFile}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!accList}" var="acc">
              <apex:column value="{!acc.name}" />
              <apex:column value="{!acc.AccountNumber}" />
              <apex:column value="{!acc.Type}" />
              <apex:column value="{!acc.Accountsource}" />
              <apex:column value="{!acc.Industry }" />
               <apex:column headerValue="Status" >
              <apex:outputText id="status"/>
              </apex:column>
           </apex:pageblocktable>
        </apex:pageBlock>
   </apex:form>
</apex:page>

Apex Class:

public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public string csvStatus{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
public string[] csvRecordData;
public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Account>();
  }
  
  public void importCSVFile()
  {
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++)
           {
               Account accObj = new Account() ;
               csvRecordData = csvFileLines[i].split(',');
               accObj.name = csvRecordData[0] ;            
               accObj.accountnumber = csvRecordData[1];
               accObj.Type = csvRecordData[2];
               accObj.AccountSource = csvRecordData[3];  
               accObj.Industry = csvRecordData[4];
               uploadStatus(accObj);
               csvRecordData[5] = csvStatus;
            }
        insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'error here');
            ApexPages.addMessage(errorMessage);
        } 
  }
  
public List<Account> uploadStatus(Account a)
   {
       for(Account acc:[SELECT Name, Accountnumber FROM Account])
       {
           if(acc.name == a.name && acc.accountnumber == a.accountnumber)
           {
               this.csvStatus = 'Duplicate';
                system.debug('inside if');
           }
           else
           {
               system.debug('inside else');
               acclist.add(a);
               this.csvStatus = 'unique';
               
           }
       }
       return acclist;
   }
}
 
I'm experiencing an unexpected error in my test class for an 'after insert' trigger.  First, the trigger works just fine in Sandbox.  So the issue has something to do with how I'm setting up my test class.  When I run the test on the test class in the Developer Console, I get the error:

-------------------------
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, leadsRoundRobin: execution of AfterInsert

caused by: System.ListException: List index out of bounds: 0

Trigger.leadsRoundRobin: line 34, column 1: []
-------------------------

If I look at the trigger leadsRoundRobin on line 34, I see that it's trying to assign the Trigger.New Lead to a variable inside the trigger:
(This is a simplified version of my trigger, including only the relevant bits)

-------------------------
trigger leadsRoundRobin on Lead (after insert) {

List<Id> triggerIds= new List<Id>();
Lead submittedLead = new Lead();

for (Lead triggerLead: trigger.new) 
        {
            triggerIds.add(triggerLead.Id);
        }

    // Get Submitted Lead Record
    submittedLeadList = [SELECT Id, FirstName, LastName, Company, Requested_Quote_Types__c, State, New_Lead__c FROM Lead WHERE Id IN : triggerIds];
    submittedLead = submittedLeadList[0];    <-- THIS IS LINE 34

etc....
-------------------------
Note that all this is doing, essentially, is assigning the Trigger.New Lead to 'submittedLead'.  It seems to me that the only way I could get the error 'List index out of bounds: 0' is if there IS no Trigger.New object!  That makes no sense.

Again, this is working perfectly fine running it in the Sandbox.  It's only trying to trigger it from the test class that gives this error.  The relevant bits of the Test class (I'm using 'SeeAllData=true' because my trigger references a Custom Setting):

-------------------------

@isTest(SeeAllData=true)
public class test_RoundRobin 
     { 
        // Add a Lead - Auto
            Lead testLead1 = new Lead();
                testLead1.Status = 'Open';
                testLead1.Company = 'Test Company 1';
                testLead1.LastName = 'Lead';
                testLead1.FirstName = 'Test1';
                if(contactRecordTypeMap.containsKey('Customer')) 
                    {
                        testLead1.RecordTypeId = leadRecordTypeMap.get('Customer').getRecordTypeId();
                    }
                testLead1.Phone = '1112223333';
                testLead1.Email = 'test@test.com';
                testLead1.Preferred_Contact_Method__c = 'Phone';
                testLead1.State = 'CA';
                testLead1.Requested_Quote_Types__c = 'Auto,';
                testLead1.New_Lead__c = FALSE;
            insert testLead1;   

            etc....
-------------------------

I can't figure it out.  It seems like the test class's 'insert testLead1' statement is firing the trigger, but not passing the Lead!

Any idea what I'm doing wrong?  I have a sneaky suspicion it has to do with 'SeeAllData=true', which I've never used before, but I just don't know.

Thanks!
Hi , Cann anyone plz help me urgenntly,
My below formula is showing a syntax error, Can anyone plz suggest where its gone wrong in syntax. I am using it in process builder.
When i tried it in formula editor, it showed the below error , But i dont think anywhere its wrong or couldnt able to figure it out. Thanks
Error: Syntax error. Missing '='
 
IF(
CASE( [Lead].Renewal_Month__c,
"January",1,
"February",2,
"March",3,
"April",4,     
"May",5,
"June", 6,
"July", 7,
"August", 8,
"September",9,
"October", 10,
"November", 11,
"December", 12,NULL)< MONTH(TODAY()),
IF(TEXT([Lead].Renewal_Month__c)="January",DATE(YEAR(TODAY()),12,1), 
DATE(YEAR(TODAY())+1,CASE([Lead].Renewal_Month__c,
"January",1,
"February",2,
"March",3,
"April",4, 
"May",5,
"June", 6,
"July", 7,
"August", 8,
"September",9,
"October", 10,
"November", 11,
"December", 12,NULL)-1,1)),
DATE(YEAR(TODAY()), MONTH(TODAY())-1, 1)

 
How can I get around the aggregrate query error? When I tried taking out the For loop- the execution then failed. Is there a better way to do it?

global class Batch_ExpDate_PricIn implements Database.Batchable<sObject>,Database.Stateful
{
   global Database.QueryLocator start(Database.BatchableContext BC)
   {
        string manualExpStr = 'Manually Expired'; //Correct Status -11/2/16 MT
        string expiredStr = 'Expired'; 
        
        string query= 'select Id,RecordTypeId,RecordType.Name,Par_Status__c,Effective_date__c,Expiration_Date__c,(select Id,Expiration_Date_Change_To__c,Effective_date__c from Pricing_Inputs__r) from Price_Authorization_Request__c where Par_Status__c !=:manualExpStr  and Par_Status__c !=:expiredStr';
             return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<Price_Authorization_Request__c> Parlist) {
            
       if(Parlist != null && !Parlist.isEmpty())
       {
              Map<String,string> maprecTypewithId = new Map<String,String>();
           List<Price_Authorization_Request__c> listPARToUpdate = new List<Price_Authorization_Request__c>();
           for(RecordType rec : [select id,Name from recordType where SObjectType = 'Price_Authorization_Request__c']) //-->system does not like this
           {
               maprecTypewithId.put(rec.Name,rec.id);
           }
           
           
           for(Price_Authorization_Request__c parObj : Parlist)
           {
            if(parObj.Pricing_Inputs__r != null && !parObj.Pricing_Inputs__r.isEmpty())
            {
                 Integer count = 0;
                 for(Pricing_Input__c PrcInputObj : parObj.Pricing_Inputs__r)
                 {
                    
                    if(PrcInputObj.Expiration_Date_Change_To__c != null && PrcInputObj.Expiration_Date_Change_To__c < system.today())
                    {
                        count = count + 1;
                    }
                 }
                 
                 if(count ==(parObj.Pricing_Inputs__r).size())  
                 {
                    parObj.Par_Status__c = 'Expired'; 
                  //  parObj.Expiration_Date__c=Date.valueOf(System.Today());
                    if(parObj.RecordType.Name == 'Standard PAR' && maprecTypewithId.get('ReadOnlyStandard PAR') != null)
                      parObj.RecordTypeId = maprecTypewithId.get('ReadOnlyStandard PAR');
                    else if(parObj.RecordType.Name == 'Formula PAR' && maprecTypewithId.get('ReadOnlyFormula PAR') != null)
                      parObj.RecordTypeId = maprecTypewithId.get('ReadOnlyFormula PAR');
                    listPARToUpdate.add(parObj);
                 }
            }
              
           }
           
           if(!listPARToUpdate.isEmpty())
               update listPARToUpdate;
       }
   }
    
    global void finish(Database.BatchableContext BC)
    {}
 }
I have the following code.  Business_Unit_new__c in the User object is the multipicklist.  
I want to pull records from the License Numbers object where the Business Unit (picklist) from the License record is equal to the Business Unit of the current user (multipicklist).  The users may have more than 1 Business Unit assigned to them.

I've tried WHERE Business_Unit__c INCLUDES (:currentuser.Business_Unit_new__c) and it errors saying includes can only be used with a multipick list

If I try 
currentuser.Business_Unit_new__c INCLUDES (:Business_Unit__c) it errors saying it doesn't understand the relationship with currentuser.

How do I fix this?(this is not the complete code, jus tthe snipit that i need the query in)
public with sharing class LicenseList { 
private final License_Numbers__c ln; 
public user currentuser{get;set;} 
public id tobeEdited{get;set;}
public decimal aTotal{get;set;}
public decimal tTotal{get;set;}
public List<AccountWrapper> wrappers{get;set;}
private Integer nextIdent=0;

public LicenseList(ApexPages.StandardSetController controller) { 
currentuser=new User(); 
currentuser=[Select Id, Business_Unit_new__c from User where Id=:userinfo.getuserId()]; 
this.ln = (License_Numbers__c)controller.getRecord(); 

wrappers=new List<AccountWrapper>();
for(Integer idx=0; idx<1; idx++)
{
    wrappers.add(new AccountWrapper(nextIdent++));
}

} 

//------------------------------------------------------------------------------------

public List<License_Numbers__c> lntypes16 = new List<License_Numbers__c>();

public List <License_Numbers__c> getLicenseList(){ 
lntypes16 = [select id, Name, X2016_Cost__c, Business_Unit__c, X2016_Starting_Amount__c, X2016_Subtotal__c, BMS_Code__c, License_Type__c, Monthly_Unit_Price__c, Running_License_Total__c, Org__c FROM License_Numbers__c where Business_Unit__c =:currentuser.Business_Unit_new__c  AND License_Year__c = '2016' ORDER BY Order_Number__c, License_Type__c];
       

return lntypes16; 
}



 
  • November 02, 2016
  • Like
  • 0
Hello.

reRender attribute does not work at all. Even when blank outputPanel (nothing inside the container) used.
This is the only element which is rerendered on the page. What can be the problem?
The paragraphs are rendered correctly on Load, 'rerender' results in general error on page.
<p> 
<apex:outputPanel>                                                   
   <apex:selectList value="{!lSoftware}" size="1" multiselect="false" >
           <apex:selectOptions value="{!SoftwareMulti}"/>
           <apex:actionSupport event="onchange" reRender="f3"/>
   </apex:selectList>                              
</apex:outputPanel>

</p>  
                                                        
<p>Database<br/>                             
    <apex:outputPanel>
          <apex:selectList value="{!lDataBase}" size="1" id="f3">
              <apex:selectOptions value="{!DataBase2Multi}"/>                                                        
          </apex:selectList>
    </apex:outputPanel>                                                      
   </p>
public List<SelectOption> getDataBase2Multi(){ 
       List<SelectOption> lSO_DataBases = new List<SelectOption>();
       ldatabase = '';
       return lSO_DataBases;
}
Even the most basic scenario causing the issue.
I used same methods on the page when new record created worked fine as well, when existing record loaded to be updated there is always an issue.
Can you advise on possible reasons, please. Why reRender attribute is not binded properly on the page?
 
  • September 09, 2016
  • Like
  • 0
We have a visualforce page where we have used actionsupport with rerendering  attribute for refreshing a output panel which worked good till 6th-May-2016 IST, and then suddenly stopped working i.e. currently rerendering is not working for outputpanel i. I just want help kin knowing is it because the latest release or something wrong in our code.

The code sample is as below
<apex:outputPanel id="Newcase" >                                          
                                        <apex:outputPanel rendered="{!IF(editAccount,true,false)}">
                                            <label>Account: </label>
                                            <apex:selectList size="1" value="{!selectedPartneraccount}" styleClass="form-control" >                             
                                                <apex:selectOptions value="{!partneraccountoptions}"/> 
                                                <apex:actionSupport event="onchange" reRender="Newcase" status="loading" />                                 
                                            </apex:selectList>
                                            
                                            <label>Machine ID: </label>                                                               
                                            <apex:selectList size="1" value="{!selectedMachineId}" styleClass="form-control" id="mId">
                                                <apex:selectOptions value="{!machineIdoptions}" />
                                                <apex:actionSupport event="onchange" reRender="Newcase" status="loading"/>    
                                            </apex:selectList>
                                        </apex:outputPanel>
                                    </apex:outputPanel>


Thanks in advance.


 
Hi, 

I'm wrecking my brain on how to achieve this. So I'm trying to run a child object from an apportunity. Child object may have multiple records. If so I need to find the previous entered record by comparing the recently created date with previous one. 

I'm writing an after insert trigger to achieve this. However, how do I find the previous records? I'm also trying to avoid nested for loops. So far this is what I have and giving me error: BudgetTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only Class.BudgetPreviousVersion.VersionUpdate: line 27
 
public without sharing class BudgetPreviousVersion {

    public static TriggerStatus__c cfg = TriggerConfig.raw;

    public static void VersionUpdate(list<Budget__c> budget){
        
        Set<Id> opportunityIds = new Set<Id>(); 
                
        for(Budget__c b: budget){
        
            if(b.Job__c != null){ 
                opportunityIds.add(b.Job__c);
                
            }
        }
        
        Map<ID, Budget__c> budmap = new Map<ID, Budget__c>();
        
        for(Budget__c b:[Select id, previous_version__c, CreatedDate From Budget__c WHERE job__c IN: opportunityIds order by createddate DESC limit 1]){
            
            budmap.put(b.id, b);                                 
        }
        
  List<budget__c> listb = new list<budget__c>();
       for(Budget__c b: budget){
           if(budmap.containskey(b.id)){
                 b.previous_version__c = true;                  

           }
           listb.add(b);
        }//for loop for each customer survey and assign them to customer survey.  */
         upsert listb;
    } 
}

Notice that I tried to upsert because upon searching it says the value is not yet commited. So upserting should update the value, right? How can I re-write this so I can avoid the nested loop?