• Jim Jam
  • SMARTIE
  • 798 Points
  • Member since 2013

  • Chatter
    Feed
  • 25
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 136
    Replies
Hi all,

I have the following custom lightning component, but it is coming up with the following error: Unknown controller action 'getOpps'.

component:
<aura:component controller="AcctOppsController" implements="flexipage:availableForRecordHome,force:hasRecordId">
    <aura:attribute name="mydata" type="OpportunityContactRole[]"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="currentRecordId" type="Id" />
    <aura:handler name="init" value="{!this }" action="{! c.doInit }"/>
    <div style="height: 300px">
        <lightning:datatable
                keyField="id"
                data="{! v.mydata }"
                columns="{! v.mycolumns }"
                hideCheckboxColumn="true"/>
    </div>
</aura:component>
controller:
({
    doInit: function (cmp, event, helper) {
        cmp.set('v.mycolumns', [
            {label: 'Opportunity Name', fieldName: 'opportunityId', type: 'text'},
            {label: 'Contact Name', fieldName: 'contact', type: 'text'},
            {label: 'Role', fieldName: 'role', type: 'text'},
            {label: 'Amount', fieldName: 'amount', type: 'currency'}
        ]);
        
        var fetchData = {
            opportunityId: "opportunityId",
            contact : "Contact.Name",
            role : "Role",
            amount : "Opportunity.Amount"
        };

        helper.fetchData(cmp,fetchData);
    }
})
helper:
({
    fetchData : function(cmp) {
        var recordId =  cmp.get("v.recordId");
        var action = cmp.get("c.getOpps");
        action.setParams({ "currentRecordId" : recordId });
        action.setCallback(this, $A.getCallback(function (response) {
            var state = response.getState();
            if (state ==="SUCCESS") {
                cmp.set("v.mydata", response.getReturnValue());
            } else if (state === "ERROR") {
                var errors = response.getError();
                console.error(errors);
            }
        }
                                               ));
        $A.enqueueAction(action);
    }
})
apex controller:
public with sharing class AcctOppsController{
@AuraEnabled
public String currentRecordId {get;set;}

    public AcctOppsController(ApexPages.StandardController controller) {
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
    }
    
    @AuraEnabled    
    public List<OpportunityContactRole> getOpps() {
        List<OpportunityContactRole> oppresults = [SELECT Contact.name, Role, OpportunityId, Opportunity.Amount, Opportunity.StageName, Opportunity.Type FROM OpportunityContactRole WHERE contact.accountid=:currentRecordId];
        return oppresults;
        }
}

Any thoughts on what I am missing?


 

I'm fairly new to writing out apex code, so any input would be greatly appreciated. 

Here is the current setup and problem I'm running into:
I have a custom formula field with the OrderItem Object which generates a JSON string based on the product information (this JSON string is used to send lineItem order information to another system). This field is called QBO_Line_JSON__c. I'm trying to populate a custom field in the Order object (QBO_JSON__c) that combines all the QBO_Line_JSON__c fields from the related OrderItem records. The goal is to have one JSON string that can be queried from the external system that lives in the Order object.

Here is the code so far:
trigger qboJSONCreator on Order (after insert, after update, after delete, after undelete) {

List<Order> OrderList = (Trigger.isInsert|| Trigger.isUnDelete) ? Trigger.new : Trigger.old;

List<Id>OrderIds = new List<Id>();

for (Order OrderStr : OrderList) {
OrderIds.add(OrderStr.OrderItems);
}

List<OrderItem> OrderItemList = [select id, (select id, QBO_Line_JSON__c from OrderItems) from Order where id in :OrderIds];

for (OrderItem ordr :OrderItemList) {
  for(integer i=1;i < ordr.OrderItem.size();i++)
  {
    ordr.QBO_JSON__c = ordr.QBO_JSON__c + '; ' + string.valueOf(ordr.OrderItem[i].QBO_Line_JSON__c);
  }
}

update OrderItemList;

}
The above gives me an error "Incompatible element type List<OrderItem> for collection of Id"

I've looked but haven't been able to piece together an understanding of how to resolve it. 

Any input or pointing in the right direction would be great. 

Thanks in advance!

 
To preface, I have very little to no development skills, and unfortunately, the org I inherited as admin is very apex-heavy. I need to make an edit to an apex class (sandbox first of course), but am unable to due to it being part of a scheduled job. We have about a dozen scheduled jobs, all of which are vaguely named. Is there a way I can tell which apex class is running which scheduled job? Of the scheduled jobs, only two of them give me the "manage" option. (see below)
User-added image
I have a variable I am trying to pass to the controller, but it is not working. According to several posts I've seen it should work. Here's my code:

