• Vinuthh S
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 20
    Replies
I am new to SOQL. 
I am trying to write a simple query where it basically says "SELECT aDate from TableA where aDate is less than today's date"
The data field for aDate is TEXT(10), and it displays as 2017-02-28.
I googled around, but somehow, it would not retrieve the output as I expected.
I found something like using TODAY, TODAY(), SYSTEM.TODAY() etc.

If I do this this works.
SELECT aDate from TableA where aDate < '2017-02-28'

What is expression that says today's date in the text format?

Thanks in advance.

 
Hi 

I geting the Too Many SOQL Queries:101 in below Line in webservice class

 List <Custom_Notification__c> notificationList = [SELECT Account_Id__c, Application_Id__c, Loan_App_Id__c, 
                                                              Message__c, Notify_Date__c 
                                                              FROM Custom_Notification__c
                                                              WHERE Account_Id__c =: accountId
                                                              AND User_Type__c =: account.Type
                                                              ORDER BY Notify_Date__c desc
                                                              LIMIT 3];

Thanks
Vinuthh S
<apex:page controller="AccountSelectClassController" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
                <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
               <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.MC_Title__c}" />
                    <apex:column value="{!accWrap.acc.MC_Content__c}" />
                    <apex:column value="{!accWrap.acc.MC_EffectiveDate__c}" />
                </apex:pageBlockTable>
               
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

Contoller

public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<MC_NewsFeed__c> selectedAccounts{get;set;}
    Date endDate = Date.newInstance(2015,02,21);
    Date startDate= Date.newInstance(2015,02,01);
    Integer maxRecord=5;
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(MC_NewsFeed__c a: [select MC_Title__c,MC_Content__c,MC_EffectiveDate__c from MC_NewsFeed__c where (MC_FeedType_del__c = 'Recent GoLive') AND (MC_EffectiveDate__c >= :startDate) AND  (MC_ExpiryDate__c < :endDate)]  ) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
     public pageReference processSelected() {
    selectedAccounts = new List<MC_NewsFeed__c>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
        if(selectedAccounts.size()>5){
             Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'Invalid block selection. Cannot insert blocks below the selected block')); 
             return null;
        }
      return null;  
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public MC_NewsFeed__c acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(MC_NewsFeed__c a) {
            acc = a;
            selected = false;
        }
    }
}
Hi ,

I am using Force.com migration tool , I have been created Apex class and Test class, in Force.com IDE test coverage is showing 100%  but while deploying its failling and throwing the error 0% code coverage. Please help me if any one has idea about that.

Thanks & Regards
Bhushan Singh
Error Message:
Code Coverage Failure
Your code coverage is 12%. You need at least 75% coverage to complete this deployment.
 
Can someone tell me why I am getting an unknown property accounts.SFDC_Account_Name__c when I pass this field as a parameter to the JS function

Save error: Unknown property 'DataIntegrityList.accounts'    
I am completely baffled as there are many examples in the forum and the web depicting this same pattern.

 
<apex:form >
		   <apex:pageBlock title="Account Data Integrity Issues List">
		      <apex:pageBlockTable value="{!accountProblemsList}" var="accounts" onRowClick="rowSelected('{!accounts.SFDC_Account_Name__c}')">
		      	
		         <apex:column value="{!accounts.PW_Account_Number_SFDC__c}"/>
		         <apex:column value="{!accounts.PW_Account_Number__c}"/>
		        
		         <apex:column value="{!accounts.SFDC_Account_Name__c}"/>
		         <apex:column value="{!accounts.SFDC_ID_PW__c}"/>        
		         <apex:column value="{!accounts.PW_Rep__c}"/>   
		         <apex:column value="{!accounts.SFDC_rep__c}"/>
		         <apex:column value="{!accounts.SFDC_repid__c}"/>
		         <apex:column value="{!accounts.PW_Acct_Status__c}"/>         
		      </apex:pageBlockTable>
		   </apex:pageBlock>
   	</apex:form>

 
