- Mohan Raj 33
- NEWBIE
- 234 Points
- Member since 2016
- Developer
- Soft Square
-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
38Questions
-
65Replies
Jquery data table provide a milliseconds format in date value column
controller:
//Remote function using updated the owner of the task public class TaskOwnerUpdate { public String dueDate { get; set; } public Set<Id> selectedTaskIdSet {get; set;} String ownerIdValue {get; set;} String selectedColumnValue {get; set;} public static List<Task> taskList { get; set;} public TaskOwnerUpdate() { } // empty constructor public List<Task>selectedtaskList {get; set;} public Task getOwnerIdTask() { return [SELECT OwnerId FROM TASK LIMIT 1]; } @RemoteAction public static List<Task> getTask (String dueDate) { system.debug('dueDate value is------>'+dueDate); List<String> stList = dueDate.split('"'); system.debug('stList value---->'+stList); List<String>s1 = stList[0].split(','); system.debug('stList[0] value is---->'+stList[0]); system.debug('stList[1] value is---->'+stList[1]); List<String> splitList = stList[1].split('/'); system.debug('splitList value is---->'+splitList); String dueDate1 = splitList[2]+'-'+splitList[0]+'-'+splitList[1]; taskList = [SELECT Id, Subject, Priority, Status, ActivityDate, Owner.Name, OwnerId FROM Task WHERE ActivityDate >= :Date.valueOf(dueDate1)]; system.debug('taskList- value is------>'+taskList); return taskList; } @RemoteAction public static List<Task> updateTask(String ownerIdValue, String selectedColumnValue ) { system.debug('OwnerId value is----->'+ownerIdValue); system.debug('selectedColumnValue value is---->'+selectedColumnValue); List<Task> updatedTaskList = new List<Task>(); Set<Id> idSet = new Set<Id>(); List<String> deserializeStringList = (List<String>)System.JSON.deserialize(selectedColumnValue, List<String>.class); system.debug('deserializeStringList value>>>>'+deserializeStringList); for (String strRecord : deserializeStringList) { Task taskRecord = new Task(); taskRecord.Id = Id.valueOf(strRecord); taskRecord.OwnerId = Id.valueOf(ownerIdValue); updatedTaskList.add(taskRecord); } if (updatedTaskList.size() > 0) { Update updatedTaskList; } return updatedTaskList; } }
page:
<apex:page controller="TaskOwnerUpdate"> <apex:form> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"/> <apex:includeScript value="https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"/> <apex:sectionHeader title="Task Ownership Update"/> <apex:pageBlock title="Tasks"> <!---- Section to draw search field for account-------> <apex:pageBlockSection title="Search Tasks" columns="2"> <apex:pageBlockSectionItem > <apex:inputText value="{!dueDate}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false)">dueDate</apex:inputText> <apex:inputField value="{!OwnerIdTask.OwnerId}" id="owner"></apex:inputField> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection > <button onclick="getTask();return false;">Get Task</button> <button id = "button">Update</button> </apex:pageBlockSection> <apex:actionFunction name="callaction" oncomplete="getTask()" reRender="output"/> <!-- result section for showing matching accounts -------> <apex:outputPanel id="output"> <apex:pageBlockSection title="Matching Tasks !" columns="1"> <!-- Created Empty table using the CSS styles of visualforce pageBlockTable This gives same look and feel ------> <table cellspacing="0" cellpadding="0" border="0" id="searchResults" class="list "> <colgroup span="2"></colgroup> <thead class="rich-table-thead"> <tr class="headerRow "> <th colspan="1" scope="col" class="headerRow">Select</th> <!--<th colspan="1" scope="col" class="headerRow">Id</th>----> <th colspan="1" scope="col" class="headerRow">Subject</th> <th colspan="1" scope="col" class="headerRow">Priority</th> <th colspan="1" scope="col" class="headerRow">Status</th> <th colspan="1" scope="col" class="headerRow">ActivityDate</th> <th colspan="1" scope="col" class="headerRow">OwnerName</th> </tr> </thead> <!-- table body left empty for populating via row template using jquery-------> <tbody /> </table> </apex:pageBlockSection> </apex:outputPanel> <script id="resultTableRowTemplate" type="text/x-jquery-tmpl"> <tr onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}" onmouseout="if (window.hiOff){hiOff(this);} " onmouseover="if (window.hiOn){hiOn(this);} " class="dataRow even first"> <td class="datacel">${Select}<input type = "checkbox" id="${Id}"/></td> <!---<td class="Idvalue">${Id}</td>------> <td class="datacell">${Subject}</td> <td class="dataCell">${Priority}</td> <td class="dataCell">${Status}</td> <td class="datecell">${ActivityDate}</td> <td class="datacell">${Owner.Name}</td> </tr> </script> </apex:pageBlock> <script type="text/javascript"> // if you are inside some component // use jquery nonConflict // var t$ = jQuery.noConflict(); console.log("check call correct"); function getTask() { var dueDate = $('[id$=":demo"]').val();//$('#demo').val(); console.log("check data",dueDate); // clear previous results, if any $("#searchResults tbody").html(''); // The Spring-11 gift from force.com. Javascript remoting fires here // Please note "abhinav" if my org wide namespace prefix // testremotingcontroller is the Apex controller // searchAccounts is Apex Controller method demarcated with @RemoteAction annotation. // DEPRECATED - abhinav.testremotingcontroller.searchAccounts( accountName, ...) // NEW - summer'12 approach for calling' dueDate = JSON.stringify(dueDate); Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.getTask}', dueDate, function(result, event){ console.log("due date",dueDate); if (event.status && event.result) { $.each(event.result, function () { // for each result, apply it to template and append generated markup // to the results table body. $("#resultTableRowTemplate" ).tmpl(this).appendTo( "#searchResults tbody" ); } ); } else { alert(event.message); } }, {escape:true}); } </script> <script type="text/javascript"> console.log("check update correct"); $(function () { $('.datacel').click(function() { var allData = $(this).parent().parent().first().text(); console.log("allData value is>>>>",allData); //alert(allData); }); $('input:not(#button)').click(function () { t = $(this).attr('id'); text = $('.time' + t).text(); //alert(text); }); $('#button').click(function (e) { e.preventDefault(); var trs = $('table tr'); var values = trs.first().find('td'); // var idr = $('#Idvalue').val(); // console.log("idr value",idr); var values1 = $('table tr td :checkbox:checked').map(function () { console.log('\nId::::',$(this).attr('id')); return $(this).attr('id'); /*return $(this).closest('tr').find('td').text() + "==" + values.eq($(this).parent().index()).text(); console.log("id val",$(this).parent().find('td').eq(1).text()); return $(this).closest('td').find('td').eq(1).text()+ values.eq($(this).parent().intex()).text();*/ }).get(); console.log("values1",values1); getUpdate(values1); console.log("after passing vales1", values1); console.log("values1",values1); return values1; }); //alert(values1); //console.log("values1",values1); //return values1; //getUpdate(values1); }); function getUpdate(values1) { var taskRecord = JSON.stringify(values1); console.log("data type taskRecord",typeof(taskRecord)); console.log("task record value is>>>",taskRecord); var ownerIdValue = $('[id$="owner_lkid"]').val(); console.log("data type ownerIdValue",typeof(ownerIdValue)); //var ownerIdValue = document.getElementById('{!$Component.owner}').value; console.log("ownerId value is >>>>",ownerIdValue); console.log("values1 >>>>",values1); Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.updateTask}', ownerIdValue, taskRecord, function(result, event){ if (event.status) { callaction(); } else { } }, {escape:true}); } </script> </apex:form> </apex:page>
For any response appreciated!!!!
- Mohan Raj 33
- February 02, 2017
- Like
- 0
How to write a test class for the update scenario?
public class CustomSyncHandler { public static void UpdateTrigger (List<QuoteLineItem> InsertedQuote, Map<Id,QuoteLineItem> OldInsertedQuoteMap) { Set<Id> ProductIdset = new Set<Id>(); Set<Id> QuoteIdset = new Set<Id>(); Set<Id> OpportunityIdset = new Set<Id>(); List<QuoteLineItem> QuoteLineItemList = new List<QuoteLineItem>(); List<OpportunityLineItem> OpportunityLineItemList = new List<OpportunityLineItem>(); for (QuoteLineItem RecordQuoteItem: InsertedQuote) { QuoteLineItem OldQuoteLineItemREC = OldInsertedQuoteMap.get(RecordQuoteItem.Id); if (OldQuoteLineItemREC.SyncCheck__c != RecordQuoteItem.SyncCheck__c) { ProductIdset.add(RecordQuoteItem.Product2Id); QuoteIdset.add(RecordQuoteItem.QuoteId); } } If (QuoteIdset.size()>0) { QuoteLineItemList = [SELECT Id, QuoteId, Product2Id, SyncCheck__c, Quote.issyncing, Quote.OpportunityId FROM QuoteLineItem WHERE Product2Id IN :ProductIdset AND Quote.issyncing = True ]; } If (QuoteLineItemList.size() > 0) { for (QuoteLineItem quoteLineitemvalue: QuoteLineItemList) { OpportunityIdset.add(quoteLineitemvalue.Quote.OpportunityId); } } List<OpportunityLineItem> OpportunityLineitemvalueList = [SELECT Id, Name, OpportunityId, SyncCheck__c, Product2Id FROM OpportunityLineItem WHERE OpportunityId IN :OpportunityIdset AND Product2Id IN :ProductIdset]; Map<Id, List<OpportunityLineItem>> OpportunityandOppolineitemMap = new Map<Id, List<OpportunityLineItem>>(); for (OpportunityLineItem OpportunityLIRecord : OpportunityLineitemvalueList) { If (!OpportunityandOppolineitemMap.Containskey(OpportunityLIRecord.Id)) { OpportunityandOppolineitemMap.put(OpportunityLIRecord.OpportunityId, new List<OpportunityLineItem>()); } OpportunityandOppolineitemMap.get(OpportunityLIRecord.OpportunityId).add(OpportunityLIRecord); } system.debug('@@@ OpportunityandOppolineitemMap value is'+OpportunityandOppolineitemMap); for (QuoteLineItem QuoteLineItemRecord : QuoteLineItemList) { if (OpportunityandOppolineitemMap.containsKey(QuoteLineItemRecord.Quote.OpportunityId)) { for (OpportunityLineItem OpporVar : OpportunityandOppolineitemMap.get(QuoteLineItemRecord.Quote.OpportunityId)) { if (OpporVar.Product2Id == QuoteLineItemRecord.Product2Id) { OpporVar.SyncCheck__c = QuoteLineItemRecord.SyncCheck__c; OpportunityLineItemList.add(OpporVar); } } } } if (OpportunityLineItemList.size() > 0) { Update OpportunityLineItemList; } } }
Here I have the custom field for the sobjects of OpportunityLineItem AND QuoteLineItem as named SyncCheck__c it's to be in here I am providing the condititon to the quote to that appropriate(own) opportunity to they SYNC to that condition if I write some thing on the QuoteLineItem field as SyncCheck__c to be updatesd to the same Opportunities Line Item field in the Product of the same opportunity having the same name field SyncCheck__c is to be updated.
if you not understand clearly do following for check:
- Provide the startsync to the condition to the quote to that related opportunity.
- To create a new QuoteLine Item to that Quote.
- And write any word to the field in the quote Line Item to that field in named SyncCheck__c to some thing.((ex) In QuoteLine Item: SyncCheck__c = 'check';)
- Then come to the Opportunity Line Item to the to preview it's should be updated to the opportunityLine item to field named SyncCheck__c then here the same word is updated.((ex) In OpportunityLineitem SyncCheck__c = 'check' ;
- Mohan Raj 33
- November 14, 2016
- Like
- 0
Count the number of converted leads to be in the particular account by trigger
For My trying trigger is followingly,
public class LeadConversionIndicationHandler { Public static void insertTrigger(List<Lead> LeadConvert){ Map<Id,Integer> NumberofconvertedLeads=new Map<Id,Integer>(); for(Lead j:LeadConvert){ if(NumberofconvertedLeads.get(j.AccountId)==Null){ NumberofconvertedLeads.put(j.AccountId,1); } else{ NumberofconvertedLeads.put(j.AccountId,NumberofconvertedLeads.get(j.AccountId)+1); } Set<id> setofid=NumberofconvertedLeads.keySet(); List<Account> acctoupdate=[SELECT Id,Number_of_converted_Leads__c FROM Account WHERE Id IN :setofid]; List<Account> listone=new List<Account>(); for(Account a:acctoupdate){ if(a.Number_of_converted_Leads__c==Null) a.Number_of_converted_Leads__c=0; a.Number_of_converted_Leads__c=a.Number_of_converted_Leads__c+NumberofconvertedLeads.get(a.Id); listone.add(a); } Update listone; } } }
If it very worst I apologize for that becoz I got the error in AccountId field is invalid for lead sobject here I am try to once the lead converted it's has the accountId so that's my concept to do in this trigger so please help me to done this function.
My requirements are followingly,
1.I have a account has the number field(number of convertedleads) for counting the number of converted leads for that account(it's a number field).
2.here Once the lead is to be converted to the particular account that account having the number of convertedleads that field is to be incremented the value by one on after the lead should be converted.
3. Once I deleted the converted lead record on the particular account the account field (number of convertedleads) has to be decreased the value by one in automatically.
this are all achieved by trigger on lead sobject.
thank you,Mohan
- Mohan Raj 33
- November 02, 2016
- Like
- 0
How to write a code for button New account for creating new account in standard controller with extension?
My controller,
public class StandardPaginationSorting { // Variables required for Sorting. public String soql {get;set;} public List <Account> CandidateList1 = New List <Account>(); public String soqlsort {get;set;} public List <Account> CandidateList2 = New List <Account>(); public List<Account> acc {get; set;} public List<Account> editdel {get; set;} // List used in to display the table in VF page. public List<Account> getCandidateList() { // Passing the values of list to VF page. return con.getRecords(); //all(); } // instantiate the StandardSetController from a query locator public StandardPaginationSorting(ApexPages.StandardController controller){ con.getRecords(); all(); LoadData(); } public ApexPages.StandardSetController con { get { if(con == null) { // String Query to have a list of cases for a respective End-user. soql = 'SELECT Name, Website, BillingCountry, Phone, Type, Owner.Name FROM Account'; // Passing the String array to a list with Selected field sorting. CandidateList1 = Database.query(soql + ' order by ' + sortField + ' ' + sortDir ); // setting values of List in StandardSetController. con = new ApexPages.StandardSetController(CandidateList1); // sets the number of records in each page set con.setPageSize(10); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } // Method for Constructor is used for Test Class. public StandardPaginationSorting(){ //all(); } //Toggles the sorting of query from asc<-->desc public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again for sorting other columns soqlsort = 'SELECT Id, Name, Phone, BillingCountry, Website, Owner.Name, Type FROM Account'; // Adding String array to a List array CandidateList2 = Database.query(soqlsort + ' order by ' + sortField + ' ' + sortDir ); // Adding Caselist to Standard Pagination controller variable con = new ApexPages.StandardSetController(CandidateList2); // Set Page Size to 10 con.setPageSize(10); } // the current sort direction. defaults to asc public String sortDir { // To set a Direction either in ascending order or descending order. get { if (sortDir == null) { sortDir = 'asc';} return sortDir;} set; } // the current field to sort by. defaults to last name public String sortField { // To set a Field for sorting. get { if (sortField == null) {sortField = 'Name'; } return sortField; } set; } ///For refresh function button public PageReference Refresh() { PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl()); pageRef.setRedirect(true); return pageRef; } //For the New Account Button String accnew = 'eeee'; public PageReference NewAccount() { Pagereference Newacc = new PageReference(ApexPages.currentPage().getUrl()); Newacc.setRedirect(); return Newacc; } // the edit and delete link function ////used to get a hold of the account record selected for deletion public string selectedAccountId {get; set;} public void LoadData() { editdel = [SELECT Id, Name, Phone, BillingCountry, Website, Owner.Name, Type FROM Account]; con = new ApexPages.StandardSetController(editdel); con.SetPageSize(10); } public void deleteAccount() { If(selectedAccountId == Null){ system.debug('@@@@@@@@@@@@@@@@'+selectedAccountId); return; } //Find account record with in collection Account deleteacc = Null; For(Account a : editdel) If(a.Id == selectedAccountId){ deleteacc = a; system.debug ('@@@@@@@@@@@@@@@@@@'+a); //Delete deleteacc; break; } //If account record found to delete it If(deleteacc != Null) { Delete deleteacc; } //refresh the dataList LoadData(); } //the alpha bar navigation filter String A; public PageReference aaa() { A = 'a'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+A+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String B; public PageReference bbb() { B = 'b'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+B+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String C; public PageReference ccc() { C = 'c'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+C+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String D; public PageReference ddd() { D = 'd'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+D+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String E; public PageReference eee() { E = 'e'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+E+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String F; public PageReference fff() { F = 'f'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+F+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String G; public PageReference ggg() { G = 'g'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+G+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String H; public PageReference hhh() { H = 'h'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+H+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String I; public PageReference iii() { I = 'i'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+I+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String J; public PageReference jjj() { J = 'j'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+J+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String K; public PageReference kkk() { K = 'k'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+K+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String L; public PageReference lll() { L = 'l'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+L+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String M; public PageReference mmm() { M = 'm'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+M+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String N; public PageReference nnn() { N = 'n'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+N+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String O; public PageReference ooo() { O = 'o'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+O+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } String P; public PageReference ppp() { P = 'p'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+P+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String Q; public PageReference qqq() { Q = 'q'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+Q+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String R; public PageReference rrr() { R = 'r'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+R+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String S; public PageReference sss() { S = 's'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+S+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String T; public PageReference ttt() { T = 't'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+T+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String U; public PageReference uuu() { U = 'u'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+U+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String V; public PageReference vvv() { V = 'v'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+V+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String W; public PageReference www() { W = 'w'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+W+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String X; public PageReference xxx() { X = 'x'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+X+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String Y; public PageReference yyy() { Y = 'y'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+Y+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } String Z; public PageReference zzz() { Z = 'z'; acc.clear(); String qry = 'SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account WHERE Name LIKE \''+Z+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return Null; } public void all() { acc = [SELECT Name, Phone, Type, Owner.Name, BillingCountry, Website FROM Account]; con = new ApexPages.StandardSetController(acc); con.setpagesize(10); } }
My Page,
<apex:page standardController="Account" extensions="StandardPaginationSorting" showHeader="false" sidebar="false" applyHtmlTag="true"> <!-- CSS added to display alternate row colors and Center align Text in PageblockTable --> <!--<style type="text/css"> .oddrow{background-color: #00FFFF; } .evenrow{background-color: #7FFFD4; } .textalign{text-align:center; } </style>---> <apex:form id="form"> <!-- Tabstyle attribute is used to assign the color scheme to the pageblock.Here Candidate Object color scheme is used for the pageblock--> <apex:pageBlock id="pgblock" tabStyle="Account"> <!--<apex:pageBlockSection title="Candidate Details - Page #{!pageNumber}" columns="1" collapsible="false">--> <!-- Rowclasses attribute is used to define different CSS classes for different rows. Rules attribute is used: borders drawn between cells in the page block table. Title attribute will be used as a help text when a user hovers mouse over the Page Block table. Styleclass, HeaderClass attributes are used to Center align Table Text in Page Block table ---> <!--refresh the page and showing the same result of this refresh button---> <apex:pageBlockButtons location="top"> <apex:commandButton value="Refresh" action="{!Refresh}" /> <!-- <apex:commandButton onclick="{!NewAccount()}" value="Newaccount"/>---> </apex:pageBlockButtons> <right> <apex:toolbar id="toolbar" width="100" height="10" style="background-color:White;background-image:none;"> <right><apex:toolbarGroup itemSeparator="line"> <apex:commandLink value="A" Action="{!aaa}"/> <apex:commandLink value="B" Action="{!bbb}"/> <apex:commandLink value="C" Action="{!ccc}"/> <apex:commandLink value="D" Action="{!ddd}"/> <apex:commandLink value="E" Action="{!eee}"/> <apex:commandLink value="F" Action="{!fff}"/> <apex:commandLink value="G" Action="{!ggg}"/> <apex:commandLink value="H" Action="{!hhh}"/> <apex:commandLink value="I" Action="{!iii}"/> <apex:commandLink value="J" Action="{!jjj}"/> <apex:commandLink value="K" Action="{!kkk}"/> <apex:commandLink value="L" Action="{!lll}"/> <apex:commandLink value="M" Action="{!mmm}"/> <apex:commandLink value="N" Action="{!nnn}"/> <apex:commandLink value="O" Action="{!ooo}"/> <apex:commandLink value="P" Action="{!ppp}"/> <apex:commandLink value="Q" Action="{!qqq}"/> <apex:commandLink value="R" Action="{!rrr}"/> <apex:commandLink value="S" Action="{!sss}"/> <apex:commandLink value="T" Action="{!ttt}"/> <apex:commandLink value="U" Action="{!uuu}"/> <apex:commandLink value="V" Action="{!vvv}"/> <apex:commandLink value="W" Action="{!www}"/> <apex:commandLink value="X" Action="{!xxx}"/> <apex:commandLink value="Y" Action="{!yyy}"/> <apex:commandLink value="Z" Action="{!zzz}"/> <apex:commandLink value="All" Action="{!all}"/> </apex:toolbarGroup></right> </apex:toolbar> </right> <apex:pageBlockTable value="{!CandidateList}" var="CadList" title="Click Column Header for Sorting" styleclass="textalign" headerClass="textalign" > <apex:column headerValue="Action"> <apex:outputLink value="/{!CadList.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> | <a href="javascript:if (window.confirm('Are you sure?')) deleteAccount('{!CadList.Id}');" style="font-weight:bold">Del</a> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Name" action="{!toggleSort}" rerender="pgblock"> <!-- Value attribute should have field (API Name) to sort in asc or desc order --> <apex:param name="sortField" value="Name" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputLink value="/{!CadList.Id}" target="_blank">{!CadList.Name}</apex:outputLink> <!--<apex:outputField value="{!CadList.Name}"/>--> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Phone" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Phone" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Phone}"/> </apex:column> <!-- <apex:column > <apex:facet name="header"> <apex:commandLink value="Name" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Email" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Email}"/> </apex:column>--> <apex:column > <apex:facet name="header"> <apex:commandLink value="Type" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Type" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Type}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="OwnerName" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Owner.Name" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Owner.Name}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Website" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Website" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Website}"/> </apex:column> </apex:pageBlockTable> <!---</apex:pageBlockSection>----> <apex:panelGrid columns="6"> <apex:commandLink action="{!first}">First</apex:commandlink> <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink> <apex:commandLink action="{!last}">Last</apex:commandlink> <apex:inputText value="{!pageNumber}"> PageNumber</apex:inputText> of 4 </apex:panelGrid> </apex:pageBlock> <apex:actionFunction action="{!deleteAccount}" name="deleteAccount" reRender="form" > <apex:param name="accountid" value="" assignTo="{!selectedAccountId}"/> </apex:actionFunction> </apex:form> </apex:page>Here I want the button name: New button.
it's function : when I clicked the button it's redirect me to the account creation page if I click the cancel it's return to the current(previous)
output page. or it's returned the output page of the my visual page after creating the account.
For answer'sthanks in advance
- Mohan Raj 33
- November 01, 2016
- Like
- 0
SObject row was retrieved via SOQL without querying the requested field: Account.Phone
So that's why I getting this error I don't know to how to rectify this error so can any one help me to solve the error.
My controller:
public class StandardPaginationSorting { // Variables required for Sorting. public String soql {get;set;} public List <Account> CandidateList1 = New List <Account>(); public String soqlsort {get;set;} public List <Account> CandidateList2 = New List <Account>(); public List<Account> acc {get; set;} // List used in to display the table in VF page. public List<Account> getCandidateList() { // Passing the values of list to VF page. return con.getRecords(); //all(); } // instantiate the StandardSetController from a query locator public StandardPaginationSorting(ApexPages.StandardController controller){ con.getRecords(); all(); } public ApexPages.StandardSetController con { get { if(con == null) { // String Query to have a list of cases for a respective End-user. soql = 'SELECT Name, Website,BillingCountry, Phone, Type, Owner.Name FROM Account'; // Passing the String array to a list with Selected field sorting. CandidateList1 = Database.query(soql + ' order by ' + sortField + ' ' + sortDir ); // setting values of List in StandardSetController. con = new ApexPages.StandardSetController(CandidateList1); // sets the number of records in each page set con.setPageSize(10); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } // Method for Constructor is used for Test Class. public StandardPaginationSorting(){ //all(); } //Toggles the sorting of query from asc<-->desc public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again for sorting other columns soqlsort = 'SELECT Name, Phone, BillingCountry, Website, Owner.Name, Type FROM Account'; // Adding String array to a List array CandidateList2 = Database.query(soqlsort + ' order by ' + sortField + ' ' + sortDir ); // Adding Caselist to Standard Pagination controller variable con = new ApexPages.StandardSetController(CandidateList2); // Set Page Size to 10 con.setPageSize(10); } // the current sort direction. defaults to asc public String sortDir { // To set a Direction either in ascending order or descending order. get { if (sortDir == null) { sortDir = 'asc';} return sortDir;} set; } // the current field to sort by. defaults to last name public String sortField { // To set a Field for sorting. get { if (sortField == null) {sortField = 'Name'; } return sortField; } set; } //the alpha bar navigation filter public PageReference ggg() { return null; } public PageReference eee() { return Null; } Public PageReference ddd() { return Null; } Public PageReference ccc() { return Null; } Public PageReference bbb() { return Null; } string x; public PageReference fff() { x = 'f'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+x+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string xx; public PageReference rrr() { xx = 'R'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+xx+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } string z; public PageReference mmm() { z = 'm'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+z+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string y; public PageReference ooo() { y = 'o'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+y+'%\' ORDER BY Name'; acc= Database.query(qry); return null; } public void all() { acc = [SELECT Name FROM Account]; con = new ApexPages.StandardSetController(acc); con.setpagesize(10); } public void aaa() { acc.clear(); acc = [SELECT Name FROM Account]; con = new ApexPages.StandardSetController(acc); con.setpagesize(10); } }
For answer's thanks in advance.
- Mohan Raj 33
- October 31, 2016
- Like
- 0
How to provide the alpha navigation bar and sorting function in same data table ?
here My problem is
My alpha navigation bar is not working.
I don't know to how to provide the navigaton bar result in the same table.(as same used to the sorting)
My Controller is,
public class StandardPaginationSorting { // Variables required for Sorting. public String soql {get;set;} public List <Account> CandidateList1 = New List <Account>(); public String soqlsort {get;set;} public List <Account> CandidateList2 = New List <Account>(); public List<Account> acc {get; set;} // List used in to display the table in VF page. public List<Account> getCandidateList() { // Passing the values of list to VF page. return con.getRecords(); //all(); } // instantiate the StandardSetController from a query locator public StandardPaginationSorting(ApexPages.StandardController controller){ con.getRecords(); all(); } public ApexPages.StandardSetController con { get { if(con == null) { // String Query to have a list of cases for a respective End-user. soql = 'SELECT Name, Website,BillingCountry, Phone, Type, Owner.Name FROM Account'; // Passing the String array to a list with Selected field sorting. CandidateList1 = Database.query(soql + ' order by ' + sortField + ' ' + sortDir ); // setting values of List in StandardSetController. con = new ApexPages.StandardSetController(CandidateList1); // sets the number of records in each page set con.setPageSize(10); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } // Method for Constructor is used for Test Class. public StandardPaginationSorting(){ //all(); } //Toggles the sorting of query from asc<-->desc public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again for sorting other columns soqlsort = 'SELECT Name, Phone, BillingCountry, Website, Owner.Name, Type FROM Account'; // Adding String array to a List array CandidateList2 = Database.query(soqlsort + ' order by ' + sortField + ' ' + sortDir ); // Adding Caselist to Standard Pagination controller variable con = new ApexPages.StandardSetController(CandidateList2); // Set Page Size to 5 con.setPageSize(10); } // the current sort direction. defaults to asc public String sortDir { // To set a Direction either in ascending order or descending order. get { if (sortDir == null) { sortDir = 'asc';} return sortDir;} set; } // the current field to sort by. defaults to last name public String sortField { // To set a Field for sorting. get { if (sortField == null) {sortField = 'Name'; } return sortField; } set; } //the alpha bar navigation filter public PageReference ggg() { return null; } public PageReference eee() { return Null; } Public PageReference ddd() { return Null; } Public PageReference ccc() { return Null; } Public PageReference bbb() { return Null; } string x; public PageReference fff() { x = 'f'; acc.clear(); String qry = 'SELECT Name FROM Account' + 'WHERE Name LIKE \''+x+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string xx; public PageReference rrr() { xx = 'R'; acc.clear(); String qry = 'SELECT Name FROM Account' + 'WHERE Name LIKE \''+xx+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string z; public PageReference mmm() { z = 'm'; acc.clear(); String qry = 'SELECT Name FROM Account' + 'WHERE Name LIKE \''+z+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string y; public PageReference ooo() { y = 'o'; acc.clear(); String qry = 'SELECT Name FROM Account' + 'WHERE Name LIKE \''+y+'%\' ORDER BY Name'; acc= Database.query(qry); return null; } public void all() { acc = [SELECT Name FROM Account]; //con = new ApexPages.StandardSetController(acc); } public void aaa() { acc.clear(); acc = [SELECT Name FROM Account]; // con = new ApexPages.StandardSetController(acc); } }
My page is,
<apex:page standardController="Account" extensions="StandardPaginationSorting" showHeader="false" sidebar="false"> <!-- CSS added to display alternate row colors and Center align Text in PageblockTable --> <!--<style type="text/css"> .oddrow{background-color: #00FFFF; } .evenrow{background-color: #7FFFD4; } .textalign{text-align:center; } </style>---> <apex:form id="form"> <!-- Tabstyle attribute is used to assign the color scheme to the pageblock.Here Candidate Object color scheme is used for the pageblock--> <apex:pageBlock id="pgblock" tabStyle="Account"> <!--<apex:pageBlockSection title="Candidate Details - Page #{!pageNumber}" columns="1" collapsible="false">--> <!-- Rowclasses attribute is used to define different CSS classes for different rows. Rules attribute is used: borders drawn between cells in the page block table. Title attribute will be used as a help text when a user hovers mouse over the Page Block table. Styleclass, HeaderClass attributes are used to Center align Table Text in Page Block table ---> <right> <apex:toolbar id="toolbar" height="20" style="background-color:White;background-image:none;"> <apex:toolbarGroup itemSeparator="line"> <apex:commandLink value="A" Action="{!aaa}"/> <apex:commandLink value="B" Action="{!bbb}"/> <apex:commandLink value="C" Action="{!ccc}"/> <apex:commandLink value="D" Action="{!ddd}"/> <apex:commandLink value="E" Action="{!eee}"/> <apex:commandLink value="F" Action="{!fff}"/> <apex:commandLink value="G" Action="{!ggg}"/> <apex:commandLink value="H"/> <apex:commandLink value="I"/> <apex:commandLink value="J"/> <apex:commandLink value="K"/> <apex:commandLink value="L"/> <apex:commandLink value="M" Action="{!mmm}"/> <apex:commandLink value="N"/> <apex:commandLink value="O" Action="{!ooo}"/> <apex:commandLink value="P"/> <apex:commandLink value="Q"/> <apex:commandLink value="R" Action="{!rrr}"/> <apex:commandLink value="S"/> <apex:commandLink value="T"/> <apex:commandLink value="U"/> <apex:commandLink value="V"/> <apex:commandLink value="W"/> <apex:commandLink value="X"/> <apex:commandLink value="Y"/> <apex:commandLink value="Z"/> <apex:commandLink value="All" Action="{!all}"/> </apex:toolbarGroup> </apex:toolbar> </right> <apex:outputPanel > <apex:pageBlockTable value="{!acc}" var="a"> <apex:column value="{!a.Name}"/> </apex:pageBlockTable> </apex:outputPanel> <apex:pageBlockTable value ="{!CandidateList}" var="CadList" title="Click Column Header for Sorting" styleclass="textalign" headerClass="textalign" > <apex:column > <apex:facet name="header"> <apex:commandLink value="Name" action="{!toggleSort}" rerender="pgblock"> <!-- Value attribute should have field (API Name) to sort in asc or desc order --> <apex:param name="sortField" value="Name" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Name}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Phone" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Phone" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Phone}"/> </apex:column> <!-- <apex:column > <apex:facet name="header"> <apex:commandLink value="Name" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Email" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Email}"/> </apex:column>--> <apex:column > <apex:facet name="header"> <apex:commandLink value="Type" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Type" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Type}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="OwnerName" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Owner.Name" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Owner.Name}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Website" action="{!toggleSort}" rerender="pgblock"> <apex:param name="sortField" value="Website" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputField value="{!CadList.Website}"/> </apex:column> </apex:pageBlockTable> <!---</apex:pageBlockSection>----> <apex:panelGrid columns="6"> <apex:commandLink action="{!first}">First</apex:commandlink> <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink> <apex:commandLink action="{!last}">Last</apex:commandlink> <apex:inputText value="{!pageNumber}"> PageNumber</apex:inputText> of 4 </apex:panelGrid> </apex:pageBlock> </apex:form> </apex:page>
Please help me to solve this issue and For answer's thanks in advance.
- Mohan Raj 33
- October 31, 2016
- Like
- 0
How to solve this problem in apex controller class?
So I don't know how to clear this error so please help me to done this task.and my apex class is followingly,
public class AccountListViewController{ public List<Account> AccountsortList {get; set;} public String SortingExpression = 'name'; public String DirectionOfSort = 'ASC'; public Integer NoOfRecords {get; set;} public Integer Size{get; set;} public AccountListViewController(ApexPages.StandardSetController controller) { AccountsortList = new List<Account>(); ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList); } /*public Integer pageNumber { get { return ssc.getpageNumber(); } set; }*/ public String ExpressionSort { get { return SortingExpression; } set { If(value == SortingExpression) { DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC'; } else { DirectionOfSort = 'ASC'; SortingExpression = value; } } } public String getDirectionOfSort() { If(SortingExpression == Null || SortingExpression == '') { return 'DESC'; } else { return DirectionOfSort; } } public void setDirectionOfSort(String value) { DirectionOfSort = value; } public List<Account>getAccounts() { return AccountsortList; } public PageReference ViewData() { String FullSortExpression = SortingExpression + ' ' + DirectionOfSort; system.debug('SortingExpression:::::'+SortingExpression); system.debug(DirectionOfSort); String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 10'; system.debug(Queryitem); AccountsortList = DataBase.query(Queryitem); system.debug(AccountsortList); return Null; } }
For answer's thanks in advance.Thanks Mohan.
- Mohan Raj 33
- October 26, 2016
- Like
- 1
Pagination and sorting not worked together
My controller:
public class AccountListViewController{ public List<Account> AccountsortList {get; set;} public String SortingExpression = 'name'; public String DirectionOfSort = 'ASC'; public Integer NoOfRecords {get; set;} public Integer Size{get; set;} public AccountListViewController(ApexPages.StandardSetController controller) { AccountsortList = new List<Account>(); ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList); } /*public Integer pageNumber { get { return ssc.getpageNumber(); } set; }*/ public String ExpressionSort { get { return SortingExpression; } set { If(value == SortingExpression) { DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC'; } else { DirectionOfSort = 'ASC'; SortingExpression = value; } } } public String getDirectionOfSort() { If(SortingExpression == Null || SortingExpression == '') { return 'DESC'; } else { return DirectionOfSort; } } public void setDirectionOfSort(String value) { DirectionOfSort = value; } public List<Account>getAccounts() { return AccountsortList; } public PageReference ViewData() { String FullSortExpression = SortingExpression + ' ' + DirectionOfSort; system.debug('SortingExpression:::::'+SortingExpression); system.debug(DirectionOfSort); String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 1000'; system.debug(Queryitem); AccountsortList = DataBase.query(Queryitem); system.debug(AccountsortList); return Null; } }
and My page is:
<apex:page standardController="Account" recordSetVar="AccountsortList" action="{!ViewData}" extensions="AccountListViewController"> <apex:sectionHeader title="My Accounts" subtitle="Account List View"/> <apex:form > <apex:pageBlock > <apex:pageMessages id="error" /> <apex:panelGrid columns="7" id="buttons" > <!---<apex:pageBlockButtons>----> <apex:commandButton reRender="error,blocktable,buttons" action="{!Save}" value="Save"/> <apex:commandButton reRender="error,blocktable,buttons" action="{!Cancel}" value="Cancel"/> <apex:inputHidden /> <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!First}" value="First"/> <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!Previous}" value="Previous"/> <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Next}" value="Next"/> <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Last}" value="Last"/> <!---</apex:pageBlockButtons>---> </apex:panelGrid> <apex:pageBlockSection id="blocktable" > <apex:pageBlockTable value="{!AccountsortList}" var="t" rendered="{!NOT(ISNULL(AccountsortList))}" id="cmdsort"> <apex:column > <apex:facet name="header"> <apex:commandLink action="{!ViewData}" value="Account Name{!IF(ExpressionSort=='name',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}"> <apex:param value="name" name="column" assignTo="{!ExpressionSort}" ></apex:param> </apex:commandLink> </apex:facet> <apex:outputLink value="/{!t.Id}" target="_blank">{!t.Name}</apex:outputLink> </apex:column> <apex:column headerValue="BillingState/Province" value="{!t.BillingState}"/> <apex:column headerValue="Phone" value="{!t.Phone}"/> <apex:column headerValue="Type" value="{!t.Type}"/> <apex:column headerValue="Account Owner Alias" value="{!t.Owner.Name}"/> <apex:column headerValue="Website" value="{!t.Website}"/> <apex:inlineEditSupport event="onClick"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Here I am using the extension controller for providing the sorting functionality I don't know why the both is working together Can any one know the help me to rectify this problem in here.For answer's thanks in advance.
- Mohan Raj 33
- October 25, 2016
- Like
- 0
Why this formula having to provide the wrong answer?
IF((MOD(DATEVALUE(Calculating_Date__c)-DATE(1996,01,01), 7) < 5), (IF((NOW() > Calculating_Date__c), ((ROUND(12*( (5*FLOOR((TODAY()-DATE(1996,01,01))/7) + MIN(5, MOD(TODAY()-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(NOW()-DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) - (5*FLOOR((DATEVALUE(Calculating_Date__c)-DATE(1996,01,01))/7) + MIN(5, MOD(DATEVALUE(Calculating_Date__c )-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(Calculating_Date__c -DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) ), 0)) + IF( (21 > (VALUE(MID(RIGHT((TEXT(NOW() + 0.2291)),9),0,2)))) || (9 < (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) , (VALUE(MID(RIGHT((TEXT(NOW() + 0.2291)),9),0,2)) - 9),0 )), ((ROUND(12*( (5*FLOOR((TODAY()-DATE(1996,01,01))/7) + MIN(5, MOD(TODAY()-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(NOW()-DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) - (5*FLOOR((DATEVALUE(Calculating_Date__c )-DATE(1996,01,01))/7) + MIN(5, MOD(DATEVALUE(Calculating_Date__c )-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(Calculating_Date__c -DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) ), 0)) - IF( (21 > (VALUE(MID(RIGHT((TEXT(NOW() + 0.2291)),9),0,2)))) || (9 < (VALUE(MID(RIGHT((TEXT(NOW() + 0.2291)),9),0,2)))) , (VALUE(MID(RIGHT((TEXT(NOW() + 0.2291)),9),0,2)) - 9), 0)))), IF((NOW() > Calculating_Date__c ), ((( (NOW() - Calculating_Date__c ) * 5 - (MOD(DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) - MOD(TODAY() - DATE(1970,1,4),7)) * 2 ) / 7 - IF(MOD(TODAY() - DATE(1970,1,4),7) = 6,1,0) - IF(MOD( DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) = 0,1,0))*12 + (VALUE(MID(RIGHT((TEXT(NOW() + 0.2291)),9),0,2)) - 9)), (( (NOW() - Calculating_Date__c ) * 5 - (MOD(DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) - MOD(TODAY() - DATE(1970,1,4),7)) * 2 ) / 7 - IF(MOD(TODAY() - DATE(1970,1,4),7) = 6,1,0) - IF(MOD( DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) = 0,1,0))*12 - (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9)))here It's provide the wrong answer in the value to taking in the Calculating Date to the NOW() here I show the example to be provide the understand clearly, To select the Calculating Date is 10/17/2016 4.27PM and the value of NOW() is 10/18/2016 4.28 PM then the output comes by the formula is 19 hours but in practically the calculating Date is to be started to be a time to measured from the given input time so here the actual time is 4.27 only so the output is only12 hours only .
Here the problem means if selected to the any date to the NOW() value it's to be only added the value of the current hour(NOW() values hour only) it's doesn't start to calculate the hour from the Calculating Date time it's considered thus value in 12 hours constant.So I don't know to how change the value and to be calculated from the Calculating Date given values time.
So that's why I am confusing here to rectify that time considered problem.
So please help me to solve this issue in here .For answer's thanks in advance. Thanks Mohan
- Mohan Raj 33
- October 18, 2016
- Like
- 0
How to reduce the size of the this formula in the formula field?
IF((MOD(DATEVALUE( Calculating_Date__c )-DATE(1996,01,01), 7) < 5), (IF((NOW() > Calculating_Date__c), ((ROUND(12*( (5*FLOOR((TODAY()-DATE(1996,01,01))/7) + MIN(5, MOD(TODAY()-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(NOW()-DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) - (5*FLOOR((DATEVALUE( Calculating_Date__c )-DATE(1996,01,01))/7) + MIN(5, MOD(DATEVALUE( Calculating_Date__c )-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD( Calculating_Date__c -DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) ), 0)) + IF( (21 > (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) || (9 < (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) , (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9), Null)), ((ROUND(12*( (5*FLOOR((TODAY()-DATE(1996,01,01))/7) + MIN(5, MOD(TODAY()-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(NOW()-DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) - (5*FLOOR((DATEVALUE( Calculating_Date__c )-DATE(1996,01,01))/7) + MIN(5, MOD(DATEVALUE( Calculating_Date__c )-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD( Calculating_Date__c -DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) ), 0)) - IF( (21 > (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) || (9 < (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) , (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9), Null)))), IF((NOW() > Calculating_Date__c ), ((( (NOW() - Calculating_Date__c ) * 5 - (MOD(DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) - MOD(TODAY() - DATE(1970,1,4),7)) * 2 ) / 7 - IF(MOD(TODAY() - DATE(1970,1,4),7) = 6,1,0) - IF(MOD( DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) = 0,1,0))*12 + (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9)), (( (NOW() - Calculating_Date__c ) * 5 - (MOD(DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) - MOD(TODAY() - DATE(1970,1,4),7)) * 2 ) / 7 - IF(MOD(TODAY() - DATE(1970,1,4),7) = 6,1,0) - IF(MOD( DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) = 0,1,0))*12 - (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9)))
here what is the problem means the formula size is 5002 charector in time of compiling so it's provide the error to the formula sizeis big it's not to be allow to save the formula so please give the solution to reduce the size of the formula to be rectified this error "Compiled formula is too big to execute (5,002 characters). Maximum size is 5,000 characters".For answer's thanks in advance.
- Mohan Raj 33
- October 18, 2016
- Like
- 0
How to chenge this formula for working correctly in within week days different also?
(CASE(MOD( DATEVALUE(Calculating_Date__c) - DATE(1985,6,24),7), 0 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 1 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 2 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 3 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 4 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 5 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 6 , CASE( MOD( NOW() - Calculating_Date__c ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 999))
So here I want to change the formula to working in with future and the current week also in correct manner of working to calculating to the weekdays only(i.e Monay to friday) only.For answer's thanks in advance. thank you Mohan
- Mohan Raj 33
- October 15, 2016
- Like
- 0
How to change this formula in working days only (like only calculated Monday to Friday only)
((DATEVALUE( NOW()) - DATEVALUE(Calculating_Date__c))-1)*24 + (24 - VALUE(MID(RIGHT((TEXT( Calculating_Date__c - 0.2916)),9),0,2))) + VALUE(MID(RIGHT((TEXT( NOW() - 0.2916)),9),0,2))
here I using the formula for calculating the time difference in the Calculating Date and Now() value in HOURS only. Here the value for the 0.2916 is for Our time zone is GMT - 7 so that's why it's subtrcted there to get the local time from the GMT so now I want to try calculate this formula field in only for the working days (Monday to Friday Only).
i.e the validation only done to Monday to Friday doesn't to calculate the saturday and sunday timevalues to in the calculating timedifference. Even If I selected to the Saturday and Sunday value in the Calculating Date it's to be automatically calculated from Monday Onwords to the end value of NOW() value.
So please help me to solve the problem.For answer's thanks in advance .Thank you, Mohan
- Mohan Raj 33
- October 14, 2016
- Like
- 0
Why this text to number conversion providing this error"#ERROR!"
VALUE(MID(RIGHT((TEXT(Calculating_Date__c - 0.2916)),9),0,5))I want to do here to take a time portion of the Calculating Date field value if it is 10/14/2016 11:35 means as like 11:35 or 23:35 is I want to in my output here but it's not working so that's my problem .For answer'sthanks in advance.Mohan(here I subtracting the value is My org is using (GMT - 7) so that's why).
- Mohan Raj 33
- October 14, 2016
- Like
- 0
why the current and setting time difference is varying to compare to the manual calculation?
ABS( Calculating_Date__c - NOW() )*24)
But in here I feel the difference in the answer by the formula and the manual calculation like as followingly,
In case if the Calculating_Date__c value is 12/10/2016 6.20 AM and the current time is 12/10/2016 7.15 PM then the difference is coming by the formula answer is 0.20 but the manually the difference is 12.55(in hours).
So That's my question why the difference is happen and If I get to the manual calculation answer what am I do?
For Answer thanks in advance.Thank you, Mohan
- Mohan Raj 33
- October 12, 2016
- Like
- 0
how to here changed the date to date time period
Total Time difference(Date/Time) = Date dCloseDate = System.CloseDate() DateTime dt = datetime.newInstance(dCloseDate.year(), dCloseDate.month(), dCloseDate.day()); Calculating_Date__c - dCloseDate;I have a three field in the Opportunity field the Close Date, Total Time Difference and Calculating Date respectively.
Here I try to get the difference between the close date and Calculating Date.
but the close date is a date field and the Calculating date is a date/time field and the Total Time Difference is a Date/Time field.
So I have struggle to complete the task in getting difference in date and date/time fields so please help to solve this task.
For answers thanks in advance.
- Mohan Raj 33
- October 12, 2016
- Like
- 0
I want a valitation rule in following condition
AND ( ISBLANK ( Fax ) && ISBLANK ( Phone ) && ISBLANK ( Website ) )
But now I want to change the validation rule to the following condition:
if the (fax, Phone, Website) is all values are blank it gives the error message.
If the any one value(in fax, Phone, website) is enter then it allow to save record.
If I entered the more then one value ( like phone, Fax or fax, Website or all in like fax, Phone, website in fax, Phone, Website) it's also produce error.
For Answer's thanks in advance, Thank you, Mohan
- Mohan Raj 33
- October 11, 2016
- Like
- 0
validation rule is not working. Why ?
IF( ISPICKVAL( StageName , "Closed Won") || ISPICKVAL( StageName, "Closed Lost" ) , PRIORVALUE( StageName ) , PRIORVALUE( NOT ( StageName ) ) )
here I want the validation rule for when I select the Opportunity itself on the "stage" piclist value is selected in any one of "Closed Won " or "Closed Lost" then the value of the particular opportunity is not changed(that stage field in the "Closed Won" to Other(Closed Lost also) or "Closed Lost" to Other(Closed Won also) ) before. Here I tried as well as I know in the validation rule for the task but It's gives the error by followingly, "Error: Field StageName is a picklist field. Picklist fields are only supported in certain functions.".So please help me to complete ths task.For answers thanks in advance.
- Mohan Raj 33
- October 11, 2016
- Like
- 0
How To enable and disable the button and make deselected the selected check box in my code
public class AccountEditController { public String closePopup { get; set; } accountwrapper1 makeEdit; List<accountwrapper1> listAccount = new List<accountwrapper1>(); List<Account> selectableAccount = new List<Account>(); //set<Account> selectableAccount2 = new set<Account>(); //public Boolean showPanel {get; set;} public Boolean showPopup { get; set; } public AccountEditController() { showPopup = False; //showPanel = False; } public List<accountwrapper1> getAccounts() { if(listAccount == Null){ for(Account a: [SELECT Id, Name, BillingCountry, Phone FROM Account]) listAccount.add(new accountwrapper1(a)); return listAccount; } else{ listAccount.clear(); for(Account a: [SELECT Id, Name, BillingCountry, Phone FROM Account]) listAccount.add(new accountwrapper1(a)); return listAccount; } } public PageReference getSelectable() { // selectableAccount.clear(); for(accountwrapper1 accwrapper : listAccount){ if(accwrapper.selected == True){ selectableAccount.add(accwrapper.acc); system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@selectableAccount:'+ selectableAccount); return Null; } } return Null; } /*public PageReference Savemeth() { for(account acc :selectableAccount ) { acc.BillingCountry = BillingCountry; selectableAccount2.add(acc); } update selectableAccount2; showPopup = False; return Null; }*/ public PageReference GetSelectedAccounts() { if(selectableAccount.size()>0) { system.debug(selectableAccount.size()); system.debug(selectableAccount); showPopup = Null; return Null; } else showPopup = Null; return Null; } public PageReference showToPopup() { // public PageReference showToPanel() { showPopUp = True; return Null; //showPanel = True; } public string BillingCountry { get; set; } public PageReference Savemeth() { map<Id, Account> mapAccountForUpdate = new map<Id, Account>(); for(account acc :selectableAccount ) { acc.BillingCountry = BillingCountry; mapAccountForUpdate.put(acc.Id, acc); } update mapAccountForUpdate.values(); //mapAccountForUpdate = Null; selectableAccount.clear(); showPopup = Null; BillingCountry = ''; //showPopup = False; return Null; } public PageReference cancelmeth() { return Null; } public PageReference closePopup() { showPopup = Null; BillingCountry = ''; //showPopup = False; return Null; } public class accountwrapper1 { public Account acc{get; set;} public Boolean selected {get; set;} public accountwrapper1(Account a) { acc = a; selected = False; } } }
My Page:
<apex:page controller="AccountEditController" applyHtmlTag="true"> <head> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" /> </head> <script> $(document).ready(function(){ select(); }); function select(){ $('[id*=chkb1]').change(function(){ $("[id*='chkb2']").attr("checked",this.checked); getSelectable(); }); $('[id*=chkb2]').click(function(){ if($('[id*=chkb2]').length== $("[id*='chkb2']: checked").length) { $("[id*='chkb1']").attr("checked",this.checked); getSelectable(); } else { var checkboxes = document.getElementsByTagName('input'); var counter = 0; var counter1 = 1; for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].type == 'checkbox') { counter++; if(checkboxes[i].checked == true){ counter1++; } } } if(counter==counter1){ $("[id*='chkb1']").attr("checked",this.checked); getSelectable(); } else { $("[id*='chkb1']").removeAttr("checked"); getSelectable(); } } }); } </script> <style type="text/css"> .PopupBackground{ background-color: white; opacity: 0.8; filter: alpha(opacity = 20); position: absolute; width: 100%; height: 200%; top: -100px; left: 10px; z-index: 9998; } .AccountEdit{ background-color: white; border-width: 8px; border-style: solid; z-index: 9999; left: 30%; padding:10px; position: absolute; width: 350px; margin-left: 75px; top:300px; } </style> <apex:form > <apex:actionFunction name="getSelectable" action="{!getSelectable}" reRender="Output"/> <apex:pageBlock Title="List of Accounts" > <apex:pageBlockButtons location="top"> <apex:commandButton value="Get selected Records" action="{!showToPopup}" rerender="Output" id="button"/> <apex:commandButton value="cancelPopup" action="{!closePopup}" rendered="output"/> <!-- <apex:commandButton value="Get selected Records" action="{!showToPanel}" rerender="Output" id="button"/>----> </apex:pageBlockButtons> <!-- {!showPanel}----> <apex:outputPanel id="Output"> <apex:outputPanel styleClass="PopupBackground" layout="black" rendered="{!showPopup}"> <apex:outputPanel styleClass="AccountEdit" layout="black" rendered="{!showPopup}"> <!--- <apex:outputPanel rendered="{!showPanel}">-----> <!---{!showPanel}----------> <apex:outputLabel value="BillingCountry: "></apex:outputLabel> <apex:inputText id="BillingCountry" value="{!BillingCountry}" size="40" style="height:13px;font-size:11px;"/><br /> <center><apex:commandButton value="Save" action="{!Savemeth}" reRender="Initialtable,Output" oncomplete="select()" /> <!-- <apex:commandButton value="cancel" action="{!cancelmeth}"/>----> <apex:commandButton value="Cancel" action="{!closePopup}"/></center> </apex:outputPanel> </apex:outputPanel> </apex:outputPanel> <!-- <apex:commandButton value="cancelPopup" action="{!closePopup}"/>---> <apex:pageBlockSection Title="List of Available Accounts" columns="1" collapsible="true"> <apex:pageblockTable value="{!accounts}" var="a" id="Initialtable"> <apex:column > <apex:facet name="header"> <apex:inputCheckbox value="{!a.selected}" id="chkb1"> <!-- <apex:actionSupport event="onclick" action="{!getSelectable}" reRender="Output"/> --> </apex:inputCheckbox> </apex:facet> <apex:inputCheckbox value="{!a.selected}" id="chkb2" /> <!-- <apex:actionSupport event="onclick" action="{!getSelectable}" reRender="Output"/> --> </apex:column> <apex:column headervalue="Account Name" value="{!a.acc.Name}" width="200"/> <apex:column headervalue="Phone" value="{!a.acc.Phone}" width="300"/> <apex:column headervalue="Billing Country" value="{!a.acc.BillingCountry}" width="300"/> </apex:pageblocktable> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page>
So here I done the update the country value(billing country) to thae appropriate account in the list of table.But I want whether the "Get Selected Records"button available(enable) only if any one check box are to be checked if no one check box are to be checked it's to be disabled mode and here if I try to change the check box value on un checked in the controller side but I have n't to get it for why means it's leads to once I checked the checkbox and deselect the check box in the same time it's not deselected in here.so Plaese help mee to solve this issue.For answers thanks in advance
- Mohan Raj 33
- October 06, 2016
- Like
- 0
How I enable and disable the "Get selected Records" button on here
My controller: public class AccountEditController { public String closePopup { get; set; } accountwrapper1 makeEdit; List<accountwrapper1> listAccount = new List<accountwrapper1>(); List<Account> selectableAccount = new List<Account>(); //set<Account> selectableAccount2 = new set<Account>(); //public Boolean showPanel {get; set;} public Boolean showPopup { get; set; } public AccountEditController() { showPopup = False; //showPanel = False; } public List<accountwrapper1> getAccounts() { if(listAccount == Null){ for(Account a: [SELECT Id, Name, BillingCountry, Phone FROM Account]) listAccount.add(new accountwrapper1(a)); return listAccount; } else{ listAccount.clear(); for(Account a: [SELECT Id, Name, BillingCountry, Phone FROM Account]) listAccount.add(new accountwrapper1(a)); return listAccount; } } public PageReference getSelectable() { // selectableAccount.clear(); for(accountwrapper1 accwrapper : listAccount){ if(accwrapper.selected == True){ selectableAccount.add(accwrapper.acc); system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@selectableAccount:'+ selectableAccount); return Null; } } return Null; } /*public PageReference Savemeth() { for(account acc :selectableAccount ) { acc.BillingCountry = BillingCountry; selectableAccount2.add(acc); } update selectableAccount2; showPopup = False; return Null; }*/ public PageReference GetSelectedAccounts() { if(selectableAccount.size()>0) { system.debug(selectableAccount.size()); system.debug(selectableAccount); showPopup = Null; return Null; } else showPopup = Null; return Null; } public PageReference showToPopup() { // public PageReference showToPanel() { showPopUp = True; return Null; //showPanel = True; } public string BillingCountry { get; set; } public PageReference Savemeth() { map<Id, Account> mapAccountForUpdate = new map<Id, Account>(); for(account acc :selectableAccount ) { acc.BillingCountry = BillingCountry; mapAccountForUpdate.put(acc.Id, acc); } update mapAccountForUpdate.values(); //mapAccountForUpdate = Null; selectableAccount.clear(); showPopup = Null; BillingCountry = ''; //showPopup = False; return Null; } public PageReference cancelmeth() { return Null; } public PageReference closePopup() { showPopup = Null; BillingCountry = ''; //showPopup = False; return Null; } public class accountwrapper1 { public Account acc{get; set;} public Boolean selected {get; set;} public accountwrapper1(Account a) { acc = a; selected = False; } } }My Page:
<apex:page controller="AccountEditController" applyHtmlTag="true"> <head> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" /> </head> <script> $(document).ready(function(){ select(); }); function select(){ $('[id*=chkb1]').change(function(){ $("[id*='chkb2']").attr("checked",this.checked); getSelectable(); }); $('[id*=chkb2]').click(function(){ if($('[id*=chkb2]').length== $("[id*='chkb2']: checked").length) { $("[id*='chkb1']").attr("checked",this.checked); getSelectable(); } else { var checkboxes = document.getElementsByTagName('input'); var counter = 0; var counter1 = 1; for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].type == 'checkbox') { counter++; if(checkboxes[i].checked == true){ counter1++; } } } if(counter==counter1){ $("[id*='chkb1']").attr("checked",this.checked); getSelectable(); } else { $("[id*='chkb1']").removeAttr("checked"); getSelectable(); } } }); } </script> <style type="text/css"> .PopupBackground{ background-color: white; opacity: 0.8; filter: alpha(opacity = 20); position: absolute; width: 100%; height: 200%; top: -100px; left: 10px; z-index: 9998; } .AccountEdit{ background-color: white; border-width: 8px; border-style: solid; z-index: 9999; left: 30%; padding:10px; position: absolute; width: 350px; margin-left: 75px; top:300px; } </style> <apex:form > <apex:actionFunction name="getSelectable" action="{!getSelectable}" reRender="Output"/> <apex:pageBlock Title="List of Accounts" > <apex:pageBlockButtons location="top"> <apex:commandButton value="Get selected Records" action="{!showToPopup}" rerender="Output" id="button"/> <apex:commandButton value="cancelPopup" action="{!closePopup}" rendered="output"/> <!-- <apex:commandButton value="Get selected Records" action="{!showToPanel}" rerender="Output" id="button"/>----> </apex:pageBlockButtons> <!-- {!showPanel}----> <apex:outputPanel id="Output"> <apex:outputPanel styleClass="PopupBackground" layout="black" rendered="{!showPopup}"> <apex:outputPanel styleClass="AccountEdit" layout="black" rendered="{!showPopup}"> <!--- <apex:outputPanel rendered="{!showPanel}">-----> <!---{!showPanel}----------> <apex:outputLabel value="BillingCountry: "></apex:outputLabel> <apex:inputText id="BillingCountry" value="{!BillingCountry}" size="40" style="height:13px;font-size:11px;"/><br /> <center><apex:commandButton value="Save" action="{!Savemeth}" reRender="Initialtable,Output" oncomplete="select()" /> <!-- <apex:commandButton value="cancel" action="{!cancelmeth}"/>----> <apex:commandButton value="Cancel" action="{!closePopup}"/></center> </apex:outputPanel> </apex:outputPanel> </apex:outputPanel> <!-- <apex:commandButton value="cancelPopup" action="{!closePopup}"/>---> <apex:pageBlockSection Title="List of Available Accounts" columns="1" collapsible="true"> <apex:pageblockTable value="{!accounts}" var="a" id="Initialtable"> <apex:column > <apex:facet name="header"> <apex:inputCheckbox value="{!a.selected}" id="chkb1"> <!-- <apex:actionSupport event="onclick" action="{!getSelectable}" reRender="Output"/> --> </apex:inputCheckbox> </apex:facet> <apex:inputCheckbox value="{!a.selected}" id="chkb2" /> <!-- <apex:actionSupport event="onclick" action="{!getSelectable}" reRender="Output"/> --> </apex:column> <apex:column headervalue="Account Name" value="{!a.acc.Name}" width="200"/> <apex:column headervalue="Phone" value="{!a.acc.Phone}" width="300"/> <apex:column headervalue="Billing Country" value="{!a.acc.BillingCountry}" width="300"/> </apex:pageblocktable> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page>
here I don't know to how the disabled the button on my visual page on "Get Selectd Records" in no one check box are selected case and it's also enabled in the where at least I selected the one check box value by using the jquery/javascript to this task so pleasehelp me to complete the task if you known the answer. For Answer's thanks in advance.
- Mohan Raj 33
- October 06, 2016
- Like
- 0
How to deselect the check box in here?
public class AccountEditController { public String closePopup { get; set; } accountwrapper1 makeEdit; List<accountwrapper1> listAccount = new List<accountwrapper1>(); List<Account> selectableAccount = new List<Account>(); //set<Account> selectableAccount2 = new set<Account>(); //public Boolean showPanel {get; set;} public Boolean showPopup { get; set; } public AccountEditController() { showPopup = False; //showPanel = False; } public List<accountwrapper1> getAccounts() { if(listAccount == Null){ for(Account a: [SELECT Id, Name, BillingCountry, Phone FROM Account]) listAccount.add(new accountwrapper1(a)); return listAccount; } else{ listAccount.clear(); for(Account a: [SELECT Id, Name, BillingCountry, Phone FROM Account]) listAccount.add(new accountwrapper1(a)); return listAccount; } } public PageReference getSelectable() { // selectableAccount.clear(); for(accountwrapper1 accwrapper : listAccount){ if(accwrapper.selected == True){ selectableAccount.add(accwrapper.acc); system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@selectableAccount:'+ selectableAccount); if(accwrapper.selected == False) return Null; } } return Null; } /*public PageReference Savemeth() { for(account acc :selectableAccount ) { acc.BillingCountry = BillingCountry; selectableAccount2.add(acc); } update selectableAccount2; showPopup = False; return Null; }*/ public PageReference GetSelectedAccounts() { if(selectableAccount.size()>0) { system.debug(selectableAccount.size()); system.debug(selectableAccount); showPopup = Null; return Null; } else showPopup = Null; return Null; } public PageReference showToPopup() { // public PageReference showToPanel() { showPopUp = True; return Null; //showPanel = True; } public string BillingCountry { get; set; } public PageReference Savemeth() { map<Id, Account> mapAccountForUpdate = new map<Id, Account>(); for(account acc :selectableAccount ) { acc.BillingCountry = BillingCountry; mapAccountForUpdate.put(acc.Id, acc); } update mapAccountForUpdate.values(); //mapAccountForUpdate = Null; selectableAccount.clear(); showPopup = Null; BillingCountry = ''; //showPopup = False; return Null; } public PageReference cancelmeth() { return Null; } public PageReference closePopup() { showPopup = Null; BillingCountry = ''; //showPopup = False; return Null; } public class accountwrapper1 { public Account acc{get; set;} public Boolean selected {get; set;} public accountwrapper1(Account a) { acc = a; selected = False; } } }
My Page:
<apex:page controller="AccountEditController" applyHtmlTag="true"> <head> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" /> </head> <script> $(document).ready(function(){ select(); }); function select(){ $('[id*=chkb1]').change(function(){ $("[id*='chkb2']").attr("checked",this.checked); getSelectable(); }); $('[id*=chkb2]').click(function(){ if($('[id*=chkb2]').length== $("[id*='chkb2']: checked").length) { $("[id*='chkb1']").attr("checked",this.checked); getSelectable(); } else { var checkboxes = document.getElementsByTagName('input'); var counter = 0; var counter1 = 1; for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].type == 'checkbox') { counter++; if(checkboxes[i].checked == true){ counter1++; } } } if(counter==counter1){ $("[id*='chkb1']").attr("checked",this.checked); getSelectable(); } else { $("[id*='chkb1']").removeAttr("checked"); getSelectable(); } } }); } </script> <style type="text/css"> .PopupBackground{ background-color: white; opacity: 0.8; filter: alpha(opacity = 20); position: absolute; width: 100%; height: 200%; top: -100px; left: 10px; z-index: 9998; } .AccountEdit{ background-color: white; border-width: 8px; border-style: solid; z-index: 9999; left: 30%; padding:10px; position: absolute; width: 350px; margin-left: 75px; top:300px; } </style> <apex:form > <apex:actionFunction name="getSelectable" action="{!getSelectable}" reRender="Output"/> <apex:pageBlock Title="List of Accounts" > <apex:pageBlockButtons location="top"> <apex:commandButton value="Get selected Records" action="{!showToPopup}" rerender="Output" id="button"/> <apex:commandButton value="cancelPopup" action="{!closePopup}" rendered="output"/> <!-- <apex:commandButton value="Get selected Records" action="{!showToPanel}" rerender="Output" id="button"/>----> </apex:pageBlockButtons> <!-- {!showPanel}----> <apex:outputPanel id="Output"> <apex:outputPanel styleClass="PopupBackground" layout="black" rendered="{!showPopup}"> <apex:outputPanel styleClass="AccountEdit" layout="black" rendered="{!showPopup}"> <!--- <apex:outputPanel rendered="{!showPanel}">-----> <!---{!showPanel}----------> <apex:outputLabel value="BillingCountry: "></apex:outputLabel> <apex:inputText id="BillingCountry" value="{!BillingCountry}" size="40" style="height:13px;font-size:11px;"/><br /> <center><apex:commandButton value="Save" action="{!Savemeth}" reRender="Initialtable,Output" oncomplete="select()" /> <!-- <apex:commandButton value="cancel" action="{!cancelmeth}"/>----> <apex:commandButton value="Cancel" action="{!closePopup}"/></center> </apex:outputPanel> </apex:outputPanel> </apex:outputPanel> <!-- <apex:commandButton value="cancelPopup" action="{!closePopup}"/>---> <apex:pageBlockSection Title="List of Available Accounts" columns="1" collapsible="true"> <apex:pageblockTable value="{!accounts}" var="a" id="Initialtable"> <apex:column > <apex:facet name="header"> <apex:inputCheckbox value="{!a.selected}" id="chkb1"> <!-- <apex:actionSupport event="onclick" action="{!getSelectable}" reRender="Output"/> --> </apex:inputCheckbox> </apex:facet> <apex:inputCheckbox value="{!a.selected}" id="chkb2" /> <!-- <apex:actionSupport event="onclick" action="{!getSelectable}" reRender="Output"/> --> </apex:column> <apex:column headervalue="Account Name" value="{!a.acc.Name}" width="200"/> <apex:column headervalue="Phone" value="{!a.acc.Phone}" width="300"/> <apex:column headervalue="Billing Country" value="{!a.acc.BillingCountry}" width="300"/> </apex:pageblocktable> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page>
here I got some unable things if once selected the check box then it's not to be disselected(un checked) until the saving the value of the account in the billing country field so that's make some issue in my process i don't know to how they done it.and also I want to even i select any check box at that time only my get selected records button should be enabled is enough but if no check box are selected that button should be enabled my code so please help me to solve the task for answers thanks in advance
- Mohan Raj 33
- October 06, 2016
- Like
- 0
How to solve this problem in apex controller class?
So I don't know how to clear this error so please help me to done this task.and my apex class is followingly,
public class AccountListViewController{ public List<Account> AccountsortList {get; set;} public String SortingExpression = 'name'; public String DirectionOfSort = 'ASC'; public Integer NoOfRecords {get; set;} public Integer Size{get; set;} public AccountListViewController(ApexPages.StandardSetController controller) { AccountsortList = new List<Account>(); ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList); } /*public Integer pageNumber { get { return ssc.getpageNumber(); } set; }*/ public String ExpressionSort { get { return SortingExpression; } set { If(value == SortingExpression) { DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC'; } else { DirectionOfSort = 'ASC'; SortingExpression = value; } } } public String getDirectionOfSort() { If(SortingExpression == Null || SortingExpression == '') { return 'DESC'; } else { return DirectionOfSort; } } public void setDirectionOfSort(String value) { DirectionOfSort = value; } public List<Account>getAccounts() { return AccountsortList; } public PageReference ViewData() { String FullSortExpression = SortingExpression + ' ' + DirectionOfSort; system.debug('SortingExpression:::::'+SortingExpression); system.debug(DirectionOfSort); String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 10'; system.debug(Queryitem); AccountsortList = DataBase.query(Queryitem); system.debug(AccountsortList); return Null; } }
For answer's thanks in advance.Thanks Mohan.
- Mohan Raj 33
- October 26, 2016
- Like
- 1
Jquery data table provide a milliseconds format in date value column
controller:
//Remote function using updated the owner of the task public class TaskOwnerUpdate { public String dueDate { get; set; } public Set<Id> selectedTaskIdSet {get; set;} String ownerIdValue {get; set;} String selectedColumnValue {get; set;} public static List<Task> taskList { get; set;} public TaskOwnerUpdate() { } // empty constructor public List<Task>selectedtaskList {get; set;} public Task getOwnerIdTask() { return [SELECT OwnerId FROM TASK LIMIT 1]; } @RemoteAction public static List<Task> getTask (String dueDate) { system.debug('dueDate value is------>'+dueDate); List<String> stList = dueDate.split('"'); system.debug('stList value---->'+stList); List<String>s1 = stList[0].split(','); system.debug('stList[0] value is---->'+stList[0]); system.debug('stList[1] value is---->'+stList[1]); List<String> splitList = stList[1].split('/'); system.debug('splitList value is---->'+splitList); String dueDate1 = splitList[2]+'-'+splitList[0]+'-'+splitList[1]; taskList = [SELECT Id, Subject, Priority, Status, ActivityDate, Owner.Name, OwnerId FROM Task WHERE ActivityDate >= :Date.valueOf(dueDate1)]; system.debug('taskList- value is------>'+taskList); return taskList; } @RemoteAction public static List<Task> updateTask(String ownerIdValue, String selectedColumnValue ) { system.debug('OwnerId value is----->'+ownerIdValue); system.debug('selectedColumnValue value is---->'+selectedColumnValue); List<Task> updatedTaskList = new List<Task>(); Set<Id> idSet = new Set<Id>(); List<String> deserializeStringList = (List<String>)System.JSON.deserialize(selectedColumnValue, List<String>.class); system.debug('deserializeStringList value>>>>'+deserializeStringList); for (String strRecord : deserializeStringList) { Task taskRecord = new Task(); taskRecord.Id = Id.valueOf(strRecord); taskRecord.OwnerId = Id.valueOf(ownerIdValue); updatedTaskList.add(taskRecord); } if (updatedTaskList.size() > 0) { Update updatedTaskList; } return updatedTaskList; } }
page:
<apex:page controller="TaskOwnerUpdate"> <apex:form> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"/> <apex:includeScript value="https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"/> <apex:sectionHeader title="Task Ownership Update"/> <apex:pageBlock title="Tasks"> <!---- Section to draw search field for account-------> <apex:pageBlockSection title="Search Tasks" columns="2"> <apex:pageBlockSectionItem > <apex:inputText value="{!dueDate}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false)">dueDate</apex:inputText> <apex:inputField value="{!OwnerIdTask.OwnerId}" id="owner"></apex:inputField> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection > <button onclick="getTask();return false;">Get Task</button> <button id = "button">Update</button> </apex:pageBlockSection> <apex:actionFunction name="callaction" oncomplete="getTask()" reRender="output"/> <!-- result section for showing matching accounts -------> <apex:outputPanel id="output"> <apex:pageBlockSection title="Matching Tasks !" columns="1"> <!-- Created Empty table using the CSS styles of visualforce pageBlockTable This gives same look and feel ------> <table cellspacing="0" cellpadding="0" border="0" id="searchResults" class="list "> <colgroup span="2"></colgroup> <thead class="rich-table-thead"> <tr class="headerRow "> <th colspan="1" scope="col" class="headerRow">Select</th> <!--<th colspan="1" scope="col" class="headerRow">Id</th>----> <th colspan="1" scope="col" class="headerRow">Subject</th> <th colspan="1" scope="col" class="headerRow">Priority</th> <th colspan="1" scope="col" class="headerRow">Status</th> <th colspan="1" scope="col" class="headerRow">ActivityDate</th> <th colspan="1" scope="col" class="headerRow">OwnerName</th> </tr> </thead> <!-- table body left empty for populating via row template using jquery-------> <tbody /> </table> </apex:pageBlockSection> </apex:outputPanel> <script id="resultTableRowTemplate" type="text/x-jquery-tmpl"> <tr onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}" onmouseout="if (window.hiOff){hiOff(this);} " onmouseover="if (window.hiOn){hiOn(this);} " class="dataRow even first"> <td class="datacel">${Select}<input type = "checkbox" id="${Id}"/></td> <!---<td class="Idvalue">${Id}</td>------> <td class="datacell">${Subject}</td> <td class="dataCell">${Priority}</td> <td class="dataCell">${Status}</td> <td class="datecell">${ActivityDate}</td> <td class="datacell">${Owner.Name}</td> </tr> </script> </apex:pageBlock> <script type="text/javascript"> // if you are inside some component // use jquery nonConflict // var t$ = jQuery.noConflict(); console.log("check call correct"); function getTask() { var dueDate = $('[id$=":demo"]').val();//$('#demo').val(); console.log("check data",dueDate); // clear previous results, if any $("#searchResults tbody").html(''); // The Spring-11 gift from force.com. Javascript remoting fires here // Please note "abhinav" if my org wide namespace prefix // testremotingcontroller is the Apex controller // searchAccounts is Apex Controller method demarcated with @RemoteAction annotation. // DEPRECATED - abhinav.testremotingcontroller.searchAccounts( accountName, ...) // NEW - summer'12 approach for calling' dueDate = JSON.stringify(dueDate); Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.getTask}', dueDate, function(result, event){ console.log("due date",dueDate); if (event.status && event.result) { $.each(event.result, function () { // for each result, apply it to template and append generated markup // to the results table body. $("#resultTableRowTemplate" ).tmpl(this).appendTo( "#searchResults tbody" ); } ); } else { alert(event.message); } }, {escape:true}); } </script> <script type="text/javascript"> console.log("check update correct"); $(function () { $('.datacel').click(function() { var allData = $(this).parent().parent().first().text(); console.log("allData value is>>>>",allData); //alert(allData); }); $('input:not(#button)').click(function () { t = $(this).attr('id'); text = $('.time' + t).text(); //alert(text); }); $('#button').click(function (e) { e.preventDefault(); var trs = $('table tr'); var values = trs.first().find('td'); // var idr = $('#Idvalue').val(); // console.log("idr value",idr); var values1 = $('table tr td :checkbox:checked').map(function () { console.log('\nId::::',$(this).attr('id')); return $(this).attr('id'); /*return $(this).closest('tr').find('td').text() + "==" + values.eq($(this).parent().index()).text(); console.log("id val",$(this).parent().find('td').eq(1).text()); return $(this).closest('td').find('td').eq(1).text()+ values.eq($(this).parent().intex()).text();*/ }).get(); console.log("values1",values1); getUpdate(values1); console.log("after passing vales1", values1); console.log("values1",values1); return values1; }); //alert(values1); //console.log("values1",values1); //return values1; //getUpdate(values1); }); function getUpdate(values1) { var taskRecord = JSON.stringify(values1); console.log("data type taskRecord",typeof(taskRecord)); console.log("task record value is>>>",taskRecord); var ownerIdValue = $('[id$="owner_lkid"]').val(); console.log("data type ownerIdValue",typeof(ownerIdValue)); //var ownerIdValue = document.getElementById('{!$Component.owner}').value; console.log("ownerId value is >>>>",ownerIdValue); console.log("values1 >>>>",values1); Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.updateTask}', ownerIdValue, taskRecord, function(result, event){ if (event.status) { callaction(); } else { } }, {escape:true}); } </script> </apex:form> </apex:page>
For any response appreciated!!!!
- Mohan Raj 33
- February 02, 2017
- Like
- 0
SObject row was retrieved via SOQL without querying the requested field: Account.Phone
So that's why I getting this error I don't know to how to rectify this error so can any one help me to solve the error.
My controller:
public class StandardPaginationSorting { // Variables required for Sorting. public String soql {get;set;} public List <Account> CandidateList1 = New List <Account>(); public String soqlsort {get;set;} public List <Account> CandidateList2 = New List <Account>(); public List<Account> acc {get; set;} // List used in to display the table in VF page. public List<Account> getCandidateList() { // Passing the values of list to VF page. return con.getRecords(); //all(); } // instantiate the StandardSetController from a query locator public StandardPaginationSorting(ApexPages.StandardController controller){ con.getRecords(); all(); } public ApexPages.StandardSetController con { get { if(con == null) { // String Query to have a list of cases for a respective End-user. soql = 'SELECT Name, Website,BillingCountry, Phone, Type, Owner.Name FROM Account'; // Passing the String array to a list with Selected field sorting. CandidateList1 = Database.query(soql + ' order by ' + sortField + ' ' + sortDir ); // setting values of List in StandardSetController. con = new ApexPages.StandardSetController(CandidateList1); // sets the number of records in each page set con.setPageSize(10); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } // Method for Constructor is used for Test Class. public StandardPaginationSorting(){ //all(); } //Toggles the sorting of query from asc<-->desc public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again for sorting other columns soqlsort = 'SELECT Name, Phone, BillingCountry, Website, Owner.Name, Type FROM Account'; // Adding String array to a List array CandidateList2 = Database.query(soqlsort + ' order by ' + sortField + ' ' + sortDir ); // Adding Caselist to Standard Pagination controller variable con = new ApexPages.StandardSetController(CandidateList2); // Set Page Size to 10 con.setPageSize(10); } // the current sort direction. defaults to asc public String sortDir { // To set a Direction either in ascending order or descending order. get { if (sortDir == null) { sortDir = 'asc';} return sortDir;} set; } // the current field to sort by. defaults to last name public String sortField { // To set a Field for sorting. get { if (sortField == null) {sortField = 'Name'; } return sortField; } set; } //the alpha bar navigation filter public PageReference ggg() { return null; } public PageReference eee() { return Null; } Public PageReference ddd() { return Null; } Public PageReference ccc() { return Null; } Public PageReference bbb() { return Null; } string x; public PageReference fff() { x = 'f'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+x+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string xx; public PageReference rrr() { xx = 'R'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+xx+'%\' ORDER BY Name'; acc= Database.query(qry); con = new ApexPages.StandardSetController(acc); return null; } string z; public PageReference mmm() { z = 'm'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+z+'%\' ORDER BY Name'; acc= Database.query(qry); //con = new ApexPages.StandardSetController(acc); return null; } string y; public PageReference ooo() { y = 'o'; acc.clear(); String qry = 'SELECT Name FROM Account WHERE Name LIKE \''+y+'%\' ORDER BY Name'; acc= Database.query(qry); return null; } public void all() { acc = [SELECT Name FROM Account]; con = new ApexPages.StandardSetController(acc); con.setpagesize(10); } public void aaa() { acc.clear(); acc = [SELECT Name FROM Account]; con = new ApexPages.StandardSetController(acc); con.setpagesize(10); } }
For answer's thanks in advance.
- Mohan Raj 33
- October 31, 2016
- Like
- 0
How to solve this problem in apex controller class?
So I don't know how to clear this error so please help me to done this task.and my apex class is followingly,
public class AccountListViewController{ public List<Account> AccountsortList {get; set;} public String SortingExpression = 'name'; public String DirectionOfSort = 'ASC'; public Integer NoOfRecords {get; set;} public Integer Size{get; set;} public AccountListViewController(ApexPages.StandardSetController controller) { AccountsortList = new List<Account>(); ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList); } /*public Integer pageNumber { get { return ssc.getpageNumber(); } set; }*/ public String ExpressionSort { get { return SortingExpression; } set { If(value == SortingExpression) { DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC'; } else { DirectionOfSort = 'ASC'; SortingExpression = value; } } } public String getDirectionOfSort() { If(SortingExpression == Null || SortingExpression == '') { return 'DESC'; } else { return DirectionOfSort; } } public void setDirectionOfSort(String value) { DirectionOfSort = value; } public List<Account>getAccounts() { return AccountsortList; } public PageReference ViewData() { String FullSortExpression = SortingExpression + ' ' + DirectionOfSort; system.debug('SortingExpression:::::'+SortingExpression); system.debug(DirectionOfSort); String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 10'; system.debug(Queryitem); AccountsortList = DataBase.query(Queryitem); system.debug(AccountsortList); return Null; } }
For answer's thanks in advance.Thanks Mohan.
- Mohan Raj 33
- October 26, 2016
- Like
- 1
How to reduce the size of the this formula in the formula field?
IF((MOD(DATEVALUE( Calculating_Date__c )-DATE(1996,01,01), 7) < 5), (IF((NOW() > Calculating_Date__c), ((ROUND(12*( (5*FLOOR((TODAY()-DATE(1996,01,01))/7) + MIN(5, MOD(TODAY()-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(NOW()-DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) - (5*FLOOR((DATEVALUE( Calculating_Date__c )-DATE(1996,01,01))/7) + MIN(5, MOD(DATEVALUE( Calculating_Date__c )-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD( Calculating_Date__c -DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) ), 0)) + IF( (21 > (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) || (9 < (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) , (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9), Null)), ((ROUND(12*( (5*FLOOR((TODAY()-DATE(1996,01,01))/7) + MIN(5, MOD(TODAY()-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD(NOW()-DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) - (5*FLOOR((DATEVALUE( Calculating_Date__c )-DATE(1996,01,01))/7) + MIN(5, MOD(DATEVALUE( Calculating_Date__c )-DATE(1996,01,01), 7) + MIN(1, 24/12*(MOD( Calculating_Date__c -DATETIMEVALUE('1996-01-01 12:00:00'), 1))) )) ), 0)) - IF( (21 > (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) || (9 < (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)))) , (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9), Null)))), IF((NOW() > Calculating_Date__c ), ((( (NOW() - Calculating_Date__c ) * 5 - (MOD(DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) - MOD(TODAY() - DATE(1970,1,4),7)) * 2 ) / 7 - IF(MOD(TODAY() - DATE(1970,1,4),7) = 6,1,0) - IF(MOD( DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) = 0,1,0))*12 + (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9)), (( (NOW() - Calculating_Date__c ) * 5 - (MOD(DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) - MOD(TODAY() - DATE(1970,1,4),7)) * 2 ) / 7 - IF(MOD(TODAY() - DATE(1970,1,4),7) = 6,1,0) - IF(MOD( DATEVALUE(Calculating_Date__c) - DATE(1970,1,4),7) = 0,1,0))*12 - (VALUE(MID(RIGHT((TEXT( NOW() + 0.2291)),9),0,2)) - 9)))
here what is the problem means the formula size is 5002 charector in time of compiling so it's provide the error to the formula sizeis big it's not to be allow to save the formula so please give the solution to reduce the size of the formula to be rectified this error "Compiled formula is too big to execute (5,002 characters). Maximum size is 5,000 characters".For answer's thanks in advance.
- Mohan Raj 33
- October 18, 2016
- Like
- 0
How to change this formula in working days only (like only calculated Monday to Friday only)
((DATEVALUE( NOW()) - DATEVALUE(Calculating_Date__c))-1)*24 + (24 - VALUE(MID(RIGHT((TEXT( Calculating_Date__c - 0.2916)),9),0,2))) + VALUE(MID(RIGHT((TEXT( NOW() - 0.2916)),9),0,2))
here I using the formula for calculating the time difference in the Calculating Date and Now() value in HOURS only. Here the value for the 0.2916 is for Our time zone is GMT - 7 so that's why it's subtrcted there to get the local time from the GMT so now I want to try calculate this formula field in only for the working days (Monday to Friday Only).
i.e the validation only done to Monday to Friday doesn't to calculate the saturday and sunday timevalues to in the calculating timedifference. Even If I selected to the Saturday and Sunday value in the Calculating Date it's to be automatically calculated from Monday Onwords to the end value of NOW() value.
So please help me to solve the problem.For answer's thanks in advance .Thank you, Mohan
- Mohan Raj 33
- October 14, 2016
- Like
- 0
Why this text to number conversion providing this error"#ERROR!"
VALUE(MID(RIGHT((TEXT(Calculating_Date__c - 0.2916)),9),0,5))I want to do here to take a time portion of the Calculating Date field value if it is 10/14/2016 11:35 means as like 11:35 or 23:35 is I want to in my output here but it's not working so that's my problem .For answer'sthanks in advance.Mohan(here I subtracting the value is My org is using (GMT - 7) so that's why).
- Mohan Raj 33
- October 14, 2016
- Like
- 0
why the current and setting time difference is varying to compare to the manual calculation?
ABS( Calculating_Date__c - NOW() )*24)
But in here I feel the difference in the answer by the formula and the manual calculation like as followingly,
In case if the Calculating_Date__c value is 12/10/2016 6.20 AM and the current time is 12/10/2016 7.15 PM then the difference is coming by the formula answer is 0.20 but the manually the difference is 12.55(in hours).
So That's my question why the difference is happen and If I get to the manual calculation answer what am I do?
For Answer thanks in advance.Thank you, Mohan
- Mohan Raj 33
- October 12, 2016
- Like
- 0
Sorting, Paging, and Ordering Custom Related Lists on an Account Page
I'm trying to setup a custom related list on the Account page that has sorting and pagination, but without losing too much of the standard functionality for the page.
So my questions are:
1. Is there a way to reorder the related lists so that the custom list is not at the bottom of all the others? I've tried moving it with javascript but when someone does inline editing then the related lists are rerendered without the custom list. I've also tried using <apex:relatedlist> tags for the other related lists, but then they do not hide/appear for the right page layouts/record types.
2. What's the easiest way to add sorting and pagination? The users would like to be able to click on a column and have it resort.
Visualforce Page
<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">
<apex:detail id="detail" relatedListHover="false" inlineedit="true" />
<!-- Active Licenses --> <apex:pageblock title="Active Licenses" id="licenses" > <apex:facet name="header"> <table border="0" cellpadding="0" cellspacing="0" style="padding:0;border-bottom:none;"><tbody><tr> <td class="pbTitle"><img src="/img/icon/cd24.png" alt="License" class="relatedListIcon" style="width:24px; display:block; margin:-4px 4px -5px -8px;" title="License"/><h3 >Active Licenses</h3></td> <td class="pbButton"><input value="New License" title="New License" class="btn" onclick="window.location.href='{!URLFOR($Action.License__c.New, $ObjectType.License__c,['CF00Na000000A8Imu'=Account.Name,'CF00Na000000A8Imu_lkid'=Account.Id,'retURL'='/'+Account.Id])}';return false;" type="button" style="padding:2px 3px;"/></td> <td class="pbHelp"> </td> </tr></tbody></table> </apex:facet> <apex:pageblocktable title="Active Licenses" id="activelicenses" value="{!Licenses}" var="license" rendered="{!Licenses.size!=0}" > <apex:column headerValue="Name"> <apex:outputlink value="/{!License.Id}" target="_parent" ><apex:outputfield value="{!license.Name}"/></apex:outputlink> </apex:column> <apex:repeat value="{!$ObjectType.License__c.FieldSets.Account_Related_List}" var="f"> <apex:column value="{!license[f]}" /> </apex:repeat> </apex:pageblocktable> <apex:outputText rendered="{!Licenses.size = 0}" value="No records to display" style="padding:5px;border:1px solid #E0E3E5;display:block;" /> </apex:pageblock>
</apex:page>
- Paul.Fox
- October 10, 2013
- Like
- 0
Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
I got this error when i save my test class:
Error: Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
CLASS:
public class ContentVersionAlt { private List<ContentVersion> ContentVersions; public string host{get;set;} public ContentVersionAlt(ApexPages.StandardController controller) { host=URL.getSalesforceBaseUrl().toExternalForm(); } public List<ContentVersion> getContentVersions() { ContentVersions= [Select c.id ,c.Software_Download__c,c.title,c.description,c.FileType From ContentVersion c where c.Software_Download__c=:System.currentPagereference().getParameters().get('id')]; return ContentVersions; } }
TEST CLASS:
@istest private class ContentVersionAltTest { static testMethod void ContentVersionsTest(){ PageReference pageRef = Page.SoftwareDownloadFiles; Test.setCurrentPageReference(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(); //create an instance of the controller ContentVersionAlt myPageCon = new ContentVersionAlt(sc); myPageCon.getContentVersions(); ContentVersion testContentInsert =new ContentVersion(); testContentInsert.ContentURL='http://www.google.com/'; testContentInsert.Title ='Google.com'; insert testContentInsert; ContentVersion testContent = [SELECT ContentDocumentId FROM ContentVersion where Id = :testContentInsert.Id]; ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace WHERE Name='Opportunity Documents ']; ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc(); newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id; newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId; insert newWorkspaceDoc; update testContent; } }
How can i solve this?
Thanks in advantage for any advice.
- Enry
- August 22, 2013
- Like
- 0
Dispaly Alpha bar navigation on Visualforce page for easy jump to pages
Hi
I have simple requirement, I need to disaplay a document list in alpha order and have an alpha bar navigation to easily jump to pages on Visualforce page(Similar to apex class/ visualforce list page which displays the list of class and on click of specific character like "C" or "D" or any other char it display result based on the charecter clicked) I need a soultion something like that any suggestion is highly appricated.
Thanks in Advance.
- Amit_
- June 25, 2013
- Like
- 0
Pop up window in visualforce
Hi,
I am new in Salesforce...I want to design a pop up window. The window will appear after save button is hit which will show the values those an user has entered as input. After the pop up comes out then the user will click the ok in pop up and the page will be redirected to the object view page.
Now how can I implement it throgh java script or any other possible way.
Can u pls provide some sample coding for it.
Thanks in advance,
- Arup..
- September 28, 2011
- Like
- 0
@RemoteAction and Date arguments from javascript
The documentation for javascript remoting says, "Your method can take Apex primitives as arguments," and I'd like to pass a Javascript Date into my remoted function. Javascript Date has a time component, so it's analogous to an Apex DateTime.
However, when I pass in the Date from javascript calling my remoted function, the remoting javascript code throws an exception complaining that I'm not passing in a DateTime but rather the time as an ISO string.
I noticed that in the opposite direction, DateTimes get marshaled as an integer of the number of milliseconds since the epoch (Jan 1, 1970), which javascript can use in a Date constructor, so I tried passing that in for the DateTime arg, but it still complained.
Is there a way to pass a Javascript Date directly to a remoted function as an Apex DateTime??
My workaround in the meantime was to accept the Date as an ISO string, replace the "T" with a space, and use the result to construct the Apex DateTime with DateTime.valueOf. It'd be nice to be able to skip this, though.
Thanks,
--Kevin
- KevinShuk
- July 22, 2011
- Like
- 1
Date Field - Exclude Weekends in formula?
I currently have a date field that displays a date 3 days from the date the form is opened. Here is the formula I used: TODAY() + 3
I would like to modify the formula to show a value of 3 business days instead of 3 days. Can someone help?
Thanks in advance.
- RRRize
- March 16, 2011
- Like
- 1
Trigger syntax for Lead Convert trigger?
trigger test on Lead (after convert) { }
but I get an Invalid Token error. There are no hints in the documentation.
thanks
David
- dmcheng
- October 28, 2008
- Like
- 1