VF:
<apex:actionFunction action="{!clickedRow}" name="call_clickedRow">
     <apex:param value="" assignTo="{!selectedRow}"/>
</apex:actionFunction>

<apex:repeat value="{!object1}" var="var1">
     <tr onclick="call_clickedRow({!var1.Name}); alert({!selectedRow});">
          //.................................................
          //.................................................
     </tr>
<apex:repeat>

Controller:
public String selectedRow{ get; set; }

public PageReference clickedRow(){
        return null;
}

I am however, getting a XmlHTTPSynchronous error that when expanded says that it is related to the onclick event shown above. I've tried several different methods of sending variables to the controller, but none have worked so far. I have also tried putting async=true in many places, but maybe not the right one. Any and all help would be appreciated. Thanks in advance.
Hello,
I have this URL which generates JSON output:
https://maps.googleapis.com/maps/api/geocode/json?address= Nuselská 23, 140 00, Praha 4 key=AIzaSyC2Hu3fh2L7MIN_UaBqgBtM-QvI-SPcGYg
I get data in JSON format using above URL and what I need is to get geolocation data (latitude and longtitude) and place these in a variabĺe.
Could anyoune please share a code how to do that.
I just need to place the URL in a code and get required geolocoation details without any "in between" step of copying/pasting JSON output format.
Appreciate your help,
Milan
Hi all,

I need some help with a validation rule please. 

I have the picklist "Network" with 30 Values. For 20 of them it is necessary to enter another information in the picklist field "Payment". 

I tried different ways, but I was only able to relate one value to the the  2nd picklist. But this I also can not reproduce anymore. Can you help me? I played with  AND and OR ...but it won't work :(
Last try is: 
AND(
ISPICKVAL(network__c,"AD"),
ISPICKVAL (network__c,"AX"),
(ISBLANK(Payment_Type__c)))

In this case I got the Error "Error: Field Affiliate_Payment_Type__c is a picklist field. Picklist fields are only supported in certain functions. " But before it worked with the field. i have no idea..

 
Hello,

I am trying to create a map of child objects as they relate to the parent object for a trigger.

I have the standard Contract object, and a custom Time Entry Object. When a Time Entry is created, udpated, or deleted my trigger kicks off and grabs all Time Entries associated with the Contract. It will then calculate the Total Time Entered and the Total Value and update this on the Contract. My current  method works, however I'm running into governor limit exceptions. Best practices states I should use a map instead of multipl SQL calls in a for loop. I've followed some examples online using this method however I am getting the error.

sObject type 'ContractwithTime' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

