- Anil Kumar Devarapu
- NEWBIE
- 40 Points
- Member since 2014
- Salesforce Developer
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
1Likes Given
-
6Questions
-
8Replies
How to replace ' & ' with ' & ' in Jquery
I am using Auto complete component from here http://goo.gl/NMpwnH
I have Special Characters in My record name for Accouunt and Other objects,
when i focused or Selected the Names with Special Characters as encoded form, It displaying ' & ' as ' & '
I have posted my component Code below
please Anyone suggest me to replace ' & ' as ' & '
VF Component
<apex:component controller="autoCompleteController"> <apex:includeScript value="{!URLFOR($Resource.jqueryui18, 'js/jquery-1.7.1.min.js')}" /> <apex:includeScript value="{!URLFOR($Resource.jqueryui18, 'js/jquery-ui-1.8.18.custom.min.js')}" /> <apex:stylesheet value="{!URLFOR($Resource.jqueryui18, 'FlickTheme.css')}"/> <!-- Attributes Required For Component --> <apex:attribute name="objectname" description="The object name you want to look for." type="String" required="true"/> <apex:attribute name="additionalfield" description="Any additional fields you'd like to search and include in the display." type="String" required="false"/> <apex:attribute name="profilename" description="To filter on the basis of profile name and include in the display." type="String" required="false"/> <apex:attribute name="autocomplete_textbox" description="The ID for the Autocomplete List Textbox." type="String" required="true"/> <!-- CSS --> <style> .ui-autocomplete-loading {background: white url({!$Resource.loadingIcon}) right center no-repeat;} </style> <!-- Javascript --> <script type="text/javascript"> var j$ = jQuery.noConflict(); j$(document).ready(function() { var sObjects; var queryTerm; j$(esc('{!autocomplete_textbox}')).autocomplete({ minLength: 1, source: function(request, response) { queryTerm = request.term; autoCompleteController.findSObjects("{!objectname}", request.term, "{!additionalfield}", "{!profilename}", function(result, event){ if(event.type == 'exception') { alert(event.message); } else { sObjects = result; response(sObjects); } }); }, focus: function( event, ui ) { j$(esc('{!autocomplete_textbox}')).val(ui.item.Name); return false; }, select: function( event, ui ) { j$(esc('{!autocomplete_textbox}')).val( ui.item.Name ); j$(esc('{!autocomplete_textbox}_lkid')).val( ui.item.Id ); j$(esc('{!autocomplete_textbox}_lkold')).val( ui.item.Name ); if (event.keyCode == 13) { event.preventDefault(); } return false; }, }) .data( "autocomplete" )._renderItem = function( ul, item ) { var entry = item.Name; if("{!additionalfield}" !='') { j$.each("{!additionalfield}".split(",") , function(key, value) { entry = entry + " " + item[value]; }); } //entry = entry + "</a>"; //entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>"); entry = entry.replace( new RegExp( "(" + queryTerm + ")" , "g" ), "<strong>$1</strong>" ); return j$( "<li></li>" ) .data( "item.autocomplete", item ) .append( "<a>" + entry + "</a>") .appendTo( ul ); }; }); function esc(myid) { return '#' + myid.replace(/(:|\.\&)/g, '\\\\$1'); //return '#' + myid.replace(/&/g, '&') } </script> </apex:component>
Component Controller
global class autoCompleteController { @RemoteAction global static SObject[] findSObjects(string obj, string qry, string addFields, string profilename) { /* More than one field can be passed in the addFields parameter Split it into an array for later use */ List<String> fieldList=new List<String>(); if (addFields != '') fieldList = addFields.split(','); /* Check whether the object passed is valid */ Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); Schema.SObjectType sot = gd.get(obj); if (sot == null) { return null; } /* Creating the filter text */ String filter = ' like \'%' + String.escapeSingleQuotes(qry) + '%\''; /* Begin building the dynamic soql query */ String soql = 'SELECT Name'; /* If any additional field was passed, adding it to the soql */ if (fieldList.size()>0) { for (String s : fieldList) { soql += ', ' + s; } } /* Adding the object and filter by name to the soql */ soql += ' from ' + obj + ' where name' + filter; if(profilename!='') { //profile name and the System Administrator are allowed soql += ' and Profile.Name like \'%' + String.escapeSingleQuotes(profilename) + '%\''; system.debug('Profile:'+profilename+' and SOQL:'+soql); } /* Adding the filter for additional fields to the soql */ if (fieldList != null) { for (String s : fieldList) { soql += ' or ' + s + filter; } } soql += ' order by Name limit 20'; system.debug('Qry: '+soql); List<sObject> L = new List<sObject>(); try { L = Database.query(soql); } catch (QueryException e) { system.debug('Query Exception:'+e.getMessage()); return null; } return L; } }
Usage :
<apex:inputText label="Name :" value="{!name}" id="Text" required="true" html-autocomplete="on" html-PlaceHolder="Name.." html-inputtype="text" > <c:AutoCompleteComponent autocomplete_textbox="{!$Component.Text}" objectname="Account" /> </apex:inputtext>
ScreeenShot of Autocomplete
-
- Anil Kumar Devarapu
- August 08, 2015
- Like
- 0
Google chart not displayed on VF Page
I am New to salesforce i am looking for embedding a Google chart in visualforce, I found this following snippet in Saleforce developer forums, I just copy phasted this to observe the response, But i am not getting the desired Chart,
<apex:page controller="GoogleChartsController" sidebar="false"> <!-- Google API inclusion --> <apex:includeScript id="a" value="https://www.google.com/jsapi" /> <apex:sectionHeader title="Google Charts + Javascript Remoting" subtitle="Demoing - Opportunities by Exepected Revenue"/> <!-- Google Charts will be drawn in this DIV --> <div id="chartBlock" /> <script type="text/javascript"> // Load the Visualization API and the piechart package. google.load('visualization', '1.0', {'packages':['corechart']}); // Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(initCharts); function initCharts() { // Following the usual Remoting syntax // [<namespace>.]<controller>.<method>([params...,] <callbackFunction>(result, event) {...} // namespace : abhinav // controller : GoogleChartsController // method : loadOpps abhinav.GoogleChartsController.loadOpps( function(result, event){ // load Column chart var visualization = new google.visualization.ColumnChart(document.getElementById('chartBlock')); // Prepare table model for chart with columns var data = new google.visualization.DataTable(); data.addColumn('string', 'Opportunity'); data.addColumn('number', 'Expected Revenue'); data.addColumn('number', 'Amount'); // add rows from the remoting results for(var i =0; i<result.length;i++){ var r = result[i]; data.addRow([r.Name, r.ExpectedRevenue, r.Amount]); } // all done, lets draw the chart with some options to make it look nice. visualization.draw(data, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:window.innerWidth,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}}); }, {escape:true}); } </script> </apex:page> ------------------------------------------------------ global with sharing class GoogleChartsController { /** Loads most recent 10 Opportunities */ @RemoteAction global static Opportunity[] loadOpps() { return [select Id, Name, ExpectedRevenue, Amount from Opportunity order by CreatedDate DESC limit 10]; } }
I am looking for this,
-
- Anil Kumar Devarapu
- May 08, 2015
- Like
- 0
Salesforce Default LightBox(Jquery) is Not Displaying on VF Page
I am using Salesforce default lightbox on VF page using a Static Resource. Actually My intension is to display a popup of editing record in a page block which is embedded inside output panel as shown below screenshots
Please anyone reply me where i am wrong,
<apex:page controller="lightboxcls"> <apex:stylesheet value="{!URLFOR($Resource.XXofficeCSS, 'css/base.css')}"/> <apex:stylesheet value="{!URLFOR($Resource.XXofficeCSS, 'popup/reveal.css')}"/> <apex:includeScript value="{!URLFOR($Resource.XXofficeCSS, 'popup/jquery.min.js')}" /> <apex:includeScript value="{!URLFOR($Resource.XXofficeCSS, 'popup/jquery.reveal.js')}"/> <script type="text/javascript"> function fun(){ alert(document.getElementById('j_id0:j_id6:pb:j_id10:j_id11').value); if(document.getElementById('j_id0:j_id6:pb:j_id10:j_id11').value!=''){ $('#myModal1').trigger('reveal:close'); } } </script> <!--<apex:inputText value="{!name}"/>--> <apex:form > <apex:pageBlock mode="edit" > <!-- <apex:pageBlockSection title="All Contacts" collapsible="false" columns="1"> --> <apex:pageblockTable value="{!Acn}" var="a" > <a data-animation="fade" dragable="true" data-reveal-id="myModal1" style="display:block;text-decoration:underline;margin-left:6px;margin-top:5px;"> <apex:column headerValue="Action" > <apex:commandlink action="{!Edit}" id="processlblsSearch" immediate="true" >Edit <apex:param value="{!a.id}" name="Sel" assignTo="{!AId}" /> </apex:commandlink> </apex:column></a> <apex:column value="{!a.Name}" headerValue="Name" > </apex:column> <apex:column headerValue="Phone" value="{!a.phone}"> </apex:column> </apex:pageblockTable> </apex:pageBlock> <div id="myModal1" class="reveal-modal"> <a class="close-reveal-modal" style="text-decoration:none;">×</a> <apex:outputpanel layout="block" rendered="{!displayPopUp}" > <apex:pageBlock id="pb" mode="Edit"> <apex:pageBlockSection > <apex:inputField value="{!acnt.name}"/> <apex:inputField value="{!acnt.Phone}"/> <apex:commandButton value="Save" action="{!save}" reRender="pb" oncomplete="return fun()"/> </apex:pageBlockSection> </apex:pageBlock> </apex:outputpanel> <a class="close-reveal-modal" style="text-decoration:none;">×</a> </div> </apex:form> </apex:page> --------------------- Controller Below------------------------- public class lightboxcls { public boolean displayPopUp{get;set;} public Account Acnt{get;set;} public string Aid{get;set;} public list<account> Acn{get;set;} //public string name{get;set;} //public Account acc{get;set;} public lightboxcls() { displayPopUp=false; //acc=new Account(); Acn = new list<Account>(); Acn = [select id,name,phone from Account]; } public void save(){ displayPopUp=false; update Acnt; // acc=new Account(); } public void Edit() { displayPopUp=true; Acnt = new Account(); Acnt = [select id,Name,Email__c,Phone,Industry,AccountSource,Amount__c from Account where id=:Aid]; system.debug('------------------> ' +Acnt); system.debug('------This is Id------------> ' +Aid); } }
If you want My static resource used in this Page get it here,
https://drive.google.com/file/d/0B1wNUoOAwRhfTkUzdUdQQjlTUFE/view?usp=sharing
-
- Anil Kumar Devarapu
- May 01, 2015
- Like
- 0
Wraper class object List Rerendering Multiple times on VF Page
Hello there,
I have a inline edit VF page that is by using Wraper class. When ever i hit the command link Edit, The page block table again ReRendering and finally resulting, The same Page block table Repeats with same records. This is happening when i hit cancel button also.
Any one Please Help me, Thanks in advance
Here is my Snippet,
Page
----------------------------------------------------
<apex:page controller="OppDisplay2" >
<apex:form >
<apex:pageBlock id="pb" > <!--rerender="pb"-->
<apex:outputLabel >Opportunity Details</apex:outputLabel>
<apex:pageBlockTable value="{!Records}" var="o" id="pbt">
<apex:column headervalue="Action">
<apex:commandLink value="Edit" action="{!Edit}" rendered="{!Not(o.ren)}" > <!--rerender="pb"-->
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandLink>
<apex:commandlink value="Delete" action="{!Delete1}" rerender="pbt" >
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandlink>
<apex:commandLink value="Save" action="{!Save}" rerender="pb" rendered="{!o.ren}"> <!--rerender="pbt"-->
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandLink>
<apex:CommandLink value="Cancel" action="{!Cancel}" rerender="pbt" rendered="{!o.ren}" immediate="true">
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:CommandLink>
</apex:column>
<apex:column headervalue="Opportunity Name">
<apex:outputField value="{!o.opp.name}" rendered="{!Not(o.ren)}"/>
<apex:inputField value="{!o.opp.name}" rendered="{!o.ren}"/>
</apex:column>
<apex:column headervalue="Close Date">
<apex:outputfield value="{!o.opp.CloseDate}" rendered="{!Not(o.ren)}"/>
<apex:inputfield value="{!o.opp.CloseDate}" rendered="{!o.ren}"/>
</apex:column>
<apex:column headervalue="Stage Name">
<apex:outputfield value="{!o.opp.StageName}" rendered="{!Not(o.ren)}"/>
<apex:inputfield value="{!o.opp.StageName}" rendered="{!o.ren}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
--------------------------------------------------------------
/* Controller */
----------------------------------------------------------------
public class OppDisplay2 {
// Param object for selected row index
public integer rowindex1{get;set;}
public Id id1{get;set;}
public List<Opportunity> lstopp = new list<Opportunity>();
public List<Wraper> lstwrap=new List<Wraper>();
wraper wrapobj;
public OppDisplay2()
{
}
public class wraper
{
public Opportunity opp{get;set;}
public integer rowindex{get;set;}
public boolean ren{get;set;}
}
public List<wraper> getRecords()
{
lstopp= [select id,name,CloseDate, StageName from Opportunity limit 6];
for(integer i=0;i<lstopp.size();i++){
wrapobj=new wraper();
wrapobj.opp=lstopp[i];
wrapobj.rowindex=i;
wrapobj.ren=false;
lstwrap.add(wrapobj);
}
return lstwrap;
}
public pagereference Save(){
if(rowindex1<lstwrap.size()){
// Updating List with Specified rowindex value
update lstwrap[rowindex1].opp;
lstwrap[rowindex1].ren=false;
}
return null;
}
public pagereference Cancel(){
id1=wrapobj.opp.id;
Opportunity oppobj=[select name,CloseDate,StageName from Opportunity where id=:id1];
if(rowindex1<lstwrap.size()){
wrapobj.opp.Name=oppobj.Name;
wrapobj.opp.CloseDate=oppobj.CloseDate;
wrapobj.opp.StageName=oppobj.StageName;
lstwrap[rowindex1].ren=false;
}
return null;
}
public pageReference Edit(){
if(rowindex1<lstwrap.size()){
lstwrap[rowindex1].ren=true;
}
return null;
}
public pagereference Delete1(){
if(rowindex1<lstwrap.size()){
//Deleting in the Object
Delete lstwrap[rowindex1].opp;
//Deleting in the List
lstwrap.remove(rowIndex1);
}
return null;
}
}
-
- Anil Kumar Devarapu
- April 20, 2015
- Like
- 0
Is it possible to initialize / Call the Schedule Class in a trigger
Hello EveryOne,
I am new to salelsforce. i have a basic knowledge on Schedulable classes, can i schedule a class(using cron expression for every 5hrs) using (after insert) Trigger. And Assuming that my Schedule class calls(creates an instance for) Another Batch Apex. i had known that, Every time of an insert of record a Job is Qued and I think All this can also be achived with simply After Insert Trigger(without batch and Schedular Class)
Is this really Possible to schedule a Class using(inside) a Trigger. Any one clarify me,
Thanks in Advance
-
- Anil Kumar Devarapu
- April 17, 2015
- Like
- 0
Page message text not visible
//VF Page <apex:page controller="SearchAllCntrlr" > <apex:form > <apex:pageMessage summary=" <b>{!qc}</b> " severity="Confirm" strength="3" rendered="{!IF((acl.size>0)||(acu.size>0),true,false)}" escape="false"/> <apex:pageBlock title="Search Keyword"> <apex:inputText value="{!Qstring}" label="Input" /> <apex:commandButton value="Search records" action="{!search}" /><br></br><br></br> Eg: Anil </apex:pageBlock> <apex:pageBlock title="Account Result" rendered="{!acl.size!=0}"> <apex:pageblockTable value="{!acl}" var="a" > <apex:column HeaderValue="Accounts"> <!--<apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>--> <apex:commandLink action="{!openAc}"> <apex:param name="SelectedId" assignTo="{!selectedId}" value="{!a.id}"/>{!a.name}</apex:commandlink> </apex:column> <apex:column value="{!a.id}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Contact Result" rendered="{!acu.size!=0}"> <apex:pageblockTable value="{!acu}" var="b"> <apex:column headerValue="Contacts"> <apex:commandLink action="{!Openco}"> <apex:param name="SelectedC" value="{!b.id}" assignTo="{!SelectedCC}"/>{!b.name}</apex:commandlink> </apex:column> </apex:pageblockTable> </apex:pageblock> <apex:pageMessages escape="false"/> </apex:form> </apex:page> ________________ //CONTROLLER public class SearchAllCntrlr { public string SelectedId{get;set;} public string selectedcc{get;set;} public list<account> acl{get;set;} public list<contact> acu{get;set;} public string queri,queriC; public string qc{get;set;} public string Qstring{get;set;} public string getqcp() { if(Qstring=='') { qc = 'You are viewing all Contacts and Accounts'; } else { qc='Search Results for <b>"'+qstring+' "</b>';} return qc; } public void search() { ASearch(); CSearch(); if(Qstring=='') { apexpages.Message msa = new Apexpages.Message(ApexPages.Severity.Confirm,'<b>You are Viewing All Accounts and Contacts</b> '); apexpages.addmessage(msa); } if(acu.size()==0&&acl.size()==0) { apexpages.Message msa = new Apexpages.Message(ApexPages.Severity.FATAL,'There were no Results found for <b> "'+qstring+' " </b> '); apexpages.addmessage(msa); } else if(acl.size()==0) { apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'There were no Results found on Accounts for <b>"'+qstring+' "</b> '); apexpages.addmessage(msg); } else if(acu.size()==0) { apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'There were no Results found on Contacts for <b> "'+qstring+' " </b> '); apexpages.addmessage(msg); } } public SearchAllCntrlr() { //displ=true; acl = new list<account>(); acu = new list<contact>(); } public void ASearch() { queri = 'Select name from account where name like \'%'+Qstring+'%\' limit 50'; acl = database.query(queri ); } public void CSearch() { queriC = 'Select name from Contact where name like \'%'+Qstring+'%\' limit 50'; acu = database.query(queriC); } public pagereference OpenAc() { pagereference pgs = new pagereference('/' +SelectedId); pgs.setRedirect(true); return pgs; } public pagereference OpenCo() { return new pagereference('/'+Selectedcc); } }
-
- Anil Kumar Devarapu
- March 09, 2015
- Like
- 0
How to replace ' & ' with ' & ' in Jquery
I am using Auto complete component from here http://goo.gl/NMpwnH
I have Special Characters in My record name for Accouunt and Other objects,
when i focused or Selected the Names with Special Characters as encoded form, It displaying ' & ' as ' & '
I have posted my component Code below
please Anyone suggest me to replace ' & ' as ' & '
VF Component
<apex:component controller="autoCompleteController"> <apex:includeScript value="{!URLFOR($Resource.jqueryui18, 'js/jquery-1.7.1.min.js')}" /> <apex:includeScript value="{!URLFOR($Resource.jqueryui18, 'js/jquery-ui-1.8.18.custom.min.js')}" /> <apex:stylesheet value="{!URLFOR($Resource.jqueryui18, 'FlickTheme.css')}"/> <!-- Attributes Required For Component --> <apex:attribute name="objectname" description="The object name you want to look for." type="String" required="true"/> <apex:attribute name="additionalfield" description="Any additional fields you'd like to search and include in the display." type="String" required="false"/> <apex:attribute name="profilename" description="To filter on the basis of profile name and include in the display." type="String" required="false"/> <apex:attribute name="autocomplete_textbox" description="The ID for the Autocomplete List Textbox." type="String" required="true"/> <!-- CSS --> <style> .ui-autocomplete-loading {background: white url({!$Resource.loadingIcon}) right center no-repeat;} </style> <!-- Javascript --> <script type="text/javascript"> var j$ = jQuery.noConflict(); j$(document).ready(function() { var sObjects; var queryTerm; j$(esc('{!autocomplete_textbox}')).autocomplete({ minLength: 1, source: function(request, response) { queryTerm = request.term; autoCompleteController.findSObjects("{!objectname}", request.term, "{!additionalfield}", "{!profilename}", function(result, event){ if(event.type == 'exception') { alert(event.message); } else { sObjects = result; response(sObjects); } }); }, focus: function( event, ui ) { j$(esc('{!autocomplete_textbox}')).val(ui.item.Name); return false; }, select: function( event, ui ) { j$(esc('{!autocomplete_textbox}')).val( ui.item.Name ); j$(esc('{!autocomplete_textbox}_lkid')).val( ui.item.Id ); j$(esc('{!autocomplete_textbox}_lkold')).val( ui.item.Name ); if (event.keyCode == 13) { event.preventDefault(); } return false; }, }) .data( "autocomplete" )._renderItem = function( ul, item ) { var entry = item.Name; if("{!additionalfield}" !='') { j$.each("{!additionalfield}".split(",") , function(key, value) { entry = entry + " " + item[value]; }); } //entry = entry + "</a>"; //entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>"); entry = entry.replace( new RegExp( "(" + queryTerm + ")" , "g" ), "<strong>$1</strong>" ); return j$( "<li></li>" ) .data( "item.autocomplete", item ) .append( "<a>" + entry + "</a>") .appendTo( ul ); }; }); function esc(myid) { return '#' + myid.replace(/(:|\.\&)/g, '\\\\$1'); //return '#' + myid.replace(/&/g, '&') } </script> </apex:component>
Component Controller
global class autoCompleteController { @RemoteAction global static SObject[] findSObjects(string obj, string qry, string addFields, string profilename) { /* More than one field can be passed in the addFields parameter Split it into an array for later use */ List<String> fieldList=new List<String>(); if (addFields != '') fieldList = addFields.split(','); /* Check whether the object passed is valid */ Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); Schema.SObjectType sot = gd.get(obj); if (sot == null) { return null; } /* Creating the filter text */ String filter = ' like \'%' + String.escapeSingleQuotes(qry) + '%\''; /* Begin building the dynamic soql query */ String soql = 'SELECT Name'; /* If any additional field was passed, adding it to the soql */ if (fieldList.size()>0) { for (String s : fieldList) { soql += ', ' + s; } } /* Adding the object and filter by name to the soql */ soql += ' from ' + obj + ' where name' + filter; if(profilename!='') { //profile name and the System Administrator are allowed soql += ' and Profile.Name like \'%' + String.escapeSingleQuotes(profilename) + '%\''; system.debug('Profile:'+profilename+' and SOQL:'+soql); } /* Adding the filter for additional fields to the soql */ if (fieldList != null) { for (String s : fieldList) { soql += ' or ' + s + filter; } } soql += ' order by Name limit 20'; system.debug('Qry: '+soql); List<sObject> L = new List<sObject>(); try { L = Database.query(soql); } catch (QueryException e) { system.debug('Query Exception:'+e.getMessage()); return null; } return L; } }
Usage :
<apex:inputText label="Name :" value="{!name}" id="Text" required="true" html-autocomplete="on" html-PlaceHolder="Name.." html-inputtype="text" > <c:AutoCompleteComponent autocomplete_textbox="{!$Component.Text}" objectname="Account" /> </apex:inputtext>
ScreeenShot of Autocomplete
- Anil Kumar Devarapu
- August 08, 2015
- Like
- 0
Google chart not displayed on VF Page
I am New to salesforce i am looking for embedding a Google chart in visualforce, I found this following snippet in Saleforce developer forums, I just copy phasted this to observe the response, But i am not getting the desired Chart,
<apex:page controller="GoogleChartsController" sidebar="false"> <!-- Google API inclusion --> <apex:includeScript id="a" value="https://www.google.com/jsapi" /> <apex:sectionHeader title="Google Charts + Javascript Remoting" subtitle="Demoing - Opportunities by Exepected Revenue"/> <!-- Google Charts will be drawn in this DIV --> <div id="chartBlock" /> <script type="text/javascript"> // Load the Visualization API and the piechart package. google.load('visualization', '1.0', {'packages':['corechart']}); // Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(initCharts); function initCharts() { // Following the usual Remoting syntax // [<namespace>.]<controller>.<method>([params...,] <callbackFunction>(result, event) {...} // namespace : abhinav // controller : GoogleChartsController // method : loadOpps abhinav.GoogleChartsController.loadOpps( function(result, event){ // load Column chart var visualization = new google.visualization.ColumnChart(document.getElementById('chartBlock')); // Prepare table model for chart with columns var data = new google.visualization.DataTable(); data.addColumn('string', 'Opportunity'); data.addColumn('number', 'Expected Revenue'); data.addColumn('number', 'Amount'); // add rows from the remoting results for(var i =0; i<result.length;i++){ var r = result[i]; data.addRow([r.Name, r.ExpectedRevenue, r.Amount]); } // all done, lets draw the chart with some options to make it look nice. visualization.draw(data, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:window.innerWidth,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}}); }, {escape:true}); } </script> </apex:page> ------------------------------------------------------ global with sharing class GoogleChartsController { /** Loads most recent 10 Opportunities */ @RemoteAction global static Opportunity[] loadOpps() { return [select Id, Name, ExpectedRevenue, Amount from Opportunity order by CreatedDate DESC limit 10]; } }
I am looking for this,
- Anil Kumar Devarapu
- May 08, 2015
- Like
- 0
Salesforce Default LightBox(Jquery) is Not Displaying on VF Page
I am using Salesforce default lightbox on VF page using a Static Resource. Actually My intension is to display a popup of editing record in a page block which is embedded inside output panel as shown below screenshots
Please anyone reply me where i am wrong,
<apex:page controller="lightboxcls"> <apex:stylesheet value="{!URLFOR($Resource.XXofficeCSS, 'css/base.css')}"/> <apex:stylesheet value="{!URLFOR($Resource.XXofficeCSS, 'popup/reveal.css')}"/> <apex:includeScript value="{!URLFOR($Resource.XXofficeCSS, 'popup/jquery.min.js')}" /> <apex:includeScript value="{!URLFOR($Resource.XXofficeCSS, 'popup/jquery.reveal.js')}"/> <script type="text/javascript"> function fun(){ alert(document.getElementById('j_id0:j_id6:pb:j_id10:j_id11').value); if(document.getElementById('j_id0:j_id6:pb:j_id10:j_id11').value!=''){ $('#myModal1').trigger('reveal:close'); } } </script> <!--<apex:inputText value="{!name}"/>--> <apex:form > <apex:pageBlock mode="edit" > <!-- <apex:pageBlockSection title="All Contacts" collapsible="false" columns="1"> --> <apex:pageblockTable value="{!Acn}" var="a" > <a data-animation="fade" dragable="true" data-reveal-id="myModal1" style="display:block;text-decoration:underline;margin-left:6px;margin-top:5px;"> <apex:column headerValue="Action" > <apex:commandlink action="{!Edit}" id="processlblsSearch" immediate="true" >Edit <apex:param value="{!a.id}" name="Sel" assignTo="{!AId}" /> </apex:commandlink> </apex:column></a> <apex:column value="{!a.Name}" headerValue="Name" > </apex:column> <apex:column headerValue="Phone" value="{!a.phone}"> </apex:column> </apex:pageblockTable> </apex:pageBlock> <div id="myModal1" class="reveal-modal"> <a class="close-reveal-modal" style="text-decoration:none;">×</a> <apex:outputpanel layout="block" rendered="{!displayPopUp}" > <apex:pageBlock id="pb" mode="Edit"> <apex:pageBlockSection > <apex:inputField value="{!acnt.name}"/> <apex:inputField value="{!acnt.Phone}"/> <apex:commandButton value="Save" action="{!save}" reRender="pb" oncomplete="return fun()"/> </apex:pageBlockSection> </apex:pageBlock> </apex:outputpanel> <a class="close-reveal-modal" style="text-decoration:none;">×</a> </div> </apex:form> </apex:page> --------------------- Controller Below------------------------- public class lightboxcls { public boolean displayPopUp{get;set;} public Account Acnt{get;set;} public string Aid{get;set;} public list<account> Acn{get;set;} //public string name{get;set;} //public Account acc{get;set;} public lightboxcls() { displayPopUp=false; //acc=new Account(); Acn = new list<Account>(); Acn = [select id,name,phone from Account]; } public void save(){ displayPopUp=false; update Acnt; // acc=new Account(); } public void Edit() { displayPopUp=true; Acnt = new Account(); Acnt = [select id,Name,Email__c,Phone,Industry,AccountSource,Amount__c from Account where id=:Aid]; system.debug('------------------> ' +Acnt); system.debug('------This is Id------------> ' +Aid); } }
If you want My static resource used in this Page get it here,
https://drive.google.com/file/d/0B1wNUoOAwRhfTkUzdUdQQjlTUFE/view?usp=sharing
- Anil Kumar Devarapu
- May 01, 2015
- Like
- 0
Wraper class object List Rerendering Multiple times on VF Page
Hello there,
I have a inline edit VF page that is by using Wraper class. When ever i hit the command link Edit, The page block table again ReRendering and finally resulting, The same Page block table Repeats with same records. This is happening when i hit cancel button also.
Any one Please Help me, Thanks in advance
Here is my Snippet,
Page
----------------------------------------------------
<apex:page controller="OppDisplay2" >
<apex:form >
<apex:pageBlock id="pb" > <!--rerender="pb"-->
<apex:outputLabel >Opportunity Details</apex:outputLabel>
<apex:pageBlockTable value="{!Records}" var="o" id="pbt">
<apex:column headervalue="Action">
<apex:commandLink value="Edit" action="{!Edit}" rendered="{!Not(o.ren)}" > <!--rerender="pb"-->
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandLink>
<apex:commandlink value="Delete" action="{!Delete1}" rerender="pbt" >
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandlink>
<apex:commandLink value="Save" action="{!Save}" rerender="pb" rendered="{!o.ren}"> <!--rerender="pbt"-->
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandLink>
<apex:CommandLink value="Cancel" action="{!Cancel}" rerender="pbt" rendered="{!o.ren}" immediate="true">
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:CommandLink>
</apex:column>
<apex:column headervalue="Opportunity Name">
<apex:outputField value="{!o.opp.name}" rendered="{!Not(o.ren)}"/>
<apex:inputField value="{!o.opp.name}" rendered="{!o.ren}"/>
</apex:column>
<apex:column headervalue="Close Date">
<apex:outputfield value="{!o.opp.CloseDate}" rendered="{!Not(o.ren)}"/>
<apex:inputfield value="{!o.opp.CloseDate}" rendered="{!o.ren}"/>
</apex:column>
<apex:column headervalue="Stage Name">
<apex:outputfield value="{!o.opp.StageName}" rendered="{!Not(o.ren)}"/>
<apex:inputfield value="{!o.opp.StageName}" rendered="{!o.ren}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
--------------------------------------------------------------
/* Controller */
----------------------------------------------------------------
public class OppDisplay2 {
// Param object for selected row index
public integer rowindex1{get;set;}
public Id id1{get;set;}
public List<Opportunity> lstopp = new list<Opportunity>();
public List<Wraper> lstwrap=new List<Wraper>();
wraper wrapobj;
public OppDisplay2()
{
}
public class wraper
{
public Opportunity opp{get;set;}
public integer rowindex{get;set;}
public boolean ren{get;set;}
}
public List<wraper> getRecords()
{
lstopp= [select id,name,CloseDate, StageName from Opportunity limit 6];
for(integer i=0;i<lstopp.size();i++){
wrapobj=new wraper();
wrapobj.opp=lstopp[i];
wrapobj.rowindex=i;
wrapobj.ren=false;
lstwrap.add(wrapobj);
}
return lstwrap;
}
public pagereference Save(){
if(rowindex1<lstwrap.size()){
// Updating List with Specified rowindex value
update lstwrap[rowindex1].opp;
lstwrap[rowindex1].ren=false;
}
return null;
}
public pagereference Cancel(){
id1=wrapobj.opp.id;
Opportunity oppobj=[select name,CloseDate,StageName from Opportunity where id=:id1];
if(rowindex1<lstwrap.size()){
wrapobj.opp.Name=oppobj.Name;
wrapobj.opp.CloseDate=oppobj.CloseDate;
wrapobj.opp.StageName=oppobj.StageName;
lstwrap[rowindex1].ren=false;
}
return null;
}
public pageReference Edit(){
if(rowindex1<lstwrap.size()){
lstwrap[rowindex1].ren=true;
}
return null;
}
public pagereference Delete1(){
if(rowindex1<lstwrap.size()){
//Deleting in the Object
Delete lstwrap[rowindex1].opp;
//Deleting in the List
lstwrap.remove(rowIndex1);
}
return null;
}
}
- Anil Kumar Devarapu
- April 20, 2015
- Like
- 0
Is it possible to initialize / Call the Schedule Class in a trigger
Hello EveryOne,
I am new to salelsforce. i have a basic knowledge on Schedulable classes, can i schedule a class(using cron expression for every 5hrs) using (after insert) Trigger. And Assuming that my Schedule class calls(creates an instance for) Another Batch Apex. i had known that, Every time of an insert of record a Job is Qued and I think All this can also be achived with simply After Insert Trigger(without batch and Schedular Class)
Is this really Possible to schedule a Class using(inside) a Trigger. Any one clarify me,
Thanks in Advance
- Anil Kumar Devarapu
- April 17, 2015
- Like
- 0
Page message text not visible
//VF Page <apex:page controller="SearchAllCntrlr" > <apex:form > <apex:pageMessage summary=" <b>{!qc}</b> " severity="Confirm" strength="3" rendered="{!IF((acl.size>0)||(acu.size>0),true,false)}" escape="false"/> <apex:pageBlock title="Search Keyword"> <apex:inputText value="{!Qstring}" label="Input" /> <apex:commandButton value="Search records" action="{!search}" /><br></br><br></br> Eg: Anil </apex:pageBlock> <apex:pageBlock title="Account Result" rendered="{!acl.size!=0}"> <apex:pageblockTable value="{!acl}" var="a" > <apex:column HeaderValue="Accounts"> <!--<apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>--> <apex:commandLink action="{!openAc}"> <apex:param name="SelectedId" assignTo="{!selectedId}" value="{!a.id}"/>{!a.name}</apex:commandlink> </apex:column> <apex:column value="{!a.id}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Contact Result" rendered="{!acu.size!=0}"> <apex:pageblockTable value="{!acu}" var="b"> <apex:column headerValue="Contacts"> <apex:commandLink action="{!Openco}"> <apex:param name="SelectedC" value="{!b.id}" assignTo="{!SelectedCC}"/>{!b.name}</apex:commandlink> </apex:column> </apex:pageblockTable> </apex:pageblock> <apex:pageMessages escape="false"/> </apex:form> </apex:page> ________________ //CONTROLLER public class SearchAllCntrlr { public string SelectedId{get;set;} public string selectedcc{get;set;} public list<account> acl{get;set;} public list<contact> acu{get;set;} public string queri,queriC; public string qc{get;set;} public string Qstring{get;set;} public string getqcp() { if(Qstring=='') { qc = 'You are viewing all Contacts and Accounts'; } else { qc='Search Results for <b>"'+qstring+' "</b>';} return qc; } public void search() { ASearch(); CSearch(); if(Qstring=='') { apexpages.Message msa = new Apexpages.Message(ApexPages.Severity.Confirm,'<b>You are Viewing All Accounts and Contacts</b> '); apexpages.addmessage(msa); } if(acu.size()==0&&acl.size()==0) { apexpages.Message msa = new Apexpages.Message(ApexPages.Severity.FATAL,'There were no Results found for <b> "'+qstring+' " </b> '); apexpages.addmessage(msa); } else if(acl.size()==0) { apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'There were no Results found on Accounts for <b>"'+qstring+' "</b> '); apexpages.addmessage(msg); } else if(acu.size()==0) { apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'There were no Results found on Contacts for <b> "'+qstring+' " </b> '); apexpages.addmessage(msg); } } public SearchAllCntrlr() { //displ=true; acl = new list<account>(); acu = new list<contact>(); } public void ASearch() { queri = 'Select name from account where name like \'%'+Qstring+'%\' limit 50'; acl = database.query(queri ); } public void CSearch() { queriC = 'Select name from Contact where name like \'%'+Qstring+'%\' limit 50'; acu = database.query(queriC); } public pagereference OpenAc() { pagereference pgs = new pagereference('/' +SelectedId); pgs.setRedirect(true); return pgs; } public pagereference OpenCo() { return new pagereference('/'+Selectedcc); } }
- Anil Kumar Devarapu
- March 09, 2015
- Like
- 0
Apex/Visualforce - Issue with "rerender" Attribute When Trying to Refresh pageBlockTable
I’ve recently encountered a problem with a project that I’m working on. I’m trying to dynamically rerender a pageBlockTable after the list it references to has been updated. I’ve been looking around the web for any possible solution to this issue, but with no success. I was wondering if any developers out there would mind looking through my code and help me debug this issue.
Background:
I have a visualforce page that has two tabs. One tab allows the user to search for contact records and then add any selected contact records to a new custom object record with a master-detail relationship. The second tab is used to list the 20 most recent of these “contact record lists” and allow the user to view all the children of each of these custom lists. The ideal user experience should be that the user searches for a list of contact records, the user adds them to a list, the user then clicks the second tab, and the user sees the newly created custom list in the pageBlockTable that houses all recent “custom record lists”.
Issue:
I was able to get the functionality to work, but the user is not able to see the newly created list in real time. In order to see it the user must refresh the page.
Code:
VF Page:
<apex:page controller="mLSearchController"> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <style> ... </style> </head> <body> <apex:form id="mLSearch"> <apex:sectionHeader title="Marketing List Search" help="http://developer.force.com"/> <apex:tabPanel switchType="client" selectedTab="mainTab" id="mLTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" > ... <!-- TAB 2: LISTS --> <apex:tab label="Lists" name="savedTab" id="searchTab2" style="font-size:12px;"> <apex:pageBlock id="containerResults" title="Lists" mode="edit"> <apex:actionFunction action="{!selectContainer}" name="selectContainer" rerender="listResults"> <apex:param name="container_sel_mL" value="" /> </apex:actionFunction> <apex:actionFunction action="{!doNothing}" name="rerenderContainers" rerender="containerResults"/> <apex:actionFunction action="{!updateMLContainers}" name="updateContainers" rerender="containerResults"/> ... </apex:tabPanel> </apex:form> <div id="opaque"/> <div id="popupcontent1" class="popupcontent"> <apex:form id="popup001"> <apex:pageBlock title="My Content" mode="edit"> <apex:pageBlockButtons> <input type="button" class="btn" onclick="passListName();" Value="Create New List"/> <apex:commandButton action="{!createList}" value="Create List"/> </apex:pageBlockButtons> <apex:pageBlockSection title="My Content Section1" columns="1"> <p>Industry:</p> <input type="text" name="mLName" id="container_name_mL"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </div> <script type="text/javascript"> function passListName() { var x = j$('#container_name_mL').val(); if ((x!=null && x!="") && (x.length < 20)) { createNewList( document.getElementById("container_name_mL").value ); hidepopup(); updateContainers(); rerenderContainers(); prependColumns(); } else { alert("You must enter name that is less than 20 characters."); return false; } } function showpopup() { document.getElementById('opaque').style.display='block'; var popUp = document.getElementById("popupcontent1"); popUp.style.display = "block"; } function hidepopup() { var popUp = document.getElementById("popupcontent1"); popUp.style.display = "none"; document.getElementById('opaque').style.display='none'; } function prependColumns() { j$('.inputSection span').wrap("<a class='linkSelector' onclick='selConFunction(this)'></a>"); } function selConFunction(e) { var containerString = j$(e).find('span').text(); selectContainer(containerString); return false; } </script> </body> <!-- All "..." in the document signify excerpts that were taken out because they were irrelevant. --> </apex:page>Apex Controller:
public with sharing class mLSearchController { private String soqlContainer {get;set;} private String soqlMList {get;set;} public List<contactWrapper> contacts {get;set;} // this is the list of contacts queried from the search page public List<contactWrapper> leadList {get;set;} // this is the list of leads queried from the search page public List<ML_List_Container__c> containerList {get;set;} public List<ML_List__c> mList {get;set;} public List<contactWrapper> selectedList { get { if (selectedList == null) selectedList = new List<contactWrapper>(); return selectedList; } set; } public mLSearchController() { updateMLContainers(); } ... public PageReference createList(){ List<ML_List__c> batchList = new List<ML_List__c>(); ML_List_Container__c newContainer = new ML_List_Container__c(); String container_name_mL = Apexpages.currentPage().getParameters().get('container_name_mL'); selectedList.clear(); for (contactWrapper cw : contacts) { if (cw.checked) selectedList.add(new contactWrapper(cw.conObj)); } for (contactWrapper cwL : leadList) { if (cwL.checked) selectedList.add(new contactWrapper(cwL.leadObj)); } newContainer.Name = container_name_mL; try { insert newContainer; } catch (Exception e) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'ERROR - Something is wrong...')); } for (contactWrapper newItem : selectedList) { ML_List__c newListItem = new ML_List__c(); newListItem.ML_List_Container__c = newContainer.Id; if (newItem.conObj != null) { newListItem.Name = newItem.conObj.Name; newListItem.Contact__c = newItem.conObj.Id; batchList.add(newListItem); } else if (newItem.leadObj != null) { newListItem.Name = newItem.leadObj.Name; newListItem.Lead__c = newItem.leadObj.Id; batchList.add(newListItem); } } insert batchList; return null; } public PageReference doNothing() { return null; } public PageReference selectContainer() { String container_sel_mL = Apexpages.currentPage().getParameters().get('container_sel_mL'); soqlMList = 'SELECT Name, Contact__c, Lead__c FROM ML_List__c where ML_List_Container__r.Name = :container_sel_mL'; mList = Database.query(soqlMList); return null; } public PageReference updateMLContainers() { soqlContainer = 'SELECT Name, CreatedDate FROM ML_List_Container__c ORDER BY CreatedDate desc LIMIT 20'; containerList = Database.query(soqlContainer); system.debug('Well, I think that something is off...'); return null; } } // All "..." in the document signify excerpts that were taken out because they were irrelevant.
Failed Solutions:
- Directing “rerendering” to the id attribute in the pageBlockTable
- Directing “rerendering” to the id attribute in the pageBlock
- Wrapping outputPanel around the desired pageBlockTable, and directing “rerendering” to the id attribute in the outputPanel
- Even tried using javascript to set a timed rerender function that would just rerender the desired section after 2 seconds.
Conclusion:
At this point, I’m pretty stumped as to why the pageBlockTable is not rerendering. I was hoping that some developers out there might be kind enough to help me out with this problem. Thanks so much for your time. Any and all suggestions/ideas are greatly appreciated.
- Thomas Fuller
- July 30, 2014
- Like
- 0
How to use the Lightbox Visualforce component provided by force.com labs to call a visualforce page
Has anyone used the Lightbox Visualforce component provided by force.com labs to call a visualforce page
The link for the App on Appexchage is
http://sites.force.com/appexchange/apex/listingDetail?listingId=a0N30000001g3u0EAA
This is a free app which has a visual force component <c:lightbox>
I want to show some visuaforce code in it.
thanks
- p999_dfs
- December 17, 2009
- Like
- 0
ADM 201 Exam sample papers
Hi,
Can you please share with me ADM 201 sample papers. I am planned to write the exam!
Your help will be appreciated...
- Legendary Performance
- May 24, 2011
- Like
- 1