• PRIYAN NEERUDU
  • NEWBIE
  • 60 Points
  • Member since 2016
  • Mold-Tek Technologies Ltd


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 24
    Replies
public string dt{set;get;}
if(dt!=NULL)
        {      
            queryString+=' and Compare_Date__c = \''+dt +'\'';
           System.debug('---------------------date---------------------------------'+queryString);
          
        }


<apex:param name="recDate" assignTo="{!dt}" value=""/>
 
<apex:page controller="getrecordtype">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
YEAR
<apex:selectList Size="1">
<apex:selectOptions value="{!items}">
</apex:selectOptions>
 </apex:selectList>
 </apex:pageBlockSectionItem>
 <apex:pageBlockSectionItem >
RECORD TYPE
<apex:selectList size="1" >
<apex:selectOptions value="{!RecordTypeItems}">
</apex:selectOptions>
<apex:actionSupport event="onchnage" rendered="amountfields"/>
 </apex:selectList>
 </apex:pageBlockSectionItem>
 
<apex:pageBlockSectionItem id="amountfields">
<apex:repeat value="{!getamount}" var="a">
<td>{!a.s}</td>
<td>{!a.a}</td>
<td>{!a.c}</td>
</apex:repeat>
</apex:pageBlockSectionItem>

 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
</apex:page>

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


public with sharing class getrecordtype {
map<id,AggregateResult> clist1 = new map<id,AggregateResult>();
   
    List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    public string selectedrecordtype {get;set;}
    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    //List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        
}
    
    public List<SelectOption> getRecordTypeItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(RecordType r : rtList){
           options.add(new SelectOption(''+r.ID,r.name)); 
        }
        return options;
    }
    

public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
          
  public map<id,AggregateResult> getGetamount() {
  if(selectedrecordtype !=null){
          for(AggregateResult ar :[select sum(PAID_AMOUNT__c) s ,sum(BALANCE_AMOUNT__c) a ,
          sum(amount__c) c,accountid  from contact where  Recordtype.Name = :selectedrecordtype group by accountid] ){
          clist1.put((Id)ar.get('accountid'),ar);
        }
           } return clist1;

    }
public map<id,AggregateResult> getdetails(){
return clist1 ;
}
            
 
}
<apex:page controller="getrecordtype">
<apex:form >
YEAR<apex:selectList Size="1">
<apex:selectOptions value="{!items}"></apex:selectOptions>
</apex:selectList>
<apex:selectList >
<apex:selectOption value="{!RecordTypeSelectedId}"></apex:selectOption>
 </apex:selectList>
 </apex:form>
</apex:page>
------------------------------------------------------------------------------------------------------------
public with sharing class getrecordtype {

    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        


public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
            
 
}
trigger CONUP on Contact (after update,after insert) {
   
    Map<Id, Decimal> acctIdToAmount = new Map<Id, Decimal>();
    
    List<Account> accountsToUpdate = new List<Account>();
   
    Map<ID,RecordType> typeMap = New Map<ID,RecordType>([SELECT Id,name from RecordType where SobjectType='Contact' and Name LIKE'%CONTACT%']);
    
    for (CONTACT CON : trigger.new) {
          // If the Record Type = Intake Form
            if (CON.RecordTypeId =='01228000000Qjh3AAC' || CON.RecordTypeId =='01228000000QjgyAAC'){
            //    Get the Contact Amount into a temp variable
            Decimal sum = CON.PAID_AMOUNT__c == null ? 0 : CON.PAID_AMOUNT__c;

            //    Sum it up with the already collected Amount    
            if(acctIdToAmount.containsKey(CON.AccountId))
                sum += acctIdToAmount.get(CON.AccountId); 
            
            //    Make a map with AccountId as Key and Amount as value     
             acctIdToAmount.put(CON.AccountId, sum);
          }
  for(Id accId : acctIdToAmount.keyset()) {
        Account acc = new Account(Id = accId, TOTAL_AMOUNT__c = acctIdToAmount.get(accId));
        accountsToUpdate.add(acc);
    }

    if(!accountsToUpdate.isEmpty())
        update accountsToUpdate;
}
}

