Saturday, 7 February 2015

JavaScript on Sidebar components

Scenario: User will select Account from RelatedTo at the time of Event creation. Automatically populate fields existing values.

Home Component Code:
<script type="text/javascript" src="https://sfzip.sunbridge.com/paid/zip-2.4.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="/soap/ajax/29.0/connection.js" ></script>
<script type="text/javascript" src="/soap/ajax/29.0/apex.js" ></script>
<script type="text/javascript">
$( document ).ready(function() {
if ($("#evt3")) {
$( "#evt3" ).bind( "change", function( ) {
window.setTimeout(function(){
var accId = $("#evt3_lkid").val();
if(accId != "" && accId )
{
sforce.connection.sessionId = document.cookie.match('sid=([^;]*)')[1];
updatespdetail(accId);
} }, 1000);
});
}});
function updatespdetail(accId)
{
sforce.connection.sessionId = document.cookie.match('sid=([^;]*)')[1];
if(accId != "")
{A
var arr** = sforce.apex.execute("*Util","get**Detail", {Id:accId});
console.log(arr**);
var phase = "";
var probability = "";

if(arr*** != null && arr**[0]!= null)
{
var ss= arr**[0];
phase = ss.Phase__c;
probability = ss.Probability__c;

}}
$("#00NO0000001Ghje").val(phase);
$("#00NO0000001Ghl6").val(probability);
}
}
</script>

No comments:

Post a Comment