Monday 1 December 2014

child to parent Field update using Trigger

trigger childtoparentupdation on Contact (after insert, after update) {

public static Boolean bool = true;

if(bool){
 bool = false;

 List<Contact> listcont  =  new List<Contact>();
 List<Account> listacct  =  new List<Account>();
 List<Account> listacct1 =  new List<Account>();

 set<id> setid  = new set<id>();
 set<id> setid1 = new set<id>();

 for(Contact con : Trigger.New){
  setid.add(con.id);  
 }
 
 List<Contact> contact = [select id, Languages__c,Account.id from contact where id IN:setid];
 
 for(contact conn:trigger.new){
 setid1.add(conn.accountid);
 }
 listacct = [select Id, SLASerialNumber__c from Account where id in:setid1];

 for(Account acc: listacct ){
 if(acc.SLASerialNumber__c == null){
  acc.SLASerialNumber__c ='Testing';
  listacct1.add(acc);
  }
 update listacct1;
}
}

Sunday 16 November 2014

Trigger on after insert and update example.

Trigger Fieldupfdate on Employee1__c (after insert, after update) {
  public static Boolean bool = true;
 if(bool){
 bool = false;
  List<Employee1__c> listemp = new  List<Employee1__c> ();
  Set<Id> setid = new Set<id>();
  for(Employee1__c empp:trigger.new){
   setid.add(empp.id);
  }
  List<Employee1__c> listem = [Select id,lastname__c from Employee1__c where id In : Setid];
  for(Employee1__c emp:listem){
   if(emp.LastName__c==null){
    emp.Lastname__c = 'Sampath';
    listemp.add(emp);
   }
  } update listemp;
}
}

Saturday 15 November 2014

Trigger on before insert and update example.




trigger Fieldupfdate on Employee1__c (before insert,before update) {
 for(Employee1__c emp:Trigger.new){
  if(emp.LastName__c==null){
   emp.LastName__c = 'sampath';
  }
 }
}

Friday 14 November 2014

Trigger updation

trigger Fieldupdations on Opportunity_Margin_Template__c (after update) {
List<Opportunity_Margin_Template__c> templist = new List<Opportunity_Margin_Template__c>();
List<Opportunity_Template_Task__c> templatetasklist = new List<Opportunity_Template_Task__c>();
set<id> setid = new set<id>();
for(Opportunity_Margin_Template__c margin: Trigger.new)
{
 setid.add(margin.id);
}
List<Opportunity_Margin_Template__c> tasklist = [select Id,Name,Template_Save_as__c,FX_Rate_to_USD__c from Opportunity_Margin_Template__c 
                                                 where id in:setid];
templatetasklist =[select id, Cost_Hr__c,Opportunity_Margin_Template__c from   Opportunity_Template_Task__c where  Opportunity_Margin_Template__r.id In : setid];                                          
for(Opportunity_Margin_Template__c temp: tasklist)
{
 if(temp.FX_Rate_to_USD__c!=Trigger.oldmap.get(temp.Id).FX_Rate_to_USD__c)
 {
   templist.add(temp);
 }
}
update templatetasklist ;        
update templist;  
                                                                                   
                
}

Friday 7 November 2014

Difference between ISBLANK and ISNULL




  • ISNULL is used for the Numeric & Text field. 
  • ISBLANK is used for both the Text as well as the Number field.
ISBLANK
ISNULL
Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.
Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
Text fields cannot be null. So use mainly for text fields.
Numeric fields cannot be blank. So use mainly for numeric fields.

Trigger for field update in Salesforce

The below Apex code is used to update a field(Comments__c) in Member__c Object,

where Marital__Status and Comments__c are fields n Member__c object.

Code:

trigger commentsUpdate on Member__c (before Insert,before update)
{
     for(Member__c member : Trigger.new) 
     {     
         if(member.Marital_Status__c != '')   
         {     
             member.Comments__c = member.Marital_Status__c;   
         }      
         else  
         {     
             member.Comments__c = 'No comments';   
         }      
     } 
}



trigger.isInsert is true when a new record is created and inserted.

trigger.isUpdate is true when an existing record is modified.

Thursday 6 November 2014

Salesforce Apex Code for Email Template | How to send

  1. trigger LeadBeforeUpdate on Lead (before update)
  2. {      
  3.  
  4. //Prefetch email Template id
  5. EmailTemplate et = [SELECT id FROM EmailTemplate WHERE Name = 'Lead_Rejected'];
  6.  
  7. //Grab the recipient as Contact
  8. Contact recipient = [SELECT id, firstname FROM Contact where id in :Trigger.newMap.keySet()];    
  9.  
  10. //Map the profile
  11. Map<Id, Profile> ProfileOwner = new Map<Id, Profile>([Select p.Id, p.Name from Profile p where Id =: userinfo.getProfileId()]);
  12.  
  13. //Lead Object Map
  14. Map<Id, Lead> LeadMap = new Map<Id,Lead>([Select Id, From Lead WHERE id in :Trigger.newMap.keySet()]);
  15.  
  16. for (lead myLead : Trigger.new)
  17.     {  
  18.        
  19.         Lead testLead = LeadMap.get(myLead.id);
  20.  
  21.         if(testLead.Status__c=='Approved') {
  22.            
  23.     /*---Mail to the Lead Owner **********/
  24.    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // new mail object
  25.  
  26.    //Depending on Schema your organization have
  27.    recipient.AccountId = opp.AccountId;  // receipient would be owner of Lead  
  28.     mail.setSenderDisplayName(ProfileOwner.get(userInfo.getUserId).Name);//Sender would be owner of Profile
  29.  
  30. //Notice : How I retrieve profile by passing value of current user id (using UserInfo Method)
  31.   mail.setTargetObjectId(recipient.id); //target to receipient
  32.   mail.setTemplateId(et.id);           // pull the email template through id
  33.   Messaging.sendEmail(new Messaging.Singleemailmessage[] {mail});  //send single email
  34.  
  35. } // end if
  36. } // end for

Salesforce Lead Duplication

  1. trigger leadDuplicatePreventer on Lead
  2.                                (before insert, before update) {
  3.  
  4.     Map<String, Lead> leadMap = new Map<String, Lead>();
  5.     for (Lead lead : System.Trigger.new) {
  6.                
  7.         // Make sure we don't treat an email address that  
  8.    
  9.         // isn't changing during an update as a duplicate.  
  10.    
  11.         if ((lead.Email != null) &&
  12.                 (System.Trigger.isInsert ||
  13.                 (lead.Email !=
  14.                     System.Trigger.oldMap.get(lead.Id).Email))) {
  15.                
  16.             // Make sure another new lead isn't also a duplicate  
  17.    
  18.             if (leadMap.containsKey(lead.Email)) {
  19.                 lead.Email.addError('Another new lead has the '
  20.                                     + 'same email address.');
  21.             } else {
  22.                 leadMap.put(lead.Email, lead);
  23.             }
  24.        }
  25.     }

Wednesday 6 August 2014

Types of Sandboxes

Types of Sandboxes
Salesforce now providing four types of sandboxes.
1. Developer Sandbox
2. Developer Pro Sandbox
3. Partial Data Sandbox
4. Full Sandbox
Developer Sandbox
Developer sandbox is a copy of production, it copies all application and configuration information to the sandbox. This type of sandboxes limited to 200MB of test or sample data, which is enough for many development and testing tasks. You can refresh a developer sandbox once per day.
Developer Pro Sandbox
Developer Pro sandboxes copy all of your production organization’s reports, dashboards, price books, products, apps, and customizations under Setup, but exclude all of your organization’s standard and custom object records, documents, and attachments. This type of sandboxes limited to 1GB of test or sample data. We can refresh developer pro type sandboxes once per day.
Partial Data Sandbox
A Partial Data sandbox is a Developer sandbox plus the data you define in a sandbox template. It includes the reports, dashboards, price books, products, apps, and customizations under Setup (including all of your metadata). Additionally, as defined by your sandbox template, Partial Data sandboxes can include your organization’s standard and custom object records, documents, and attachments up to 5 GB of data and a maximum of 10,000 records per selected object. A Partial Data sandbox is smaller than a Full sandbox and has a shorter refresh interval. You can refresh a Partial Data sandbox every 5 days.
Sandbox templates allow you to pick specific objects and data to copy to your sandbox, so you can control the size and content of each sandbox. Sandbox templates are only available for Partial Data or Full sandboxes.
Full Copy Sandbox
Full copy sandboxes are exact copy of production including standard and custom objects records, attachments and documents. You can refresh full copy sandbox every 29 days.

Tuesday 5 August 2014

Salesforce Summer ’14 Release Notes

1. Change sets included in the Deployment Status Page.
2. Notes & Attachments & Files size Limit Increased 5MB to 25MB.
3. Limit Raised for External IDs from 3 to 7.

Salesforce Release Months


Spring = February, 
Summer=June,
Winter=October.

Tuesday 15 July 2014

Best Practices of Test Classes in Apex


  • Use Test.startTest() to reset Governor limits in Test methods
  • If you are doing any Asynchronous operation in code, then don’t forget to callTest.stopTest() to make sure that operation is completed.
  • Use System.runAs() method to enforce OWD and Profile related testings. This is very important from Security point of view.
How to write Test method of Controller Extension for StandardController ?
Example :
//Lets Assume we are writing Controller Extension for Account
Account acct = [SELECT ID FROM Account LIMIT 1];

//Start Test Context, It will reset all Governor limits
Test.startTest();

//Inform Test Class to set current page as your Page where Extension is used
Test.setCurrentPage(Page.YOUR_PAGE);

//Instantiate object of "ApexPages.StandardController" by passing object
ApexPages.StandardController stdController = new ApexPages.StandardController(acct);

//Now, create Object of your Controller extension by passing object of standardController
YOUR_Extension ext = new YOUR_Extension(stdController);

//Here you can test all public methods defined on Extension "ext"
//..... your code

//Finish Test
Test.stopTest();

Monday 23 June 2014

Based on Picklist Visible Lookup Field


Here "Risk Assessment" is a Picklist and "Peer Reviewer" is a Lookup field.

<apex:pageBlockSectionItem >
 <apex:outputLabel value="Risk Assessment"></apex:outputLabel>
  <apex:actionRegion>
   <apex:inputField value="{!thisCon.theCase.Risk_Assessment__c}" rendered="{!thisCon.caseRTN       ame == 'OD Change'}"> 
    <apex:actionSupport event="onchange" rerender="pr,prr" />      
  </apex:inputField>
 </apex:actionRegion>
</apex:pageBlockSectionItem>
  
<apex:pageBlockSectionItem >
 <apex:outputLabel value="Peer Reviewer"></apex:outputLabel>
  <apex:outputPanel id="pr"> 
   <apex:outputPanel rendered="{!if(thisCon.theCase.Risk_Assessment__c != null,true,false)}"> 
   <apex:inputField value="{!thisCon.theCase.Peer_Reviewer__c}" rendered="{!thisCon.caseRTNam        e == 'OD Change'}" required="true"/>
  </apex:outputPanel>
 </apex:outputPanel> 
</apex:pageBlockSectionItem>


This is another way:-


 <apex:actionRegion >
  <apex:inputField value="{!thisCon.theCase.Risk_Assessment__c}" required="true" rendered="{!     thisCon.caseRTName == 'OD Change'}">  
   <apex:actionSupport event="onchange" rerender="pr,rp" />      
  </apex:inputField>   
 </apex:actionRegion>
   
 <apex:pageBlockSectionItem >
  <apex:outputPanel id="rp" >
   <apex:outputText value="Risk Assessment" rendered="{!if(thisCon.theCase.Risk_Assessment__c       != null,true,false)}"/>
  </apex:outputPanel> 

 <apex:outputPanel id="pr">
  <apex:outputPanel rendered="{!if(thisCon.theCase.Risk_Assessment__c != null,true,false)}">
   <apex:inputField value="{!thisCon.theCase.Peer_Reviewer__c}" rendered="{!thisCon.caseRTNam         e == 'OD Change'}" />
  </apex:outputPanel>
 </apex:outputPanel>  
</apex:pageBlockSectionItem>


Friday 13 June 2014

Using Schedulable interface Testclass

@isTest 
public class ContractAmendmentLinkageTestClass{
@isTest static void Amendment(){
ContractAmendmentLinkage Contractobj = new ContractAmendmentLinkage ();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('ContractAmendmentLinkage JOB', sch, Contractobj);

Datetime sysTime = System.now().addSeconds( 300 );     
String chronExpression = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
System.Schedule('SelfSchedule ' + sysTime, chronExpression, new ContractAmendmentLinkage() );
  }
}



sch: Is the corn expression ,the corn expression is nothing but the next scheduled time.
ContractAmendmentLinkage JOB: is the name of the job.

Contractobj:: is the object of the scheduled class which we need to run.
corn expression for to run schedule(ContractAmendmentLinkage) every 5min. below

// This is Self-Schedule To Execution purpose.

(Datetime sysTime = System.now().addSeconds( 300 );   
String chronExpression = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
System. Schedule( 'SelfSchedule ' + sysTime, chronExpression, new ContractAmendmentLinkage() );)

Thursday 12 June 2014

Refreshing the formula field based on text field using Trigger.

Refreshing the fields based on text field(FX Rate to usd) parent to child will refresh(Calculations using formula field) parent.

Parent to child to parent updation using trigger.

Trigger:-

trigger Fieldupdations on Opportunity_Margin_Template__c (after update) {
List<Opportunity_Margin_Template__c> templist = new List<Opportunity_Margin_Template__c>();
List<Opportunity_Template_Task__c> templatetasklist = new List<Opportunity_Template_Task__c>();
set<id> setid = new set<id>();
for(Opportunity_Margin_Template__c margin: Trigger.new)
{
 setid.add(margin.id);
}
List<Opportunity_Margin_Template__c> tasklist = [select Id,Name,Template_Save_as__c,FX_Rate_to_USD__c from Opportunity_Margin_Template__c
                                                 where id in:setid];
templatetasklist =[select id, Cost_Hr__c,Opportunity_Margin_Template__c from   Opportunity_Template_Task__c where  Opportunity_Margin_Template__r.id In : setid];                                        
for(Opportunity_Margin_Template__c temp: tasklist)
{
 if(temp.FX_Rate_to_USD__c!=Trigger.oldmap.get(temp.Id).FX_Rate_to_USD__c)
 {
   templist.add(temp);
 }
}
update templatetasklist ;      
update templist;                                                                                
             

}

Wednesday 21 May 2014

Based on Picklist i need to display On Text Field.


Picklist,   Text
PD (NA), 207.7
PD (UK), 174.95
CN (NA), 149
CN (UK), 157.4
CN (Ind), 24.4
CN (China), 24.4
CN (Japan), 120

Through Work flow i have done.
Work Flow Rule Criteria:  True
Field Updation:- 
CASE(Resource_Role__c,"PD(NA)", 207.7, 
"PD(UK)",174.95, "CN(NA)",149, "CN(UK)",157.4,"CN(Ind)",24.4, 
"CN(China",24.4, "CN(Japan)",120, "SS(NA)",134.95, "SS(UK)",128.95, "SS(Ind)",24.4,"EM(NA)",149,"EM(UK)",157.4,"EM(Ind)",24.4,"EM(Japan)",120,"Dev/QA(Ind)",24.4,"FTC Admin(Ind)",24.4, 
null)



Getting #Error! in a formula field


Basically i am getting this error(#Error!) on using formula field.


Is this happening when Total_Revenue__c is blank or equal to 0?  This would cause the error.  You need to add checks in the formula for if Total_Revenue__c is 0, to prevent trying to divide by 0.
Total_Revenue__c,Total_Cost__c these fields are Formula fields
Solution:-

IF(
     OR(
          ISBLANK(Total_Revenue__c),
          Total_Revenue__c = 0
     ),
     0,
     (Total_Revenue__c - Total_Cost__c) / Total_Revenue__c)
)

Tuesday 20 May 2014

Based on picklist values i need to update Text field(Dynamically) in salesforce.


I have 2objects with Master-detail Relationship.

1st Object Paretn1,Paretn2,Paretn3,Paretn4,Paretn5 all are Number Fields.

I enter Partner2(Parent) some value
User-added image

2nd Object

In child i selected in picklist(partner2) i am not get the "Cost/Hr$(NumberField)" here.
Picklist Values :-

User-added image

When i select Partner1 with data when select on picklist for that Partner1 automatically need to display on "Cost(Number Field).



Like this Through Work flow i have done.

Rule Criteria:-  true

Field Update:-  
IF(ISPICKVAL(Resource_Role__c,"Partner1"), Opportunity_Margin_Template__r.Partner1__c,
IF(ISPICKVAL(Resource_Role__c,"Partner2"),
Opportunity_Margin_Template__r.Partner2__c,
IF(ISPICKVAL(Resource_Role__c,"Partner3"),
Opportunity_Margin_Template__r.Partner3__c,
IF(ISPICKVAL(Resource_Role__c,"Partner4"),
Opportunity_Margin_Template__r.Partner4__c,
IF(ISPICKVAL(Resource_Role__c,"Partner5"),
Opportunity_Margin_Template__r.Partner5__c,Null
)))))

I have done single Workflow for these requirement.

CASE(Resource_Role__c,"PD(NA)", 207.7, 
"PD(UK)",174.95, "CN(NA)",149, "CN(UK)",157.4,"CN(Ind)",24.4, 
"CN(China",24.4, "CN(Japan)",120, "SS(NA)",134.95, "SS(UK)",128.95, "SS(Ind)",24.4,"EM(NA)",149,"EM(UK)",157.4,"EM(Ind)",24.4,"EM(Japan)",120,"Dev/QA(Ind)",24.4,"FTC Admin(Ind)",24.4, 
IF(ISPICKVAL(Resource_Role__c,"Partner1"), Opportunity_Margin_Template__r.Partner1__c, 
IF(ISPICKVAL(Resource_Role__c,"Partner2"), 
Opportunity_Margin_Template__r.Partner2__c, 
IF(ISPICKVAL(Resource_Role__c,"Partner3"), 
Opportunity_Margin_Template__r.Partner3__c, 
IF(ISPICKVAL(Resource_Role__c,"Partner4"), 
Opportunity_Margin_Template__r.Partner4__c, 
IF(ISPICKVAL(Resource_Role__c,"Partner5"), 
Opportunity_Margin_Template__r.Partner5__c,Null 
))))) 

)


Sunday 18 May 2014

Roll up summaries don't support summation of Cross Object formula.


  • Roll up summaries don't support summation of Cross Object formula. 
  • So we need to go through Trigger.

Monday 12 May 2014

Select lookup icon the related data automatically display


When i select 'Gold' The related data display.

Apex Class:-
------------

public class TemplateTaskData {
 public TemplateTaskData(ApexPages.StandardController controller) {
        lookupDataPop = new Template_Tasks__c();
        //lookupDataPop = (Template_Tasks__c )controller.getrecord();
      }
    public Template_Tasks__c lookupDataPop {get;set;}
    public string lkpdata {get;set;}
    public List < Template_Tasks__c > templatetask {get;set;}

    public pagereference currentData() {
        system.debug('lookupDataPop.Template__c****' + lookupDataPop.Templates_Name__c);

        templatetask = new list < Template_Tasks__c > ();
        if (lkpdata == 'MAT-Maestro(SMB) - Gold') {
            for(Integer i=0; i<5; i++){
                lookupDataPop = new Template_Tasks__c();
          //      lookupDataPop.Templates_Name__c = lookupDataPop.Templates_Name__c;
         //      lookupDataPop.Billing_function__c = 'CN';
         //       lookupDataPop.Billing_HOURS__c = '82';
                templatetask.add(lookupDataPop);
            }
            templatetask[0].Template_Task_Name__c = 'Maestro 5 LMS Implementation Package';
            templatetask[0].Billing_HOURS__c = '82';
            templatetask[0].Billing_function__c = 'CN';
            templatetask[1].Template_Task_Name__c = 'Data Migration';
            templatetask[1].Billing_HOURS__c = '44';
            templatetask[1].Billing_function__c = 'CN';
            templatetask[2].Template_Task_Name__c = 'Data migration - Express';
            templatetask[2].Billing_HOURS__c = '44';
            templatetask[2].Billing_function__c = 'CN';
            templatetask[3].Template_Task_Name__c = 'Data Migration - Full';
            templatetask[3].Billing_HOURS__c = '84';
            templatetask[3].Billing_function__c = 'CN';
            templatetask[4].Template_Task_Name__c = 'Maestro Full data migration X3';
            templatetask[4].Billing_HOURS__c = '252';
            templatetask[4].Billing_function__c = 'CN';
           
        } else if (lkpdata == 'MAT-Maestro(SMB) - Bronze') {
            for(Integer i=0; i<5; i++){
                lookupDataPop = new Template_Tasks__c();
                templatetask.add(lookupDataPop);
             }
            templatetask[0].Template_Task_Name__c = 'Maestro 5 LMS Implementation Package';
            templatetask[0].Billing_HOURS__c = '44';
            templatetask[0].Billing_function__c = 'CN';
            templatetask[1].Template_Task_Name__c = 'Data Migration';
            templatetask[1].Billing_HOURS__c = '44';
            templatetask[1].Billing_function__c = 'CN';          
            templatetask[2].Template_Task_Name__c = 'Data migration - Express';
            templatetask[2].Billing_HOURS__c = '44';
            templatetask[2].Billing_function__c = 'CN';          
            templatetask[3].Template_Task_Name__c = 'Data Migration - Full';
            templatetask[3].Billing_HOURS__c = '84';
            templatetask[3].Billing_function__c = 'CN';          
            templatetask[4].Template_Task_Name__c = 'Maestro Full data migration X3';
            templatetask[4].Billing_HOURS__c = '252';
            templatetask[4].Billing_function__c = 'CN';          
        } else if (lkpdata == 'MAT-Maestro(SMB) - Silver') {
            for(Integer i=0; i<5; i++){
                lookupDataPop = new Template_Tasks__c();
              templatetask.add(lookupDataPop);              
            }
            templatetask[0].Template_Task_Name__c = 'Maestro 5 LMS Implementation Package';
            templatetask[0].Billing_HOURS__c = '61';
            templatetask[0].Billing_function__c = 'CN';
            templatetask[1].Template_Task_Name__c = 'Data Migration';
            templatetask[1].Billing_HOURS__c = '44';
            templatetask[1].Billing_function__c = 'CN';          
            templatetask[2].Template_Task_Name__c = 'Data migration - Express';
            templatetask[2].Billing_HOURS__c = '44';
            templatetask[2].Billing_function__c = 'CN';          
            templatetask[3].Template_Task_Name__c = 'Data Migration - Full';
            templatetask[3].Billing_HOURS__c = '84';
            templatetask[3].Billing_function__c = 'CN';          
            templatetask[4].Template_Task_Name__c = 'Maestro Full data migration X3';
            templatetask[4].Billing_HOURS__c = '252';
            templatetask[4].Billing_function__c = 'CN';        
        }
        return null;
    }
}


VF Page:-
---------
<apex:page StandardController="Template_Tasks__c" extensions="TemplateTaskData">
 <apex:Form >
  <apex:pageBlock >
   <apex:pageBlockButtons >
    <apex:commandButton value="Save" action="{!Save}"/>
    <apex:commandButton value="Cancel" action="{!Cancel}"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection title="Template Tasks" columns="1">
    <apex:inputfield value="{!lookupDataPop.Templates_Name__c}" onchange="currentDataFecth();" id="lkp">
     <apex:actionFunction name="currentDatafn" action="{!currentData}" reRender="pgbsc" />
    </apex:inputfield>
 
   <apex:pageblocktable value="{!templatetask}" var="row" id="pgbsc" >
       <apex:column headerValue="Template Task name"  value="{!row.Template_Task_Name__c}"/>
       <apex:column headerValue="Billing Function"  value="{!row.Billing_Function__c}"/>
       <apex:column headerValue="Billing Hours"  value="{!row.Billing_hours__c}"/>  
   </apex:pageblocktable>
 
<apex:inputhidden value="{!lkpdata}" id="theHiddenInput" />
<script>
 var lkpvalue='';
  function currentDataFecth(){
      lkpvalue =document.getElementById("{!$Component.lkp}").value;
      document.getElementById("{!$Component.theHiddenInput}").value = lkpvalue ;
      currentDatafn();
  }
 </script>
   
   </apex:pageBlockSection>
  </apex:pageBlock>
 </apex:Form>
</apex:page>