-
ChatterFeed
-
7Best Answers
-
0Likes Received
-
0Likes Given
-
16Questions
-
47Replies
custom object data edit/delete using website created in site.com
- Amol_Nikam
- March 22, 2013
- Like
- 0
Nested IF Problem
Hello. I'm having a problem with a complex nested IF condition. Just cant seem to get the syntax correct. Here is my condition-with my comments:
Line 1: Check to see if todayminus_365__c falls in between the start date and the end date.
Line 2: If it does, see if the first condition is less than or equal to the second condition.
Line 3: Check to see if this condition is greater than 366. If it is, my end value should be 365, otherwise its 0.
IF (todayminus_365__c >= Start_Date__c && todayminus_365__c <= End_Date__c,
IF (End_Date__c - todayminus_365__c <= 365, End_Date__c - todayminus_365__c,
IF (End_Date__c - todayminus_365__c > 366, 365,0)))
- Gary Yantsos
- March 18, 2013
- Like
- 0
Billing System Integartion
Hi All,
My knowledge is limited for integration. I was hoping to get some answer. We have some home built billing system. We want to integrate this with SF in future. What are my options? Please answer. Not to mention there are very good integrator like Informatica, Cast-Iron but these are very costly tools. Also are there any option for exporting data from SF to billing system one way.
PLease advise
Thanks
Abhi
- AB003
- March 15, 2013
- Like
- 0
call conga composer from APEX
Does any one know how to call conga composer from APEX?
Tried to follow [http://knowledge.congasphere.com/congakb/ext/kb69-how-to-call-conga-composer-from-apex?mode=searchresults]
but I get "Your Salesforce session has expired or the Salesforce API Servers are offline. INVALID SESSION ID or SERVER URL"
Any help is greatly appreciated.
Thank you,
Manohar
- ManoharSF
- October 11, 2013
- Like
- 0
System.Today() and System.Now() in test class
How can we mockup System.Today() and System.Now() in Test class for any further logic?
Thank you,
Manohar
- ManoharSF
- October 07, 2013
- Like
- 0
Test coverage for batchable class
Hi there,
How can i get 100% coverage for this code? I get only 55% so far..
Any help is greatly appreciated.
Thank you,
Manohar
global class ISMTrackingBatchProcess implements Database.Batchable < sObject > { global Database.QueryLocator start(Database.BatchableContext ctx) { System.Debug('***** Here it starts *****'); String Query = 'Select Owner_Name__c, Contact_Name__c,CaseNumber, Owner_Email__c, Dummy_ISM_Datetime__c, TFS_ID__c, Id, ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c From Case where Dummy_ISM_Datetime__c <> Null and ISM_Priority_Set_Critical_High_At__c <> Null and TFS_ID__c <> Null and ISM_Priority__c in (\'Critical\',\'High\')' ; return Database.getQueryLocator(Query); } global void execute(Database.BatchableContext ctx, List<sObject> scope) { integer failedUpdates1; integer failedUpdates2; List<Case> cs= (List<Case>)scope; List<ISM_Communication_Tracker__c> ismcts = new List<ISM_Communication_Tracker__c>(); List<ISM_Communication_Alert__c> ismcas = new List<ISM_Communication_Alert__c>(); boolean missflg ; integer missflg10; if (cs.size()>0) { for(Integer i = 0; i < cs.size(); i++){ if (cs[i].ISM_Priority__c == 'Critical' ) { // Send Email ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j++){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30) and Subject in ('Call','Email') limit 1]; if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Created_Date_and_Time__c = System.now() , Case_Owner_Email__c =cs[i].Owner_Email__c, ISM_Priority__c =cs[i].ISM_Priority__c, Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30)), Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30), of_Emails__c = j)); } } ////Test not covered until here // Create ISM Communication Logs integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < hrincr; j++){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + string.valueof(j) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } ////Test not covered until here Else if (cs[i].ISM_Priority__c == 'High' ) { // Send Email ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j=j+4){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(150) and Subject in ('Call','Email') limit 1]; if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Created_Date_and_Time__c = System.now() , Case_Owner_Email__c =cs[i].Owner_Email__c, ISM_Priority__c =cs[i].ISM_Priority__c, Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(150)), Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210), of_Emails__c = j)); } } ////Test not covered until here //Create ISM Communication Tracking Log integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 3; j < hrincr; j=j+4){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + + string.valueof(j-3) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } } failedUpdates1 = 0; List<Database.UpsertResult> dsrs1 = Database.upsert(ismcts, false); for(Database.UpsertResult dsr1 : dsrs1){ if(!dsr1.isSuccess()){ failedUpdates1++; ////Test not covered until here } } failedUpdates2 = 0; List<Database.UpsertResult> dsrs2 = Database.upsert(ismcas, false); for(Database.UpsertResult dsr2 : dsrs2){ if(!dsr2.isSuccess()){ failedUpdates2++; } } } } global void finish(Database.BatchableContext ctx) { System.debug(LoggingLevel.WARN,'Batch Process Finished'); } }
My Test Class so far...
@isTest private class testscheduleCriticalISM{ public static testMethod void testscheduleISMTrackingBatchProcess() { Test.startTest(); scheduleISMTrackingBatchProcess s = new scheduleISMTrackingBatchProcess(); string sch = '0 0 * * 1-12 ? *'; system.schedule('Process Trans 1', sch, s); Test.stopTest(); } public static testMethod void testISMTrackingBatchProcess() { //get the initial details Profile pf = [Select Id from Profile where Name = 'System Administrator']; //creating RunAs User Record User u = new User(); u.FirstName = 'Test'; u.LastName = 'user'; u.Email = 'testuser@test123456789.com'; u.CompanyName = 'test.com'; u.Title = 'Test user'; u.Username = 'testuser@test123456789.com'; u.Alias = 'testuser'; u.CommunityNickname = 'Test User'; u.TimeZoneSidKey = 'America/Chicago'; u.LocaleSidKey = 'en_US'; u.EmailEncodingKey = 'ISO-8859-1'; u.ProfileId = pf.Id; u.LanguageLocaleKey = 'en_US'; insert u; // Datetime dToday = datetime.newInstance(MySystem.SetToday().year(), MySystem.SetToday().month(),MySystem.SetToday().day()); Datetime origDate = DateTime.valueOf('2013-01-01 0:0:0'); Datetime nowDatetime = DateTime.valueOf('2013-01-01 12:0:0'); String ISM_Priority; List <Case> kases = new List<Case>(); for(integer i = 0; i<200; i++){ if (i < 100) { ISM_Priority = 'Critical';} else { ISM_Priority = 'High';} Case c = new Case(Subject='testCase'+'i', Ownerid = u.ID, Status = 'Open', Origin = 'Other', TFS_ID__c = i, ISM_Priority_Set_Critical_High_At__c = origDate, Dummy_ISM_Datetime__c = origDate.addMinutes(-30), ISM_Priority__c = ISM_Priority ); kases.add(c); } insert kases; task[] t =[select id from task where Subject in ('Call','Email') ]; integer hrincr = (Math.Floor(decimal.valueOf(nowDatetime.getTime() - origDate.getTime() )) / (1000.0*60.0*60.0)).intValue(); integer dmincr = (Math.Floor(decimal.valueOf(nowDatetime.getTime() - origDate.addMinutes(-30).getTime() )) / (1000.0*60.0*60.0)).intValue(); Test.startTest(); ISMTrackingBatchProcess b = new ISMTrackingBatchProcess(); ID myBatchJobID = database.executebatch(b); if (t.size() ==0 && hrincr > 4) { System.AssertEquals(database.countquery('SELECT COUNT() FROM ISM_Communication_Alert__c WHERE ISM_Priority__c =\'Critical\''), 0); } if (t.size() ==0 && hrincr > 4) { System.AssertEquals(database.countquery('SELECT COUNT() FROM ISM_Communication_Tracker__c WHERE ISM_Priority__c =\'Critical\' and Missed_Communication__c = true'), 0); } Test.stopTest(); } }
- ManoharSF
- October 07, 2013
- Like
- 0
Rest API delay response
Hi there,
How can I delay the response for an REST API Request?
Thanks
Manohar
- ManoharSF
- September 30, 2013
- Like
- 0
Apex syntax
Hi ther,
need help in getting the syntax right for the class.
public class class1{ public class Result1 { public Decimal a1{get;set;} public Decimal b1{get;set;} public Decimal c1{get;set;} public Decimal d1{get;set;} } public Result1 method1 (id recId ) { ... some logic... ...... Result1 r1 = New Result1(); r1.a1 = some value; r1.b1 = some value; r1.c1 = some value; return r1; } } global class class2{ global class Result2 { public Decimal a2{get;set;} public Decimal b2{get;set;} public Decimal c2{get;set;} public Decimal d2{get;set;} } global Result2 method(){ ... some logic... ...... Result2 r2 = New Result2(); class1 c1 = new class1(); **r2 = c1.method1(rid);** <-- How can I get the result1 from method1 and parse it and assign it to each variable in r2? like r2.a2 = c1.method1(rid).a1; like r2.b2 = c1.method1(rid).b1; like r2.c2 = c1.method1(rid).c1; } }
any help is greatly appreciated.
Thanks,
Manohar
- ManoharSF
- September 27, 2013
- Like
- 0
batchable and schedulable class
Hi there,
Can someone let me know whats missing in this batchable and schedulable class as its not firing off as it suppose to? but it fires off fine if I call execute method directly.
Any help is greatly appreciated.
Thanks
Manohar
Batchable class
global class ISMTrackingBatchProcess implements Database.Batchable < sObject > { Double failedUpdates1{get; set;} Double failedUpdates2{get; set;} global Database.QueryLocator start(Database.BatchableContext ctx) { System.Debug('***** Here it starts *****'); String Query = 'Select Owner_Name__c, Contact_Name__c,CaseNumber, Owner_Email__c, Dummy_ISM_Datetime__c, TFS_ID__c, Id, ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c From Case where Dummy_ISM_Datetime__c <> Null and ISM_Priority_Set_Critical_High_At__c <> Null and TFS_ID__c <> Null and ISM_Priority__c in (\'Critical\',\'High\')' ; return Database.getQueryLocator(Query); } global void execute(Database.BatchableContext ctx, List <sObject> scope) { List<Case> cs= (List<Case>)scope; List<ISM_Communication_Tracker__c> ismcts = new List<ISM_Communication_Tracker__c>(); List<ISM_Communication_Alert__c> ismcas = new List<ISM_Communication_Alert__c>(); boolean missflg =Null ; integer missflg10; if (cs.size()>1) { for(Integer i = 0; i < cs.size(); i++){ if (cs[i].ISM_Priority__c == 'Critical' ) { // Create records in temp table to Send ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j++){ //i know this is
task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30) and Subject in ('Call','Email') limit 1]; System.Debug('***** CriticalEmailStartDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) ); System.Debug('***** CriticalEmailEndDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30) ); if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30)),Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30), of_Emails__c = j)); /* List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>(); List<String> toAddresses = new List<String>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); toAddresses.add(cs[i].Owner_Email__c); System.Debug('***** CriticaltoAddresses *****' +i+'***'+j+'**:'+ cs[i].Owner_Email__c ); mail.setToAddresses(toAddresses); mail.setSubject('WARNING communication deadline approaching on ' + cs[i].ISM_Priority__c +'ISM Priority Case ' + cs[i].CaseNumber); String messageBody = '<html><body>Body: Dear ' + cs[i].Owner_Name__c + ',<br><br> Your mandatory customer contact time is approaching for case number '+ cs[i].CaseNumber +', ISM number XXXXX?. <br><br> Please initiate contact with the customer, '+ cs[i].Contact_Name__c + ', regarding an update on the status of their case and document your discussion in Salesforce. <br><br> https://cs18.salesforce.com/' +cs[i].Id; mail.setHtmlBody(messageBody); mailList.add(mail); Messaging.sendEmail(mailList); */ } } // Create ISM Communication Logs integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < hrincr; j++){ System.Debug('***** CaseId *****' +i+'***'+j+'**:'+ cs[i].id ); System.Debug('***** first hr *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)); System.Debug('***** second hr *****' +i+'***'+j+1+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1)); task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } System.Debug('***** missflg *****' +i+'***'+j+'**: '+ missflg ); ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + string.valueof(j) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } Else if (cs[i].ISM_Priority__c == 'High' ) { // Creates records in temp table to Send ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j++){ task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210) and Subject in ('Call','Email') limit 1]; System.Debug('***** CriticalEmailStartDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) ); System.Debug('***** CriticalEmailEndDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210) ); if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210)),Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210), of_Emails__c = j)); /* List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>(); List<String> toAddresses = new List<String>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); toAddresses.add(cs[i].Owner_Email__c); System.Debug('***** HightoAddresses *****' +i+'***'+j+'**:'+ cs[i].Owner_Email__c ); mail.setToAddresses(toAddresses); mail.setSubject('WARNING communication deadline approaching on ' + cs[i].ISM_Priority__c + 'ISM Priority Case ' + cs[i].CaseNumber); String messageBody = '<html><body>Body: Dear ' + cs[i].Owner_Name__c + ',<br><br> Your mandatory customer contact time is approaching for case number '+ cs[i].CaseNumber +', ISM number XXXXX?. <br><br> Please initiate contact with the customer, '+ cs[i].Contact_Name__c + ', regarding an update on the status of their case and document your discussion in Salesforce. <br><br> https://cs18.salesforce.com/' +cs[i].Id; mail.setHtmlBody(messageBody); mailList.add(mail); Messaging.sendEmail(mailList); */ } } //Create ISM Communication Tracking Log integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 3; j < hrincr; j=j+4){ System.Debug('***** CaseId *****' +i+'***'+j+'**:'+ cs[i].id ); System.Debug('***** first hr *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)); System.Debug('***** second hr *****' +i+'***'+j+1+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1)); task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } System.Debug('***** missflg *****' +i+'***'+j+'**: '+ missflg ); ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + + string.valueof(j-3) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } } failedUpdates1 = 0; List<Database.UpsertResult> dsrs1 = Database.upsert(ismcts, false); for(Database.UpsertResult dsr1 : dsrs1){ if(!dsr1.isSuccess()){ failedUpdates1++; } } failedUpdates2 = 0; List<Database.UpsertResult> dsrs2 = Database.upsert(ismcas, false); for(Database.UpsertResult dsr2 : dsrs2){ if(!dsr2.isSuccess()){ failedUpdates2++; } } } } global void finish(Database.BatchableContext ctx) { System.debug(LoggingLevel.WARN,'Batch Process Finished'); } }
Schedulable class
global class scheduleISMTrackingBatchProcess implements Schedulable { global void execute(SchedulableContext sc) { ISMTrackingBatchProcess ismt = new ISMTrackingBatchProcess(); ID myBatchJobID = database.executebatch(ismt, 1); } }
and finally invoked from
System.schedule('ScheduleISMTrackingBatchProcess0', '0 0 * * * ? *' , new scheduleISMTrackingBatchProcess());
This is how I tested to see if its working
ISMTrackingBatchProcess myBatch = new ISMTrackingBatchProcess (); myBatch.execute(NULL, [Select Owner_Name__c, Contact_Name__c,CaseNumber, Owner_Email__c, Dummy_ISM_Datetime__c, TFS_ID__c, Id, ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c From Case where Dummy_ISM_Datetime__c <> Null and ISM_Priority_Set_Critical_High_At__c <> Null and TFS_ID__c <> Null and ISM_Priority__c in ('Critical','High')]);
- ManoharSF
- September 17, 2013
- Like
- 0
Inline visualforce create record
Hi there,
Is it possible to create record through inline VF page?
thanks
Manohar
- ManoharSF
- August 23, 2013
- Like
- 0
get endpoint URL
Hi there,
How can I get the endpoint URL? I tried to use RestRequest.getendpoint() but I get "Method does not exist or incorrect signature: [RestRequest].getEndpoint()"
I am trying to use that for a router logic ie to check if the URL contain certain text then insert into some object otherwise some other object.
Any help is grealy appreciated.
Thanks
Manohar
- ManoharSF
- August 22, 2013
- Like
- 0
Visualforce email template
Hi there, can some one please let me know whats missing as I dont get the records back for my VF email template?
Any help is greatly apreciated.
Thanks
Manohar
<messaging:emailTemplate subject="Deign Package Rejected Reasons" recipientType="Contact" relatedToType="Construction_Package__c"> <messaging:htmlEmailBody > <c:rejectedlist CotId="{!relatedTo.Id}" /><br/><br/> </messaging:htmlEmailBody> </messaging:emailTemplate>
componentt name :rejectedlist
<apex:component controller="rejectedlist" access="global"> <apex:attribute name="CotId" type="Id" description="Id of the Construction Package" assignTo="{!conID}"/> <table border = "2" cellspacing = "5"> <tr> <td>Name</td> <td>Rejection Reason</td> <td>Suggested Resolution</td> <td>Status</td> </tr> <apex:repeat value="{!rejectedlist}" var="rl"> <tr> <td>{!rl.Name}</td> <td>{!rl.Rejection_Reason__c}</td> <td>{!rl.Suggested_Resolution__c}</td> <td>{!rl.Status__c}</td> </tr> </apex:repeat> </table> </apex:component>
public with sharing class rejectedlist { public Id conID {get;set;} public List<Rejection_Checklist__c > getrejectedlist () { list <Rejection_Checklist__c> rejlst; rejlst = [Select id, Name, Rejection_Reason__c, Suggested_Resolution__c, Status__c from Rejection_Checklist__c where Construction_Package_ID__c = :conID AND (Status__c = 'Rejected' OR Status__c = 'Not Resolved')]; return rejlst ; } }
- ManoharSF
- August 19, 2013
- Like
- 0
Salesforce to Salesforce & Trigger
Hi there,
Background - I have S2S setup to transfer external org records into ours. I am trying to pull detail object record in Master Detail relationship, since it doesnt accept the Id of the master I am getting that in a text field. but before inserting I have 'before insert' trigger that I am trying to use to grab the Master object record Id, and stamp it on the master Id field. but looks like my trigger is not firing , its complaining on the master field saying "Error: You must enter a value". I can understand that Master field is required on Detail object for Master Detail Relationship. wouldnt expect it would fire before the trigger.
Am I missing anything or any other way I can achive it?
trigger createS2SLeadSolarArray on String_Array__c (before insert) { for (String_Array__c sa: Trigger.new) {
// I tried commenting out the If statement as well if (sa.Source__c == 'S2S'){
//query for master record Solar_System__c ssg = [SELECT Lead__c, Id FROM Solar_System__c WHERE Source_Solar__c = :sa.Solar_System_Text__c limit 1]; sa.Solar_System__c = ssg.Id;
// tried hardcoding the id value // sa.Solar_System__c = 'a1oK0000000bNi9IAE'; } } }
Thanks
Manohar
- ManoharSF
- July 10, 2013
- Like
- 0
Too many SOQL queries: 101
Hi there,
what can be changed in this to avoid 'Too many SOQL queries: 101' issue?
thanks
Manohar
trigger UpdateApprovalPercentForRest on Opportunity (after delete, after undelete, after update) { List<Opportunity> buildsToUpdate = new List<Opportunity>{}; for( Opportunity parent: Trigger.new) { List<Opportunity> restBuildswiththePartner =[SELECT Partner_Cap_Reached__c , Build_Partner__c,Construction_Approval_Payment__c, StageName,Substantial_Completion_Payment__c FROM Opportunity WHERE Build_Partner_ID__c = :parent.Build_Partner_ID__c AND StageName NOT IN ('Construction Approved', 'Substantial Completion Pending Approval', 'Substantial Completion', 'Final Completion Pending Approval', 'Final Completion', 'Cancelled - Customer', 'Cancelled - SCF') ]; for(Opportunity o : restBuildswiththePartner){ if (o.Partner_Cap_Reached__c == true && (o.Construction_Approval_Payment__c != 0.00 && o.Substantial_Completion_Payment__c != 0.80 ) && (o.StageName != 'Construction Approved' && o.StageName != 'Substantial Completion Pending Approval' && o.StageName != 'Substantial Completion' && o.StageName != 'Final Completion Pending Approval' && o.StageName != 'Final Completion' && o.StageName != 'Cancelled - Customer' && o.StageName != 'Cancelled - SCF')) { o.Construction_Approval_Payment__c = 0.00; o.Substantial_Completion_Payment__c = 0.80; o.Final_Completion_Payment__c = 0.20; buildsToUpdate.add(o); } if (o.Partner_Cap_Reached__c == false && (o.Construction_Approval_Payment__c != 0.40 && o.Substantial_Completion_Payment__c != 0.40 ) && (o.StageName != 'Construction Approved' && o.StageName != 'Substantial Completion Pending Approval' && o.StageName != 'Substantial Completion' && o.StageName != 'Final Completion Pending Approval' && o.StageName != 'Final Completion' && o.StageName != 'Cancelled - Customer' && o.StageName != 'Cancelled - SCF')) { o.Construction_Approval_Payment__c = 0.40; o.Substantial_Completion_Payment__c = 0.40; o.Final_Completion_Payment__c = 0.20; buildsToUpdate.add(o); } } if (!buildsToUpdate.isEmpty()){ update buildsToUpdate; } } }
- ManoharSF
- July 01, 2013
- Like
- 0
mass email & cc
Hi there,
Any way we can include CC when we are trying to implement MAss Email using MassEmailMessage in Apex? if not how can achieve it in any other way?
My requirement is send email to some contacts using particular email template, attachment and need CC the Account owner of the Account that the contact is tied to.
Any help is greatly appreciated.
Thanks
MAnohar
- ManoharSF
- March 23, 2013
- Like
- 0
enterprise wsdl & attachments
Hi,
we are building a integration between a portal and SF using SOAP API and using Enterprise wsdl for that.
1. Does Enterprise wsdl supports attachments?
2. Can we upload attachments through the SOAP API that could be attached to standard object in SF?
Any help is greatly apprecaiated.
Thanks
Manohar
- ManoharSF
- March 20, 2013
- Like
- 0
Adding multiple attachment using C#
Hi there,
Has any one got experience or know how to add multiple attachments to an object using C#? if yes, please help.
Thanks
Manohar
- ManoharSF
- March 19, 2013
- Like
- 0
convert file to base64Binary in C#
Hi there,
Has anyone encoded a file into base64binary in C#? I have requirement to attach a file to leads through a external site.
Has anyone got experience in this, if so can you please share?
Thanks
Manohar
- ManoharSF
- March 17, 2013
- Like
- 0
convert file to base64Binary in C#
Hi there,
Has anyone encoded a file into base64binary in C#? I have requirement to attach a file to leads through a external site.
Has anyone got experience in this, if so can you please share?
Thanks
Manohar
- ManoharSF
- March 16, 2013
- Like
- 0
System.Today() and System.Now() in test class
How can we mockup System.Today() and System.Now() in Test class for any further logic?
Thank you,
Manohar
- ManoharSF
- October 07, 2013
- Like
- 0
Test coverage for batchable class
Hi there,
How can i get 100% coverage for this code? I get only 55% so far..
Any help is greatly appreciated.
Thank you,
Manohar
global class ISMTrackingBatchProcess implements Database.Batchable < sObject > { global Database.QueryLocator start(Database.BatchableContext ctx) { System.Debug('***** Here it starts *****'); String Query = 'Select Owner_Name__c, Contact_Name__c,CaseNumber, Owner_Email__c, Dummy_ISM_Datetime__c, TFS_ID__c, Id, ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c From Case where Dummy_ISM_Datetime__c <> Null and ISM_Priority_Set_Critical_High_At__c <> Null and TFS_ID__c <> Null and ISM_Priority__c in (\'Critical\',\'High\')' ; return Database.getQueryLocator(Query); } global void execute(Database.BatchableContext ctx, List<sObject> scope) { integer failedUpdates1; integer failedUpdates2; List<Case> cs= (List<Case>)scope; List<ISM_Communication_Tracker__c> ismcts = new List<ISM_Communication_Tracker__c>(); List<ISM_Communication_Alert__c> ismcas = new List<ISM_Communication_Alert__c>(); boolean missflg ; integer missflg10; if (cs.size()>0) { for(Integer i = 0; i < cs.size(); i++){ if (cs[i].ISM_Priority__c == 'Critical' ) { // Send Email ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j++){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30) and Subject in ('Call','Email') limit 1]; if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Created_Date_and_Time__c = System.now() , Case_Owner_Email__c =cs[i].Owner_Email__c, ISM_Priority__c =cs[i].ISM_Priority__c, Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30)), Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30), of_Emails__c = j)); } } ////Test not covered until here // Create ISM Communication Logs integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < hrincr; j++){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + string.valueof(j) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } ////Test not covered until here Else if (cs[i].ISM_Priority__c == 'High' ) { // Send Email ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j=j+4){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(150) and Subject in ('Call','Email') limit 1]; if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Created_Date_and_Time__c = System.now() , Case_Owner_Email__c =cs[i].Owner_Email__c, ISM_Priority__c =cs[i].ISM_Priority__c, Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(150)), Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210), of_Emails__c = j)); } } ////Test not covered until here //Create ISM Communication Tracking Log integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 3; j < hrincr; j=j+4){ //Test not covered from here onwards task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + + string.valueof(j-3) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } } failedUpdates1 = 0; List<Database.UpsertResult> dsrs1 = Database.upsert(ismcts, false); for(Database.UpsertResult dsr1 : dsrs1){ if(!dsr1.isSuccess()){ failedUpdates1++; ////Test not covered until here } } failedUpdates2 = 0; List<Database.UpsertResult> dsrs2 = Database.upsert(ismcas, false); for(Database.UpsertResult dsr2 : dsrs2){ if(!dsr2.isSuccess()){ failedUpdates2++; } } } } global void finish(Database.BatchableContext ctx) { System.debug(LoggingLevel.WARN,'Batch Process Finished'); } }
My Test Class so far...
@isTest private class testscheduleCriticalISM{ public static testMethod void testscheduleISMTrackingBatchProcess() { Test.startTest(); scheduleISMTrackingBatchProcess s = new scheduleISMTrackingBatchProcess(); string sch = '0 0 * * 1-12 ? *'; system.schedule('Process Trans 1', sch, s); Test.stopTest(); } public static testMethod void testISMTrackingBatchProcess() { //get the initial details Profile pf = [Select Id from Profile where Name = 'System Administrator']; //creating RunAs User Record User u = new User(); u.FirstName = 'Test'; u.LastName = 'user'; u.Email = 'testuser@test123456789.com'; u.CompanyName = 'test.com'; u.Title = 'Test user'; u.Username = 'testuser@test123456789.com'; u.Alias = 'testuser'; u.CommunityNickname = 'Test User'; u.TimeZoneSidKey = 'America/Chicago'; u.LocaleSidKey = 'en_US'; u.EmailEncodingKey = 'ISO-8859-1'; u.ProfileId = pf.Id; u.LanguageLocaleKey = 'en_US'; insert u; // Datetime dToday = datetime.newInstance(MySystem.SetToday().year(), MySystem.SetToday().month(),MySystem.SetToday().day()); Datetime origDate = DateTime.valueOf('2013-01-01 0:0:0'); Datetime nowDatetime = DateTime.valueOf('2013-01-01 12:0:0'); String ISM_Priority; List <Case> kases = new List<Case>(); for(integer i = 0; i<200; i++){ if (i < 100) { ISM_Priority = 'Critical';} else { ISM_Priority = 'High';} Case c = new Case(Subject='testCase'+'i', Ownerid = u.ID, Status = 'Open', Origin = 'Other', TFS_ID__c = i, ISM_Priority_Set_Critical_High_At__c = origDate, Dummy_ISM_Datetime__c = origDate.addMinutes(-30), ISM_Priority__c = ISM_Priority ); kases.add(c); } insert kases; task[] t =[select id from task where Subject in ('Call','Email') ]; integer hrincr = (Math.Floor(decimal.valueOf(nowDatetime.getTime() - origDate.getTime() )) / (1000.0*60.0*60.0)).intValue(); integer dmincr = (Math.Floor(decimal.valueOf(nowDatetime.getTime() - origDate.addMinutes(-30).getTime() )) / (1000.0*60.0*60.0)).intValue(); Test.startTest(); ISMTrackingBatchProcess b = new ISMTrackingBatchProcess(); ID myBatchJobID = database.executebatch(b); if (t.size() ==0 && hrincr > 4) { System.AssertEquals(database.countquery('SELECT COUNT() FROM ISM_Communication_Alert__c WHERE ISM_Priority__c =\'Critical\''), 0); } if (t.size() ==0 && hrincr > 4) { System.AssertEquals(database.countquery('SELECT COUNT() FROM ISM_Communication_Tracker__c WHERE ISM_Priority__c =\'Critical\' and Missed_Communication__c = true'), 0); } Test.stopTest(); } }
- ManoharSF
- October 07, 2013
- Like
- 0
Rest API delay response
Hi there,
How can I delay the response for an REST API Request?
Thanks
Manohar
- ManoharSF
- September 30, 2013
- Like
- 0
Apex syntax
Hi ther,
need help in getting the syntax right for the class.
public class class1{ public class Result1 { public Decimal a1{get;set;} public Decimal b1{get;set;} public Decimal c1{get;set;} public Decimal d1{get;set;} } public Result1 method1 (id recId ) { ... some logic... ...... Result1 r1 = New Result1(); r1.a1 = some value; r1.b1 = some value; r1.c1 = some value; return r1; } } global class class2{ global class Result2 { public Decimal a2{get;set;} public Decimal b2{get;set;} public Decimal c2{get;set;} public Decimal d2{get;set;} } global Result2 method(){ ... some logic... ...... Result2 r2 = New Result2(); class1 c1 = new class1(); **r2 = c1.method1(rid);** <-- How can I get the result1 from method1 and parse it and assign it to each variable in r2? like r2.a2 = c1.method1(rid).a1; like r2.b2 = c1.method1(rid).b1; like r2.c2 = c1.method1(rid).c1; } }
any help is greatly appreciated.
Thanks,
Manohar
- ManoharSF
- September 27, 2013
- Like
- 0
batchable and schedulable class
Hi there,
Can someone let me know whats missing in this batchable and schedulable class as its not firing off as it suppose to? but it fires off fine if I call execute method directly.
Any help is greatly appreciated.
Thanks
Manohar
Batchable class
global class ISMTrackingBatchProcess implements Database.Batchable < sObject > { Double failedUpdates1{get; set;} Double failedUpdates2{get; set;} global Database.QueryLocator start(Database.BatchableContext ctx) { System.Debug('***** Here it starts *****'); String Query = 'Select Owner_Name__c, Contact_Name__c,CaseNumber, Owner_Email__c, Dummy_ISM_Datetime__c, TFS_ID__c, Id, ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c From Case where Dummy_ISM_Datetime__c <> Null and ISM_Priority_Set_Critical_High_At__c <> Null and TFS_ID__c <> Null and ISM_Priority__c in (\'Critical\',\'High\')' ; return Database.getQueryLocator(Query); } global void execute(Database.BatchableContext ctx, List <sObject> scope) { List<Case> cs= (List<Case>)scope; List<ISM_Communication_Tracker__c> ismcts = new List<ISM_Communication_Tracker__c>(); List<ISM_Communication_Alert__c> ismcas = new List<ISM_Communication_Alert__c>(); boolean missflg =Null ; integer missflg10; if (cs.size()>1) { for(Integer i = 0; i < cs.size(); i++){ if (cs[i].ISM_Priority__c == 'Critical' ) { // Create records in temp table to Send ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j++){ //i know this is
task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30) and Subject in ('Call','Email') limit 1]; System.Debug('***** CriticalEmailStartDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) ); System.Debug('***** CriticalEmailEndDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30) ); if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30)),Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(30), of_Emails__c = j)); /* List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>(); List<String> toAddresses = new List<String>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); toAddresses.add(cs[i].Owner_Email__c); System.Debug('***** CriticaltoAddresses *****' +i+'***'+j+'**:'+ cs[i].Owner_Email__c ); mail.setToAddresses(toAddresses); mail.setSubject('WARNING communication deadline approaching on ' + cs[i].ISM_Priority__c +'ISM Priority Case ' + cs[i].CaseNumber); String messageBody = '<html><body>Body: Dear ' + cs[i].Owner_Name__c + ',<br><br> Your mandatory customer contact time is approaching for case number '+ cs[i].CaseNumber +', ISM number XXXXX?. <br><br> Please initiate contact with the customer, '+ cs[i].Contact_Name__c + ', regarding an update on the status of their case and document your discussion in Salesforce. <br><br> https://cs18.salesforce.com/' +cs[i].Id; mail.setHtmlBody(messageBody); mailList.add(mail); Messaging.sendEmail(mailList); */ } } // Create ISM Communication Logs integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < hrincr; j++){ System.Debug('***** CaseId *****' +i+'***'+j+'**:'+ cs[i].id ); System.Debug('***** first hr *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)); System.Debug('***** second hr *****' +i+'***'+j+1+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1)); task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } System.Debug('***** missflg *****' +i+'***'+j+'**: '+ missflg ); ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + string.valueof(j) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } Else if (cs[i].ISM_Priority__c == 'High' ) { // Creates records in temp table to Send ISM Alert Emails integer dmincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].Dummy_ISM_Datetime__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 0; j < dmincr; j++){ task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210) and Subject in ('Call','Email') limit 1]; System.Debug('***** CriticalEmailStartDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j) ); System.Debug('***** CriticalEmailEndDate *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210) ); if (t.size() == 0 ) { ismcas.add(new ISM_Communication_Alert__c(Unique_index__c =cs[i].CaseNumber +string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210)),Case__c = cs[i].id, Log_start_at__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j), Log_End_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j).addMinutes(210), of_Emails__c = j)); /* List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>(); List<String> toAddresses = new List<String>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); toAddresses.add(cs[i].Owner_Email__c); System.Debug('***** HightoAddresses *****' +i+'***'+j+'**:'+ cs[i].Owner_Email__c ); mail.setToAddresses(toAddresses); mail.setSubject('WARNING communication deadline approaching on ' + cs[i].ISM_Priority__c + 'ISM Priority Case ' + cs[i].CaseNumber); String messageBody = '<html><body>Body: Dear ' + cs[i].Owner_Name__c + ',<br><br> Your mandatory customer contact time is approaching for case number '+ cs[i].CaseNumber +', ISM number XXXXX?. <br><br> Please initiate contact with the customer, '+ cs[i].Contact_Name__c + ', regarding an update on the status of their case and document your discussion in Salesforce. <br><br> https://cs18.salesforce.com/' +cs[i].Id; mail.setHtmlBody(messageBody); mailList.add(mail); Messaging.sendEmail(mailList); */ } } //Create ISM Communication Tracking Log integer hrincr = (Math.Floor(decimal.valueOf(Datetime.now().getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0)).intValue(); for (integer j = 3; j < hrincr; j=j+4){ System.Debug('***** CaseId *****' +i+'***'+j+'**:'+ cs[i].id ); System.Debug('***** first hr *****' +i+'***'+j+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j)); System.Debug('***** second hr *****' +i+'***'+j+1+'**:'+ cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1)); task[] t =[select id from task where whatId = :cs[i].id and createddate >= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3) and createddate <= :cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1) and Subject in ('Call','Email') limit 1]; if (t.size() > 0 ) { missflg = false; missflg10 = 0; } else { missflg = true; missflg10 = 1; } System.Debug('***** missflg *****' +i+'***'+j+'**: '+ missflg ); ismcts.add(new ISM_Communication_Tracker__c(Case__c = cs[i].id, Missed_Communication__c = missflg, Missed_Communication1_0__c = missflg10, Log_Start_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j-3), PrimaryKey__c = string.valueOf(cs[i].id) + string.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c) + cs[i].ISM_Priority__c + + string.valueof(j-3) , ISM_Priority__c = cs[i].ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c, Logged_At__c = cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1), of_hrs_since_ISM_Priority_Chnaged__c =Math.Floor(Decimal.valueOf(cs[i].ISM_Priority_Set_Critical_High_At__c.addhours(j+1).getTime() - cs[i].ISM_Priority_Set_Critical_High_At__c.getTime() )) / (1000.0*60.0*60.0) )); } } } failedUpdates1 = 0; List<Database.UpsertResult> dsrs1 = Database.upsert(ismcts, false); for(Database.UpsertResult dsr1 : dsrs1){ if(!dsr1.isSuccess()){ failedUpdates1++; } } failedUpdates2 = 0; List<Database.UpsertResult> dsrs2 = Database.upsert(ismcas, false); for(Database.UpsertResult dsr2 : dsrs2){ if(!dsr2.isSuccess()){ failedUpdates2++; } } } } global void finish(Database.BatchableContext ctx) { System.debug(LoggingLevel.WARN,'Batch Process Finished'); } }
Schedulable class
global class scheduleISMTrackingBatchProcess implements Schedulable { global void execute(SchedulableContext sc) { ISMTrackingBatchProcess ismt = new ISMTrackingBatchProcess(); ID myBatchJobID = database.executebatch(ismt, 1); } }
and finally invoked from
System.schedule('ScheduleISMTrackingBatchProcess0', '0 0 * * * ? *' , new scheduleISMTrackingBatchProcess());
This is how I tested to see if its working
ISMTrackingBatchProcess myBatch = new ISMTrackingBatchProcess (); myBatch.execute(NULL, [Select Owner_Name__c, Contact_Name__c,CaseNumber, Owner_Email__c, Dummy_ISM_Datetime__c, TFS_ID__c, Id, ISM_Priority__c, ISM_Priority_Set_Critical_High_At__c From Case where Dummy_ISM_Datetime__c <> Null and ISM_Priority_Set_Critical_High_At__c <> Null and TFS_ID__c <> Null and ISM_Priority__c in ('Critical','High')]);
- ManoharSF
- September 17, 2013
- Like
- 0
get endpoint URL
Hi there,
How can I get the endpoint URL? I tried to use RestRequest.getendpoint() but I get "Method does not exist or incorrect signature: [RestRequest].getEndpoint()"
I am trying to use that for a router logic ie to check if the URL contain certain text then insert into some object otherwise some other object.
Any help is grealy appreciated.
Thanks
Manohar
- ManoharSF
- August 22, 2013
- Like
- 0
on insert wants to copy values from previous record
Hi guys,
I need opinion on how I can achieve the required functionality.
I have a custom object A that stores user progress details every month. When a new record is added next month I want to copy user’s previous month’s scorer to newly added record. I nut shall I want to have users previous month’s score into the current month record in custom field.
Am I right to think that I need before insert trigger to achieve it. But don’t know how I can save previous month’s score in the trigger temporarily and then added to new record. Any help?
Thanks,
- ArrgHunter
- August 20, 2013
- Like
- 0
Simple apex trigger update query
Hi,
I have an established piece of code. What it is doing is writing, on save, from one record (week__c) in an object, and creating/updating a series of records in another one (PCM_Time_Record__c).
The only bugbear is that it is writing the other records as whoever is triggering the Apex. I need it to assign the written records as the owner of the source.
The code looks like this:
List<PCM_Time_Record__c> insertBlocks = new List<PCM_Time_Record__c> {new PCM_Time_Record__c(Time_Block_Name__c='Monday AM1', Type__c=week.Monday_AM1__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25),
As you can see, it is doing a simple create.
I assumed it was as simple as adding another clause to the bracket that said OwnerID = week__c.OwnerID, but that is throwing up an "Expect ID error".
Here is the full trigger in case anyone needs it:
trigger createTimeBlocks on Week__c (after insert, after update) { //hours in the day, split into quarters decimal hours = 7.5/4; String recordTypeId = [Select Id from RecordType where Name = 'Time Block' and SobjectType = 'PCM_Time_Record__c' limit 1].id; PCM_Time_Record__c timeBlock; for (Week__c week : Trigger.new) { //For each week record being saved if(Trigger.isUpdate) { //If the Week record has been saved previously, then check for existing timeBlocks. These should also exist. List<PCM_Time_Record__c> timeBlocks = [select id from PCM_Time_Record__c where Weekly_Time__c = :week.Id]; if(!timeBlocks.isEmpty()) { delete timeBlocks; } } //Create timeblocks. List<PCM_Time_Record__c> insertBlocks = new List<PCM_Time_Record__c> {new PCM_Time_Record__c(Time_Block_Name__c='Monday AM1', Type__c=week.Monday_AM1__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Monday AM2', Type__c=week.Monday_AM2__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Monday PM1', Type__c=week.Monday_AM2__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Monday PM2', Type__c=week.Monday_AM2__c, Date__c=week.Week_Commencing__c, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Tuesday AM1', Type__c=week.Tuesday_AM1__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Tuesday AM2', Type__c=week.Tuesday_AM2__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Tuesday PM1', Type__c=week.Tuesday_PM1__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Tuesday PM2', Type__c=week.Tuesday_PM2__c, Date__c=week.Week_Commencing__c+1, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Wednesday AM1', Type__c=week.Wednesday_AM1__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Wednesday AM2', Type__c=week.Wednesday_AM2__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Wednesday PM1', Type__c=week.Wednesday_PM1__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Wednesday PM2', Type__c=week.Wednesday_PM2__c, Date__c=week.Week_Commencing__c+2, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Thursday AM1', Type__c=week.Thursday_AM1__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Thursday AM2', Type__c=week.Thursday_AM2__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Thursday PM1', Type__c=week.Thursday_PM1__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Thursday PM2', Type__c=week.Thursday_PM2__c, Date__c=week.Week_Commencing__c+3, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Friday AM1', Type__c=week.Friday_AM1__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Friday AM2', Type__c=week.Friday_AM2__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Friday PM1', Type__c=week.Friday_PM1__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Friday PM2', Type__c=week.Friday_PM2__c, Date__c=week.Week_Commencing__c+4, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Saturday AM1', Type__c=week.Saturday_AM1__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Saturday AM2', Type__c=week.Saturday_AM2__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Saturday PM1', Type__c=week.Saturday_PM1__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Saturday PM2', Type__c=week.Saturday_PM2__c, Date__c=week.Week_Commencing__c+5, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Sunday AM1', Type__c=week.Sunday_AM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Sunday AM2', Type__c=week.Sunday_AM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Sunday PM1', Type__c=week.Sunday_AM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25), new PCM_Time_Record__c(Time_Block_Name__c='Sunday PM2', Type__c=week.Sunday_PM2__c, Date__c=week.Week_Commencing__c+6, Weekly_Time__c = week.Id,RecordTypeId=recordTypeId, Duration_hours__c=hours, Proportion_Of_Day__c=0.25) }; insert insertBlocks; } }
Thanks for any help!
- fourfourfun
- August 20, 2013
- Like
- 0
soql query
AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROM Call2_vod__c WHERE Call_Date_vod__c >= :QuarterStartDate AND Call_Date_vod__c <= :QuarterEndDate AND Account_Type__c =:accStaticRec.Account_Type__c AND Territory_vod__c = :accStaticRec.Territory__c AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' OR Call_Type_vod__c != 'Event Only' OR Call_Type_vod__c != 'Event Detail)
AND Account_vod__c IN :accIdSet
AND Activity_Type__c <> 'Staff'
GROUP BY Account_vod__c ];
AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROM Call2_vod__c WHERE Call_Date_vod__c >= :QuarterStartDate AND Call_Date_vod__c <= :QuarterEndDate AND Account_Type__c =:accStaticRec.Account_Type__c AND Territory_vod__c = :accStaticRec.Territory__c AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' AND Call_Type_vod__c != 'Event Only' AND Call_Type_vod__c != 'Event Detail')
AND Account_vod__c IN :accIdSet
AND Activity_Type__c <> 'Staff'
GROUP BY Account_vod__c ];
which query is correct.Please correct me
- kiran2000
- August 20, 2013
- Like
- 0
Visualforce email template
Hi there, can some one please let me know whats missing as I dont get the records back for my VF email template?
Any help is greatly apreciated.
Thanks
Manohar
<messaging:emailTemplate subject="Deign Package Rejected Reasons" recipientType="Contact" relatedToType="Construction_Package__c"> <messaging:htmlEmailBody > <c:rejectedlist CotId="{!relatedTo.Id}" /><br/><br/> </messaging:htmlEmailBody> </messaging:emailTemplate>
componentt name :rejectedlist
<apex:component controller="rejectedlist" access="global"> <apex:attribute name="CotId" type="Id" description="Id of the Construction Package" assignTo="{!conID}"/> <table border = "2" cellspacing = "5"> <tr> <td>Name</td> <td>Rejection Reason</td> <td>Suggested Resolution</td> <td>Status</td> </tr> <apex:repeat value="{!rejectedlist}" var="rl"> <tr> <td>{!rl.Name}</td> <td>{!rl.Rejection_Reason__c}</td> <td>{!rl.Suggested_Resolution__c}</td> <td>{!rl.Status__c}</td> </tr> </apex:repeat> </table> </apex:component>
public with sharing class rejectedlist { public Id conID {get;set;} public List<Rejection_Checklist__c > getrejectedlist () { list <Rejection_Checklist__c> rejlst; rejlst = [Select id, Name, Rejection_Reason__c, Suggested_Resolution__c, Status__c from Rejection_Checklist__c where Construction_Package_ID__c = :conID AND (Status__c = 'Rejected' OR Status__c = 'Not Resolved')]; return rejlst ; } }
- ManoharSF
- August 19, 2013
- Like
- 0
Rest API - 'No profiling information'
|[17]|MAP<String,String>.get(Object) 23:12:36.034 (34396000)|SYSTEM_METHOD_EXIT|[17]|MAP<String,String>.get(Object) 23:12:36.034 (34406000)|VARIABLE_SCOPE_BEGIN|[17]|q_fulfillment|String|false|false 23:12:36.034 (34415000)|VARIABLE_ASSIGNMENT|[17]|q_fulfillment|null 23:12:36.034 (34419000)|STATEMENT_EXECUTE|[19] 23:12:36.034 (34422000)|STATEMENT_EXECUTE|[20] 23:12:36.034 (34425000)|STATEMENT_EXECUTE|[22] 23:12:36.034 (34427000)|LIMIT_USAGE|[22]|SCRIPT_STATEMENTS|13|200000 23:12:36.034 (34433000)|HEAP_ALLOCATE|[22]|Bytes:81 23:12:36.034 (34444000)|HEAP_ALLOCATE|[22]|Bytes:4 23:12:36.034 (34455000)|HEAP_ALLOCATE|[22]|Bytes:7 23:12:36.043 (43288000)|SOQL_EXECUTE_BEGIN|[22]|Aggregations:0|select Id, Email, FirstName, LastName from Contact where Email = :tmpVar1 limit 1 23:12:36.043 (43302000)|LIMIT_USAGE|[22]|SOQL|1|100 23:12:36.043 (43306000)|LIMIT_USAGE|[22]|AGGS|0|300 23:12:36.049 (49713000)|SOQL_EXECUTE_END|[22]|Rows:1 23:12:36.049 (49730000)|LIMIT_USAGE|[22]|SOQL_ROWS|1|50000 23:12:36.049 (49745000)|HEAP_ALLOCATE|[22]|Bytes:8 23:12:36.049 (49765000)|HEAP_ALLOCATE|[22]|Bytes:103 23:12:36.049 (49937000)|HEAP_ALLOCATE|[22]|Bytes:8 23:12:36.049 (49958000)|HEAP_ALLOCATE|[22]|Bytes:33 23:12:36.050 (50034000)|HEAP_ALLOCATE|[22]|Bytes:20 23:12:36.050 (50049000)|VARIABLE_SCOPE_BEGIN|[22]|attendee|Contact|true|false 23:12:36.050 (50090000)|VARIABLE_ASSIGNMENT|[22]|attendee|{"serId":1,"value":{"Email":"hucas.m@e (13 more) ...","FirstName":"hucas","Id":"003K000000dWxT3IAK","LastName":"M"}}|0x11362c1f 23:12:36.050 (50099000)|STATEMENT_EXECUTE|[23] 23:12:36.050 (50103000)|LIMIT_USAGE|[23]|SCRIPT_STATEMENTS|14|200000 23:12:36.050 (50109000)|HEAP_ALLOCATE|[23]|Bytes:47 23:12:36.050 (50120000)|HEAP_ALLOCATE|[23]|Bytes:4 23:12:36.052 (52617000)|SOQL_EXECUTE_BEGIN|[23]|Aggregations:0|select Id from User where Id = :tmpVar1 limit 1 23:12:36.052 (52630000)|LIMIT_USAGE|[23]|SOQL|2|100 23:12:36.052 (52635000)|LIMIT_USAGE|[23]|AGGS|0|300 23:12:36.054 (54488000)|SOQL_EXECUTE_END|[23]|Rows:0 23:12:36.054 (54504000)|LIMIT_USAGE|[23]|SOQL_ROWS|1|50000 23:12:36.054 (54516000)|HEAP_ALLOCATE|[23]|Bytes:4 23:12:36.054 (54526000)|HEAP_ALLOCATE|[23]|Bytes:0 23:12:36.054 (54604000)|HEAP_ALLOCATE|[23]|Bytes:4 23:12:36.054 (54617000)|HEAP_ALLOCATE|[23]|Bytes:30 23:12:36.054 (54708000)|HEAP_ALLOCATE|[23]|Bytes:46 23:12:36.054 (54745000)|VARIABLE_SCOPE_BEGIN|[56]|e|Exception|true|false 23:12:36.055 (55004000)|VARIABLE_ASSIGNMENT|[56]|e|"common.apex.runtime.impl.ExecutionException: List has no rows for assignment to SObject"|0x2e5f1556 23:12:36.055 (55017000)|STATEMENT_EXECUTE|[56] 23:12:36.055 (55021000)|STATEMENT_EXECUTE|[57] 23:12:36.055 (55024000)|LIMIT_USAGE|[57]|SCRIPT_STATEMENTS|15|200000 23:12:36.055 (55031000)|HEAP_ALLOCATE|[57]|Bytes:5 23:12:36.664 (56368000)|CUMULATIVE_LIMIT_USAGE 23:12:36.664|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 2 out of 100 Number of query rows: 1 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Number of code statements: 15 out of 200000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 10 Number of Email Invocations: 0 out of 10 Number of fields describes: 0 out of 100 Number of record type describes: 0 out of 100 Number of child relationships describes: 0 out of 100 Number of picklist describes: 0 out of 100 Number of future calls: 0 out of 10 23:12:36.664|TOTAL_EMAIL_RECIPIENTS_QUEUED|0 23:12:36.664|STATIC_VARIABLE_LIST| double:MIN_NORMAL:0 double:POSITIVE_INFINITY:0 long:serialVersionUID:0 Boolean:TRUE:0 double:MIN_VALUE:0 int:SIZE:0 int[]:sizeTable:0 char[]:DigitOnes:0 char[]:DigitTens:0 double:NaN:0 String:_sfdcAdditionalTypeInfo:0 String:_sfdcAdditionalCodeLocations:0 String:_sfdcAdditionalTypeInfo:0 String:_sfdcAdditionalTypeInfo:0 double:NEGATIVE_INFINITY:0 int:MIN_VALUE:0 int:SIZE:0 String:_sfdcAdditionalCodeLocations:0 String:_sfdcAdditionalCodeLocations:0 double:MAX_VALUE:0 long:serialVersionUID:0 int:MAX_EXPONENT:0 int:MIN_EXPONENT:0 String:_sfdcAdditionalCodeLocations:0 Boolean:FALSE:0 int:MAX_VALUE:0 char[]:digits:0 long:serialVersionUID:0 23:12:36.664|CUMULATIVE_LIMIT_USAGE_END 23:12:36.670|CUMULATIVE_PROFILING_BEGIN 23:12:36.670|CUMULATIVE_PROFILING|SOQL operations| Class.TTradeService.doGet: line 22, column 1: [ SELECT Id, Email, FirstName, LastName FROM Contact WHERE Email = :attendee_email LIMIT 1]: executed 1 time in 15 ms Class.TTradeService.doGet: line 23, column 1: [SELECT Id FROM User WHERE Id = :customField1 LIMIT 1]: executed 1 time in 4 ms 23:12:36.670|CUMULATIVE_PROFILING|No profiling information for SOSL operations 23:12:36.670|CUMULATIVE_PROFILING|No profiling information for DML operations 23:12:36.670|CUMULATIVE_PROFILING|method invocations|External entry point: global static String doGet(): executed 1 time in 22 ms Class.TTradeService.doGet: line 7, column 1: global String __sfdc_remoteAddress(): executed 1 time in 0 ms Class.TTradeService.doGet: line 8, column 1: global Blob __sfdc_requestBody(): executed 1 time in 0 ms Class.TTradeService.doGet: line 9, column 1: global String __sfdc_requestURI(): executed 2 times in 0 ms Class.TTradeService.doGet: line 10, column 1: global MAP<String,String> __sfdc_params(): executed 1 time in 0 ms Class.TTradeService.doGet: line 12, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms Class.TTradeService.doGet: line 13, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms Class.TTradeService.doGet: line 14, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms Class.TTradeService.doGet: line 15, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms Class.TTradeService.doGet: line 17, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms Class.TTradeService.doGet: line 16, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms 23:12:36.670|CUMULATIVE_PROFILING_END 23:12:36.056 (56571000)|CODE_UNIT_FINISHED|TTradeService.doGet 23:12:36.056 (56583000)|EXECUTION_FINISHED
@RestResource(urlMapping='/ttradeservice') global class TTradeService { @HttpGet global static string doGet() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String remoteAdd = RestContext.request.remoteAddress; Blob reqBody = RestContext.request.requestBody; String answerId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Map <String, String> reqParams = RestContext.request.params; String first_name = RestContext.request.params.get('attendee_person_firstName'); String last_Name = RestContext.request.params.get('attendee_person_lastName'); String customField0 = RestContext.request.params.get('attendee_customField0'); String attendee_email = RestContext.request.params.get('attendee_email'); String customField1 = RestContext.request.params.get('attendee_customField1'); String q_fulfillment = RestContext.request.params.get('questionId__fulfillment'); try { Contact attendee = [ SELECT Id, Email, FirstName, LastName FROM Contact WHERE Email = :attendee_email LIMIT 1]; User CSA = [SELECT Id FROM User WHERE Id = :customField1 LIMIT 1]; List<ts2__Assessment__c> assmnts = [SELECT ts2__User__c, TimeTrade_Event_ID__c, Location__c, Campus__c, Appointment_Type__c,Date__c,Details__c,End_Time__c,Start_Time__c,ts2__Contact__c FROM ts2__Assessment__c WHERE Id = :attendee.Id LIMIT 1]; if (assmnts.size() > 0) { return 'no error1'; } else if (attendee.Id != '' ) { ts2__Assessment__c newassmnt = new ts2__Assessment__c(); newassmnt.ts2__Contact__c = customField0 ; // newassmnt.Appointment_Type__c = // newassmnt.Date__c = // newassmnt.Start_Time__c = // newassmnt.End_Time__c = // newassmnt.Details__c = // newassmnt.TimeTrade_Event_ID__c = // newassmnt.Location__c = // newassmnt.Campus__c = newassmnt.ts2__User__c = CSA.Id; insert newassmnt; return 'no error2'; } else { return 'Hello '+first_name; } } catch (exception e) { return 'error'; } } }
Hi there,
Can someone help me to debug the issue here?
I am trying to build rest API process. where the thirdparty application is trying to some info into our org with out authenitcation. I have exposed the apex class using public access setting on a force.com site and calling this class through that.
I can see that I can do a proper handshake but I get 'error' from the exception. May I know whats causing it to avoid try section of the code?
Thank you,
Manohar
- manoharp
- August 11, 2013
- Like
- 0
Salesforce to Salesforce & Trigger
Hi there,
Background - I have S2S setup to transfer external org records into ours. I am trying to pull detail object record in Master Detail relationship, since it doesnt accept the Id of the master I am getting that in a text field. but before inserting I have 'before insert' trigger that I am trying to use to grab the Master object record Id, and stamp it on the master Id field. but looks like my trigger is not firing , its complaining on the master field saying "Error: You must enter a value". I can understand that Master field is required on Detail object for Master Detail Relationship. wouldnt expect it would fire before the trigger.
Am I missing anything or any other way I can achive it?
trigger createS2SLeadSolarArray on String_Array__c (before insert) { for (String_Array__c sa: Trigger.new) {
// I tried commenting out the If statement as well if (sa.Source__c == 'S2S'){
//query for master record Solar_System__c ssg = [SELECT Lead__c, Id FROM Solar_System__c WHERE Source_Solar__c = :sa.Solar_System_Text__c limit 1]; sa.Solar_System__c = ssg.Id;
// tried hardcoding the id value // sa.Solar_System__c = 'a1oK0000000bNi9IAE'; } } }
Thanks
Manohar
- ManoharSF
- July 10, 2013
- Like
- 0
Too many SOQL queries: 101
Hi there,
what can be changed in this to avoid 'Too many SOQL queries: 101' issue?
thanks
Manohar
trigger UpdateApprovalPercentForRest on Opportunity (after delete, after undelete, after update) { List<Opportunity> buildsToUpdate = new List<Opportunity>{}; for( Opportunity parent: Trigger.new) { List<Opportunity> restBuildswiththePartner =[SELECT Partner_Cap_Reached__c , Build_Partner__c,Construction_Approval_Payment__c, StageName,Substantial_Completion_Payment__c FROM Opportunity WHERE Build_Partner_ID__c = :parent.Build_Partner_ID__c AND StageName NOT IN ('Construction Approved', 'Substantial Completion Pending Approval', 'Substantial Completion', 'Final Completion Pending Approval', 'Final Completion', 'Cancelled - Customer', 'Cancelled - SCF') ]; for(Opportunity o : restBuildswiththePartner){ if (o.Partner_Cap_Reached__c == true && (o.Construction_Approval_Payment__c != 0.00 && o.Substantial_Completion_Payment__c != 0.80 ) && (o.StageName != 'Construction Approved' && o.StageName != 'Substantial Completion Pending Approval' && o.StageName != 'Substantial Completion' && o.StageName != 'Final Completion Pending Approval' && o.StageName != 'Final Completion' && o.StageName != 'Cancelled - Customer' && o.StageName != 'Cancelled - SCF')) { o.Construction_Approval_Payment__c = 0.00; o.Substantial_Completion_Payment__c = 0.80; o.Final_Completion_Payment__c = 0.20; buildsToUpdate.add(o); } if (o.Partner_Cap_Reached__c == false && (o.Construction_Approval_Payment__c != 0.40 && o.Substantial_Completion_Payment__c != 0.40 ) && (o.StageName != 'Construction Approved' && o.StageName != 'Substantial Completion Pending Approval' && o.StageName != 'Substantial Completion' && o.StageName != 'Final Completion Pending Approval' && o.StageName != 'Final Completion' && o.StageName != 'Cancelled - Customer' && o.StageName != 'Cancelled - SCF')) { o.Construction_Approval_Payment__c = 0.40; o.Substantial_Completion_Payment__c = 0.40; o.Final_Completion_Payment__c = 0.20; buildsToUpdate.add(o); } } if (!buildsToUpdate.isEmpty()){ update buildsToUpdate; } } }
- ManoharSF
- July 01, 2013
- Like
- 0
INSUFFICIENT_ACCESS_OR_READONLY possible on hitting API usage limit?
If I run out of API Requests, is it possible that my queries (in this case, a PATCH to /services/data/v20.0/sobjects/notes) might fail with INSUFFICIENT_ACCESS_OR_READONLY, or would that give a different error message?
The docs simply say:
INSUFFICIENT_ACCESS_OR_READONLY You can't perform the specified action because you do not have sufficient permissions.
Does "sufficient permissions" include API exhaustion, or is it specifically about object permissions?
Going through my logs, I noticed that we hit the API Usage limit same day that we saw a rash of these errors. Are they related, or do I have two problems?
Thanks,
-ck
- ck2
- May 29, 2013
- Like
- 0
custom object data edit/delete using website created in site.com
- Amol_Nikam
- March 22, 2013
- Like
- 0