- SFDC Admin & Analyst
- NEWBIE
- 125 Points
- Member since 2011
-
ChatterFeed
-
5Best Answers
-
0Likes Received
-
0Likes Given
-
7Questions
-
8Replies
Problem in Rendered based on list size and invoke using Action Function
Hi,
I have a VF page and Controller class. I have two page blocks. First page block loads all the data and second pageblock must be rendered if any record in first page block is selected. The rendered attribute is not working based on the list size.
Here is the code
<apex:page standardController="Contact" extensions="ContactCodeExtension" id="pg">
<apex:form id="frm">
<apex:outputPanel id="errorPnl">
<apex:pageMessages />
</apex:outputPanel>
<!------------------------------------------------------------- ACTION FUNCTIONS ---------------------------------------------------------------------------->
<apex:actionFunction action="{!populateContactCode}" name="populateContactCodeAF" reRender="pbResult,errorPnl" status="actionStatus" >
</apex:actionFunction>
<apex:actionFunction action="{!addtoSelectedList}" name="addtoSelectedListAF" reRender="pbResult2,errorPnl" status="actionStatus"/ >
<apex:actionFunction action="{!addtoTEst}" name="addtoTEstAF" reRender="pbResult2" status="actionStatus"/>
<!------------------------------------------------------------- ACTION FUNCTIONS ---------------------------------------------------------------------------->
<apex:pageBlock rendered="{!if(contactId != null,true,false)}" id="pb">
<apex:pageBlockButtons id="pgButtons">
<apex:commandButton value="Cancel" action="{!cancel}" />
<apex:actionStatus id="actionStatus" startText="Please wait....">
<apex:facet name="start"> <apex:image value="/img/indicator.gif"/></apex:facet>
<apex:facet name="stop"></apex:facet>
</apex:actionStatus>
</apex:pageBlockButtons>
<h1 style="font-weight:bold;font-size:20px">Adding Contact Codes for {!con.Name}.</h1>
<br/>
<br/>
<apex:pageBlocksection title="Contact Codes" columns="1" id="pbResult">
<apex:outputPanel rendered="{!if(wrapperList.size>0,true,false)}">
<table><tr><td>
<div style="overflow:auto; height:470px;width:870px;">
<apex:pageBlockTable id="resultTable" value="{!wrapperList}" var="wrapper" rendered="{!if(wrapperList.size>0,true,false)}">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox id="allSelected" onclick="checkAll(this,'checkdone');addtoTEstAF();" />
</apex:facet>
<apex:inputCheckbox value="{!wrapper.isSelected}" id="checkdone" onclick="addtoSelectedListAF();"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >
cade444
</apex:outputPanel>
</apex:facet>
<apex:outputField value="{!wrapper.ccDesc.Description__c}" />
</apex:column>
<apex:column >
<apex:facet name="header">
code
</apex:facet>
<apex:outputField value="{!wrapper.ccDesc.Description__c}" />
</apex:column>
</apex:pageBlockTable>
</div> </td></tr></table>
</apex:outputPanel>
<apex:outputPanel rendered="{!If(wrapperList.size = 0,true,false)}" id="errMsg">
<span style="color:red;">No Records found</span>
</apex:outputPanel>
</apex:pageblocksection>
</apex:pageBlock>
<apex:pageBlock rendered="{!If(backupContactCodes.size>0,true,false)}" id="pbResult2">
<apex:pageblocksection title="Selected Contact Codes" columns="1" >
<apex:outputpanel id="ProductUnitsInformation" >
<table><tr><td>
<div style="overflow:auto; height:470px;width:870px;">
<apex:pageBlockTable id="resultTable2" value="{!backupContactCodes}" var="wrapper2">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >
Code Description
</apex:outputPanel>
</apex:facet>
<apex:outputField value="{!wrapper2.Description__c}" title="Code Description"/>
</apex:column>
</apex:pageBlockTable>
</div> </td></tr></table>
</apex:outputpanel>
</apex:pageBlocksection>
</apex:pageBlock>
<!-- // @Sashi Singh -- 09/19/2013 -- RRM Request Number -- REQ-00002156 -->
<input type="hidden" id="oldCodeType" value="" />
<script type="text/javascript">
function checkAll(cb,cbid){
var allchecked = cb.checked;
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++){
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
document.getElementById("allSelected").checked = allchecked;
addtoSelectedListAF();
}
function closeWindow(){
//window.opener.parent.location.href = '/{!contactId}';
window.self.close();
return false;
}
function testingactionfunction(){
addtoSelectedListAF();
}
function changeUrl(url) {
location.href = url;
window.reload();
}
</script>
</apex:form>
</apex:page>
___________________________________________________________________________________________
public with sharing class ContactCodeExtension {
public List<ContactCodeDescWrapper> wrapperList {set;get;}
public String contactId {set;get;}
public Contact con {set;get;}
private Set<Id> selectedCodeDescs;
Public static List<ContactCodeDescription__c> backupContactCodes { set; get;}
public string selectedCCDesc {get; set;}
Public static Boolean renderSetbackupCC = false;
Public static Boolean isPageLoad {get;set;}
public List<ContactCodeDescWrapper> selectedWrapperList {set;get;}
public set<Id> setId {set;get;}
//****************************************************************************
//Constructor
//***************************************************************************/
public ContactCodeExtension(ApexPages.StandardController stdController){
contactId = Apexpages.currentPage().getParameters().get('contactId');
init();
}
//////////////////////////////// Private Methods ////////////////////////////
//****************************************************************************
// Method for initialization
///***************************************************************************/
private void init(){
//
system.debug('***renderSetbackupCC1'+renderSetbackupCC);
//renderSetbackupCC = false;
system.debug('***renderSetbackupCC2'+renderSetbackupCC);
isPageLoad = true;
System.Debug('***renderSetbackupCC'+renderSetbackupCC);
backupContactCodes = new List<ContactCodeDescription__c>();
////
wrapperList = new List<ContactCodeDescWrapper>();
selectedWrapperList = new List<ContactCodeDescWrapper>();
setId = new set<Id>();
selectedCodeDescs = new Set<Id>();
if(contactId != null){
populateContactCode();
getContact();
system.debug('***renderSetbackupCC3'+renderSetbackupCC);
addtoSelectedList();
addtoTEst();
system.debug('***renderSetbackupCC6'+renderSetbackupCC);
}else{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Please associate Contact Codes directly from the Contact object.'));
}
}
private void getContact(){
for(Contact contact : [select Id,name,Email,Phone,MobilePhone from Contact where Id =:contactId limit 1]){
con = contact;
}
}
public void backupSelection(){
selectedCodeDescs.clear();
for(ContactCodeDescWrapper wrapper : wrapperList){
if(wrapper.isSelected){
selectedCodeDescs.add(wrapper.ccDesc.Id);
}
}
System.Debug('***wrapperList'+wrapperList);
}
//Cancel
Public void cancel(){
}
//****************************************************************************
// Method to populate contact code
///***************************************************************************/
public void populateContactCode(){
String query ='Select Description__c From ContactCodeDescription__c';
backupSelection();
System.Debug('***selectedCodeDescs populateContactCode'+selectedCodeDescs);
System.Debug('***wrapperList populateContactCode'+wrapperList);
for(Id ccDesc : selectedCodeDescs)
setId.add(ccDesc);
//selectedWrapperList.add(new ContactCodeDescWrapper(ccDesc,selectedCodeDescs.contains(ccDesc.Id))) ;
Map<ContactCodeDescription__c,boolean> ccDescStatus = new Map<ContactCodeDescription__c,boolean>();
for(ContactCodeDescWrapper wrapper : wrapperList){
ccDescStatus.put(wrapper.ccDesc,wrapper.isSelected);
//If(selectedWrapperList.contains(wrapper))
//selectedWrapperList.put(wrapper.ccDesc, wrapper.isSelected);
}
for(ContactCodeDescWrapper wrapper : selectedWrapperList ){
If(ccDescStatus.containskey(wrapper.ccDesc) != null){
If(ccDescStatus.containskey(wrapper.ccDesc)){
If(wrapper.isSelected != ccDescStatus.get(wrapper.ccDesc))
wrapper.isSelected= ccDescStatus.get(wrapper.ccDesc);
}
}
}
wrapperList.clear();
for(ContactCodeDescription__c ccDesc : Database.query(query)){
wrapperList.add(new ContactCodeDescWrapper(ccDesc,selectedCodeDescs.contains(ccDesc.Id)));
system.Debug('***isPageLoad'+isPageLoad);
If(isPageLoad != null && isPageLoad ){
selectedWrapperList.add(new ContactCodeDescWrapper(ccDesc,selectedCodeDescs.contains(ccDesc.Id)));
}
}
isPageLoad = false;
for(ContactCodeDescWrapper wrapper : wrapperList){
If(setId.contains(wrapper.ccDesc.Id)){
wrapper.isSelected = true;
}
}
System.debug('wrapperList 1 ***' + wrapperList.size());
}
public void addtoSelectedList(){
//wrapperList = new List<ContactCodeDescWrapper>();
backupContactCodes = new List<ContactCodeDescription__c>();
System.Debug('***wrapperList'+wrapperList);
//searchedWrapperList
System.Debug('***wrapperList.size'+wrapperList.size());
System.Debug('***backupContactCodes'+backupContactCodes);
//
Map<ContactCodeDescription__c,boolean> ccDescStatus = new Map<ContactCodeDescription__c,boolean>();
for(ContactCodeDescWrapper wrapper : wrapperList){
ccDescStatus.put(wrapper.ccDesc,wrapper.isSelected);
//If(selectedWrapperList.contains(wrapper))
//selectedWrapperList.put(wrapper.ccDesc, wrapper.isSelected);
}
for(ContactCodeDescWrapper wrapper : selectedWrapperList ){
If(ccDescStatus.containskey(wrapper.ccDesc)){
If(wrapper.isSelected != ccDescStatus.get(wrapper.ccDesc))
wrapper.isSelected= ccDescStatus.get(wrapper.ccDesc);
}
}
system.Debug('***selectedWrapperList'+selectedWrapperList);
For( ContactCodeDescWrapper wrapper : selectedWrapperList ){
If(wrapper.isSelected){
backupContactCodes.add(wrapper.ccDesc);
//rendered="{!renderSetbackupCC}"
system.debug('***renderSetbackupCC5'+renderSetbackupCC);
renderSetbackupCC = true;
}
}
system.debug('***renderSetbackupCC6'+renderSetbackupCC);
If(backupContactCodes.size() > 0)
renderSetbackupCC = true;
System.Debug('***wrapperList'+wrapperList);
System.Debug('***backupContactCodes'+backupContactCodes);
System.Debug('***renderSetbackupCC '+renderSetbackupCC );
System.Debug('***renderSetbackupCC '+renderSetbackupCC );
System.Debug('***selectedCCDesc'+selectedCCDesc);
}
public void addtoTEst(){
system.Debug('***isPageLoadALLL'+isPageLoad);
If(isPageLoad){
For( ContactCodeDescWrapper wrapper : wrapperList ){
//If(wrapper.isSelected)
backupContactCodes.add(wrapper.ccDesc);
//rendered="{!renderSetbackupCC}"
//renderSetbackupCC = true;
}
}
}
//****************************************************************************
//Wrapper Class for ContactCodeDescription__c
//***************************************************************************/
public class ContactCodeDescWrapper{
public ContactCodeDescription__c ccDesc {set;get;}
public boolean isSelected {set;get;}
//Constructor
public ContactCodeDescWrapper(ContactCodeDescription__c ccDesc,Boolean isSelected){
this.isSelected = isSelected;
this.ccDesc = ccDesc;
}
}
}
Please let me know. How to fix this.
Thanks
- SFDC Admin & Analyst
- October 11, 2013
- Like
- 0
Formula Field exceeding 5000 characters
Hi
My formula is exceeding 5000 characters while compiling.
Here is the formula
________________________________________________________________________________________
IF(US_Account_Manager__c != null,If(EU_Account_Manager__c != null,If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
1234
,
123
),If(EU_Relationship_Manager__c != null,
124
,
12
)),
If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
134
,
13
),If(EU_Relationship_Manager__c != null,
14
,
1
)))
,If(EU_Account_Manager__c != null,If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
234
,
23
),If(EU_Relationship_Manager__c != null,
24
,
2
)),If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
34
,
3
),If(EU_Relationship_Manager__c != null,
4
,
''
))))
----------------------------------------------------------------------------
A1 = US_Account_Manager__c != null
A2 = EU_Account_Manager__c != null
A3 = US_Relationship_Manager__c != null
A4 = EU_Relationship_Manager__c != null
-------------------------------------------------------------------------------------
1 = US_Account_Manager__r.FirstName + US_Account_Manager__r.LastName + ' ' + '(US CSM)'+' '+','+' '+
2 = EU_Account_Manager__r.FirstName + EU_Account_Manager__r.LastName + ' ' + '(EU CSM)'+' '+' ,'+' '+
3 = US_Relationship_Manager__r.FirstName + US_Relationship_Manager__r.LastName + ' ' + '(US RM)'+' '+','+' '+
4 = EU_Relationship_Manager__r.FirstName + EU_Relationship_Manager__r.LastName + ' ' + '(EU RM)'
_________________________________________________________________________________________
- SFDC Admin & Analyst
- August 18, 2013
- Like
- 0
Name field in User object is not accessible in Formula Field
Hi
I have a formula which is exceeding 5000 characters when compiling.
I used AccountMAnager__r.Firstname+' '+AccountMAnager__r.Lastname in the formula. I see that there is Name standard field on User object. This field is not accessible in Formula field.
Is there any way to reduce my formula characters while compiling. Please help.
Thanks
- SFDC Admin & Analyst
- August 18, 2013
- Like
- 0
Issue with Aggergate query summing in USD for CAD opportunity
Hi I have an issue in code with Aggregate query.
I have an object Deal Summary which sums up fields in Opportunity products and displays as related list in opportunity.
This is done by an after update trigger on oppportunity. But here if the currency of an Opportunity product is CAD, It shows up the deal Summary in USD; because the aggregate query is aggregating everything in USD.
Here is my trigger
Trigger SGSFA_NA_UPDATE_DEAL_SUMMARY on Opportunity (After Update) {
Please help. I am stuck here. How do aggregate in Canadian Dollars. |
- SFDC Admin & Analyst
- March 19, 2012
- Like
- 0
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SGSFA_OPPTY_UK_UPDATE_CNTRCT: Test Methods Fail in Production
Hi
Test Methods in our org failed suddenly with the following error:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SGSFA_OPPTY_UK_UPDATE_CNTRCT: execution of AfterUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact ...
It seems the test methods failed because of a trigger on oppportunity after update
Here is the trigger:
trigger SGSFA_OPPTY_UK_UPDATE_CNTRCT on Opportunity (after update) {
//Trigger to uncheck Related Opportunity checkbox from contract object
//Select UK Record Type
RecordType rType = [Select Id From RecordType
where sObjectType='Opportunity'
and DeveloperName = 'UK_All_opportunity_rec_type'
and isActive=true
limit 1];
List<Id> lstOppID = new List<Id>();
for(Opportunity o : Trigger.New){
if(o.recordTypeID == rType.Id){
lstOppID.add(o.Id);
}
}
List<Id> lstCloseDateChanged = new List<id>();
for(Opportunity o : Trigger.New){
if(o.CloseDate != Trigger.oldMap.get(o.id).CloseDate)
lstCloseDateChanged.add(o.id);
}
//find the list of contracts to update
List<Contract> lstCntrct = new List<Contract> ();
lstCntrct = [select id, Related_Opportunity__c from contract c
where c.id in (select o.Contract_ID__c From OpportunityLineItem o
where o.OpportunityID in :lstOppID)
and c.id not in (select o1.Contract_ID__c From OpportunityLineItem o1
where o1.Opportunity.IsClosed = False)
];
//set related opportunity field to false and update the contract list
if(!lstCntrct.isEmpty()) {
for(Integer i = 0; i < lstCntrct.size(); i++){
lstCntrct[i].Related_Opportunity__c = false;
}
update lstCntrct;
}
//update all opportunity products if the close date changed. This will trigged the WF rules
if(!lstCloseDateChanged.isEmpty()){
List<OpportunityLineItem> lstLine = [select id From OpportunityLineItem o
where o.OpportunityID in :lstCloseDateChanged];
if(!lstLine.isEmpty())
update lstLine;
}
}
I don't understand what is making test method fail. Any help will be greatly appreciated. Thanks
Below is the test method which is failing at Insert oppli
static testmethod void test_batchoppty() |
- SFDC Admin & Analyst
- March 18, 2012
- Like
- 0
Duplicate Username DML Exceptions in Test Classes in Production
Test Classes in Production have failed suddenly with the following DML Exception. Please help.
Here is the error:
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.<br>Another user has already selected this username.<br>Please select another.: [Username]
Class.SGPRM_TestingClass.testSGPRM_OwnerChange_Before_Update: line 14, column 1
Here is the test class
@isTest
private class SGPRM_TestingClass
{
//*#*Test Method for SGPRM_OwnerChange_Before_Update Trigger
static testMethod void testSGPRM_OwnerChange_Before_Update() {
Profile Profile1 = [select id from profile where name='System Administrator'];
Profile Profile2 = [select id from profile where name='Standard User'];
User CEO = new User(alias = 'ceo', email='admin@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = Profile1.Id,
timezonesidkey='America/Los_Angeles', username='admin@testorg.com');
insert CEO;
User SalesManager = new User(alias = 'smngr', email='sManager@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = Profile2.Id, managerId = CEO.id,
timezonesidkey='America/Los_Angeles', username='sManager@testorg.com');
insert SalesManager;
User SalesRep = [Select Id,Name,Email,managerId ,timezonesidkey from User where Name = 'Deborah BUELL' ];
System.runAs(SalesRep)
{
Id RT = [select id from RecordType where SObjectType = 'Lead' AND developerName = 'DealRegistration'][0].Id;
Lead lead = new Lead();
lead.RecordTypeId = RT;
lead.firstname = 'Test';
lead.lastname = 'User';
lead.Company = 'Test Group';
lead.city = 'Test';
lead.state = 'NJ';
lead.country = 'United States';
//lead.OwnerId = '005A0000000iviM';
insert lead;
Test.startTest();
// Lead Submitted for Approval
lead.Status = 'Submitted for Approval';
lead.OwnerId = SalesManager.Id;
update lead;
Test.stopTest();
}
}}
- SFDC Admin & Analyst
- March 16, 2012
- Like
- 0
Unable to create a new custom object with Auto number; Error Invalid number.
I am trying to create a new custom object Candidates with Auto number.
But when I give starting number: C-{00001}; It gives error Invalid number.
Also give some permissions warning. Please help.
- SFDC Admin & Analyst
- December 01, 2011
- Like
- 0
Problem in Rendered based on list size and invoke using Action Function
Hi,
I have a VF page and Controller class. I have two page blocks. First page block loads all the data and second pageblock must be rendered if any record in first page block is selected. The rendered attribute is not working based on the list size.
Here is the code
<apex:page standardController="Contact" extensions="ContactCodeExtension" id="pg">
<apex:form id="frm">
<apex:outputPanel id="errorPnl">
<apex:pageMessages />
</apex:outputPanel>
<!------------------------------------------------------------- ACTION FUNCTIONS ---------------------------------------------------------------------------->
<apex:actionFunction action="{!populateContactCode}" name="populateContactCodeAF" reRender="pbResult,errorPnl" status="actionStatus" >
</apex:actionFunction>
<apex:actionFunction action="{!addtoSelectedList}" name="addtoSelectedListAF" reRender="pbResult2,errorPnl" status="actionStatus"/ >
<apex:actionFunction action="{!addtoTEst}" name="addtoTEstAF" reRender="pbResult2" status="actionStatus"/>
<!------------------------------------------------------------- ACTION FUNCTIONS ---------------------------------------------------------------------------->
<apex:pageBlock rendered="{!if(contactId != null,true,false)}" id="pb">
<apex:pageBlockButtons id="pgButtons">
<apex:commandButton value="Cancel" action="{!cancel}" />
<apex:actionStatus id="actionStatus" startText="Please wait....">
<apex:facet name="start"> <apex:image value="/img/indicator.gif"/></apex:facet>
<apex:facet name="stop"></apex:facet>
</apex:actionStatus>
</apex:pageBlockButtons>
<h1 style="font-weight:bold;font-size:20px">Adding Contact Codes for {!con.Name}.</h1>
<br/>
<br/>
<apex:pageBlocksection title="Contact Codes" columns="1" id="pbResult">
<apex:outputPanel rendered="{!if(wrapperList.size>0,true,false)}">
<table><tr><td>
<div style="overflow:auto; height:470px;width:870px;">
<apex:pageBlockTable id="resultTable" value="{!wrapperList}" var="wrapper" rendered="{!if(wrapperList.size>0,true,false)}">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox id="allSelected" onclick="checkAll(this,'checkdone');addtoTEstAF();" />
</apex:facet>
<apex:inputCheckbox value="{!wrapper.isSelected}" id="checkdone" onclick="addtoSelectedListAF();"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >
cade444
</apex:outputPanel>
</apex:facet>
<apex:outputField value="{!wrapper.ccDesc.Description__c}" />
</apex:column>
<apex:column >
<apex:facet name="header">
code
</apex:facet>
<apex:outputField value="{!wrapper.ccDesc.Description__c}" />
</apex:column>
</apex:pageBlockTable>
</div> </td></tr></table>
</apex:outputPanel>
<apex:outputPanel rendered="{!If(wrapperList.size = 0,true,false)}" id="errMsg">
<span style="color:red;">No Records found</span>
</apex:outputPanel>
</apex:pageblocksection>
</apex:pageBlock>
<apex:pageBlock rendered="{!If(backupContactCodes.size>0,true,false)}" id="pbResult2">
<apex:pageblocksection title="Selected Contact Codes" columns="1" >
<apex:outputpanel id="ProductUnitsInformation" >
<table><tr><td>
<div style="overflow:auto; height:470px;width:870px;">
<apex:pageBlockTable id="resultTable2" value="{!backupContactCodes}" var="wrapper2">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >
Code Description
</apex:outputPanel>
</apex:facet>
<apex:outputField value="{!wrapper2.Description__c}" title="Code Description"/>
</apex:column>
</apex:pageBlockTable>
</div> </td></tr></table>
</apex:outputpanel>
</apex:pageBlocksection>
</apex:pageBlock>
<!-- // @Sashi Singh -- 09/19/2013 -- RRM Request Number -- REQ-00002156 -->
<input type="hidden" id="oldCodeType" value="" />
<script type="text/javascript">
function checkAll(cb,cbid){
var allchecked = cb.checked;
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++){
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
document.getElementById("allSelected").checked = allchecked;
addtoSelectedListAF();
}
function closeWindow(){
//window.opener.parent.location.href = '/{!contactId}';
window.self.close();
return false;
}
function testingactionfunction(){
addtoSelectedListAF();
}
function changeUrl(url) {
location.href = url;
window.reload();
}
</script>
</apex:form>
</apex:page>
___________________________________________________________________________________________
public with sharing class ContactCodeExtension {
public List<ContactCodeDescWrapper> wrapperList {set;get;}
public String contactId {set;get;}
public Contact con {set;get;}
private Set<Id> selectedCodeDescs;
Public static List<ContactCodeDescription__c> backupContactCodes { set; get;}
public string selectedCCDesc {get; set;}
Public static Boolean renderSetbackupCC = false;
Public static Boolean isPageLoad {get;set;}
public List<ContactCodeDescWrapper> selectedWrapperList {set;get;}
public set<Id> setId {set;get;}
//****************************************************************************
//Constructor
//***************************************************************************/
public ContactCodeExtension(ApexPages.StandardController stdController){
contactId = Apexpages.currentPage().getParameters().get('contactId');
init();
}
//////////////////////////////// Private Methods ////////////////////////////
//****************************************************************************
// Method for initialization
///***************************************************************************/
private void init(){
//
system.debug('***renderSetbackupCC1'+renderSetbackupCC);
//renderSetbackupCC = false;
system.debug('***renderSetbackupCC2'+renderSetbackupCC);
isPageLoad = true;
System.Debug('***renderSetbackupCC'+renderSetbackupCC);
backupContactCodes = new List<ContactCodeDescription__c>();
////
wrapperList = new List<ContactCodeDescWrapper>();
selectedWrapperList = new List<ContactCodeDescWrapper>();
setId = new set<Id>();
selectedCodeDescs = new Set<Id>();
if(contactId != null){
populateContactCode();
getContact();
system.debug('***renderSetbackupCC3'+renderSetbackupCC);
addtoSelectedList();
addtoTEst();
system.debug('***renderSetbackupCC6'+renderSetbackupCC);
}else{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Please associate Contact Codes directly from the Contact object.'));
}
}
private void getContact(){
for(Contact contact : [select Id,name,Email,Phone,MobilePhone from Contact where Id =:contactId limit 1]){
con = contact;
}
}
public void backupSelection(){
selectedCodeDescs.clear();
for(ContactCodeDescWrapper wrapper : wrapperList){
if(wrapper.isSelected){
selectedCodeDescs.add(wrapper.ccDesc.Id);
}
}
System.Debug('***wrapperList'+wrapperList);
}
//Cancel
Public void cancel(){
}
//****************************************************************************
// Method to populate contact code
///***************************************************************************/
public void populateContactCode(){
String query ='Select Description__c From ContactCodeDescription__c';
backupSelection();
System.Debug('***selectedCodeDescs populateContactCode'+selectedCodeDescs);
System.Debug('***wrapperList populateContactCode'+wrapperList);
for(Id ccDesc : selectedCodeDescs)
setId.add(ccDesc);
//selectedWrapperList.add(new ContactCodeDescWrapper(ccDesc,selectedCodeDescs.contains(ccDesc.Id))) ;
Map<ContactCodeDescription__c,boolean> ccDescStatus = new Map<ContactCodeDescription__c,boolean>();
for(ContactCodeDescWrapper wrapper : wrapperList){
ccDescStatus.put(wrapper.ccDesc,wrapper.isSelected);
//If(selectedWrapperList.contains(wrapper))
//selectedWrapperList.put(wrapper.ccDesc, wrapper.isSelected);
}
for(ContactCodeDescWrapper wrapper : selectedWrapperList ){
If(ccDescStatus.containskey(wrapper.ccDesc) != null){
If(ccDescStatus.containskey(wrapper.ccDesc)){
If(wrapper.isSelected != ccDescStatus.get(wrapper.ccDesc))
wrapper.isSelected= ccDescStatus.get(wrapper.ccDesc);
}
}
}
wrapperList.clear();
for(ContactCodeDescription__c ccDesc : Database.query(query)){
wrapperList.add(new ContactCodeDescWrapper(ccDesc,selectedCodeDescs.contains(ccDesc.Id)));
system.Debug('***isPageLoad'+isPageLoad);
If(isPageLoad != null && isPageLoad ){
selectedWrapperList.add(new ContactCodeDescWrapper(ccDesc,selectedCodeDescs.contains(ccDesc.Id)));
}
}
isPageLoad = false;
for(ContactCodeDescWrapper wrapper : wrapperList){
If(setId.contains(wrapper.ccDesc.Id)){
wrapper.isSelected = true;
}
}
System.debug('wrapperList 1 ***' + wrapperList.size());
}
public void addtoSelectedList(){
//wrapperList = new List<ContactCodeDescWrapper>();
backupContactCodes = new List<ContactCodeDescription__c>();
System.Debug('***wrapperList'+wrapperList);
//searchedWrapperList
System.Debug('***wrapperList.size'+wrapperList.size());
System.Debug('***backupContactCodes'+backupContactCodes);
//
Map<ContactCodeDescription__c,boolean> ccDescStatus = new Map<ContactCodeDescription__c,boolean>();
for(ContactCodeDescWrapper wrapper : wrapperList){
ccDescStatus.put(wrapper.ccDesc,wrapper.isSelected);
//If(selectedWrapperList.contains(wrapper))
//selectedWrapperList.put(wrapper.ccDesc, wrapper.isSelected);
}
for(ContactCodeDescWrapper wrapper : selectedWrapperList ){
If(ccDescStatus.containskey(wrapper.ccDesc)){
If(wrapper.isSelected != ccDescStatus.get(wrapper.ccDesc))
wrapper.isSelected= ccDescStatus.get(wrapper.ccDesc);
}
}
system.Debug('***selectedWrapperList'+selectedWrapperList);
For( ContactCodeDescWrapper wrapper : selectedWrapperList ){
If(wrapper.isSelected){
backupContactCodes.add(wrapper.ccDesc);
//rendered="{!renderSetbackupCC}"
system.debug('***renderSetbackupCC5'+renderSetbackupCC);
renderSetbackupCC = true;
}
}
system.debug('***renderSetbackupCC6'+renderSetbackupCC);
If(backupContactCodes.size() > 0)
renderSetbackupCC = true;
System.Debug('***wrapperList'+wrapperList);
System.Debug('***backupContactCodes'+backupContactCodes);
System.Debug('***renderSetbackupCC '+renderSetbackupCC );
System.Debug('***renderSetbackupCC '+renderSetbackupCC );
System.Debug('***selectedCCDesc'+selectedCCDesc);
}
public void addtoTEst(){
system.Debug('***isPageLoadALLL'+isPageLoad);
If(isPageLoad){
For( ContactCodeDescWrapper wrapper : wrapperList ){
//If(wrapper.isSelected)
backupContactCodes.add(wrapper.ccDesc);
//rendered="{!renderSetbackupCC}"
//renderSetbackupCC = true;
}
}
}
//****************************************************************************
//Wrapper Class for ContactCodeDescription__c
//***************************************************************************/
public class ContactCodeDescWrapper{
public ContactCodeDescription__c ccDesc {set;get;}
public boolean isSelected {set;get;}
//Constructor
public ContactCodeDescWrapper(ContactCodeDescription__c ccDesc,Boolean isSelected){
this.isSelected = isSelected;
this.ccDesc = ccDesc;
}
}
}
Please let me know. How to fix this.
Thanks
- SFDC Admin & Analyst
- October 11, 2013
- Like
- 0
Formula Field exceeding 5000 characters
Hi
My formula is exceeding 5000 characters while compiling.
Here is the formula
________________________________________________________________________________________
IF(US_Account_Manager__c != null,If(EU_Account_Manager__c != null,If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
1234
,
123
),If(EU_Relationship_Manager__c != null,
124
,
12
)),
If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
134
,
13
),If(EU_Relationship_Manager__c != null,
14
,
1
)))
,If(EU_Account_Manager__c != null,If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
234
,
23
),If(EU_Relationship_Manager__c != null,
24
,
2
)),If(US_Relationship_Manager__c != null,If(EU_Relationship_Manager__c != null,
34
,
3
),If(EU_Relationship_Manager__c != null,
4
,
''
))))
----------------------------------------------------------------------------
A1 = US_Account_Manager__c != null
A2 = EU_Account_Manager__c != null
A3 = US_Relationship_Manager__c != null
A4 = EU_Relationship_Manager__c != null
-------------------------------------------------------------------------------------
1 = US_Account_Manager__r.FirstName + US_Account_Manager__r.LastName + ' ' + '(US CSM)'+' '+','+' '+
2 = EU_Account_Manager__r.FirstName + EU_Account_Manager__r.LastName + ' ' + '(EU CSM)'+' '+' ,'+' '+
3 = US_Relationship_Manager__r.FirstName + US_Relationship_Manager__r.LastName + ' ' + '(US RM)'+' '+','+' '+
4 = EU_Relationship_Manager__r.FirstName + EU_Relationship_Manager__r.LastName + ' ' + '(EU RM)'
_________________________________________________________________________________________
- SFDC Admin & Analyst
- August 18, 2013
- Like
- 0
Name field in User object is not accessible in Formula Field
Hi
I have a formula which is exceeding 5000 characters when compiling.
I used AccountMAnager__r.Firstname+' '+AccountMAnager__r.Lastname in the formula. I see that there is Name standard field on User object. This field is not accessible in Formula field.
Is there any way to reduce my formula characters while compiling. Please help.
Thanks
- SFDC Admin & Analyst
- August 18, 2013
- Like
- 0
Regarding Chatter Poll
Hello,
I want to create a apex class and visualforce page which include all the functionallity of chatter like Post, Link, File and Poll.
Now i created all the features except poll functionallity. Can Anybody help me on how to create Chatter Poll by using our own visualforce page and controller?
thank in advance!!!
- Indrasen
- February 02, 2013
- Like
- 0
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SGSFA_OPPTY_UK_UPDATE_CNTRCT: Test Methods Fail in Production
Hi
Test Methods in our org failed suddenly with the following error:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SGSFA_OPPTY_UK_UPDATE_CNTRCT: execution of AfterUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact ...
It seems the test methods failed because of a trigger on oppportunity after update
Here is the trigger:
trigger SGSFA_OPPTY_UK_UPDATE_CNTRCT on Opportunity (after update) {
//Trigger to uncheck Related Opportunity checkbox from contract object
//Select UK Record Type
RecordType rType = [Select Id From RecordType
where sObjectType='Opportunity'
and DeveloperName = 'UK_All_opportunity_rec_type'
and isActive=true
limit 1];
List<Id> lstOppID = new List<Id>();
for(Opportunity o : Trigger.New){
if(o.recordTypeID == rType.Id){
lstOppID.add(o.Id);
}
}
List<Id> lstCloseDateChanged = new List<id>();
for(Opportunity o : Trigger.New){
if(o.CloseDate != Trigger.oldMap.get(o.id).CloseDate)
lstCloseDateChanged.add(o.id);
}
//find the list of contracts to update
List<Contract> lstCntrct = new List<Contract> ();
lstCntrct = [select id, Related_Opportunity__c from contract c
where c.id in (select o.Contract_ID__c From OpportunityLineItem o
where o.OpportunityID in :lstOppID)
and c.id not in (select o1.Contract_ID__c From OpportunityLineItem o1
where o1.Opportunity.IsClosed = False)
];
//set related opportunity field to false and update the contract list
if(!lstCntrct.isEmpty()) {
for(Integer i = 0; i < lstCntrct.size(); i++){
lstCntrct[i].Related_Opportunity__c = false;
}
update lstCntrct;
}
//update all opportunity products if the close date changed. This will trigged the WF rules
if(!lstCloseDateChanged.isEmpty()){
List<OpportunityLineItem> lstLine = [select id From OpportunityLineItem o
where o.OpportunityID in :lstCloseDateChanged];
if(!lstLine.isEmpty())
update lstLine;
}
}
I don't understand what is making test method fail. Any help will be greatly appreciated. Thanks
Below is the test method which is failing at Insert oppli
static testmethod void test_batchoppty() |
- SFDC Admin & Analyst
- March 18, 2012
- Like
- 0
Test Coverage Error for an Simple ' before update' trigger
Hi All,
Here is my trigger, and I have got an error while writing the test class.
trigger UpdateRating on Lead (before update) { for(Lead l:Trigger.new) { if(l.Pardot_Rating__c !=null && l.Pardot_Rating__c =='A') { l.Rating = 'A'; } else if(l.Pardot_Rating__c !=null && l.Pardot_Rating__c =='B') { l.Rating ='B'; } else if(l.Pardot_Rating__c !=null && l.Pardot_Rating__c =='C') { l.Rating = 'C'; } } }
Here is the Test Class.
@isTest(seeAllData = true) Private Class TestUpdateRatingTrigger{ @isTest Private Static Void testUpdateRatingTrigger(){ Test.StartTest(); Lead testLead = new Lead( FirstName = 'TestFirstName', LastName = 'TestLastName', Email = 'Srinu.mandalapu@stratus.com', Phone = '4055090045', Prospect_Type__c = 'Direct End User', Title = 'Test Title', Company = 'ABC', Status = 'Open', Rating = 'A' ); insert testLead; testLead.Rating = 'B'; update testLead; //verifying updation Lead updatedLead = [SELECT Rating FROM Lead WHERE Id = :testLead.Id]; System.assertEquals('B', updatedLead.Rating); Test.StopTest(); } }
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, jigsaw_clean.crmLastModifiedLead: execution of BeforeInsert caused by: line -1, column -1: Previous load of class failed: knowledgecontroller: [] Class.TestUpdateRatingTrigger.testUpdateRatingTrigger: line 17, column 1
Here "KnowledgeController" is the controller in my org.
Is "knowledgeController" managed package in my org? I saw the packages in my ORG, I did not find any package under that name...
Any help would be greatly aprreciated...
- Srinu
- March 18, 2012
- Like
- 0
Duplicate Username DML Exceptions in Test Classes in Production
Test Classes in Production have failed suddenly with the following DML Exception. Please help.
Here is the error:
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.<br>Another user has already selected this username.<br>Please select another.: [Username]
Class.SGPRM_TestingClass.testSGPRM_OwnerChange_Before_Update: line 14, column 1
Here is the test class
@isTest
private class SGPRM_TestingClass
{
//*#*Test Method for SGPRM_OwnerChange_Before_Update Trigger
static testMethod void testSGPRM_OwnerChange_Before_Update() {
Profile Profile1 = [select id from profile where name='System Administrator'];
Profile Profile2 = [select id from profile where name='Standard User'];
User CEO = new User(alias = 'ceo', email='admin@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = Profile1.Id,
timezonesidkey='America/Los_Angeles', username='admin@testorg.com');
insert CEO;
User SalesManager = new User(alias = 'smngr', email='sManager@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = Profile2.Id, managerId = CEO.id,
timezonesidkey='America/Los_Angeles', username='sManager@testorg.com');
insert SalesManager;
User SalesRep = [Select Id,Name,Email,managerId ,timezonesidkey from User where Name = 'Deborah BUELL' ];
System.runAs(SalesRep)
{
Id RT = [select id from RecordType where SObjectType = 'Lead' AND developerName = 'DealRegistration'][0].Id;
Lead lead = new Lead();
lead.RecordTypeId = RT;
lead.firstname = 'Test';
lead.lastname = 'User';
lead.Company = 'Test Group';
lead.city = 'Test';
lead.state = 'NJ';
lead.country = 'United States';
//lead.OwnerId = '005A0000000iviM';
insert lead;
Test.startTest();
// Lead Submitted for Approval
lead.Status = 'Submitted for Approval';
lead.OwnerId = SalesManager.Id;
update lead;
Test.stopTest();
}
}}
- SFDC Admin & Analyst
- March 16, 2012
- Like
- 0