-
ChatterFeed
-
0Best Answers
-
2Likes Received
-
0Likes Given
-
17Questions
-
18Replies
Testing loading a page
There is an action that fires when the opportunity page is loaded (via a visualforce page). I know the controller extension and action work because its been proven via the UI. Just not sure to how properly write a unit test to load the page, and thus trigger the action to run.
-
- jjvdev
- August 11, 2016
- Like
- 0
- Continue reading or reply
AggregateResult returns values when executing anonymously, but not when running a unit test
List<AggregateResult> contactsPerAccount = [select AccountId, count(Id) accountContacts from Contact group by AccountId]; system.debug ('contactsPerAccount size: ' + contactsPerAccount.size());
-
- jjvdev
- March 01, 2016
- Like
- 0
- Continue reading or reply
Why the duplicate lead history values?
select Id, CreatedDate, Field, LeadId, NewValue, OldValue from LeadHistory where (field = 'ownerAssignment' or field = 'Owner')The lead history object has one record where the newvalue/oldvalue is the actual owner/ namequeue name, and then a duplicate record with the exact same CreatedDate time stamp that shows newvalue/oldvalue as the owner id/queue id.
What is going on here? Why does lead history have 2 records for the exact same event?
-
- jjvdev
- September 04, 2015
- Like
- 2
- Continue reading or reply
Process Builder error, cannot re-activate a process
"Unfortunately, there was a problem. Please try again. If the problem continues, contact Salesforce Customer Support with the error ID shown here and any other related details. Error ID: 158541872-10573 (1952119784)"
Submitted a case to Support, but find the community often does a better job answering these questions.
-
- jjvdev
- August 09, 2015
- Like
- 0
- Continue reading or reply
What is the best way to process selected records in a VF page using a custom list button
Custom controller example:
public class wrapperClassController { //Our collection of the class/wrapper objects cContact public List<cContact> contactList {get; set;} //This method uses a simple SOQL query to return a List of Contacts public List<cContact> getContacts() { if(contactList == null) { contactList = new List<cContact>(); for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) { // As each contact is processed we create a new cContact object and add it to the contactList contactList.add(new cContact(c)); } } return contactList; } public PageReference processSelected() { //We create a new list of Contacts that we be populated only with Contacts if they are selected List<Contact> selectedContacts = new List<Contact>(); //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list for(cContact cCon: getContacts()) { if(cCon.selected == true) { selectedContacts.add(cCon.con); } } // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc System.debug('These are the selected Contacts...'); for(Contact con: selectedContacts) { system.debug(con); } contactList=null; // we need this line if we performed a write operation because getContacts gets a fresh list now return null; } // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value public class cContact { public Contact con {get; set;} public Boolean selected {get; set;} //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false public cContact(Contact c) { con = c; selected = false; } } }
Visualforce page example:
<apex:page controller="wrapperClassController"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/> </apex:pageBlockButtons> <!-- In our table we are displaying the cContact records --> <apex:pageBlockTable value="{!contacts}" var="c" id="table"> <apex:column > <!-- This is our selected Boolean property in our wrapper class --> <apex:inputCheckbox value="{!c.selected}"/> </apex:column> <!-- This is how we access the contact values within our cContact container/wrapper --> <apex:column value="{!c.con.Name}" /> <apex:column value="{!c.con.Email}" /> <apex:column value="{!c.con.Phone}" /> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Custom list button to be added example:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} records = {!GETRECORDIDS($ObjectType.Contact)}; if (records[0] == null) { alert("Please select at least one row"); } else { if(records.length==1) { var state = {}; var callback = { onSuccess: findContact, onFailure: queryFailed, source: state}; sforce.connection.query( "Select Email, Name, AccountID From Contact where id='" + records[0] + "'", callback); } else { var where_clause = ""; for (var n=0; n<records.length; n++) { where_clause+=(where_clause.length>0?" or ":"") + "id='" + records[n] + "'"; } var state = {}; var callback = { onSuccess: layoutResults, onFailure: queryFailed, source: state}; sforce.connection.query( "Select Email, Name From Contact where " + where_clause, callback); } } function queryFailed(error, source) { alert("An error has occurred: " + error); } function layoutResults(queryResult, source) { if (queryResult.size == 0) return; var records = queryResult.getArray('records'); var count = 0; var params = "company=" + escape(getContactListName()+" List View Blast - {!Today} "); for (var i = 0; i < records.length; i++) { var contact= records[i]; if(contact.Email=='' || contact.Email==null) continue; var name = contact.Name.replace(",", ""); params+=(params.length>0?"&":"") + "email=" + escape(name + " <" + contact.Email + ">"); count++; } if(count==0) { alert("No selected rows contain email addresses"); return; } var url = "http://clearslide.com/manage/email/external_link?" + params;; if(url.length>2000) { alert("Too many items are selected at once. Please enter the addresses directly into ClearSlide."); return; } //alert(url ); window.open(url); } //////// single contact selected - look up account for company name function findContact(queryResult, state) { if (queryResult.size == 0) return; var records = queryResult.getArray('records'); state["Email"] = records[0].Email; state["Name"] = records[0].Name; if(state["Email"]=='' || state["Email"]==null) { alert("This contact has no email address"); return; } state["Name"] = state["Name"] .replace(",", ""); var callback = { onSuccess: findAccount, onFailure: queryFailed, source: state}; sforce.connection.query( "Select Name From Account where id='" + records[0].AccountId + "'", callback); } function findAccount(queryResult, state) { var params = ""; if (queryResult.size > 0) { var records = queryResult.getArray('records'); params = "company=" + escape(records[0].Name); } var email = state["Email"]; var name = state["Name"]; if(email!='' && email!=null) params += (params.length>0?"&":"") +"email=" + escape(name + " <" + email + ">"); else params += (params.length>0?"&":"") +"name=" + escape(name); var url = "http://clearslide.com/manage/email/external_link?" + params; //alert(url ); window.open(url); } function getContactListName() { try { var a = document.getElementsByTagName("select"); for(var i = 0; i < a.length; i++) { if(a[i].name.indexOf("fcf", a[i].name.length - 3) !== -1) { return "'" + a[i].options[a[i].selectedIndex].text + "'"; } } } catch(e) {} return "Salesforce"; }
-
- jjvdev
- July 30, 2015
- Like
- 0
- Continue reading or reply
System.NullPointerException: Attempt to de-reference a null object Error
Here is the error "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, leadTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object".
How do you get the Id for trigger.new?
trigger leadTrigger on Lead (before insert, after insert, after update) { Set<ID> ids = Trigger.newMap.keySet(); // getting error here List<Lead> triggerLeads = [SELECT Id, Email, LeadSource FROM Lead WHERE Id in :ids]; }
-
- jjvdev
- May 26, 2015
- Like
- 0
- Continue reading or reply
OwnerId.IsActive = false after assignment to test lead
So explain this to me???
15:44:36.155 (9155332602)|USER_DEBUG|[9]|DEBUG|***** user data *****User:{IsActive=true, Id=00517000000GYztAAG}
15:44:36.499 (9499882380)|USER_DEBUG|[15]|DEBUG|***** lead owner active *****false
How is the same user active in one query, but inactive in another???
@isTest private class UserIsActiveTest { static testMethod void myUnitTest() { // get active users List<User> reps = new List<User> ([select Id, IsActive from User where IsActive = true]); User activeuser = reps.get(0); system.debug ('***** user data *****'+reps.get(0)); // insert test lead and assign to active user Lead testLead = new Lead(LastName='Test1', Company='Test1 Inc.', Email='test1@test.com', Description='Description', OwnerId=activeuser.Id); insert testLead; system.assertEquals(activeuser.Id, testLead.OwnerId); system.debug ('***** lead owner active *****'+testLead.Owner.IsActive); } }
-
- jjvdev
- April 27, 2015
- Like
- 0
- Continue reading or reply
Delayed Unit Test
Is it possible to delay the assertion of something in a unit test?
Example:
1. 0 hour, a lead is created in Salesforce
2. 15 minutes later, Salesforce syncs the lead to a 3rd party app
3. 30 minutes later, the 3rd party app does some stuff
4. 1 hour later, 3rd party app syncs back to Salesforce
Did #3 happen as expected? In the apex test method is possible to write a unit test to check that the 3rd party app performed as expected? How can this be accomplished?
Thanks in advance.
-
- jjvdev
- October 14, 2013
- Like
- 0
- Continue reading or reply
Filter Dashboard Data by Search
Is it possible for a dashboard filter to be a search based filter? For example a lead dashboard that returns data based on the lead company name that a user searches for in this filter? Perhaps through a visualforce component? Extra credit if there is a way to incorporate this - http://jqueryui.com/autocomplete/.
Thanks
-
- jjvdev
- April 12, 2013
- Like
- 0
- Continue reading or reply
Reducing Formula Compile Sizes
I've noticed that using multiple operators with CONTAIN functions ( : ) instead of OR functions and using CASE statements instead of nested IF statements can have a big impact on reducing formula compile sizes.
What are some other things for reducing compile sizes?
-
- jjvdev
- January 26, 2012
- Like
- 0
- Continue reading or reply
Associating New Task with Person Account and Opportunity
Need to create a new task upon creation of a new opportunity and associate the task with both the opportunity and a person account. Attempting to put the person account Id in the WhoId of the new task but recieving the error FIELD_INTEGRITY_EXCEPTION, Contact/Lead ID: id value of incorrect type: 001L00000033TM9IAM: [WhoId]
What is the workaround for this?
Thanks
List<Opportunity> opps = [select Id, OwnerId, Person_Account__c from Opportunity where Id IN :trigger.new]; for(Opportunity o: opps) { Task newTask = new Task(OwnerId=o.OwnerId, Subject='Initial Call', Type ='Call',ActivityDate=Date.Today(), Status='Not Started', WhoId=o.Person_Account__c, WhatId=o.Id); activities.add(newTask); }
-
- jjvdev
- October 03, 2011
- Like
- 0
- Continue reading or reply
Customizing Workflow Task
Is possible to have a workflow rule trigger the creation of a task that is related to both an opportunity AND a contact related to the opportunity for an opportunity workflow fule? The Workflow Task creation does not appear to provide options for both WhatId and WhoId, it seems to only be one or the other depending on the object that the workflow triggers on.
Know that this give be created by writing an apex trigger but would rather do it out the of box if possible.
Thanks
-
- jjvdev
- October 02, 2011
- Like
- 0
- Continue reading or reply
"Starts with vowel sound"?
Out of curiosity, when creating a new custom object there is a checkbox "Starts with vowel sound". What is this used for?
-
- jjvdev
- February 11, 2011
- Like
- 0
- Continue reading or reply
Change Default Search Options by Tab
Is it possible to change the default search settings based on which tab the user is currently viewing? Wondering if this can be coded with apex/visualforce.
For example, if the user clicks on Cases, then does a search in the search bar, the search options automatically search only for Cases. Of course there should be an option for the user to disable this behavior.
-Thanks
-
- jjvdev
- January 20, 2011
- Like
- 0
- Continue reading or reply
Update Button
Want to create a button that saves the current record, and returns to the current record. Can this be done using OnClick JavaScript?
-Thanks
-
- jjvdev
- January 17, 2011
- Like
- 0
- Continue reading or reply
OpportunityTeamMember Trigger
Is it possible to write a trigger on OpportunityTeamMember object?
-Thanks
-
- jjvdev
- January 15, 2011
- Like
- 0
- Continue reading or reply
Cannot Login to External Site Within iframe in IE
I have an external site being rendered through an <iframe>. This external page has a login which I can login fine using Chrome and Firefox, but I can not login through the iframe in IE 7. How can this problem be fixed without changing IE security settings?
<apex:tab label="MyExternalPage" name="ExternalPage" id="External"> <iframe width="100%" height="800" scrolling="true" marginheight="100%" marginwidth="100%" escape="false" src="https://login.yahoo.com/config/login_verify2?&.src=ym"> <!--just an example not my actual page!--> </iframe> </apex:tab>
Thanks
-
- jjvdev
- December 06, 2010
- Like
- 0
- Continue reading or reply
Why the duplicate lead history values?
select Id, CreatedDate, Field, LeadId, NewValue, OldValue from LeadHistory where (field = 'ownerAssignment' or field = 'Owner')The lead history object has one record where the newvalue/oldvalue is the actual owner/ namequeue name, and then a duplicate record with the exact same CreatedDate time stamp that shows newvalue/oldvalue as the owner id/queue id.
What is going on here? Why does lead history have 2 records for the exact same event?
-
- jjvdev
- September 04, 2015
- Like
- 2
- Continue reading or reply
Testing loading a page
There is an action that fires when the opportunity page is loaded (via a visualforce page). I know the controller extension and action work because its been proven via the UI. Just not sure to how properly write a unit test to load the page, and thus trigger the action to run.
- jjvdev
- August 11, 2016
- Like
- 0
- Continue reading or reply
Why the duplicate lead history values?
select Id, CreatedDate, Field, LeadId, NewValue, OldValue from LeadHistory where (field = 'ownerAssignment' or field = 'Owner')The lead history object has one record where the newvalue/oldvalue is the actual owner/ namequeue name, and then a duplicate record with the exact same CreatedDate time stamp that shows newvalue/oldvalue as the owner id/queue id.
What is going on here? Why does lead history have 2 records for the exact same event?
- jjvdev
- September 04, 2015
- Like
- 2
- Continue reading or reply
Process Builder error, cannot re-activate a process
"Unfortunately, there was a problem. Please try again. If the problem continues, contact Salesforce Customer Support with the error ID shown here and any other related details. Error ID: 158541872-10573 (1952119784)"
Submitted a case to Support, but find the community often does a better job answering these questions.
- jjvdev
- August 09, 2015
- Like
- 0
- Continue reading or reply
System.NullPointerException: Attempt to de-reference a null object Error
Here is the error "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, leadTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object".
How do you get the Id for trigger.new?
trigger leadTrigger on Lead (before insert, after insert, after update) { Set<ID> ids = Trigger.newMap.keySet(); // getting error here List<Lead> triggerLeads = [SELECT Id, Email, LeadSource FROM Lead WHERE Id in :ids]; }
- jjvdev
- May 26, 2015
- Like
- 0
- Continue reading or reply
OwnerId.IsActive = false after assignment to test lead
So explain this to me???
15:44:36.155 (9155332602)|USER_DEBUG|[9]|DEBUG|***** user data *****User:{IsActive=true, Id=00517000000GYztAAG}
15:44:36.499 (9499882380)|USER_DEBUG|[15]|DEBUG|***** lead owner active *****false
How is the same user active in one query, but inactive in another???
@isTest private class UserIsActiveTest { static testMethod void myUnitTest() { // get active users List<User> reps = new List<User> ([select Id, IsActive from User where IsActive = true]); User activeuser = reps.get(0); system.debug ('***** user data *****'+reps.get(0)); // insert test lead and assign to active user Lead testLead = new Lead(LastName='Test1', Company='Test1 Inc.', Email='test1@test.com', Description='Description', OwnerId=activeuser.Id); insert testLead; system.assertEquals(activeuser.Id, testLead.OwnerId); system.debug ('***** lead owner active *****'+testLead.Owner.IsActive); } }
- jjvdev
- April 27, 2015
- Like
- 0
- Continue reading or reply
Recursion check prevents After triggers from running
I recently changed all my triggers to classes and then created a main trigger for each object that calls the classes for each respective object.
Anywho, my opportunity trigger calls quite a few classes. The issue is that if I don't add a recursion check, I can't deploy the trigger due to the SOQL query limit being broken. But if I do add the recursion check, only the Before triggers work. Not the After triggers.
Here is the trigger (with the recursion call up top):
trigger MainTriggerOpportunity on Opportunity (before insert, before update, after insert, after update) {
if(checkRecursive.runOnce()){
if(trigger.isBefore){
if(trigger.isInsert){
ClassOppIndustry updater = new ClassOppIndustry();
updater.updateOppIndustry(trigger.new);
ClassRenewalDate updater1 = new ClassRenewalDate();
updater1.updateRenewalDate(trigger.new);
}
if(trigger.isUpdate){
ClassOppIndustry updater = new ClassOppIndustry();
updater.updateOppIndustry(trigger.new);
ClassRenewalDate updater1 = new ClassRenewalDate();
updater1.updateRenewalDate(trigger.new);
}
}
if(trigger.isAfter){
if(trigger.isInsert){
ClassRenewalProcess updater = new ClassRenewalProcess();
updater.updateRenewalStatus(Trigger.new);
ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
updater1.addBrand(trigger.new);
}
if(trigger.isUpdate){
ClassRenewalProcess updater = new ClassRenewalProcess();
updater.updateRenewalStatus(Trigger.new);
ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
updater1.addBrand(trigger.new);
ClassChatterAlerts updater2 = new ClassChatterAlerts();
updater2.addChatterAlert(Trigger.new,Trigger.oldMap);
}
}
}
}
Here is the recursion check class:
public Class checkRecursive{
private static boolean run = true;
public static boolean runOnce(){
if(run){
run=false;
return true;
}
else{
return run;
}
}
}
Perhaps I have to allow the trigger to run twice? I'm a newb, so any help would be much appreciated!
Thanks,
Greg
- ChickenOrBeef
- March 25, 2014
- Like
- 0
- Continue reading or reply
Visualforce search box
I am very new to visualforce and apex, so I hope this is not a dumb question. I am looking for a simple search where I can put a field on a visualforce page and a search box. When the button is hit I want it to lookup leads for the last name using the input in the field. I am just not even sure how to start with this.
- Scott0987
- October 08, 2012
- Like
- 0
- Continue reading or reply
Formula to big to execute!
Hate it when this happens!!
Any ideas on how I can reduce Compiled Size is 5,960 - so only a little bit over!
IF( AND( Account_Manager_Assigned__c ="OK", Accounts_Approval__c ="OK", Final_Client_Approval__c ="OK", Initial_Client_Approval__c ="OK", QAT_Approval__c ="OK", QAT_Approval__c ="OK", Sales_Handover_Completed__c ="OK", Script_Build_Complete__c ="OK", Scriptor_Allocated__c ="OK", SID_Received__c ="OK", Skill_Level_Assigned__c ="OK", Trainer_Assigned__c ="OK", Training_Completed__c ="OK", UAT_Approval__c ="OK", Welcome_Call_Completed__c ="OK"), IMAGE("/img/msg_icons/confirm16.png","OK"), IMAGE("/img/msg_icons/error16.png","Stop"))
- GRStevenBrookes
- August 04, 2011
- Like
- 0
- Continue reading or reply
One pageBlockTable with multiple sObjects?
Hey all,
trying to figure out if there is anywhere out there where someone has made a single pageBlockTable/dataTable (whatever) that combines multiple objects, and uses pagination.
Use case would be something like:
a single list of History type happenings that tracks: new files, new notes, maybe a change in field value here and there - all in one quick list rather that multiples...
Paginaiton would be great if I could use "standardSet Controler" ( http://www.salesforce.com/us/developer/docs/pages/Content/pages_custom_list_controller.htm )
- JNic
- April 04, 2011
- Like
- 0
- Continue reading or reply
OpportunityTeamMember Trigger
Is it possible to write a trigger on OpportunityTeamMember object?
-Thanks
- jjvdev
- January 15, 2011
- Like
- 0
- Continue reading or reply
Cannot Login to External Site Within iframe in IE
I have an external site being rendered through an <iframe>. This external page has a login which I can login fine using Chrome and Firefox, but I can not login through the iframe in IE 7. How can this problem be fixed without changing IE security settings?
<apex:tab label="MyExternalPage" name="ExternalPage" id="External"> <iframe width="100%" height="800" scrolling="true" marginheight="100%" marginwidth="100%" escape="false" src="https://login.yahoo.com/config/login_verify2?&.src=ym"> <!--just an example not my actual page!--> </iframe> </apex:tab>
Thanks
- jjvdev
- December 06, 2010
- Like
- 0
- Continue reading or reply
Not able to login into external site embedded as IFrame in VF page
I have designed a VF page and using <apex:iframe> tag to open an external site into the page itself. Purpose of embedding this iframe is to allow user to login into another website and view the external details in the same VF page. In Internet explorer, I can see the login screen but when I pass username/password, It does nothing and I can't login into external site. Same VF page is working perfect in Firefox and Chrome and I am able to login successfully and view external details.
Any help is appreciated.
- ajitverma
- October 28, 2010
- Like
- 0
- Continue reading or reply
How to Have a Currency Field in a Formula Text Field
I have an IF statement that needs to read
"New monthly rate going forward is $1,000.00"
My formula is
IF(ISBLANK( Custom_Description__c ),
"" ,
"New monthly rate going forward is" &""& Opportunity__r.Current_Monthly_Revenue__c)
but the Opportunity__r field is a currency field and the formula Error says "Incorrect parameter for function &(). Expected Text, received Number
Thank you in advance
- WPCMS
- July 12, 2010
- Like
- 2
- Continue reading or reply
Bind parameters in SOQL INCLUDE
Does bind parameters work when they appear in the "INCLUDES" clause of SOQL. Here's my observation
String userTypes='\'All\',\'Avon Leader\''; String titleLevels='\'All\',\'4\''; String SPLASHPAGE_TYPE='Splash Page'; System.debug('>>>>>>>>>>>>>>>userTypes='+userTypes); System.debug('>>>>>>>>>>>>>>>titleLevels='+titleLevels); List<Market_Content__c> mcList = [select Type__c,Content_Type__c,Content__c, User_Type__c, Title_Levels__c, Market__r.Name from Market_Content__c where Type__c='Splash Page' and Market__r.Market_Id__c = 'RO' and User_Type__c includes (:userTypes) and Title_Levels__c includes (:titleLevels) order by CreatedDate];
This SOQL returns 0 rows. However the following SOQL returns 1 row:
List<Market_Content__c> mcList = [select Type__c,Content_Type__c,Content__c, User_Type__c, Title_Levels__c, Market__r.Name from Market_Content__c where Type__c='Splash Page' and Market__r.Market_Id__c = 'RO' and User_Type__c includes ('All','Avon Leader') and Title_Levels__c includes ('All','4') order by CreatedDate];
What am I missing?
- Anand@SAAS
- April 15, 2010
- Like
- 0
- Continue reading or reply
How to retrieve multi-select picklists using includes/excludes in static soql
Hi guys,
Here is my situation, I want to query multi-select picklists in static soql, I have done this in dynamic soql, but in static soql, I don't know how to do it?
code snippet:
String categories = 'Featured, Super Featured';List<Product2> products = [select Category__c from Product2 where Category__c includes (:categories)];
In this way, I want to select all the products include Featured or Super Featured category, but I cannot get the right records.
But in this way, I got the right records.
List<Product2> products = [select Category__c from Product2 where Category__c includes ('Featured','Super Featured')];
Is there anyone can help me this problem? Thanks in advance!!
Thanks
- Eriksson
- March 02, 2010
- Like
- 0
- Continue reading or reply
? Tips on reducing compiled formula size ?
- Lori_
- March 21, 2007
- Like
- 0
- Continue reading or reply