can anyone help to resolve the above error............
User-added image

I have three record type C2B B2B D2B for contacts i have to update account amount filed with sum of contacts  amount field WITH DIFFERENT RECORDTYPE

eg: 10,000(C2B AMOUNT)+10,000(D2B MOUNT )-10,000(B2B AMOUNT)=AMOUNT(ACCOUNT FILED)


 
m trying to add two input textvalues using javascript ...but using below code m unable to do....how i can get dis functioanlity done

-------------------------------------------------------------------------
<apex:page >
<apex:form >
 <p id="demo"></p>
<apex:inputText id="txt1"/>
<apex:inputText id="txt2"/>


<script>
      function myFunction() {
        var y = document.getElementById("txt1").value;
        var z = document.getElementById("txt2").value;
        var x = y + z;
        document.getElementById("c").innerHTML = x;
      }
    </script>

<p id="demo"></p>

<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton onclick="sum()" value="sum"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

i Have 2 picklist one should have all subjects, second picklist should have fields related to selected objects in picklist 1, now if I select a field in picklist 2 and metion a field valu in an one input filed then records with same field value in  selected object should be displayed
 
public class objectController1
{

public  string searchTxt {get; set;}

 String queryString;
 
    public void searchrecords() {
      
    
    
   
      
        system.debug('selectedObject ---selectedField--------'+selectedObject+'---'+selectedField ); 
        
        
        queryString = 'SELECT Id, name';
        
        
        if (selectedObject!= null && selectedObject!= '')
         {
            queryString += ' from  '+ selectedObject+'';
        }
        
        
        if ( searchTxt != null && searchTxt!= '')
        
         {
            if (selectedField != null && selectedField != '') {
            
            queryString += ' where ' + selectedField +' = '+searchTxt;
            
            system.debug('queryString -----'+queryString );
            
            }
            
        }
        

       
        system.debug('queryString -----------'+queryString );    
            
        lstQuery= database.query(queryString);
       
        
    }

    public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    

    public String selectedObject {get; set;}
    
    
      public list<sobject >lstQuery{get; set;}
      

    public String selectedField {get; set;}

    Public objectController1()
    {   
        selectedObject = 'account';
    }
    
    

    public List<SelectOption> getObjectNames()
        
    {
        List<SelectOption> objNames = new List<SelectOption>();
        
        List<String> entities = new List<String>(schemaMap.keySet());
        
        entities.sort();
        
        for(String name : entities)
        {
            objNames.add(new SelectOption(name,name));
        }
        return objNames;
     }
     
     

     public List<SelectOption> getObjectFields() 
     {
            Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
            
            Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
            
            Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
            
            List<SelectOption> fieldNames = new List<SelectOption>();
            
            for (String fieldName: fieldMap.keySet()) 
            {  
                fieldNames.add(new SelectOption(fieldName,fieldName));
                
            
            }
            return fieldNames;
      }       
}
-------------------------------------------------------------------------------------------------------------------------------------------


<apex:page controller="objectController1" setup="false" showHeader="false" sidebar="false">

 <apex:form >
  <apex:pageBlock > 

<apex:pageBlockSection columns="4"> 
 <apex:pageBlockSectionItem >
 <apex:outputlabel value="Object Names :"/> 
 <apex:actionRegion >
  <apex:selectList value="{!selectedObject}" size="1">
  <apex:selectOptions value="{!ObjectNames}"/> 
  <apex:actionSupport event="onchange" rerender="myFields"/>
   </apex:selectList>
    </apex:actionRegion> 
    </apex:pageBlockSectionItem>
  
   
    <apex:pageBlockSectionItem >
     <apex:outputlabel value="Field Names :"/>
     <apex:outputPanel id="myFields">
     <apex:actionRegion > 
     <apex:selectList value="{!selectedField}" size="1">
      <apex:selectOptions value="{!ObjectFields}"/> 
      </apex:selectList> 
      </apex:actionRegion> 
      </apex:outputPanel>
       </apex:pageBlockSectionItem> 
       
       <apex:pageBlockSectionItem >
          <input id="a" placeholder="label" style="margin-left:10px;" />
      </apex:pageBlockSectionItem>
      
      <apex:pageBlockSectionItem >
        <apex:commandButton onclick="callSearch();" value="Search" reRender="x" style="margin-left:10px;" />
      </apex:pageBlockSectionItem> 
     
