• srinu_SFDC
  • NEWBIE
  • 105 Points
  • Member since 2013

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 25
    Replies
Note: I'm very much a beginner at this, so please bear with me!

I am working on an apex trigger to add new leads to the appriate campaign, based on two of the lead fields: Trip Name and Trip Date. The campaign would be named Trip Name Trip Date, with a space between the name and the date.

Here's the trigger:
trigger AddWebLeadToTripCampaign on Lead (after insert) {
    CampaignMember[] cms = new CampaignMember[0];
    for(Lead record:Trigger.new)
        try{
            if(!String.isBlank(record.Trip_Name__c)) {
                String cname = record.Trip_Name__c+' '+record.Trip_Date__c;
                cname = cname.trim();
                System.debug('the value of cname is >>>>> ' + cname);
                List <Campaign> CIDs = [select id, name from Campaign where name = :cname limit 1];
                System.debug('the list of CIDs is >>>>> ' + CIDs);
                String CID = [SELECT ID FROM Campaign].ID;
                cms.add(new CampaignMember(LeadId=record.Id,CampaignId=CID));
            }
        insert cms;
        }catch (Exception e){
            system.debug('The following exception has occurred: ' + e.getMessage());
        }
}
For some reason it doesn't seem to be working. In the debug log I get an error:
USER_DEBUG|[16]|DEBUG|The following exception has occurred: List has more than 1 row for assignment to SObject

But shouldn't the "limit 1" in the query fix that?

Thanks for your help!
I just created an Apex Class in my Sandbox Org that is running on the Summer 2014 preview. The code works fine, but when I deploy the changeset to Production I get the below error:

"This change set contains components that require 31.0 or higher platform version. Please select an Organization with a platform version of 31.0 of higher".


Is there a way around this or do I need to wait until July 18th when SFDC Production is updated with Summer 2014? 
I am trying to do a soql query using database.query so that I can dynamically build the search parameters.  the problem I am having is with the following portion:
qry3 = qry2 + 'where name like :%' + sobj.name + '% OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I put it in this way I get the error : no viable alternative at character '%'
I have tried:
qry3 = qry2 + 'where name like :\'%' + sobj.name + '%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I do it this way I get the error: unexpected token: '%test test%'
and I have tried it this way: 
qry3 = qry2 + 'where name like :\'%\'' + sobj.name + '\'%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
and I get the error: unexpected token: '%'

Any idea what I need to change to get the like statement to work?

I have been able to implement pagination in the my visual force page but stuck with duplicate selectList problem. My requirment requires the Page Size drop down to be shown  in top as well as bottom. Now even if I change the pageSize it gets resetted to default value

Please suggest if there is way to achieve it.

<apex:actionFunction name="topChangeLimit" action="{!changeLimit}" status="sortStatus" reRender="page,bottomPageSize"/> <apex:actionFunction name="bottomChangeLimit" action="{!changeLimit}" status="sortStatus" reRender="page,topPageSize"/> <apex:selectList id="topPageSize" value="{!limits}" size="1" onchange="topChangeLimit();return false;"> <apex:selectOptions value="{!items}"/> </apex:selectList> <apex:selectList id="bottomPageSize" value="{!limits}" size="1" onchange="bottomChangeLimit();return false;"> <apex:selectOptions value="{!items}"/> </apex:selectList>

 

I am getting this error  in the ApexTrigger in the production environment , And i am also pasting the query  where i am  getting this error 

Map<ID, Contact> contactsForAccounts = new Map<ID, Contact>([select Id
                                                            ,AccountId
                                                            from Contact
                                                             where AccountId in :acctIds and Name != null and Contact_Type__c includes ('Technical Contact')]);

ApexTrigger: execution of AfterUpdate  caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

I have searched so many blogs in google , what ever they suggested in that blog are there in this query , eventhough i dont know why i am getting this error.
If any one have any idea on this , please Kindly help me over this error.


list<Student__c> stnewlist=new list<Student__c>();
list<Student__c> stlist=[select id,name from Student__c where Sport__cid in:set2 ];




Error:  No such column 'Library__cid' on entity 'Sport__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.User-added image
Note: I'm very much a beginner at this, so please bear with me!