Code:
trigger trg_TimeEntryRollupToContract on Time_Entry__c (after delete, after insert, after update) 
{
    double dblTotalHours = 0.0;
    double curTotalValue = 0.00;


    if(Trigger.isInsert||Trigger.isUpdate||Trigger.isDelete)
    { 
        //***********************************************
        //New Record
        //***********************************************
           
        if(Trigger.isInsert)
        { 


           List<Contract> ContractwithTime = [SELECT Id, Total_Time_Entry_Value__c, Total_Time_Entry_Hours__c,
                                                    (SELECT Id, Total_Time__c, Total_Entry_Value__c FROM TimeEntry__r)
                                                    FROM ContractwithTime WHERE Id IN :Trigger.newMap.KeySet()];
            
            for(Contract con : ContractwithTime){
                for(TimeEntry__c ti : ContractwithTime.Time_Entry__r){
                    	if (ti.Total_Time__c == null) ti.Total_Time__c = 0;
                        dblTotalHours += ti.Total_Time__c;
                        if(ti.Time_Entry_Value__c!=null) curTotalValue += ti.Time_Entry_Value__c;
                        if(dblTotalHours > 0) contractwithTime.Total_Time_Entry_Hours__c = dblTotalHours;
;
                        contractwithTime.Total_Time_Entry_Value__c = curTotalValue;
                }
            }
}



 
Hello,
I am using below api call in my project "https://ap2.salesforce.com/services/data/v20.0/query?q=select+FirstName,LastName,Phone,Email+from Contact where+FirstName+LIKE+'%a%' "
but i am get  400 bad request error can you please any one help me to resolve that 
i have created a Connected app in my sandbox account 

Note: its working for one of my old account, earlier i created one new sandbox account with that i am getting bad request error
Hello,

I'm trying to find out how to add custom content in the Community Builder. I was under the impression I have to build a component within Developer Console, but then I can't see how I get that component to appear within Community Builder? I've followed several different guides and none seem to make it appear anywhere to be selectable. I thought it'd be possible to make it appear within the lightning components list under the page editor section?

Thanks,

Tom
Hi SFDC, I'm new in the Apex world :)
I have some trouble with picklist value, i will explain.
I have a picklist that show me the StartDate from the Period Objects.
I have also a List of ForecastingQuota by User.
The problem is that when I select a value in the picklist, the controller doesn't get it, so my query wich show the user can't change.
Controller :
public List<SelectOption> optionspl {get;set;}
public List<User> resultsusers{get;set;}
public Date dateinput{get;set;}
public Date dateinput2 {get;set;}


public List<SelectOption> getPeriodList(){
 		List<SelectOption> optionspl = new List<SelectOption>();
 		List<SObject> resultspl = [SELECT FullyQualifiedLabel, StartDate FROM Period WHERE StartDate > TODAY AND Type = 'Quarter'];
 		for(SObject pl : resultspl){
 			optionspl.add(new SelectOption(String.valueOf(pl.get('StartDate')),String.valueOf(pl.get('StartDate'))));
 		}
 		return optionspl;
 	}

public  List<ForecastingQuota> getAllQuotas(){
		dateinput = Date.today();
		date mydate2 = mydate.addDays(90);

		List<ForecastingQuota> resultsquotas = new List<ForecastingQuota>();
	    resultsquotas = [SELECT Id,QuotaAmount,QuotaOwnerId, StartDate FROM ForecastingQuota WHERE StartDate >:dateinput AND StartDate <:mydate2 ORDER BY QuotaOwnerId, StartDate ASC];
	    
	    List<User> resultsusers = new List<User>();
		resultsusers = [SELECT Id FROM User WHERE IsActive = TRUE AND ForecastEnabled = TRUE LIMIT 999];

		Map<Id, ForecastingQuota> fqsByOwnerId = new Map<Id, ForecastingQuota>();
			for (ForecastingQuota fq : resultsquotas)
			{
			    fqsByOwnerId.put(fq.QuotaOwnerId, fq);
			}
		
			// new map of quotas keyed by all user ids
		Map<Id, ForecastingQuota> allUserFqsByOwnerId = new Map<Id, ForecastingQuota>();
			for (User u : resultsusers)
			{
			     allUserFqsByOwnerId.put(u.id, fqsByOwnerId.containsKey(u.id) ? fqsByOwnerId.get(u.id) : new ForecastingQuota(QuotaOwnerId = u.id, QuotaAmount = null));
			    	
			}
			List<ForecastingQuota> allthequotas = new List<ForecastingQuota>();
			allthequotas = allUserFqsByOwnerId.values();
			allthequotas.sort();
			return allthequotas;
	}

And the VFP code :
<apex:pageBlockSection columns="4">
<apex:selectList value="{!dateinput2}" id="dateinput2" size="1">
    <apex:selectOptions value="{!periodlist}" />
     <apex:actionSupport event="onchange" rerender="allquotas"/>
</apex:selectList>
			<apex:pageBlockTable value="{!allquotas}" var="key">
				<apex:column>
				<input type="checkbox" name="pouet"/>
				</apex:column>
				<apex:column headerValue="Name">
				    <apex:outputField  value="{!key.QuotaOwnerId}"/>
				</apex:column>
    			<apex:column headerValue="Quota">
			    	<apex:inputField value="{!key.QuotaAmount}"/>
			    </apex:column>
			    <apex:column headerValue="Date">
			    	<apex:outputField value="{!key.StartDate}"/>
			    </apex:column>
			</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

Thank's for the help :)
 
Hello,

I have a picklist field that contains values A-Z. I need to write a validation rule that says if the Picklist is set to A, B or C then the same Picklist can't be changed to the value X but can be changed to other values. 

OR(
AND(
ISPICKVAL(PRIORVALUE( VPM_Field__c ),"A"), NOT(ISPICKVAL(VPM_Field__c,"X))
),
AND(
ISPICKVAL(PRIORVALUE(VPM_Field__c),"B"), NOT(ISPICKVAL(VPM_Field__c,"X")))
),
AND(
ISPICKVAL(PRIORVALUE(VPM_Field__c),"C"), NOT(ISPICKVAL(VPM_Field__c,"X")))
)


The above is what i have but it doesnt work 

Thanks 

 
I have the following Batch job :

global class AdvisorGroupsBatch implements Database.Batchable<sObject>{
    
    public String query;
    
    global database.querylocator start(Database.BatchableContext BC)
  {
      String query = 'Select Id, Name, YTD_Gross_Adv_Group__c, SV_Assets_for_Team__c, (select Id, Name, YTD_Gross_Sales__c, Assets_with_WB__c from Contacts__r) from Advisor_group__c';
      return Database.getQueryLocator(query);
  }
   global void execute(Database.BatchableContext BC, List<sObject> scope)
  {
      decimal total_YTD;
      decimal total_SV;
      for (sObject obj: scope){
          total_YTD = 0;
          total_SV = 0;
          Advisor_group__c advgrp = (Advisor_group__c)obj;
          for (Contact c: advgrp.Contacts__r){
              total_YTD = total_YTD + c.YTD_Gross_Sales__c;
              total_SV = total_SV + c.Assets_with_WB__c;
          }
          advgrp.YTD_Gross_Adv_Group__c = total_YTD;
          advgrp.SV_Assets_for_Team__c = total_SV;
          update advgrp;
        
      }
  } 
  
  global void finish(Database.BatchableContext BC)
  {
    System.debug('Advisor Groups Batch finished.');
  }
    
}


I am trying to write a test class, following is the test class :
@isTest
private class AdvisorGroupsBatchTest {
    public static testMethod void test(){
       
       String query = 'Select Id, Name, YTD_Gross_Adv_Group__c, SV_Assets_for_Team__c, (select Id, Name, YTD_Gross_Sales__c, Assets_with_WB__c from Contacts__r) from Advisor_group__c LIMIT 2';
    
     Advisor_Group__c[] adv = new List<Advisor_Group__c>();
     
           Advisor_Group__c a1 = new Advisor_Group__c(
               Name='Adv Group',
               Id='000',
               YTD_Gross_Adv_Group__c=100,
               SV_Assets_for_Team__c=200);
 
           adv.add(a1);
     
     insert adv;
     
     Test.startTest();
     AdvisorGroupsBatch a = new AdvisorGroupsBatch(query);
      Database.executeBatch(a);
     //ID batchprocessid = Database.executeBatch(a);
     Test.stopTest();
  } 
                      
}

I am unable to reach a code coverage of 75%. it is not increasing more than 24%. Please suggest

 
Hi All,

I have written a batch class with the below scenario.
if (ObjectName==Account)
{ need to query account  records
}
else if (ObjectName =Contact )
{ Query Contact records)
}
So i will get either account or contact records in scope and in execute method i will create records for other custom object means if it is account it will insert with account Id in the new custom object and if Contact contact Id in the new object .Right now it is captuirng the Id into another custom Object but the problem is whenever i am executing it is capturing the same .

So here i want to eliminate the creation of duplicates means if the Record Id(Acc or con Id already in the new custom object then it should not create new record if the record is not existing then create new record with the Acc or Con Id

My Code:
  global void execute(Database.BatchableContext BC, List<SObject> scope)
    { 
        Map<id, Custom Object> CustomMap= new Map<id,Custom Map>();
         for(Sobject obj: scope)
         {      
                Custom Object cm= new Custom Object();
                 
                 cm.Recordt_ID__c =obj.Id;
                 
                  CustomMap.put(Cm.Object_ID__c, cm);
             
          }
          if(!CustomMap.isEmpty())
        {
            Database.SaveResult[] InsertResult = Database.insert(CustomMap.values(),false);
            
        }
        
    }

So here how i will check if there is already a record with same Object Id is there then it should not insert if it is not there it should create new custom object Record.Any one please guide how to do this

Thanks in advance
My apex class is working as desired, but when I convert it to an extension (as my visualforce page has already a custom controller), it is not working.
I have a RemoteAction written in a Apex class which performs auto complete lookup fields. DId I miss anything in save_custom button of custom controller, or the syntax of Controller Extension for custom controller? Why the same code working good as controller, but not as extension? 
public class ExtensionAutocomplete {
    public General_Ledge_Account__c wildCardForGeneralLedgerAccount {get; set;}
    public General_Ledge_Account__c selected {get; set;}
    public Tax_Code__c wildCardForTaxCode {get; set;}
    public Tax_Code__c selectedTC {get; set;}
    public Journal__c wildCardForJournal {get; set;}
    public Journal__c selectedJ {get; set;}    
    public Dimension__c wildCardForDimension {get; set;}
    public Dimension__c selectedD {get; set;}  
    
	// Constructor for extension of custom controller 
	// 
    public ExtensionAutocomplete(JournalDetail_Controller_2T ctrlParam) {    // JournalDetail_Controller_2T is the controller for the VF page 
    }
    // JavaScript Remoting Action call 
    @RemoteAction
    public static List<General_Ledge_Account__c> lookupSearch(String wildCardForGeneralLedgerAccount) {
        System.debug('lookup: '+wildCardForGeneralLedgerAccount );
        List<General_Ledge_Account__c> master = Database.query('Select Id, Name from General_Ledge_Account__c where Name like \'%' + String.escapeSingleQuotes(wildCardForGeneralLedgerAccount) + '%\'');
        return master;
    }

Custom Controller: 
public with sharing class JournalDetail_Controller_2T  {
    // MVC concept to data binding in VF page & controller
    public Journal__c objectJournal{get; set;}
    public Line_Item__c objectLineItem{get; set;}
        
    //define the constructor 
      public JournalDetail_Controller_2T(ApexPages.StandardController stdController) {}

    public JournalDetail_Controller_2T(){
        // Initiate objects 
        objectJournal = new Journal__c();
        objectLineItem = new Line_Item__c();
    }
    public void save_custom()
    {
        try
        {
            insert objectJournal;
            insert objectLineItem;
        }   
        catch(Exception ex)
        {
            System.debug('\n\nException ='+ex.getMessage()+'\n\n');
        }    
    }
    public void cancel(){}  
    
       }

VF
 
<apex:page id="page" Controller="JournalDetailController_T"  sidebar="false" showHeader="false" standardStylesheets="false" >
    <apex:form id="form" >
        <html id="html">
            <head id="head">
                
                <style>
                    *{
                    <!-- font-size: 1.2vw;           viewport sized typography -->
                    }
                    html{
                    background-color: #E7EDF3;
                    }
                    body{ 
                    margin: 1rem; background-color: white;
                    }    
                    h3{
                    clear:both; background-color: #5B5DFE; width: 95%; padding-left: 1rem; color: white; margin: 2% 2.5% 1% 2.5%;
                    }
                    #div-table-1, #journal-status-left{
                    float: left; width: 45%; margin-left: 5%;
                    }
                    #div-table-2{
                    
                    }
                    #journal-detail-table-1{
                    
                    }
                    #journal-detail-table-2{
                    
                    }
                    #line-item-table{
                    margin-left: 5%;
                    }
                    #accordion3{
                    padding-bottom: 3%;
                    }
                    .lookupInput
                    {
                    display: inline;
                    vertical-align: middle;
                    white-space: nowrap;
                    }
                    .lookupInput img
                    {
                    background-repeat: no-repeat;
                    margin-right: .25em;
                    vertical-align: middle;
                    }
                    .lookupInput .disabled
                    {
                    background-color: #ccc;
                    }
                    .lookupInput .emptyDependentLookup
                    {
                    font-style: italic;
                    }
                    .lookupInput input[readonly]
                    {
                    background-color: #e6e6e6;
                    border: 2px solid #e6e6e6;
                    color: #333;
                    cursor: default;
                    }
                    .lookupInput a.readOnly
                    {
                    float: right;
                    }
                    .lookupInput span.readOnly
                    {
                    display: block;
                    white-space: normal;
                    }
                    .lookupInput span.totalSummary
                    {
                    font-weight: bold;
                    }
                    .inlineEditRequiredDiv .lookupInput img,.inlineEditDiv .lookupInput img
                    {
                    vertical-align: middle;
                    }
                    .quickCreateModule .lookupInput input {
                    max-width: 155px
                    }
                    .lookupIcon {
                    background-image: url(/img/func_icons/util/lookup20.gif);
                    background-position: 0 0;
                    width: 20px;
                    height: 20px;
                    background-position: top left
                    }
                    .lookupIconOn {
                    background-image: url(/img/func_icons/util/lookup20.gif);
                    background-position: 0 0;
                    width: 20px;
                    height: 20px;
                    background-position: top right
                    }
                </style>    
                <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
                <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script>
                <apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.10/angular.min.js"/>
                <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
                <script>
                $(function() { $("#accordion1").accordion({ header: "h3", collapsible: true }); });
                $(function() { $("#accordion2").accordion({ header: "h3", collapsible: true }); });
                $(function() { $("#accordion3").accordion({ header: "h3", collapsible: true }); });
                </script>
            </head>
            
            
            <body id="body" >
                <div>
                    <b> <span style="margin: 0 5% 0 5%; font-size:1.5rem">Journal Detail </span> </b>
                    
                    <apex:commandButton action="{!save_custom}" value="Post" style="background-color:#5B5DFE; color:white;font-weight: bold;  padding: .5rem 2rem .5rem 2rem; margin: 3rem 1rem 1rem 0; " />
                    <apex:commandButton action="{!cancel}" value="Cancel" style="background-color:#5B5DFE; color:white;font-weight: bold;  padding: .5rem 2rem .5rem 2rem; margin: 3rem 1rem 1rem 0; " />
                </div>
                <div class="journal-detail" id="accordion1" >
                    <h3>
                        Journal Detail
                    </h3>
                    <div>
                        <div id="div-table-1">
                            <table id="journal-detail-table-1" border="1" >
                                <apex:pageBlock >
                                    <apex:pageBlockSection >
                                        <tr>  
                                            <apex:inputField value="{!objectJournal.Type__c}"  /> </tr> <tr>
                                        <apex:inputField value="{!objectJournal.Journal_Date__c}" /> </tr><tr>
                                        <apex:inputField value="{!objectJournal.Journal_Currency__c}" /> </tr> <tr>
                                        <apex:inputField value="{!objectJournal.Reference__c}" /> </tr> <tr>
                                        <apex:inputField value="{!objectJournal.Journal_Description__c}"  /> </tr><tr>
                                        <apex:inputField value="{!objectJournal.Transaction__c}"  /> </tr> <tr>
                                        </tr>
                                    </apex:pageBlockSection>
                                </apex:pageBlock>
                            </table>
                        </div>
                        <div id="div-table-2">
                            <table  id="journal-detail-table-2" >
                                <apex:pageBlock >
                                    <apex:pageBlockSection >
                                        <tr><apex:outputField value="{!objectJournal.Name}" /> </tr> <tr> 
                                        <apex:inputField value="{!objectJournal.Period__c}"  /> </tr> <tr>
                                        <apex:inputField value="{!objectJournal.Debits__c}" /> </tr><tr>
                                        <apex:inputField value="{!objectJournal.Credits__c}"  />  </tr> <tr>
                                        <apex:inputField value="{!objectJournal.Invoice_Number__c}" /></tr><tr>
                                        <apex:inputField value="{!objectJournal.Total__c}" /> </tr>
                                    </apex:pageBlockSection>
                                </apex:pageBlock>
                            </table>
                        </div>
                    </div>
                </div>
                
                <div id="accordion2">
                    <h3 >
                        Journal Line Item
                    </h3>    
                   
				<div id="room-and-adding-room">
                	    <div id="field_wrapper_header_id" class="field_wrapper_header">
                                Line Type   	Line Description 		Journal			General Ledger Account	 	Amount 
                                Tax Code		Tax Amount 				Total Amount 	Dimension 

                    </div>
                    <div class="field_wrapper" style="border: dotted;" >
                        <div>      <apex:inputField value="{!objectLineItem.Line_Type__c}" style="width:3rem; float:left;"/> </div><div>
                        <apex:inputField value="{!objectLineItem.Line_Description__c}" style="width:5rem; float:left;"/> </div><div>
                        <apex:inputField value="{!objectLineItem.Journal__c}" style="width:3rem; float:left;"/> </div><div>
                        <apex:inputField value="{!objectLineItem.General_Ledge_Account__c}" style="width:4rem; float:left;"/> </div><div>
                        <apex:inputField value="{!objectLineItem.Amount__c}" style="width:5rem;  float:left;"/> </div><div>
                        <apex:inputField value="{!objectLineItem.Tax_Code__c}" style="width:5rem; float:left;"/> </div><div>
                        <apex:outputText value="{!objectLineItem.Tax_Amount__c}" style="width:3rem; float:left;"/> </div><div>
                        <apex:outputText value="{!objectLineItem.Total_Amount__c}" style="width:3rem; float:left;"/> </div><div>
                        <apex:inputField value="{!objectLineItem.Dimension_1__c}" style="width:6rem; float:left;"/> </div> <br/>
                </div> 
                    
                </div> <!-- End of room-and-adding-room div -->
                    <a href="javascript:void(0);" class="add_button"  title="Add field" style="background-color: red; display:inline-block;" > Add Room </a>
                    
                <div id="accordion3">
                    <h3 >
                        Journal Status
                    </h3>    
                    <div>
                    <div id="journal-status-left">
                        Journal Status <apex:inputField value="{!objectJournal.Journal_Status__c}" />
                    </div>
                    <div>
                        Discard Reason <apex:inputField value="{!objectJournal.Discard_Reason__c}" />
                    </div>
                    </div>
                </div>
                <!-- Script to enable autocomplete functionality -->

                    <apex:pageBlock id="searchBlock" >
                 <apex:outputLabel value="Search General Ledger Account" for="Box" />
                 <apex:outputPanel >
                     <apex:inputText id="TextBox" value="{!wildCardForGeneralLedgerAccount}" styleClass="General Ledger Account"/>
                     <apex:inputHidden id="searchId" value="{!selected}" /> <br/>
                 </apex:outputPanel>
                    
            <apex:outputLabel value="Search Tax Code" for="BoxTC" />
            <apex:outputPanel >
                     <apex:inputText id="TextBoxTC" value="{!wildCardForTaxCode}" styleClass="Tax code"/>
                <apex:inputHidden id="searchIdTC" value="{!selectedTC}" /> <br/>
            </apex:outputPanel>
           <apex:outputLabel value="Search Journal" for="BoxJ" />
            <apex:outputPanel >
                     <apex:inputText id="TextBoxJ" value="{!wildCardForJournal}" styleClass="wild card for Journal"/>
                <apex:inputHidden id="searchIdJ" value="{!selectedJ}" />  <br/>
                </apex:outputPanel>                                       
              <apex:outputLabel value="Search Dimension" for="BoxD" />
            <apex:outputPanel >
                     <apex:inputText id="TextBoxD" value="{!wildCardForDimension}" styleClass="wild card for Dimension"/>
                     <apex:inputHidden id="searchIdD" value="{!selectedD}" />    
                    </apex:outputPanel>
        </apex:pageBlock>
                </div>

    
                   	<!-- Script to add room -->
           <script type="text/javascript">
