• pankaj kabra 8
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 15
    Replies
This is my first attempt at apex.  Can anone help me understand why this loop only updates one record when it should be updating multiple?

global class Idea_Votes_Copy_to_Enhancement implements Schedulable{
    global void execute(SchedulableContext ctx) {
        List<SFDC_Component__c> enhList = new List <SFDC_Component__c>();
        SFDC_Component__c ER = new SFDC_Component__c();
        List<Idea> iList=[SELECT VoteTotal, Enhancement_Requirement_ID__c FROM Idea WHERE VoteTotal >0 AND Status !='Deployed' AND Enhancement_Requirement_ID__c != null];
           for(idea i:IList){
            ER.id = i.Enhancement_Requirement_ID__c;
            ER.Vote_Count__c = i.VoteTotal;
            enhList.add(ER);
             }
        Set<SFDC_Component__c> erSet = new Set<SFDC_Component__c>();
        erSet.addAll(enhList);
        enhList.clear();
        enhList.addAll(erSet);  
        upsert enhList; 
    }
}
I am trying to write a grammar for parsing a SOQL query and while doing that I faced a problem where I need to find the maximum number of Aggregate functions (SUM (FieldName), COUNT (FieldName),... etc.) can be used in a single select clause of a SOQL query. Any help we appreciated. Thanks in advance!!!!!!
User-added image 
like this type of attachment code by using jqury or javascript or html
please provide immediatly
Hi all,

My Scenario, i inserted some contacts with Dataloader in to Contacts Obj while inserting i left Account Name field empty in Contacts Obj. Now i want to update that field(Account Name field in Contact Obj).

Ex: For Contacts, starts with 'Al%' Account Name will be "Infosys".
      For Contacts, starts with 'Na%' Account Name will be "IBM".
      For Contacts,  starts with 'Ma%' Account Name will be "TCS".

for this i wrote a trigger as below it didn't showing error but not updating Account Name field in Contact.

Trigger:

trigger AddAccName on Contact (before insert, before update) {

list<contact> lst = new list<contact>([select id,name from contact where name like 'al%']);
for(contact c: trigger.new)

    {

      c.account.name = 'Infosys';
      lst.add(c);
    }
   
    insert lst;
  
}
Hi

I am trying to query contactid of logged in user like this.
But i dont see any value.
Where am i going wrong??
 
Id Uid=UserInfo.getUserId();
//DEBUG HERE GETS LOGGED IN USER ID
string contid='select contactid from user where id = '+ Uid + '';
//DEBUG HERE IN CONSOLE SHOWS 1 record BUT VALUE SEEMS TO BE NULL.
List<accountcontactrole> acr =[select accountid,Account.name from accountcontactrole where contactid =:contid];
//DEBUG HERE IS EMPTY LIST.
Thanks in advance!!
 
I have a scenario where, I want to populate LOOKUP field based on <apex:selectionlist>

Example:
<apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
                  <apex:selectList id="theform" value="{!selectedCategory}" size="1" required="true" style="width:180px" >
                <apex:selectOptions value="{!Categories}" />
                <!--<apex:actionSupport event="onchange" action="{!createServiceAgreement}" reRender="pg"/>-->
                <!--<apex:actionFunction name="createServiceAgreement" action="{!createServiceAgreement}" reRender="panel"/>
                <apex:actionSupport event="onchange"/>-->
              </apex:selectList>        
              </apex:outputPanel>

And my lookup field is :

<apex:inputField id="panel" value="{!ReqUser.ServiceAgreement__c}" required="true"/>


I tried couple of solutions using:

<apex:actionFunction name="createServiceAgreement" action="{!createServiceAgreement}" reRender="panel"/>
and there is no solution.


1..Is that really possible to populate LOOKUP field based on selectionlist using <APEX:ACTIONFUNCTION>???
or 2.Have to only Trigger in such scenario??

Pls help. 
<apex:page Controller="Delet">

<apex:form >

  <center>
  <apex:pageBlock >
    <b>Category:&nbsp;&nbsp;</b>
    <apex:selectList value="{!ctgry}" size="1">
      <apex:selectOptions value="{!ctgrys}"/>
    </apex:selectList> 
  </apex:pageBlock>
  </center>
 
</apex:form>
</apex:page>





public class Delet
{

    public String[] ctgry = new String[]{};
   
    public Delet()
    {

    }
   
    public List<SelectOption> getCtgrys()
    {   
      List<SelectOption> options = new List<SelectOption>();
      options.add(new SelectOption('US','US'));
      options.add(new SelectOption('CANADA','Canada'));
      options.add(new SelectOption('MEXICO','Mexico'));
      return options;
    }
   
    public String[] getCtgry()
    {
      return ctgry;
    }
   
    public void setCtgry(String[] ctgry)
    {
    this.ctgry = ctgry;
    }   

}



Can some one tell me in the above code,what is &nbsp;&nbsp and in the line public String[] ctgry = new String[]{};
why [] and {} both the braces is used and what does that line mean.
why  MEXICO','Mexico' caps and small letters used.why constructor,getter and setter used.