I I have two custom obj one is called Parent and the other Child..lookup relationship exists between the two obj..i want to count the child records for each parent and update it in a field named "ContactsCount"..I facing some exception error when tryin to insert Child records..below is the code
trigger ConCount on Child__c (after insert) {
Set <id> CHildIds = new set<id>();
List<Child__c> ChildList = new List<Child__c>();
List<Child__c> ListCon = new List<Child__c>();
List<Parent__c> ParentList = new List <Parent__c>();
List<Parent__c> ListParent = new List <Parent__c>();
Map<id,integer> ConMap = new map <id,integer>();
if(Trigger.isInsert){
    for(Child__c Chil : Trigger.New){
    CHildIds.add(Chil.Parentlookup__c);}   
    ParentList = [select id, name from Parent__c where id IN :CHildIds];
    ChildList = [select id,name , Parentlookup__c from Child__c where Parentlookup__c IN :CHildIds];
        for(Parent__c P :ParentList){
        Listcon.clear();
        for(Child__c C : ChildList){
        if(C.Parentlookup__c == P.id){
        ListCon.add(C);
         ConMap.put(P.id,ListCon.size());
         
         } }}
        if(ParentList.size()>0){
        for(Parent__c Pa : ParentList){
        if(ConMap.size()>0){
        Pa.ContactsCount__c = ConMap.get(Pa.id);
        ListParent.add(Pa);
        }}}
        if(ListParent.size()>0)
        update ListParent;
        }}

 
Hello, 

I have this commandlink on a visualforce page:
 
<apex:commandlink action="{!saveProdChanges}" rerender="Messages" value="Save" immediate="true" styleclass="buttonprod" onclick="console.log('click save')">
                                                                    <apex:param name="buttonsave" value="{!product.id}" id="saveParam" assignTo="{!saveProd}"/>                                                                  
                                            </apex:commandlink>

which calls this method on my controller:
public string saveProd {get; set;}

public pageReference saveProdChanges(){

producto_simulacion__c productoEdit = new producto_simulacion__c();
productoEdit = [SELECT Id, categoria__c, cantidad__c, importe__c, descripcion__c, costo_unitario__c FROM producto_simulacion__c WHERE id =: saveProd];

update productoEdit;
}
I edited so i can try the button, I also trying with just:
 
public pageReference saveProdChanges(){

system.debug('Hello, this is saveProdChanges method');

}

but is not doing anything when i press the button. Browser console is not showing any error, it's displaying correctly the console.log on it.
Log in developer console is not showing the debug, but it does a log when I click it....

What could be wrong?

 
  • April 06, 2017
  • Like
  • 0
Hi All,

I am working on a requirement where we need to show the columns in a vf page based on the selected values in a multiselect picklist.
Below is the mock for the same.
User-added image
Any help on this would be greatly appreciated. We have completed one half of the thing but we are stuck with errors will be posting the code soon.

Thanks and Regards,
Bharath Kumar M
 
Hi,

Visualforce page is not showing column header in customer portal.  Kindly check two images of visualforce page in adminstrator profile and customer portal profile.   Please let me know how to display the column headers in sites.  Below is the code.

public class outstanding {
    public list<f_97__c> f{set;get;}
    public outstanding(){
        f=[select type__c, assignment__c, Doc_Date__c, bline_date__c, total__c from f_97__c where sap_code__c= 'VF0209' limit 99];
    }
}
<apex:page controller="outstanding" sidebar="false" setup="false" showHeader="true">
    <apex:form >
        <apex:pageBlock title="Outstanding" >
            <apex:pageBlockTable value="{!f}" var="a" >                
                <apex:column value="{!a.Type__c}" headerValue="Type" />
                <apex:column value="{!a.Assignment__c}" headerValue="Invoice No"/>              
                <apex:column value="{!a.Doc_Date__c}" headerValue="DocDate" />
                <apex:column value="{!a.Bline_Date__c}" headerValue="Due Date" />                
                <apex:column value="{!a.Total__c}" headerValue="Amount" />                      
            </apex:pageBlockTable>        
        </apex:pageBlock>
    </apex:form>