$(document).ready(function(){
    var maxField = 10; //Input fields increment limitation
    var addButton = $('.add_button'); //Add button selector
    var wrapper = $('.field_wrapper'); //Input field wrapper
    var fieldHTML = '<div><apex:inputField value="{!objectLineItem.Line_Type__c}" style="width:3rem; float:left;"/><apex:inputField value="{!objectLineItem.Line_Description__c}" style="width:5rem; float:left;"/><apex:inputField value="{!objectLineItem.Journal__c}" style="width:3rem; float:left;"/><apex:inputField value="{!objectLineItem.General_Ledge_Account__c}" style="width:4rem; float:left;"/><apex:inputField value="{!objectLineItem.Amount__c}" style="width:5rem;  float:left;"/><apex:inputField value="{!objectLineItem.Tax_Code__c}" style="width:5rem; float:left;"/><apex:outputText value="{!objectLineItem.Tax_Amount__c}" style="width:3rem; float:left;"/><apex:outputText value="{!objectLineItem.Total_Amount__c}" style="width:3rem; float:left;"/><apex:inputField value="{!objectLineItem.Dimension_1__c}" style="width:6rem; float:left;"/><a href="javascript:void(0);" class="remove_button" title="Remove field">Remove</a></div>';
    var x = 1; //Initial field counter is 1
    $(addButton).click(function(){ //Once add button is clicked
        if(x < maxField){ //Check maximum number of input fields
            x++; //Increment field counter
            $(wrapper).append(fieldHTML); // Add field html
        }
    });
    $(wrapper).on('click', '.remove_button', function(e){ //Once remove button is clicked
        e.preventDefault();
        $(this).parent('div').remove(); //Remove field html
        x--; //Decrement field counter
    });
});
</script>
    
    <script type="text/javascript">
    // A FOR LOOP will be added soon to optimize the length of the code
    // for id = [TextBox, TextBoxTC, TextBoxJ, TextBoxD]   searchID  $('[id$=id]')
    //------------------------------------GLA--------------------------
        var PLACEHOLDER = ''; 
        var masterObjects;
        var queryTerm;
        
        $('[id$=TextBox]').autocomplete({
            minLength: 0,
            source: function(request, response) {
                        queryTerm = request.term;
                        AutoCompleteLookupField.lookupSearch(request.term, function(result, event)  {
                            if(event.type == 'exception') {
                                  alert(event.message);
                            } else {
                                 masterObjects = result;
                                 response(masterObjects);
                            }
                        });
                   },
            focus: function( event, ui ) {
                    $('[id$=TextBox]').val( ui.item.Name );
                    return false;
                    },
            select: function( event, ui ) {
                        $('[id$=TextBox]').val( ui.item.Name );
                        $('[id$=searchId]').val( ui.item.Id );
                        return false;
                    },
         })
         .data( "autocomplete" )._renderItem = function( ul, item ) {
            var entry = "<a>" + item.Name;
           
            entry = entry + "</a>";
            entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>");
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( entry )
                .appendTo( ul );
        };
            
        // Add or remove placeholder values
        $('[id$=TextBox]').val(PLACEHOLDER);
        $('[id$=TextBox]').on("focus",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === PLACEHOLDER ){
                $tgt.val('');
                $tgt.removeClass('placeHolder');
            }
        });
        $('[id$=TextBox]').on( "blur",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === '' ){
                $tgt.val(PLACEHOLDER);
                $tgt.addClass('placeHolder');
            }
        });

    // ----------------------------------TC-----------------------
            var PLACEHOLDER = ''; 
        var masterObjectsTC;
        var queryTerm;
        $('[id$=TextBoxTC]').autocomplete({
            minLength: 0,
            source: function(request, response) {
                        queryTerm = request.term;
                        AutoCompleteLookupField.lookupSearchTC(request.term, function(result, event)  {
                            if(event.type == 'exception') {
                                  alert(event.message);
                            } else {
                                 masterObjectsTC = result;
                                 response(masterObjectsTC);
                            }
                        });
                   },
            focus: function( event, ui ) {
                    $('[id$=TextBoxTC]').val( ui.item.Name );
                    return false;
                    },
            select: function( event, ui ) {
                        $('[id$=TextBoxTC]').val( ui.item.Name );
                        $('[id$=searchIdTC]').val( ui.item.Id );
                        return false;
                    },
         })
         .data( "autocomplete" )._renderItem = function( ul, item ) {
            var entry = "<a>" + item.Name;
           
            entry = entry + "</a>";
            entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>");
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( entry )
                .appendTo( ul );
        };
            
        // Add or remove placeholder values
        $('[id$=TextBoxTC]').val(PLACEHOLDER);
        $('[id$=TextBoxTC]').on("focus",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === PLACEHOLDER ){
                $tgt.val('');
                $tgt.removeClass('placeHolder');
            }
        });
        $('[id$=TextBoxTC]').on( "blur",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === '' ){
                $tgt.val(PLACEHOLDER);
                $tgt.addClass('placeHolder');
            }
        });

    // -----------------------------------------------------====================Journal
       var PLACEHOLDER = ''; 
        var masterObjectsJ;
        var queryTerm;
        $('[id$=TextBoxJ]').autocomplete({
            minLength: 0,
            source: function(request, response) {
                        queryTerm = request.term;
                        AutoCompleteLookupField.lookupSearchJ(request.term, function(result, event)  {
                            if(event.type == 'exception') {
                                  alert(event.message);
                            } else {
                                 masterObjectsJ = result;
                                 response(masterObjectsJ);
                            }
                        });
                   },
            focus: function( event, ui ) {
                    $('[id$=TextBoxJ]').val( ui.item.Name );
                    return false;
                    },
            select: function( event, ui ) {
                        $('[id$=TextBoxJ]').val( ui.item.Name );
                        $('[id$=searchIdJ]').val( ui.item.Id );
                        return false;
                    },
         })
         .data( "autocomplete" )._renderItem = function( ul, item ) {
            var entry = "<a>" + item.Name;
           
            entry = entry + "</a>";
            entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>");
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( entry )
                .appendTo( ul );
        };
            
        // Add or remove placeholder values
        $('[id$=TextBoxJ]').val(PLACEHOLDER);
        $('[id$=TextBoxJ]').on("focus",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === PLACEHOLDER ){
                $tgt.val('');
                $tgt.removeClass('placeHolder');
            }
        });
        $('[id$=TextBoxJ]').on( "blur",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === '' ){
                $tgt.val(PLACEHOLDER);
                $tgt.addClass('placeHolder');
            }
        });

    // -----------------=============================---------------________________ Dimension
       var PLACEHOLDER = ''; 
        var masterObjectsD;
        var queryTerm;
        $('[id$=TextBoxD]').autocomplete({
            minLength: 0,
            source: function(request, response) {
                        queryTerm = request.term;
                        AutoCompleteLookupField.lookupSearchD(request.term, function(result, event)  {
                            if(event.type == 'exception') {
                                  alert(event.message);
                            } else {
                                 masterObjectsD = result;
                                 response(masterObjectsD);
                            }
                        });
                   },
            focus: function( event, ui ) {
                    $('[id$=TextBoxD]').val( ui.item.Name );
                    return false;
                    },
            select: function( event, ui ) {
                        $('[id$=TextBoxD]').val( ui.item.Name );
                        $('[id$=searchIdD]').val( ui.item.Id );
                        return false;
                    },
         })
         .data( "autocomplete" )._renderItem = function( ul, item ) {
            var entry = "<a>" + item.Name;
           
            entry = entry + "</a>";
            entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>");
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( entry )
                .appendTo( ul );
        };
            
        // Add or remove placeholder values
        $('[id$=TextBoxD]').val(PLACEHOLDER);
        $('[id$=TextBoxD]').on("focus",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === PLACEHOLDER ){
                $tgt.val('');
                $tgt.removeClass('placeHolder');
            }
        });
        $('[id$=TextBoxD]').on( "blur",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === '' ){
                $tgt.val(PLACEHOLDER);
                $tgt.addClass('placeHolder');
            }
        });

    </script>
                            </body>
        </html>
    </apex:form>
</apex:page>