• thecrmninja
  • NEWBIE
  • 205 Points
  • Member since 2008

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 53
    Replies

I have been asked to set up meeting requests and adding them to contact and lead activities related lists. Can anyone help me to get started on this?

 

Thank you!

Ok So i have this big nasty controller and I am hitting 70% on my code coverage. There are no setters only getters. Which I have to do because sites doesnt let you use a standard controller. heres one of the pieces its complaining about.

 

public class repPageController { 

 String prods='';

public String getRequiredProducts()

{prods= '';

lib = [Select Link__C, Sales__c, Thumbnail__c, Headline__c, Teaser_Text__c From Sales_Library__c

Where Required__c = true AND Sales_Library_Category__c = 'Product Information'];

prods='<div class="floatLeft" style="width:70%"><p><h3><a href="'+lib.Link__c +'" target="_blank">'

+lib.Headline__c+'</a></h3><br/>'+lib.Teaser_Text__c+'&nbsp;&nbsp;<a href="'+lib.Link__c

+'" target="_blank">More...</a>'+secondaryLink+' </p></div><div class="floatRight" style="width:28%">'

+imgLink+'</div><div class"clear"></div>';

return prods; 

} 

 

 

So heres my test statement.

 

public class TestRepPageControllers {

  public static testMethod void RepPageTester()

{

  string LiveID='00530000001f0fkAAA';

PageReference pageRef2 = Page.ICHomepage;

Test.setCurrentPageReference(pageRef2);

ApexPages.currentPage().getParameters().put('uid', LiveID);

RepPageController controller = new RepPageController();

controller.getRequiredProducts();

 

} 

 

Best I can tell its saying that I dont have coverage on the Lib variable But I am not sure how else to any help would be great

 

Message Edited by mike83 on 05-11-2009 03:14 PM

I have a Line Item Custom Object on Contracts. It allows our Sales Team to book line items against a contract. There maybe multiple line items all with differing Start and End Dates, Length of Days, Total Video Streams(over that period) and Streams per day.

 

We want to do something with a Report that will show Booked Streams for a given month.

 

Example:

 

Contract A

 

Example 1 - with field names

 

Line Item 1 - Start Date(Start_Date__c) = 1/28/2009 - End Date(End_Date__c) = 6/12/2009 - Length of Days(Length_of_Days__c this is a formula field - ( End_Date__c - Start_Date__c )+1) = 136 - Total Video Streams (Total_Line_Item_Streams__c) = 5,000,000 - Streams per Day(Streams_per_Day__c this is also a formula field - Total_Line_Item_Streams__c / Length_of_Days__c) = 36,765

 

Line Item 2 - Start Date = 3/1/2009 - End Date = 7/31/2009 - Length of Days = 153 - Total Video Streams = 5,000,000 - Streams per Day = 32,680

 

 

How can my Report show how many Streams are booked for the Month of April? Is it at all Possible?

Message Edited by MATTYBME on 04-22-2009 10:19 AM

I am researching for a development effort at my company.  I am hearing from some developers that it is not possible to perform a 'clone' via API.  I know that it's possible within APEX, so it seems counterintuitive that this is not possible with API's. 

Does anybody have experience with this and, if so, what approaches are available?

We would like to remove the ability for anyone to uncheck the 'Notify contact on Case Close' box on the Case Closure. I searched but there doesn't seem to be a way to make this a 'read-only' field, so the workaround I came up with was to go to Support Settings, then add Closed to the Status field on Case Details page, and then remove the Close Case button. This way, the user will never see the Case Closed page and thus will not be able to uncheck the 'Notify contact on Case Close' box.

However, the problem now is: when I set the Status to Closed, it doesn't trigger the email to Contact. Does anyone know how to trigger the email to go out EVERYTIME a Case is set to Closed status? Thanks much!

I have a conundrum I can't seem to sort out.  I would like to be able to lock a record type from certain users when all but a few fields are edited.  I have a semi-functional rule in place.  However, the issue is that if one of my Editable fields is changed, the validation allows any of the other fields to be changed.  I can't come at it the other way b/c this object has too many "protected" fields to compile a rule with that approach. 

 

Here is a generic version of what I have now....

 

 

AND( $RecordType.Name = "Record Type Name", NOT(OR( (ISCHANGED(Field1__c)), (ISCHANGED(Field2__C)), (ISCHANGED(Field3__c)), (ISCHANGED(Field4__c)) )))

 

I'm working with a few more fields and some more logic-layering, but the idea is generally captured above.  My question is, is there a way of ensuring that ONLY the "OK" fields are edited, not "OK" fields OR "Protected" fields when OK fields are edited at the same time? (traditional approaches like Read Only, etc. cannot be applied in this case due to permissions)

 

 

I am designing a trigger to update a Campaign Lookup field on the Lead object based on the various Campaigns a Lead is a member of. My ultimate goal is to achieve the following....

-If Lead has membership in a Campaign NOT NAMED "General Marketing" or "Online Application" and is from the last 365 Days, select the oldest Campaign Membership to use in updating the Lead Lookup
-Else if Lead has membership in a Campaign NOT NAMED "General Marketing" or "Online Application" and is NOT from the last 365 Days, select the oldest Campaign Membership to use in updating the Lead Lookup
-Else if Lead has membership in a Campaign NAMED "Online Application" update Lead lookup with Online Application Campaign
-Else assign Lead Lookup current Campaign being associated to it

I have constructed a trigger on the Campaign Member object that is able to find Leads related to the new Campaign Member(s), find the oldest Campaign Membership for said Lead(s) in the last 365 days and update a Custom Lookup on the Lead with the Campaign Name from the appropriate Campaign Membership.
To accomplish this, I had to introduce Limits on the results my SOQL query returned because the Relationship Query used to build the "LeadWithCampMembs" list would return duplicate Lead IDs, to avoid generating a "Duplicate ID" error.

What is the best way to facilitate conditional statements into this trigger so that if I don't meet the current set of criteria ("LeadsWithCampMembs"), I can move on to a second set of criteria and then a third?
Is it possible to workaround having a Limit in my Relationship Query and then get down to one record to add to the leadUpdate2 from inside my for loop?

///////////////////CURRENT TRIGGER///////////////////////

trigger LeadCreditedCampaign on CampaignMember (After Insert) { List<ID> leadCPGsIDs = New List<ID>(); //Run through Tasks in trigger, for those associated to Lead, add to above List for (CampaignMember c:System.Trigger.new) {if (c.Leadid<>Null) { leadCPGsIDs.add( c.LeadId ) ; }} List<Lead> LeadWithCampMembs = [select id, name, Credited_Campaign__c, (select id, CreatedDate, CampaignId from CampaignMembers where LeadId IN :leadCPGsIDs AND CreatedDate = LAST_N_DAYS:365 Order by CreatedDate Asc Limit 1) from Lead where Id IN :leadCPGsIDs]; List<lead> leadUpdate2 = new List<lead>(); for(Lead l : LeadWithCampMembs){ for(CampaignMember cb: l.CampaignMembers){ l.Credited_Campaign__c = cb.CampaignId; leadUpdate2.add(l); } } Update LeadUpdate2; }

 

I'm a self-proclaimed novice programmer, especially with Apex.  I'm working with a WSDL based webservice callout and not seeing what I would expect.  Any perspective would be appreciated.  The following sample is broken into three portions(urls, authentication redacted).  ...1.Asynchronous Callout 2.WSDL2APEX Class 3.Debug log of @future callout. 

 

 

/////////////////////////////////////////////////////Callout///////////////////////////////////////////////////// public class LeadIVAULTCallout { @future (callout=true) public static void LeadIVAULTCalloutPOST(Set <Id> leadPDFIDs) { Map<ID,Attachment> leadPDFMap = new Map<ID,Attachment>( [select attachment.ID from Attachment where id IN :leadPDFIDs] ) ; for( ID i : leadPDFIDs ){ Attachment STLeadPDF = leadPDFMap.get(i); String DocumentID = STLeadPDF.ID; String applicationId = 'GFT-CUST-99YR'; //docSample.DocSamplePort stub = new docSample.DocSamplePort(); globalforexSpringthroughComServices.SFDocumentManagementSoap stub = new globalforexSpringthroughComServices.SFDocumentManagementSoap(); stub.inputHttpHeaders_x = new Map<String, String>(); //Setting a basic authentication header stub.inputHttpHeaders_x.put('Authorization', <VALUE>); globalforexSpringthroughComServices.SFResult Stub2 = Stub.QueueDocument(DocumentID,applicationId); stub.outputHttpHeaders_x = new Map<String, String>(); String myHeader = stub.outputHttpHeaders_x.get('My-Header'); system.debug('headers: ' + stub.outputHttpHeaders_x + myHeader); } } } /////////////////////////////////////////////////////wsdl2apex///////////////////////////////////////////////////// //Generated by wsdl2apex public class globalforexSpringthroughComServices { public class SFDocumentManagementSoap { public String endpoint_x = 'http://<URLHERE>'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; public Integer timeout_x; public globalforexSpringthroughComServices.AuthSoapHeader AuthSoapHeader; private String AuthSoapHeader_hns = 'AuthSoapHeader=http://<URLHERE>'; private String[] ns_map_type_info = new String[]{'http://<URLHERE>', 'globalforexSpringthroughComServices'}; public globalforexSpringthroughComServices.SFResult QueueDocument(String documentId,String applicationId) { globalforexSpringthroughComServices.QueueDocument_element request_x = new globalforexSpringthroughComServices.QueueDocument_element(); globalforexSpringthroughComServices.QueueDocumentResponse_element response_x; request_x.documentId = documentId; request_x.applicationId = applicationId; Map<String, globalforexSpringthroughComServices.QueueDocumentResponse_element> response_map_x = new Map<String, globalforexSpringthroughComServices.QueueDocumentResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://<URLHERE>', 'http://<URLHERE>', 'QueueDocument', 'http://<URLHERE>', 'QueueDocumentResponse', 'globalforexSpringthroughComServices.QueueDocumentResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.QueueDocumentResult; } } public class AuthSoapHeader { public String UserName; public String Password; private String[] UserName_type_info = new String[]{'UserName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://globalforex.springthrough.com/services/','true','false'}; private String[] field_order_type_info = new String[]{'UserName','Password'}; } public class QueueDocumentResponse_element { public globalforexSpringthroughComServices.SFResult QueueDocumentResult; private String[] QueueDocumentResult_type_info = new String[]{'QueueDocumentResult','http://globalforex.springthrough.com/services/','SFResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'QueueDocumentResult'}; } public class QueueDocument_element { public String documentId; public String applicationId; private String[] documentId_type_info = new String[]{'documentId','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] applicationId_type_info = new String[]{'applicationId','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'documentId','applicationId'}; } public class SFResult { public Boolean success; public String returnValue; private String[] success_type_info = new String[]{'success','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'}; private String[] returnValue_type_info = new String[]{'returnValue','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'success','returnValue'}; } } /////////////////////////////////////////////////////Debug Log///////////////////////////////////////////////////// User Tom Fox Date 2/24/2010 8:18:53 PM EST Status Success Application Browser Request Type Api Operation FutureHandler Duration (ms) 282 Log Length 20100225011853.316:Class.LeadIVAULTCallout.LeadIVAULTCalloutPOST: line 34, column 1: headers: {}null

 

 

 

 

Am I crazy to expect more from my Debug Log?  I'm fearful that I'm not properly requesting the response from the webservice.

One of the SFDC bloggers I often follow,  Perspectives on Salesforce,  recently posed the following question: how do i cast an object result from a dynamic query to a datetime variable?

 

Well, here is how I did it.  In this instance, I have a Lead Distribution System.  This controller evaluates the volume of Leads that a user is able to pull on a daily basis, tracking values like languages spoken, extra leads allowed for the day, etc.  One variable it tracks, is the last day the User pulled.  

 

(I've only included the query and the setting of variables as well as me casting to a list by calling those variables, including Date).

 

 

//Call all the values to an object instance, to then be passed to variables public User usr = [Select TruePerDiem__c, LeadPullQueues__c, PerDiem__c,Last_Pulled__c,Open_Leads_Owned__c,PulledXDaysAgo__C, Lang1__c, Lang2__c, Lang3__c, Lang4__c, Lang5__c from User where Id = :userinfo.getuserid() LIMIT 1]; //Create variables to receive dynamic values from above query public String Queue = usr.LeadPullQueues__c; public Double NewMAX= usr.PerDiem__c; public Integer NewDiem = newMax.intvalue(); //LOOK HERE - This is where I am pulling date!!!! Public Date LastPulled = usr.Last_Pulled__c; //Here is where I cast to a list with a SOQL Query, using dynamic variables from above //(please note, I removed alot of the variables I create in my controller for the sake of brevity. List<Lead> leads = [select Id,ownerid,PulledYes__c,ELPLang__c,Priotizer__c from lead where ownerid = :Queue AND (ELPLang__c LIKE :Lang1 OR ELPLang__c LIKE :Lang2 OR ELPLang__c LIKE :Lang3 OR ELPLang__c LIKE :Lang4 OR ELPLang__c LIKE :Lang5)

 

Now, in my example, I use the LastPulled Date Variable for ternary, if/else logic but it could easily be applied to a SOQL statement.  ("...where Date = :LastPulled).

 

Does anybody else have any examples of other approaches.  This really is a great opportunity to learn about dynamic queries, a rich capability of Apex.

 

 

I have an apex trigger that creates a text file on input of a PDF file.  It works fine except for one bit.

 

 

textbody = 'CODEPAGE:819'+' \r '+ 'COMMENT: Begin Prolog'+' \r '+ 'COMMENT: Customer Identifier – GFF'+' \r '+

 

Creates a textbody of 

 

 CODEPAGE:819
 COMMENT: Begin Prolog
 COMMENT: Customer Identifier â€" GFF 

 

As you can see.  '-' is producing a value of  –.  Search as I might on the forums, I can't find any reference to how to declare a Hyphen in a Textbody Call.  

 

 

 

I am generating the following error in my Asynch Test Method:

 

Error: Compile Error: Method does not exist or incorrect signature: UpdBOPCallout.UpdBOPCalloutPOST() at line 26 column 8

 

 

 

the documentation that I have found doesn't make it clear why I am generating this error.  I am pretty sure I'm not passing through the right value or need to construct a method within the test but I am a bit lost at this point.  Any input that I could get would be very helpful.

 

//////////////////////////////////Controller//////////////////////////////////////////////////////// public class UpdBOPCallout { @future (callout=true) public static void UpdBOPCalloutPOST(Set <Id> LeadIDs) { Map<ID,Lead> leadMap = new Map<ID,Lead>( [select Lead.ID, Lead.DemoUserID__c, LastModifiedBy.User_Demo_Group__c from Lead where id IN :leadIDs] ) ; for( ID i : leadIDs ){ Lead BOPLead = leadMap.get(i); HttpRequest req = new HttpRequest(); req.setEndpoint('END POINT URL - REMOVED FOR FORUM POST'); req.setMethod('POST'); //System.debug('before soap body: ' + soapBody); //System.debug('after soap body: ' + soapBody); //(old non-variable approach)req.setBody('request_type=modify&login=BOPLead.customstring__c&groups=BOPLead.LastModifiedBy.customstring__c'); req.setBody('request_type=modify&login=' + BOPLead.customstring__c + '&groups=' + BOPLead.LastModifiedBy.customstring__c); //HttpResponse res = http.send(req); //System.debug(res.getBody()); } } } //////////////////////////////////Trigger/////////////////////////////////////////////////////////// trigger UpdateBOP on Lead (after Update) { Set<Id> leadIDs = new Set<Id>(); for (Integer i = 0; i < Trigger.new.size(); i++) { if (Trigger.new[i].OwnerID != Trigger.old[i].OwnerID && Trigger.old[i].ELPlead__c > 0) { //leadStatus.put(Trigger.new[i].OwnerId leadIDs.add( Trigger.new[i].Id ) ; } } UpdBOPCallout.UpdBOPCalloutPOST(leadIDs) ; } //////////////////////////////////Test Method/////////////////////////////////////////////////////// Global Class TestBOP{ static testMethod void BOPtest() { String QuB = [select Queue.id from QueueSobject where Queue.name='ELPLeadsUS'][0].Queue.id; Profile p = [select id from profile where name='Standard User']; User BOPae = new User(username='testBOPae@test.com', lastname='BOPae', email='testBOPae@test.com', alias='test', communitynickname='tBOP', User_Demo_Group__c='demo_default', LanguageLocaleKey = 'en_US', Localesidkey = 'en_US', TimeZoneSidKey = 'America/Los_Angeles', emailencodingkey = 'ISO-8859-1', profileid = p.id); insert BOPae; Lead leadBOP1 = new Lead(LastName='Test1', Company='Test1 Inc.', Email='test1@duptest.com', DemoUserID__c = 'demo123456', OwnerId=QuB); //Lead leadBOP2 = new Lead(LastName='Test2', Company='Test2 Inc.', Email='test4@duptest.com', DemoUserID__c = 'demo123456'); //Lead leadBOP3 = new Lead(LastName='Test3', Company='Test3 Inc.', Email='test5@duptest.com', DemoUserID__c = 'demo123456'); //Lead[] BOPleads = new Lead[] {leadBOP1, leadBOP2, leadBOP3}; //insert BOPleads; insert leadBOP1; leadBOP1.ownerid=BOPae.id; Update leadBOP1; Test.startTest(); //UpdBOPCallout.UpdBOPCalloutPOST(); System.debug('running myTest..'); Test.stopTest(); }}

 

 

I am looking to output SF attachments programmatically and need to eventually get them to TIFF, I would love ot hear any starting point suggestions.

I am building a custom controller.  My end goal is to have a method that reacts to data from the user pressing a button on a VF page to determine if they can get Leads and react accordingly.

The controller functions properly in my dev environment.  However, my testing methodology is not hitting every branch of the method and I'm a bit confused as to the reason.

 

Controller:

 

global without sharing class TomController{

public String getResult(){
return res;
}
private String res=null;

//Here we set variables utilized later to define user-specific search parameters
public Double MAX= [select TruePerDiem__c from User where ID = :userinfo.getuserid()][0].TruePerDiem__c;
public Integer Diem = Max.intvalue();
public String Queue = [select LeadPullQueues__c from User where ID = :userinfo.getuserid()][0].LeadPullQueues__c;
public Double NewMAX= [select PerDiem__c from User where ID = :userinfo.getuserid()][0].PerDiem__c;
public Integer NewDiem = newMax.intvalue();
Public Date LastPulled = [select Last_Pulled__c from User where ID = :userinfo.getuserid()][0].Last_Pulled__c;
public Double DaysSince= [select PulledXDaysAgo__c from User where ID = :userinfo.getuserid()][0].PulledXDaysAgo__c;
public Integer LastPull = DaysSince.intvalue();


//Everything below is the method that reacts to a button being pushed on the VF Page

public PageReference doSearch() {

// Once the button is pushed, This method dictates a path of action to take based on data of the user pressing the button
// In the first branch, A user has not pulled Leads today, so we use their Regular Per Diem since they are free to pull their full allotment of Leads
// The trigger updating the user record will also follow this logic to reset the number of Leads a User has pulled on THIS day
// The trigger will ALWAYS update a User's Last Pulled Date
if(LastPull > 0){
// We update the Lead records only when the owner id = User's Lead Pull Queue Value
List<Lead> leads = [select Id,ownerid,PulledYes__c from lead where ownerid = :Queue limit :NewDiem];
List<User> Users = [select ID, PulledToday__c from User where ID = :userinfo.getuserid() Limit 1];
ID u = [select ID from User where ID = :userinfo.getuserid()][0].Id;

for(Lead l:leads){
l.ownerid=u;
l.PulledYes__c='yes';
l.this_was_pulled__c=Date.Today();
}

update leads;

res = 'success';
return new PageReference('/00Q/o');
}

// In this second branch, A user has pulled Leads today, so we use their True Per Diem to make ensure they only get the Leads they should
// The trigger updating the user record will also follow this logic to add to the number of Leads a User has pulled on THIS day

else if(MAX > 0 && LastPull <= 0){
// We update the Lead records only when the owner id = User's Lead Pull Queue Value
List<Lead> leads = [select Id,ownerid,PulledYes__c from lead where ownerid = :Queue limit :Diem];
List<User> Users = [select ID, PulledToday__c from User where ID = :userinfo.getuserid() Limit 1];
ID u = [select ID from User where ID = :userinfo.getuserid()][0].Id;

for(Lead l:leads){
l.ownerid=u;
l.this_was_pulled__c=Date.Today();

}

update leads;

res = 'success';
return new PageReference('/00Q/o');
}

// In this third branch, A user has pulled Leads today and has none left to pull, so we inform them with a simple message
// The trigger updating the user record will do nothing since no Leads will be pulled

else if(MAX <= 0 && LastPull < 1){
system.debug('User reached Daily Lead Limit, must generate an error message...');
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.INFO, 'You have reached your Daily Lead Limit');
ApexPages.addMessage(myMsg);
return null;
}

// In this final branch, none of the criteria has been met and the user will be notified to contact the System Administrator
// The trigger updating the user record will do nothing since no Leads will be pulled

Else {
system.debug('General Error on Lead Puller Controller, must generate an error message...');
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.ERROR, 'The Get Leads function did not assign you Leads, Please contact your System Administrator');
ApexPages.addMessage(myMsg);
return null;

}

}

}

 Testing Method:

 

@isTest
private class TestTomCtrlr3{

static testmethod void TestTomCtrlr2a(){

//Prepare user for the test data
date dueDate = date.newInstance(2008, 1, 30);

String Quv = [select Queue.id from QueueSobject where Queue.name='A Test US Leads'][0].Queue.id;

Profile p = [select id from profile where name='Standard User'];
User Luse1 = new User(username='testa1@test.com', lastname='test', PerDiem__c = 4, PulledToday__c = 5,
DailyQuota__c = 5, email='testa1@test.com', alias='test', communitynickname='test',
LanguageLocaleKey = 'en_US', Localesidkey = 'en_US', TimeZoneSidKey = 'America/Los_Angeles',
emailencodingkey = 'ISO-8859-1', profileid = p.id, Last_Pulled__c = DueDate, LeadPullQueues__c = Quv);
insert Luse1;

QueueSobject Qu = [select Queue.id from QueueSobject where Queue.name='A Test US Leads'];


// Seed the database with some leads, and make sure they can
// be bulk inserted successfully.

Lead lead1 = new Lead(LastName='Test1', Company='Test1 Inc.', Email='test1@duptest.com', PulledYes__c = '', OwnerId=Qu.Queue.ID);
Lead lead2 = new Lead(LastName='Test2', Company='Test2 Inc.', Email='test4@duptest.com', PulledYes__c = '', OwnerId=Qu.Queue.ID);
Lead lead3 = new Lead(LastName='Test3', Company='Test3 Inc.', Email='test5@duptest.com', PulledYes__c = '', OwnerId=Qu.Queue.ID);
Lead[] leads = new Lead[] {lead1, lead2, lead3};
insert leads;

PageReference pageRef = Page.leadgetter;
Test.setCurrentPageReference(pageRef);
ApexPages.currentPage().getParameters().put('id',Luse1.id);


TomController controller = new TomController();

controller.doSearch();
Integer t = [Select count() from Lead where ownerid = :Luse1.id];

system.AssertEquals(3, t);

}

static testmethod void TestTomCtrlr2b(){

//Prepare Queue for User
// tried this but did not work Queue Qd = New Queue(Name='TmpQueue', Type='Queue');

String Quv = [select Queue.id from QueueSobject where Queue.name='A Test US Leads'][0].Queue.id;

//Prepare user for the test data

Profile p = [select id from profile where name='Standard User'];
User Luse2 = new User(username='test2a@test.com', lastname='test', PerDiem__c = 4, PulledToday__c = 0,
DailyQuota__c = 5, email='tes2t@test.com', alias='test', communitynickname='test',
LanguageLocaleKey = 'en_US', Localesidkey = 'en_US', TimeZoneSidKey = 'America/Los_Angeles',
emailencodingkey = 'ISO-8859-1', profileid = p.id, Last_Pulled__c = Date.Today(), LeadPullQueues__c = Quv);
insert Luse2;
QueueSobject Qu = [select Queue.id from QueueSobject where Queue.name='A Test US Leads'];


// Seed the database with some leads, and make sure they can
// be bulk inserted successfully.

Lead lead1 = new Lead(LastName='Test1', Company='Test1 Inc.', Email='test1@duptest.com', PulledYes__c = '', OwnerId=Qu.Queue.ID);
Lead lead2 = new Lead(LastName='Test2', Company='Test2 Inc.', Email='test4@duptest.com', PulledYes__c = '', OwnerId=Qu.Queue.ID);
Lead lead3 = new Lead(LastName='Test3', Company='Test3 Inc.', Email='test5@duptest.com', PulledYes__c = '', OwnerId=Qu.Queue.ID);
Lead[] leads = new Lead[] {lead1, lead2, lead3};
insert leads;

PageReference pageRef = Page.leadgetter;
Test.setCurrentPageReference(pageRef);
ApexPages.currentPage().getParameters().put('id',Luse2.id);


TomController controller = new TomController();

controller.doSearch();
Integer t = [Select count() from Lead where id in :ownerid = :Luse2.id];


system.AssertEquals(3, t);

}

static testmethod void TestTomCtrlr2ErrorA(){

//Create Flag for Message Check

Boolean errorFound = false;

String Quv = [select Queue.id from QueueSobject where Queue.name='A Test US Leads'][0].Queue.id;

//Prepare user for the test data
//This user will trigger the third branch by having met the daily pull quota and having a "pull date" of today

Profile p = [select id from profile where name='Standard User'];
User Muse = new User(username='testamsg@test.com', lastname='test', PerDiem__c = 0, PulledToday__c = -1,
DailyQuota__c = 0, email='testamsg@test.com', alias='test', communitynickname='test',
LanguageLocaleKey = 'en_US', Localesidkey = 'en_US', TimeZoneSidKey = 'America/Los_Angeles',
emailencodingkey = 'ISO-8859-1', profileid = p.id, Last_Pulled__c = (Date.Today()-1), LeadPullQueues__c = Quv);
insert Muse;

//Trigger Controller by calling VF page, Button Method both in context of above user

PageReference pageRef = Page.leadgetter;
Test.setCurrentPageReference(pageRef);

ApexPages.currentPage().getParameters().put('id',Muse.id);

TomController controller = new TomController();

controller.doSearch();

//Controller's been instantiated, now check to make sure the message from third branch displays

/*
String error = controller.getError();
System.AssertEquals(error,'Link or ID must be at least 15 characters long.');
*/

//This is an approach that seems not to be working

ApexPages.Message[] mssgs = ApexPages.getMessages();
for(ApexPages.Message m : mssgs){
if(m.getDetail()=='You have reached your Daily Lead Limit')
errorFound=true;
}
System.assert(errorFound==false);

}

}

 I'm still playing with ideas here but it would be a big help if anybody with more experience could point out any glaring issues/ommissions.  

 

Basically, I'm able to cover the first DML transaction and the  setting the variables.  For some reason, calling the second and third branches is not running the "Do Search" method and moving the Leads or generating the message.

 

 

 

A successful, actively growing orgnization in West Michigan is seeking an individual with strong SF knowledge to join it's SF Operations Department.  This is a international business that has recently put forward a concerted initiative to develop and maintain SF in a spirited fashion.  The candidate would report directly to the manager of Salesforce Operations. 

The ideal individual would be passionate about developing his/her CRM skillset, have a very positive 'bedside' manner when working with end users and exercise a high level of professionalism at all times.  This is a great opportunity for somebody that's new to the CRM field or looking for stable employment at a dynamic, good-natured organization that is consistnently recognized for it's industry-leading accomplishments.

 

UPD 12/21/2009 - PLEASE NOTE THAT THIS SEARCH HAS BEEN ENDED

Message Edited by thecrmninja on 01-04-2010 11:30 AM

I am researching for a development effort at my company.  I am hearing from some developers that it is not possible to perform a 'clone' via API.  I know that it's possible within APEX, so it seems counterintuitive that this is not possible with API's. 

Does anybody have experience with this and, if so, what approaches are available?

We would like to remove the ability for anyone to uncheck the 'Notify contact on Case Close' box on the Case Closure. I searched but there doesn't seem to be a way to make this a 'read-only' field, so the workaround I came up with was to go to Support Settings, then add Closed to the Status field on Case Details page, and then remove the Close Case button. This way, the user will never see the Case Closed page and thus will not be able to uncheck the 'Notify contact on Case Close' box.

However, the problem now is: when I set the Status to Closed, it doesn't trigger the email to Contact. Does anyone know how to trigger the email to go out EVERYTIME a Case is set to Closed status? Thanks much!

Here is the situation. I have a trigger on an opportunity that calls an asynchronous @future method which runs some logic and updates the opportunity. I also have several roll-up summary fields on the opportunity. When I run on updated on on OpportunityLineItem this executes the Opportunity trigger and queues up the @future method  which is throwing this error a lot: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record.


According to the documentation here, http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm , it says transactions that included a summary field (I assume it means roll up summary field) are especially prone to deadlocks. This makes me think that roll-up summary fields are also an asynchronous action but I am still looking for confirmation. If you know please respond.

 

UPDATE: Documentation here, http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm , makes it sound like roll-up summary fields are a synchronous operation. I'm confused. I think roll-up summary calculation may be synchronous if you edit the parent and asynchronous if you edit a child?

 

This is my theory. Trigger on opp fires and queues up both the @future method and the roll-up summary recalculation. Both are asynchronous (assumption) and they are both trying to update the opp at the same time. So how to solve this problem? Below is one possible idea but I have no idea if it would even work.

 

 

try{
	update oppsToUpdate;
}catch(Exception e1){
	if(e1.getMessage().contains('UNABLE_TO_LOCK_ROW')){
		try{
			update oppsToUpdate;
		}catch(Exception e2){
			if(e2.getMessage().contains('UNABLE_TO_LOCK_ROW')){
				try{
					update oppsToUpdate;
				}catch(Exception e3){
					//error handing after 3 failed updated attempts
				}
			}
		}
	}else{
		//other error handling
	}
}

 

This would attempt to updated the opp 3 separate times if the error returned is unable to lock row. Some unknowns here that hopefully someone with direct saleforce.com knowledge can address is are these three updated statements truly unique and separate update transactions or will the record being updated appear locked for the entire duration of the class execution? The updates would also me milliseconds apart and I don't know if the delay would be enough for the record to unlock.

 

If anyone has suggestions for this tricky problem I am all ears.

 

Thanks,

Jason

  • September 14, 2010
  • Like
  • 0

Apex provides supports for convert String to Hex value but not the Hex value to String. Can you help me on this.

 

Thank you

I have been asked to set up meeting requests and adding them to contact and lead activities related lists. Can anyone help me to get started on this?

 

Thank you!

Hi All,

I built a VF page with custom controller which calls another VF page that returns a PDF. The PDF is is extracted via getContent(), and attached to an email. It all works fine in the sandbox through the UI, but the test method fails, unfortunately without detailed log information.

 

I already found these two threads but none really points to an explanation why it fails in test methods while working fine in the UI:

http://community.salesforce.com/t5/Apex-Code-Development/error-quot-System-VisualforceException-quot-at-getContent/td-p/173307?view=by_date_ascending

 

http://community.salesforce.com/t5/Apex-Code-Development/RageReference-getContent-failing-on-Spring-10-release/td-p/168272

 

Here is the relevant code from the action method:

 

    public PageReference send(){

        for (string address:CCAddresses)
        {
        	if(!address.endsWith('@symmetricom.com')) address += '.full';
        }
        
        PageReference pdfPage = Page.quotePDF;
        pdfPage.getParameters().put('id',theQuote.ID);
        //pdfPage.setRedirect(true);
        System.Debug('pdfPage::::::::::::::::::::::::::::::::::::::: ' + pdfPage);
        transient Blob theBlob;
        theBlob = pdfPage.getContent();
        
        transient Attachment a = new Attachment (
            parentID = theQuote.ID,
            name = 'SymmQuote ' + theQuote.Name + '.pdf',
            body = theBlob);
        

 It fails at the line theBlob = pdfPage.getContent(); when called from the test method, otherwise it works fine. Error message is:

System.VisualforceException: List has no rows for assignment to SObject

The quotePDF page uses the same controller and I was wondering if that causes the issue. Maybe the test cannot handle another instance of the same controller? The PageReference for the pdfPage is created correctly

 

here is the test method:

 

		PageReference pageRef2 = Page.quoteSend;
		Test.setCurrentPage(pageRef2);
		ApexPages.currentPage().getParameters().put('id',quote1.Id);
		quoteLineEdit_v1 editController2 = new quoteLineEdit_v1();
		
		editController2.send();

 

 

 

 

 

 

 

 

 

I wasn't sure which topic I should submit this issue, but since there have been recent posts about performance in the Visualforce Development category, I am entering the post here. However, the issue appears on the standard tab pages with no custom development code involved.

 

Has anyone seen a huge performance degradation when resizing the Salesforce window when viewing information on the standard tabs like Accounts, Leads, Contacts, etc.? You won't see the problem if you just click on the Tab. You will need to select a view and click the Go button. Then, grab a corner of the window and drag it to a new size. It takes an incredibly long time for the contents of the window to redraw/update. 

 

I am using FF 3.6.2, but have confirmed that it is an issue with FF 3.5.8, as well as IE. It happens with both the old and new UIs in Salesforce.

 

I have no idea when this started happening. We just stumbled upon it recently.

 

If I get others to confirm that it is indeed a problem, then I will submit a case for it. Thanks!

 

 

  • April 02, 2010
  • Like
  • 0

I have a conundrum I can't seem to sort out.  I would like to be able to lock a record type from certain users when all but a few fields are edited.  I have a semi-functional rule in place.  However, the issue is that if one of my Editable fields is changed, the validation allows any of the other fields to be changed.  I can't come at it the other way b/c this object has too many "protected" fields to compile a rule with that approach. 

 

Here is a generic version of what I have now....

 

 

AND( $RecordType.Name = "Record Type Name", NOT(OR( (ISCHANGED(Field1__c)), (ISCHANGED(Field2__C)), (ISCHANGED(Field3__c)), (ISCHANGED(Field4__c)) )))

 

I'm working with a few more fields and some more logic-layering, but the idea is generally captured above.  My question is, is there a way of ensuring that ONLY the "OK" fields are edited, not "OK" fields OR "Protected" fields when OK fields are edited at the same time? (traditional approaches like Read Only, etc. cannot be applied in this case due to permissions)

 

 

In Apex, how to query contact fields in the same query?

 

Event ev=[Select who.email,who.title from event where Id='xxxxx']; ?

 

If we can't do this way, can someone please advice how i can grab the contact Object values in soql query by quering Event Object?

Message Edited by mavs on 02-26-2010 12:42 PM
  • February 26, 2010
  • Like
  • 0

I'm a self-proclaimed novice programmer, especially with Apex.  I'm working with a WSDL based webservice callout and not seeing what I would expect.  Any perspective would be appreciated.  The following sample is broken into three portions(urls, authentication redacted).  ...1.Asynchronous Callout 2.WSDL2APEX Class 3.Debug log of @future callout. 

 

 

/////////////////////////////////////////////////////Callout///////////////////////////////////////////////////// public class LeadIVAULTCallout { @future (callout=true) public static void LeadIVAULTCalloutPOST(Set <Id> leadPDFIDs) { Map<ID,Attachment> leadPDFMap = new Map<ID,Attachment>( [select attachment.ID from Attachment where id IN :leadPDFIDs] ) ; for( ID i : leadPDFIDs ){ Attachment STLeadPDF = leadPDFMap.get(i); String DocumentID = STLeadPDF.ID; String applicationId = 'GFT-CUST-99YR'; //docSample.DocSamplePort stub = new docSample.DocSamplePort(); globalforexSpringthroughComServices.SFDocumentManagementSoap stub = new globalforexSpringthroughComServices.SFDocumentManagementSoap(); stub.inputHttpHeaders_x = new Map<String, String>(); //Setting a basic authentication header stub.inputHttpHeaders_x.put('Authorization', <VALUE>); globalforexSpringthroughComServices.SFResult Stub2 = Stub.QueueDocument(DocumentID,applicationId); stub.outputHttpHeaders_x = new Map<String, String>(); String myHeader = stub.outputHttpHeaders_x.get('My-Header'); system.debug('headers: ' + stub.outputHttpHeaders_x + myHeader); } } } /////////////////////////////////////////////////////wsdl2apex///////////////////////////////////////////////////// //Generated by wsdl2apex public class globalforexSpringthroughComServices { public class SFDocumentManagementSoap { public String endpoint_x = 'http://<URLHERE>'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; public Integer timeout_x; public globalforexSpringthroughComServices.AuthSoapHeader AuthSoapHeader; private String AuthSoapHeader_hns = 'AuthSoapHeader=http://<URLHERE>'; private String[] ns_map_type_info = new String[]{'http://<URLHERE>', 'globalforexSpringthroughComServices'}; public globalforexSpringthroughComServices.SFResult QueueDocument(String documentId,String applicationId) { globalforexSpringthroughComServices.QueueDocument_element request_x = new globalforexSpringthroughComServices.QueueDocument_element(); globalforexSpringthroughComServices.QueueDocumentResponse_element response_x; request_x.documentId = documentId; request_x.applicationId = applicationId; Map<String, globalforexSpringthroughComServices.QueueDocumentResponse_element> response_map_x = new Map<String, globalforexSpringthroughComServices.QueueDocumentResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://<URLHERE>', 'http://<URLHERE>', 'QueueDocument', 'http://<URLHERE>', 'QueueDocumentResponse', 'globalforexSpringthroughComServices.QueueDocumentResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.QueueDocumentResult; } } public class AuthSoapHeader { public String UserName; public String Password; private String[] UserName_type_info = new String[]{'UserName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://globalforex.springthrough.com/services/','true','false'}; private String[] field_order_type_info = new String[]{'UserName','Password'}; } public class QueueDocumentResponse_element { public globalforexSpringthroughComServices.SFResult QueueDocumentResult; private String[] QueueDocumentResult_type_info = new String[]{'QueueDocumentResult','http://globalforex.springthrough.com/services/','SFResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'QueueDocumentResult'}; } public class QueueDocument_element { public String documentId; public String applicationId; private String[] documentId_type_info = new String[]{'documentId','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] applicationId_type_info = new String[]{'applicationId','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'documentId','applicationId'}; } public class SFResult { public Boolean success; public String returnValue; private String[] success_type_info = new String[]{'success','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'}; private String[] returnValue_type_info = new String[]{'returnValue','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'success','returnValue'}; } } /////////////////////////////////////////////////////Debug Log///////////////////////////////////////////////////// User Tom Fox Date 2/24/2010 8:18:53 PM EST Status Success Application Browser Request Type Api Operation FutureHandler Duration (ms) 282 Log Length 20100225011853.316:Class.LeadIVAULTCallout.LeadIVAULTCalloutPOST: line 34, column 1: headers: {}null

 

 

 

 

Am I crazy to expect more from my Debug Log?  I'm fearful that I'm not properly requesting the response from the webservice.

I want to be able to run a report based on the number of cases opened and closed per hour of the day, so I need to create a custom field that takes the Time/Date Opened field and converts it to just show the Hour created (24 hour time) and the same thing for the Time/Date Closed.

 

I've done this in the past at my last company, but don't  remember the formula. Does anyone know how to do this?

Hello All,

I have a trigger that is a bulk update. Sometimes the same object will make it into my update list more than once, which causes the error

 

UpdateParticipationTrigger: execution of AfterInsert caused by: System.ListException: Duplicate id in list: SomeSalesforceIDHere

 

 My list is built using

 

 

Set<Id> ConIds = new Set<Id> {}; for (Payments__c p : payments) { ConIds.add( p.Contact__c ); }

 

 How can I prevent duplicates from making it into that list, and hence causing errors? I am sure it is very simple to do (basically look in the list to see if the ID we are about to add is already in there, if so, don't add it). Let me know. Thanks!