• test batch
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 7
    Replies
Am haviing two vf pages, each page has assigned to separate record type, i created one custom button to navigate record edit page, here am getting error coz of for loop, guys please help me, where i went wrong.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 
if({!Invoice__c.RecordTypeId} =='01250000000V8nG'){ 

alert("hi"); 

var refString = '/apex/ShowAllTimecards2?RecordType={!Invoice__c.RecordTypeId}&id={!Invoice__c.Id}'; 
window.location.href=refString; 
} 

else { 

var refString1 = '/apex/Semiinvoice?RecordType={!Invoice__c.RecordTypeId}&id={!Invoice__c.Id}'; 
window.location.href=refString1; 
}
Can able to display all object records with below snippet except Account Object, please let me know the reason behind this.
<apex:page standardController="Account" recordSetVar="items" >
 <apex:pageBlock >
  <apex:pageBlockTable value="{!items}" var="a">
   <apex:column value="{!a.name}"/>
   <apex:column value="{!a.industry}"/>
  
  
  </apex:pageBlockTable>
 
 </apex:pageBlock>
  
</apex:page>
public ShowallTimeCatdsCtrl2(ApexPages.StandardController controller) {
        string invoiceid = ApexPages.currentPage().getParameters().get('id') ;
       
        system.debug('emailinvoice' + EmailInvoice);
        selectedtimecards = new List<Wrapclass>();
        selectedtimecards1 = new List<Wrapclass>();
        diselectedtimecards = new List<Wrapclass>();
        selectedtimecardsWrpr = new List<TimeCardWrapClass> ();
        mainPageWrap = new List<MainWrap>();
        wrap = new Map<string, List<Wrapclass>>();
        wrap1 = new List<Wrapclass>();
        empAmount = new map<string,decimal> ();
        clpAggList = new List<AggregateResult>();
        totalbool = true;
        tc = new Timecard__c();
        //invoiceId= new List<Id>();
        timeCardIds = new Set<Id>();
        payments = 0.00;
        downlodPdf = false;
        defalval = true;
        defalttotalbool = false;
        isEmptyEmail = false; //JS
        if(String.isNotBlank(invoiceid)) {
            objInvoices = [ SELECT  Id,
                           Name,
                           Account__c,Account__r.Accounts_Payable_Email__c,
                           Amount__c,
                           Check_No__c,
                           Comments__c,
                           Cross_Checked_Approved__c,
                           Date_Paid__c,
                           Due_Date__c,
                           Ext_Id__c,
                           Payment_Mode__c,
                           RecordType.Name,
                           Project__c,
                           Service_Term_From__c,
                           Service_Term_To__c,
                           Status__c,
                           Sub_Contractor_Employee__c,
                           Today__c
                           FROM    Invoice__c
                           WHERE   Id = :invoiceid];
            acdate = objInvoices.Service_Term_From__c; 
            dcdate = objInvoices.Service_Term_To__c;
        } else {
            objInvoices = new Invoice__c();
        }
        mailString=objInvoices.Account__r.Accounts_Payable_Email__c;//list of account mail ids.
        recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
        
        try {
            recordTypename = [  SELECT  id,
                              name
                              FROM    RecordType
                              WHERE   SobjectType ='Invoice__c'
                              AND Id = :recordTypeId
                              LIMIT   1 ].name;
        } catch(Exception e) {
            System.debug('Exception occurred while querying for RecordType : ' + e.getMessage());
        }
        
        
    }
    
    ========================vf================

 <apex:outputText value="{!callfunc}" escape="false"></apex:outputText>
        <apex:actionFunction name="calculateData" action="{!calculateData}" reRender="rrp,otpl,gtp1,txt,tpanl,messages"/>  
        <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId') " style="display:none;" />
        <apex:pageBlock title="Invoices" id="invoices">
            <apex:pageMessages id="messages"/>
            <apex:pageblocksection >           
                <apex:inputField value="{!objInvoices.Account__c}"/>    
                <apex:pageBlockSectionItem >
                    RecordType Name
                   <!--  <apex:outputText value="Auto Invoice"/>-->
                     <apex:outputText value="{!RecordtypeName}" style="color:red;font-weight: bold;"/>
                </apex:pageBlockSectionItem>
            </apex:pageblocksection>
            <apex:pageblockSection >
                <apex:inputField value="{!objInvoices.Status__c}"/>    
            </apex:pageblockSection>
            
            <apex:pageblockSection >
                <apex:inputField value="{!objInvoices.Cross_Checked_Approved__c}"/>
                <apex:inputField value="{!objInvoices.Project__c}"/> 
            </apex:pageblockSection>
            
            <apex:pageblockSection >
                <apex:inputField value="{!objInvoices.Service_Term_From__c}"/>  
            </apex:pageblockSection>

 
public pagereference dosave(){
    
                      
        try { 
            upsert objInvoices;
        }
         catch (DMLException dmlExcp) {
            ApexPages.addMessages(dmlExcp);
        }
        
       //  PageReference redirectSuccess = new ApexPages.StandardController('/'+objInvoices.id).view();
       // return (redirectSuccess);

        pageReference pr2=new pagereference('/'+objInvoices.id).setredirect(true);
        return pr2;
        
    }