I am working on an apex trigger to add new leads to the appriate campaign, based on two of the lead fields: Trip Name and Trip Date. The campaign would be named Trip Name Trip Date, with a space between the name and the date.

Here's the trigger:
trigger AddWebLeadToTripCampaign on Lead (after insert) {
    CampaignMember[] cms = new CampaignMember[0];
    for(Lead record:Trigger.new)
        try{
            if(!String.isBlank(record.Trip_Name__c)) {
                String cname = record.Trip_Name__c+' '+record.Trip_Date__c;
                cname = cname.trim();
                System.debug('the value of cname is >>>>> ' + cname);
                List <Campaign> CIDs = [select id, name from Campaign where name = :cname limit 1];
                System.debug('the list of CIDs is >>>>> ' + CIDs);
                String CID = [SELECT ID FROM Campaign].ID;
                cms.add(new CampaignMember(LeadId=record.Id,CampaignId=CID));
            }
        insert cms;
        }catch (Exception e){
            system.debug('The following exception has occurred: ' + e.getMessage());
        }
}
For some reason it doesn't seem to be working. In the debug log I get an error:
USER_DEBUG|[16]|DEBUG|The following exception has occurred: List has more than 1 row for assignment to SObject

But shouldn't the "limit 1" in the query fix that?

Thanks for your help!
If I want to show a smaller, more compact layout on salesforce1 for my mobile users, but continue to show our current default view when users are using a computer to view salesforce, how do I do that? If you can only have one profile per user and one page layout per profile for a specific record type, how can I do this?
Hi....
i have upload same image in static resource and i want shuffle those images randomly after some time.
pls help....
I just created an Apex Class in my Sandbox Org that is running on the Summer 2014 preview. The code works fine, but when I deploy the changeset to Production I get the below error:

"This change set contains components that require 31.0 or higher platform version. Please select an Organization with a platform version of 31.0 of higher".


Is there a way around this or do I need to wait until July 18th when SFDC Production is updated with Summer 2014? 
<apex:page standardController="Restaurant_Supp_App__c" showHeader="true">
<head>
    <link rel="stylesheet" type="text/css" href="https://www.insynergyconnect.com/tables.css"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
    <script>
        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
        });
        j$(function() {
            j$("#show").click(function(){
                 j$("#protection").show("slow");
            });
            j$("#hide").click(function() {
                 j$("#protection").hide("slow");
             });
            j$("#toggle").click(function() {
                j$("#protection").toggle("slow");
             });
          });
    </script>
</head>
<body>
    <p>
    What about this style
    </p>
    <apex:form >
        <div id="protection">
        <table align="center" id="bldgprotect">
            <caption>
                Common Protection Questions
            </caption>
          <tr>
            <td id="question">Are any Banquets or Functions?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Banquet_or_Function__c}"/></td>
            <td id="question">Is the lodging area sprinkled?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Area_Sprinklered__c}"/></td>
          </tr>
          <tr>
            <td id="question">Describe Banquets And Functions</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Describe_Banquet_or_Functions__c}"/></td>
            <td id="question">Does emergency lighting exist?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Does_Emergency_Lighting_Exist__c}"/></td>
          </tr>
          <tr>
            <td id="question">Does each room have smoke detectors?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Ea_Room_Smoke_Detectors__c}"/></td>
            <td id="question">Are evacuation routes well marked?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Evac_Routes__c}"/></td>
          </tr>
          <tr>
            <td id="question">Is there a second means of egress?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Second_Means_Egress__c}"/></td>
            <td id="question">Are evacuation routes well marked?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Evac_Routes__c}"/></td>
          </tr>
          <tr>
            <td id="question">Describe the security for lodging:</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Security__c}"/></td>
            <td id="question">Are smoke detectors in common areas?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Smoke_Det_Common_Areas__c}"/></td>
          </tr>
          <tr>
            <td id="question">What type of smoke detectors?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Smoke_Det_Type__c}"/></td>
            <td id="question">Are smoke detectors in common areas?</td>
            <td id="answer"><apex:inputfield value="{!Restaurant_Supp_App__c.Lodging_Smoke_Det_Common_Areas__c}"/></td>
          </tr>
        </table>
        </div>
        <p>
        </p>
        <div align="center">
            <button id="show">Show</button>
            <button id="hide">Hide</button>
            <button id="toggle">Toggle</button>
        </div>
    </apex:form>