</apex:pageBlockSection> 

 <apex:pageblockTable value="{!lstQuery}" var="eachRecord" id="list">
            <apex:column value="{!eachRecord.id}"/>
            <apex:column value="{!eachRecord['Name']}"/>
            
        
 </apex:pageblockTable>

</apex:pageBlock>

 <apex:actionFunction name="callSearch" action="{!searchRecords}" reRender="list">
        <apex:param name="a" value="" assignTo="{!searchTxt}"/>
       
    </apex:actionFunction>
 </apex:form>
  </apex:page>
i want to retrieve all the objects as dropdownlist and after selecting one object i want to display all the mandatory field of that object with its data type and search that particular object records based on mandatory field selected and  display in my vf page
public string dt{set;get;}
if(dt!=NULL)
        {      
            queryString+=' and Compare_Date__c = \''+dt +'\'';
           System.debug('---------------------date---------------------------------'+queryString);
          
        }


<apex:param name="recDate" assignTo="{!dt}" value=""/>
 
Challenge Not yet complete... here's what's wrong:
The 'LEAD Trend by Source' dashboard component does not have the wedges set to 'Lead Source'. eventhoug I have set Wedges to Lead Source!!!!!
<apex:page controller="getrecordtype">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
YEAR
<apex:selectList Size="1">
<apex:selectOptions value="{!items}">
</apex:selectOptions>
 </apex:selectList>
 </apex:pageBlockSectionItem>
 <apex:pageBlockSectionItem >
RECORD TYPE
<apex:selectList size="1" >
<apex:selectOptions value="{!RecordTypeItems}">
</apex:selectOptions>
<apex:actionSupport event="onchnage" rendered="amountfields"/>
 </apex:selectList>
 </apex:pageBlockSectionItem>
 
<apex:pageBlockSectionItem id="amountfields">
<apex:repeat value="{!getamount}" var="a">
<td>{!a.s}</td>
<td>{!a.a}</td>
<td>{!a.c}</td>
</apex:repeat>
</apex:pageBlockSectionItem>

 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
</apex:page>

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


public with sharing class getrecordtype {
map<id,AggregateResult> clist1 = new map<id,AggregateResult>();
   
    List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    public string selectedrecordtype {get;set;}
    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    //List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        
}
    
    public List<SelectOption> getRecordTypeItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(RecordType r : rtList){
           options.add(new SelectOption(''+r.ID,r.name)); 
        }
        return options;
    }
    

public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
          
  public map<id,AggregateResult> getGetamount() {
  if(selectedrecordtype !=null){
          for(AggregateResult ar :[select sum(PAID_AMOUNT__c) s ,sum(BALANCE_AMOUNT__c) a ,
          sum(amount__c) c,accountid  from contact where  Recordtype.Name = :selectedrecordtype group by accountid] ){
          clist1.put((Id)ar.get('accountid'),ar);
        }
           } return clist1;

    }
public map<id,AggregateResult> getdetails(){
return clist1 ;
}
            
 
}
<apex:page controller="getrecordtype">
<apex:form >
YEAR<apex:selectList Size="1">
<apex:selectOptions value="{!items}"></apex:selectOptions>
</apex:selectList>
<apex:selectList >
<apex:selectOption value="{!RecordTypeSelectedId}"></apex:selectOption>
 </apex:selectList>
 </apex:form>