</apex:page>

User-added image

User-added image
 
I am trying to teach myself Apex, so I've come up with a project to create and am figuring it out step-by-stumbling-step. Here is the step I am stuck on.

Here is my goal: I want a page that shows you a list of records in a table. When you click the name of one of the records, the whole list disappears and you see a page showing information from that record.

Here's my code so far which is not working. It's a page which loads the two separate pages, and decides which one to render based on whether a certain variable (the selected record id) is null or not.

Controller:
public class testController {
    public id gameId{get; set;}
    
    public List<Game__c> getGames() {
    	List<Game__c> results = Database.query(
        	'SELECT id,name,owner.name,LastModifiedDate FROM game__c'
        );
        return results;
    }
}

Page 1:
<apex:page showheader="true" controller="testController">
    <apex:include pageName="listPage" rendered="{! ISNULL( gameId ) }"/>
    <apex:include pageName="detailPage" rendered="{! NOT( ISBLANK( gameId )) }"/>
</apex:page>
listPage:
<apex:page showHeader="false" controller="testController" id="display">

        <apex:form >
            <apex:pageblock >
                <apex:pageblocktable value="{! games}" var="g">                   
                    
                    <apex:column headerValue="Name">
                        <apex:commandLink value="{!g.Name}" rerender="display" >
                            <apex:param assignTo="{!gameId}" name="{!g.Id}" value="{!g.Id}"/>
                        </apex:commandLink>
                    </apex:column>

                </apex:pageblocktable>
           </apex:pageblock>
       </apex:form>
</apex:page>

detailPage:
<apex:page showHeader="false" controller="testController">    
    <apex:outputtext value="test" />
</apex:page>
Expected behavior: I click the the name of the any of the Game records in the list on the listPage and the whole list disappears and is replaced with a blank white screen and the word "test".
Actual results: Clicking the name does nothing.

Am I on the right track trying to do this with three separate pages? Or should this all be handled in one visualforce page?
in 3rd line created list of ID's List<ID> ids, then in 5th line [SELECT Name FROM Account WHERE ID in :ids];  .i think parameter ids has null values then how can we query like ID IN :ids...please explain me what will exists in the parameter of 'ids' in 3rd line...
public class AccountQueryAction {
@InvocableMethod(label='Get Account Names' description='Returns the list of account names corresponding to the specified account IDs.')
public static List<String> getAccountNames(List<ID> ids) {
List<String> accountNames = new List<String>();
List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids];
for (Account account : accounts) {
accountNames.add(account.Name);
}
return accountNames;
}
}
I am new to SOQL. 
I am trying to write a simple query where it basically says "SELECT aDate from TableA where aDate is less than today's date"
The data field for aDate is TEXT(10), and it displays as 2017-02-28.
I googled around, but somehow, it would not retrieve the output as I expected.
I found something like using TODAY, TODAY(), SYSTEM.TODAY() etc.

If I do this this works.
SELECT aDate from TableA where aDate < '2017-02-28'

What is expression that says today's date in the text format?

Thanks in advance.

 
Hi, 

Appreciate any help. We can't deploy our Apex class and trigger as some of the existing Apex test are failing. I believe it is required to run test on all classes. Any way around this? The failed test consists of both managed scripts and custom scripts created on our first implementation of Salesforce by a vendor. How can I find out if there's any impact if we remove these scripts?
I have the following pagination code/vf page. I am getting an error that says 'List controllers are not supported for Task '. How can I update the code to make the visualforce page work?

Apex: 
public class PaginationTaskHomePage1{


public String soql {get;set;}
public List <Task> TaskList1 = New List <Task>();
public String soqlsort {get;set;}
public List <Task> TaskList2= New List <Task>();
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
            public List <Task> getTaskList()
            {
            return con.getRecords();
            }
            