</body>
</apex:page>
I am trying to do a soql query using database.query so that I can dynamically build the search parameters.  the problem I am having is with the following portion:
qry3 = qry2 + 'where name like :%' + sobj.name + '% OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I put it in this way I get the error : no viable alternative at character '%'
I have tried:
qry3 = qry2 + 'where name like :\'%' + sobj.name + '%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I do it this way I get the error: unexpected token: '%test test%'
and I have tried it this way: 
qry3 = qry2 + 'where name like :\'%\'' + sobj.name + '\'%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
and I get the error: unexpected token: '%'

Any idea what I need to change to get the like statement to work?
i have a problem saving multiple records at a time. i think the problem is in the saveSeats() i just don't get it. the data display fine in the pageblocktable but it doesn't save when i click the save button. any idea what's the problem here? please help.

Apex Class:
public with sharing class NewScheduleSeatsCX {
    List<Seat__c> seatList = new List<Seat__c>();    //saving seat records
    public List<SeatsWrapper> wrappers {get;set;}        //wrapperlist
    public List<Integer> numberOfSeats {get;set;}
   
    public Schedule__c sd {get;set;}
    public Schedule__c schedule {
      get {
        if (schedule == null)
          schedule = new Schedule__c();
        return schedule;
      }
      set;
    }

    public NewScheduleSeatsCX(ApexPages.StandardController controller) {
        wrappers = new List<SeatsWrapper>();
        numberOfSeats = new List<Integer>();
      
        sd=[select id, name, Number_Of_Seats__c from Schedule__c where id =: apexPages.currentPage().getParameters().get('id')];
        for(integer i=1;i<=sd.Number_Of_Seats__c; i++){
            SeatsWrapper temp = new SeatsWrapper();
            temp.seatNum = i;
            temp.seat = new Seat__c();
            wrappers.add(temp);
        }
    }
  
/**************    Wrapper    *************/
    public class SeatsWrapper {
 public Seat__c seat {get;set;}
 public Integer seatNum {get;set;}
    }
/**************    /Wrapper    *************/

//------------------------------   Save Seats     ------------------------------//
    public pageReference saveSeats() {
        try {
            for(SeatsWrapper  s : wrappers ) {
                    Seat__c newSeats = new Seat__c();
   
                    String seatName = newSeats.Name;
                    Integer sN = Integer.valueOf(seatName);
                   
                    sN = s.seatNum;
                    newSeats.Schedule__c = schedule.Id;
                    newSeats.Taken__c = s.seat.Taken__c;
                   
                    seatList.add(newSeats);
                }
                insert seatList;            //save all seats
          
        } catch(Exception e) {
            apexPages.addMessages(e);
        }
        return null;
    }
//------------------------------   /Save Seats     ------------------------------//
}

VF Page:
               <apex:pageBlockTable value="{!wrappers}" var="sched">
                         <apex:column headerValue="Seat #" style="padding: 0px 20px;">
                                     <apex:outputText value="{!sched.seatNum}"/>
                         </apex:column>
                         <apex:column headerValue="Taken" style="padding: 0px 20px;">
                                     <apex:inputField value="{!sched.seat.Taken__c}"/>
                         </apex:column>
                </apex:pageBlockTable>

  • January 02, 2014
  • Like
  • 0
Asset - Assetid,serialnumber and qty

transaction - tno , Asset(fk)


I want to relate to transaction (Asset) to Asset(serialnumber)


public List<Asset> Incemp {get;set;}   ---> I m not using list<> =new list<> , because i added a row...

  temp = Incemp.Asset__c - working fine

  temp = Incemp.Asset__r.serialnumber__c - not working


Any idea...
  • January 02, 2014
  • Like
  • 1
I have a SOQL limit problem which I'm not sure how to fix,  it concerns this class but I've tried to make it with lists and maps so the SOQL limit wouldn't exceed. And it's only that underlined part which doesn't work .

