Friday, March 4, 2016

custom bootstrap lookup

<apex:page standardController="Contact" >
<apex:stylesheet value="/resource/bootCss"/>
<apex:includeScript value="{!$Resource.jq191}"/>
<apex:includeScript value="{!$Resource.bootJs}"/>

<apex:form id="contact_form">
        <apex:inputField value="{!contact.accountId}" id="accountId"/>
        <div class="input-group">
                 <input id="conactValue" type="text" class="form-control" placeholder="Contact Name" aria-describedby="basic-addon2"
                 onkeypress="if(event.keyCode == 13){$('#cntct').click();}"
                 value="{!contact.account.name}"
                 />
                  <span class="input-group-addon" id="cntct"
                  data-toggle="modal" data-target=".mobile-lookup-modal"
                  onclick="setTargetLookupFieldId('{!$Component.contact_form.accountId}','conactValue');getLookupValues($('#conactValue').val());">Lookup</span>
        </div>
        <apex:commandButton action="{!save}" value="Save" id="theButton"/>
</apex:form>

<!-- lookupCode -->
<div id="lookupModal" class="modal fade mobile-lookup-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" >
  <div class="modal-dialog modal-lg" >
          <div class="modal-content" style="padding: 20px;background-color: #FFFFFF;">
              <div class="input-group">
                  <input type="text" class="form-control" placeholder="Contact Name" aria-describedby="basic-addon2" id="lookupSearchVal"/>
                  <span class="input-group-addon" id="go" onclick='getLookupValues($("#lookupSearchVal").val());'>Go</span>
            </div>
            <hr/>
              <h4>Result</h4><p class="text-warning" id="lookupMessage"></p><div id="lookUpResult"></div>
          </div>
  </div>
</div>

<apex:remoteObjects jsNamespace="MyCorpModels">
    <apex:remoteObjectModel name="Account" fields="Name,Id"/>
</apex:remoteObjects>
<script>
    function getLookupValues(qryString) {
        try{
            tmpQryString = qryString;
            qryString = qryString.replace(/\*/g, "%");
            $("#lookupSearchVal").val(tmpQryString);
            if(qryString.length < 4){$("#lookupMessage").html("please type minimun 4 charaters to lookup");$("#lookUpResult").html("");return;}
            else{$("#lookupMessage").html("");}
            $("#lookUpResult").html("<img src='/resource/waiting' />");
            $("#lookupSearchVal").focus();
            var c = new MyCorpModels.Account();
            c.retrieve({ limit: 100, where: {Name: {like: qryString+'%' }} }, function (err, records) {
                if (err) {$("#lookUpResult").html(err); } else {displayLookupQueryResult(records);}
            });
        }catch(err){
            alert(err);
        }
    }
    function displayLookupQueryResult(records){
            try{
                 var resultOutPut = "Total "+records.length+" record(s) ( display only 25 records, refine serach)<br/>";
                 if(records.length>0){
                             resultOutPut += "<table class='table table-striped table-condensed'>";
                            resultOutPut += "<thead>";
                            resultOutPut += "<tr>";
                            resultOutPut += "<th>Name</th>";
                            resultOutPut += "<th>Id</th>";
                            resultOutPut += "</tr>";
                            resultOutPut += "</thead>";
                            resultOutPut += "<tbody>";
                        $.each(records, function() {
                            resultOutPut += "<tr>";
                            var name = "'"+this.get('Name')+"'";
                            var id = "'"+this.get('Id')+"'";
                            resultOutPut += "<td><a href='#' onclick=\"assignVal(" + name+"," + id +");\" >"+this.get('Name')+"</a></td>";
                            resultOutPut += "<td>"+this.get('Id')+"</td>";
                            resultOutPut += "</tr>";
                        });
                            resultOutPut += "</tbody>";
                            resultOutPut += "</table>";
                            resultOutPut += "<hr/>";
                    }
                    $("#lookUpResult").html(resultOutPut);
        }catch(err){
            alert(err);
        }                   
    }   
    $("#lookupSearchVal").keyup(function(event){if(event.keyCode == 13){$("#go").click();}});
    var targetLookupFieldId = "";
    var targetLookupSearchFieldId="";
    function setTargetLookupFieldId(lkFldId,searchLKFieldId){
        targetLookupFieldId = lkFldId;
        targetLookupSearchFieldId = searchLKFieldId;
        //document.getElementById(targetLookupFieldId).value="";
        //document.getElementById(targetLookupFieldId+"_lkid").value="";
    }
    function assignVal(recordName,recordId){
    try{
                document.getElementById(targetLookupFieldId).value=recordName;
                document.getElementById(targetLookupFieldId+"_lkid").value=recordId;
                document.getElementById(targetLookupSearchFieldId).value=recordName;
                $('#lookupModal').modal('hide');
        }catch(err){
            alert(err);
        }       
    }
        function getFieldValue(fieldId){
        return document.getElementById(fieldId).value;
    }
    function setFieldValue(fieldId,fieldVal){
        document.getElementById(fieldId).value=fieldVal;
    }   
   
</script>

</apex:page>

Thursday, February 19, 2015

Salesforce - apex - how to connect / transfer data to FTP server from Salesforce.com

  1. Using salesforce API  ( e.g. Java APIs ) 
    • Java program can connect with Salesforce.com and FTP server and you have better control
    • generate jar file and schedule job as regular scheduling you do
  2. You can also use Salesforce.com Dataloader command line interface ( CLI ) and can schedule .bat on windows or .sh and cron job on Linux / unix.

Salesforce APEX - how to process more than 10000 rows in VF/Apex using Queueable interface

A great improvement by salesforce by adding feature like Queueable Interface


Using salesforce Queueable interface you can execute, 
you can create up to 50 asynchronous jobs, 
each with 10000 DML rows limit.
 
List<String> lstVal1 = new List<String>(); 
List<String> lstVal2 = new List<String>(); 
 
ID jobID1 = System.enqueueJob(new AsyncExecutionExample(lstVal1));
ID jobID2 = System.enqueueJob(new AsyncExecutionExample(lstVal2));
 
Set<Id> lstJbIds = new  Set<Id>();
lstJbIds.add(jobID1);
lstJbIds.add(jobID2);
 
// now track jobs status using following query from Visualforce page,
// use action poller.
// this is a great improvement from salesforce.com 
/// 
List<AsyncApexJob> jobInfo = 
    [SELECT Status,NumberOfErrors FROM AsyncApexJob WHERE Id in:lstJbIds];
 
 
------------------------------------------------------------------------------------------------------------
public class AsyncExecutionExample implements Queueable {
 
List<String> recordsList = null; 
 
public AsyncExecutionExample(List<String> listParam){
 this.recordsList = listParam;
} 
 
public void execute(QueueableContext context) {
   // process recrdsList here
} 
 
}

Monday, November 24, 2014




I am building quiz and tests for my community.....

http://www.exampeta.com/v/agpzfmV4YW1wZXRhchgLEgtVc2VyUHJvZmlsZRiAgICAgMijCww

following is my exampeta profile

Sunday, October 26, 2014

Salesforce online tests

try salesforce.com developer / admin online tests here




http://www.exampeta.com/search_result?q=salesforce