</apex:page>
------------------------------------------------------------------------------------------------------------
public with sharing class getrecordtype {

    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        


public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
            
 
}
trigger CONUP on Contact (after update,after insert) {
   
    Map<Id, Decimal> acctIdToAmount = new Map<Id, Decimal>();
    
    List<Account> accountsToUpdate = new List<Account>();
   
    Map<ID,RecordType> typeMap = New Map<ID,RecordType>([SELECT Id,name from RecordType where SobjectType='Contact' and Name LIKE'%CONTACT%']);
    
    for (CONTACT CON : trigger.new) {
          // If the Record Type = Intake Form
            if (CON.RecordTypeId =='01228000000Qjh3AAC' || CON.RecordTypeId =='01228000000QjgyAAC'){
            //    Get the Contact Amount into a temp variable
            Decimal sum = CON.PAID_AMOUNT__c == null ? 0 : CON.PAID_AMOUNT__c;

            //    Sum it up with the already collected Amount    
            if(acctIdToAmount.containsKey(CON.AccountId))
                sum += acctIdToAmount.get(CON.AccountId); 
            
            //    Make a map with AccountId as Key and Amount as value     
             acctIdToAmount.put(CON.AccountId, sum);
          }
  for(Id accId : acctIdToAmount.keyset()) {
        Account acc = new Account(Id = accId, TOTAL_AMOUNT__c = acctIdToAmount.get(accId));
        accountsToUpdate.add(acc);
    }

    if(!accountsToUpdate.isEmpty())
        update accountsToUpdate;
}
}

can anyone help to resolve the above error............
User-added image

I have three record type C2B B2B D2B for contacts i have to update account amount filed with sum of contacts  amount field WITH DIFFERENT RECORDTYPE

eg: 10,000(C2B AMOUNT)+10,000(D2B MOUNT )-10,000(B2B AMOUNT)=AMOUNT(ACCOUNT FILED)


 
Hi my requirement is, i want to fetdch the recors from Account object based on the name enter in the VFpage, (when i enter the name ram in VFpage  ,then total recordswith the Name ram have to be fetched ) for that i have written the belwo code, in this codewhen enter the name in the vfpage ima getting the error like bleow
"Attempt to de-reference a null object
Error is in expression '{!values}' in component <apex:commandButton> in page chennai: Class.chennai.values: line 18, column 1 "

andmy code is as follows,

vf code:

<apex:page controller="chennai">

<apex:form>

<apex:outputText>EnterName</apex:outputText>

<apex:inputField value="{!a.Name}"/>

<apex:commandButton value="Enter"  action="{!values}" reRender="one"/>


<apex:pageBlock id="one">
<apex:pageBlockSection >

<apex:pageBlockTable value="{!at}" var="b">

<apex:column value="{!b.Name}"/>


</apex:pageBlockTable>

</apex:pageBlockSection>
</apex:pageBlock>




  </apex:form>
</apex:page>


Apex Code:

Public class chennai
{

Public chennai()
{
List<Account> at=new List<Account>();

Account a=new Account();
}

Public List<Account> at{get;set;}

Public Account a{get;set;}

Public void values()
{

List<Account> at=[select Name from Account where Name=:a.Name];


}

}

Please suggest me

Regards,
siva.


 
how can we display the opportunites account related list along with oppetunity name can any one answer this question please?
i want to retrieve all the objects as dropdownlist and after selecting one object i want to display all the mandatory field of that object with its data type and search that particular object records based on mandatory field selected and  display in my vf page

trigger AccountDuplicateTrigger on Account (before insert, before update)
{
for(Account a:Trigger.new)
{
List<Account> acc="Select id from Account where Name=:a.Name";
if(acc.size()>0)
{
acc.Name.addError(‘You Cannot Create the Duplicate Account’);
}
}
}
It should display error when account name is duplicate please help me
 
Dear all,

We have an integration of Eloqua with Salesforce and when pushing contacts from Eloqua to SalesForce as leads, following error messages are triggered"

Message 1: Duplicate value found: unknown duplicates value on record with id: ---------------------
Message 2: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires that some subset of rows save without any errors in order to avoid inconsistent side effects from those triggers. Number of retries: 2

Any thoughts on how to resolve these errors ?

Individual contacts can be pushed from Eloqua and the external calls are successful (leads are created successfully). Above mentioned errors are triggered when I try to push more than 30 contact records.

A few forums suggested turning off the History tracking of Lead fields that I have already due, but the error is persistent.

https://success.salesforce.com/issues_view?id=a1p30000000T2URAA0



Thanks very in advance for any help,

Navin Krishnan