public class UpdateMainAccountTechnologyList
{  
    public Boolean UpdateList(Account acc)
    {
        Boolean hasPolycom = false;
        Boolean hasDS = false;
        Boolean hasCisco = false;
        Boolean hasVidyo = false;
       
        List<String> codecdetails = new List<String>();
       
        List<String> polycoms = new List<String>();
        polycoms.add('Polycom');
        polycoms.add('HDX');
        polycoms.add('VSX');
        polycoms.add('QDX');
        polycoms.add('Group');
       
        List<String> vidyos = new List<String>();
        vidyos.add('Vidyo');
        vidyos.add('HD50');
        vidyos.add('HD100');
        vidyos.add('HD200');
       
        List<String> ciscos = new List<String>();
        ciscos.add('Cisco');
        ciscos.add('Cx');
        ciscos.add('Cxx');
        ciscos.add('EXxx');
        ciscos.add('MXxx');
        ciscos.add('SXxx');
        ciscos.add('MXP');
        ciscos.add('Profile');
       
        List<String> signages = new List<String>();
        signages.add('Signage');
       
        List<Asset__c> assets = [select Codec_Model__c, Codec_Details__c from Asset__c where Setup__c in (select Id from Setup__c Where Main_Account__c = :acc.Name and RecordType.Name != 'Infra') and (Codec_Model__c != null or Codec_Details__c != null)];
        for(Asset__c assetti : assets)
        {
            codecdetails.add(assetti.Codec_Model__c + ' : ' + assetti.Codec_Details__c);
        }
           
        List<Setup__c> setupit = [select Platform_Manufacturer__c, Name, RelatedMCU__c from Setup__c where Main_Account__c = :acc.Name];
        List<Setup__c> infrasetupit = [select Id, Platform_Manufacturer__c from Setup__c where Platform_Manufacturer__c != null];
       
         // Mika R 2013-Dec-13: Map the infra setups
        Map<Id, String> infraSetupMap = New Map<Id, String>();
        for (Setup__c s: infrasetupit) if (!infraSetupMap.containsKey(s.Id)) infraSetupMap.put(s.Id, s.Platform_Manufacturer__c);
       
        for(Setup__c setuppi : setupit)
        {
            if(setuppi.Platform_Manufacturer__c != null)
            {
                codecdetails.add(setuppi.Platform_Manufacturer__c);
            }
            //if the account has only virtual meeting rooms, we must find setup that has vmr as related mcu and find in what platform that vmr is
            if(setuppi.RelatedMCU__c != null)
            {
                // Mika R 2013-Dec-13: Fetch infra from map
                if (infraSetupMap.containsKey(setuppi.RelatedMCU__c)) codecdetails.add(infraSetupMap.get(setuppi.RelatedMCU__c));
              
                //Setup__c MCUSetup = [select Platform_Manufacturer__c from Setup__c where Id = :setuppi.RelatedMCU__c];              
                /*
                if(MCUSetup.Platform_Manufacturer__c != null)
                {
                    codecdetails.add(MCUSetup.Platform_Manufacturer__c);
                }
                */
            }
        }

        for(String detail : codecdetails)
        {
             for(String polycom : polycoms)
             {
                 if(detail.contains(polycom))
                 {
                     hasPolycom = true;
                     break;
                 }
             }
               
            for(String vidyo : vidyos)
            {
                if(detail.contains(vidyo))
                {
                    hasVidyo = true;
                    break;
                }
            }
               
            for(String cisco : ciscos)
            {
                if(detail.contains(cisco))
                {
                    hasCisco = true;
                    break;
                }
            }
              
            for(String signage : signages)
            {
                if(detail.contains(signage))
                {
                    hasDS = true;
                    break;
                }
            }         
        }
            
        String accountData = acc.Service_Type_List__c;

        if(hasPolycom)
        {
            if(String.isBlank(accountData))
            {
                accountData = 'Polycom';
            }
            else if(!accountData.contains('Polycom'))
            {
                accountData += ';Polycom';
            }
        }
           
        if(hasVidyo)
        {
            if(String.isBlank(accountData))
            {
                accountData = 'Vidyo';
            }
            else if(!accountData.contains('Vidyo'))
            {
                accountData += ';Vidyo';
            }
        }
               
        if(hasCisco)
        {
            if(String.isBlank(accountData))
            {
                accountData = 'Cisco';
            }
            else if(!accountData.contains('Cisco'))
            {
                accountData += ';Cisco';
            }
        }
        if(hasDS)
        {
            if(String.isBlank(accountData))
            {
                accountData = 'DS';
            }
            else if(!accountData.contains('DS'))
            {
                accountData += ';DS';
            }
        }
           
        acc.Service_Type_List__c = accountData;
        update acc;
        return true;
    }
}
  • January 02, 2014
  • Like
  • 0