            public Apexpages.StandardSetController con{
            get{
                    if(con==null){
                 size=500; 
                string OwnersId =  userinfo.getUserId() ; 
                string type1 =   'Lost NB Round 1';
                string type2 = 'Lost Renewals';
                    soqlsort='Select Subject,WhoID,WhatId,OwnerId,Opportunity_Effective_Date__c,Primary_Medical_Effective_Date__c,Type,CreatedDate From Task Where OwnerId = :OwnersId AND (Type = :type1 OR Type= :type2)';   
                    
                    TaskList1 = Database.query(soqlsort + ' Order by ' +  sortField +' ' + sortDir);
                    
                    con= new ApexPages.StandardSetController(TaskList1);
                    con.setPageSize(size);
                    noOfRecords=Con.getResultSize();
                  }
                  return con;
             }
             set;
             }
             public Boolean hasNext {
             
             get {
                 return con.getHasNext();
                 }
                 set;
                 
                 }
                 
                 //indicates whether therre are more records before the current page set. 
                 
                 public Boolean hasPrevious{
                 get{
                 return con.getHasPrevious();
                 
                 }
                 set;
                 }
                 
            public Integer pageNumber {
            get{
            return con.getPageNumber();
            }
            set;
            }
            
            public void next(){
            con.next();
            
            }
            //returns the PageRerfernce of the original page, if known, or home page. 
            public void cancel() {
            con.cancel();
            }
            // Method for Constructor is used for Test Class
            public PaginationTaskHomePage1()
            {
            }
            //Toggles the sorting of query from asc to desc
            
            public void toggleSort() {
            
            //simply toggle the direction
            sortDir= sortDir.equals('asc') ? 'desc' : 'asc';
            
            //run the query again for sorting other columns 
                     string OwnersId =  userinfo.getUserId() ;
               
                string type1 =   'Lost NB Round 1';
                string type2 = 'Lost Renewals';
            soqlsort = 'Select Subject,WhoID,WhatId,OwnerId,Opportunity_Effective_Date__c,Primary_Medical_Effective_Date__c,Type,CreatedDate From Task Where OwnerId = :OwnersId AND (Type = :type1 OR Type= :type2)';      
                    
            
            //adding string array to a List array
            TaskList2 = Database.query(soqlsort + ' Order by ' +  sortField + ' ' + sortDir);
            
            // Adding Caselist to standard Pagination controller variable
             con= new ApexPages.StandardSetController(TaskList2);
            
            //Set Page Size to 500
            con.setPageSize(500);
            }
            //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 probability
                
                public String sortField{
               //to set a field sorting.
                    get{if (sortField==null){sortField='Opportunity_Effective_Date__c';} return sortField;}
                    set;
                    }
                    
                    
                    
                    
                        public pageReference refresh() {
                       Con = null;
                       getTaskList();
                       Con.setPageNumber(1);
                       return null; 
    }
    
    
                    }

VisualForce:
 
<apex:page controller="PaginationTaskHomePage1" tabstyle="Task">
    <apex:form >
       <apex:pageBlock id="pb">
       <apex:sectionHeader title="{!$User.FirstName}'s Lost Renewal & New Business List"/>
       <apex:commandButton value="New Opportunity" onClick="window.open('https://cs15.salesforce.com/006/e?retURL=%2F006%2Fo&RecordType=01240000000Uexl&ent=Opportunity');"/>
       <apex:commandButton value="Detailed Report" onClick="window.open('https://cs15.salesforce.com/00Oe0000000fRSG');"/>
       
            <apex:pageBlockTable value="{!TaskList}" var="o" id="myTable">
         <apex:column >
        <apex:facet name="header">
            <apex:commandLink value="Subject" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="Subject" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputlink value="/{!o.subject}" target="__blank">{!o.subject}</apex:outputlink> 
    </apex:column>
    <apex:column >
        <apex:facet name="header">
            <apex:commandLink value="WhoID" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="WhoId" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputField value="{!o.WhoId}" />
    </apex:column>
    <apex:column >
     <apex:facet name="header">
            <apex:commandLink value="WhatId" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="WhatId" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputField value="{!o.WhatId}" />
    </apex:column>
    <apex:column >
        <apex:facet name="header">
            <apex:commandLink value="OwnerId" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="OwnerId" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputlink value="/{!o.OwnerId}" target="__blank">{!o.OwnerId}</apex:outputlink> 
    </apex:column>
 <apex:column >
     <apex:facet name="header">
            <apex:commandLink value="Opportunity_Effective_Date__c" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="Opportunity_Effective_Date__c" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputField value="{!o.Opportunity_Effective_Date__c}" />
    </apex:column>
    <apex:column >
     <apex:facet name="header">
            <apex:commandLink value="Primary_Medical_Effective_Date__c" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="Primary_Medical_Effective_Date__c" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputField value="{!o.Primary_Medical_Effective_Date__c}" />
    </apex:column>
    <apex:column >
     <apex:facet name="header">
            <apex:commandLink value="Type" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="Type" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputField value="{!o.Type}" />
    </apex:column>
    <apex:column >
     <apex:facet name="header">
            <apex:commandLink value="Create Date" action="{!toggleSort}" reRender="pb">
                <apex:param name="sortField" value="CreatedDate" assignTo="{!sortField}" />
            </apex:commandLink>
        </apex:facet>
        <apex:outputField value="{!o.CreatedDate}" />
    </apex:column>   
</apex:pageBlockTable>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!Con.first}" disabled="{!!Con.hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!Con.previous}" disabled="{!!Con.hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!Con.next}" disabled="{!!Con.hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!Con.last}" disabled="{!!Con.hasNext}" title="Last Page"/>
                <apex:outputText >{!(Con.pageNumber * size)+1-size}-{!IF((Con.pageNumber * size)>noOfRecords, noOfRecords,(Con.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                  <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                   </apex:outputPanel> 
            </apex:panelGrid>
            </apex:pageBlock>
    </apex:form>
</apex:page>

 
Hello,

I am using picklist field. I want to write manually in that field. I know its not posiible. But is there any other way?

Thanks & Regards,
Utz
HI ,

I have vf component and I am trying to save data from this component into a custom SObject .
Because I am unable to use Standard Controllers in vf component I am struggling with this.
This is what my vf componet looks like


<apex:component controller="wk_NotesController" id="tst" allowDML="true">
    <apex:attribute name="componentValue" description="Attribute on the component."
                  type="Boolean" required="required" assignTo="{!controllerValue}"/>

        <apex:commandButton value="Show Pop up" action="{!showPopup}" rerender="tstpopups"/>
        <apex:pageBlock >
           Older Notes Section 
        </apex:pageBlock>      
        <apex:outputPanel id="tstpopups">
        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
           <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
     <!-- Comments box -->       
    <apex:outputLabel styleClass="label"   value="{!$ObjectType.Account_Notes_and_Alerts__c.fields.Note_Text__c.Label}" />
    <apex:inputField id="txtcmnt" value="{!val.Note_Text__c}" styleClass="box"/>
              
       <!-- NOte Type Drpdwn -->
    <apex:outputLabel styleClass="label"   value="{!$ObjectType.Account_Notes_and_Alerts__c.fields.Note_Type__c.Label}" />
    <apex:inputField id="drpdwn" value="{!val.Note_Type__c}" styleClass="box"/>  

      <!-- Check Box -->
           <apex:outputLabel styleClass="label" value="{!$ObjectType.Account_Notes_and_Alerts__c.fields.Alert__c.Label}"></apex:outputLabel>
           <apex:inputCheckbox styleClass="" value="{!val.Alert__c}" />
   
    <apex:commandButton action="{!saveValues}" value="Save" id="btnSave" />               
          <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="tstpopups"/>                  

              
            </apex:outputPanel>
        </apex:outputPanel>

</apex:component>