I am trying to hide Stage field of opportunity from visualforce page but I am not able to achieve the task.
If I am using style="display:none" nothing is happening and if I am using rendered="false” I am getting error as “The inline edit-enabled dependent picklist 'Lost Reasons' requires its controlling field 'Stage' to be present on the page.” Please help me regarding this ASAP.

I have used the below code. Please let me know if I am missing out something.


<apex:page standardController="Opportunity" docType="html-5.0" id="TheOppPage" tabStyle="Opportunity" showChat="false">
    <apex:form >
        <apex:pageBlock mode="maindetail"  id="thePageBlockDetail1" rendered="{!opportunity.StageName = 'Closed Won' || opportunity.StageName = 'Closed Lost'}">
          
            <!-- All Buttons are defined here-->
            <apex:pageBlockButtons >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit" style="display:none"/>
                <apex:commandButton action="{!save}" id="saveButton" value="Save" style="display:none"/>
                <apex:commandButton action="{!delete}" id="deleteButton" value="Delete" style="display:none"/>
                <apex:commandButton action="{!cancel}" id="cancelButton" value="Cancel" style="display:none" />
            </apex:pageBlockButtons>
          
            <!--Main details of this opportunity are defined here. -->
          
            <apex:pageBlockSection id="thePageBlockSectionDetail1">
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton, deleteButton" event="ondblclick"
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit" />
                  
                <apex:outputField value="{!opportunity.StageName}" style="display:none"/>
                <apex:outputField value="{!opportunity.Won_Reasons__c}" rendered="{!opportunity.StageName = 'Closed Won'}"/>
                <apex:outputField value="{!opportunity.Lost_Reasons__c}" rendered="{!opportunity.StageName = 'Closed Lost'}"/>
                <apex:outputField value="{!opportunity.customfield1__c}" rendered="{!opportunity.StageName = 'Closed Lost'}"/><br/>
                <apex:outputField value="{!opportunity.customfield2__c}" rendered="{!opportunity.StageName = 'Closed Lost'}"/>    
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Thanks in advance!
:)

Regards,
R_Shri
  • December 30, 2014
  • Like
  • 0

hello group,

 

        i have 2 obj enquiry and course i developed 2 pages for both enquiry and course . In enquiry page  i want to have picklist field  'select course',

        but iam not able to execute perfectly.........

         pls go through my below code and  resolve my  prblm

 

      <apex:outputLabel style="font-weight:Bold" value="Select a course :" />
     <apex:SelectList size="1" value="{!lst}">
     <apex:selectOptions value="{!items}"/>
     </apex:SelectList>

    ----------------------------------------------------------------------------------------------

    public List<Course__c> lst{get;set;}

    public Course__C getlst() {
      if (lst == null) {
        lst = [select Name from Course__c];
          }
        return lst;
       }
    }

    public List<SelectOption> getItems(){
           
        List<SelectOption> options = new List<SelectOption>();
        for(Integer i=0; i < lst.size(); i++){
        
            options.add(new SelectOption(lst[i].Name,lst[i].Name));
        }
        
        return options;
    }

 

  iam getting an error that 'un expected token ' at line 'public List<SelectOption> getItems(){'

 

 

note: i dont have a field picklist in my enquiry obj... but i wanrt to display it in vf page is this possible to do

 

 

       pls help me ............

 

 thanks for giving reply in advance