-
ChatterFeed
-
8Best Answers
-
1Likes Received
-
0Likes Given
-
17Questions
-
53Replies
- Anoop Reddy
- August 07, 2019
- Like
- 0
Trigger on Chiled object when parent object field is updated
I Have parent Object and child object
Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)
Need help in writing a trigger :
Scenerio:When ever picklist values are changed ex: IN to OUt or OUT to IN The trigger need to Check the YES filed and immediately and then Uncheck.
Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)
Need help in writing a trigger :
Scenerio:When ever picklist values are changed ex: IN to OUt or OUT to IN The trigger need to Check the YES filed and immediately and then Uncheck.
- KCL
- August 06, 2019
- Like
- 0
I am getting this error when building in Process Builder "The formula expression is invalid: Syntax error. Missing '='". What is wrong with my code?
I am trying to update a record field with type formula. Below is the formula that I have written. Any help?
List<[Order_Item__c> Orders = [SELECT Product_Record_Type__c, Total_Price__c FROM [Order_Item__c]];
Integer total = 0;
for ([Order_Item__c] order : Orders){
IF(order.Product_Record_Type__c == "Building Option",
total += order.Total_Price__c;
)
};
return total;
List<[Order_Item__c> Orders = [SELECT Product_Record_Type__c, Total_Price__c FROM [Order_Item__c]];
Integer total = 0;
for ([Order_Item__c] order : Orders){
IF(order.Product_Record_Type__c == "Building Option",
total += order.Total_Price__c;
)
};
return total;
- Blake Reeves 9
- June 13, 2019
- Like
- 0
Receiving System.NullPointerException: Attempt to de-reference a null object () error email.
I am receiving error email from ApexApplication <info@salesforce.com> with following content:
Subject: Developer script exception from ABC : ContactTrigger : ContactTrigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object ()
Apex script unhandled trigger exception by user/organization:
ContactTrigger: execution of AfterUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.ContactTriggerHandler.onAfterUpdate: line 28, column 1
Trigger.ContactTrigger: line 15, column 1
Here is the Trigger:
Here is apex class handler
Subject: Developer script exception from ABC : ContactTrigger : ContactTrigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object ()
Apex script unhandled trigger exception by user/organization:
ContactTrigger: execution of AfterUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.ContactTriggerHandler.onAfterUpdate: line 28, column 1
Trigger.ContactTrigger: line 15, column 1
Here is the Trigger:
trigger ContactTrigger on Contact (after insert, after update,after delete,after undelete) if(Trigger.isAfter) { if(Trigger.isUpdate) { ContactTriggerHandler.onAfterUpdate(Trigger.new,Trigger.oldMap); } if(Trigger.isInsert){ ContactTriggerHandler.OnAfterInsert(Trigger.new); } if(Trigger.IsDelete){ ContactTriggerHandler.OnAfterDelete(Trigger.old); } if(Trigger.IsUnDelete){ ContactTriggerHandler.OnUndelete(Trigger.new); } } }
Here is apex class handler
public class ContactTriggerHandler { public static void onAfterUpdate(List<Contact> newContacts, Map<id,Contact> oldContacts) { updateSortedCorrespondencePreferneceData(newContacts,oldContacts); updateSalutationOnCommunicationContent(newContacts,oldContacts); id cpCapitalPartnerRT = fetchRecordTypeId('Account','CP Capital Partner'); List<Contact> newList = new List<Contact>(); set<Id> oldAndNewAccountIds = new set<id>(); for(Contact con : newContacts) { oldAndNewAccountIds.add(con.accountId); oldAndNewAccountIds.add(oldContacts.get(con.id).accountId); } Map<Id,Account> accountDetails = new Map<Id,Account>([Select Id,RecordTypeId from Account where Id in :oldAndNewAccountIds]); for(Contact con : newContacts) { if(accountDetails !=NULL && con!= Null && con.accountId != oldContacts.get(con.Id).accountId ) { if( accountDetails.containsKey(con.accountId) && (accountDetails.get(con.accountId).recordTypeId == cpCapitalPartnerRT || accountDetails.get(oldContacts.get(con.Id).accountId).recordTypeId == cpCapitalPartnerRT) ) { newList.add(con); } } else if(accountDetails !=NULL && con!= Null && accountDetails.get(con.accountId).recordTypeId == cpCapitalPartnerRT ) { newList.add(con); } } Email_InformationClass.getEmailTableData(newList,oldContacts); updateCPIntralinksAccess(newContacts,oldContacts); } public static void OnAfterDelete(contact[] oldList){ updateCPIntralinksAccess(oldList, null); } public static void OnAfterInsert(contact[] newList){ updateCPIntralinksAccess(newList, null); } public static void OnUndelete(contact[] newList){ updateCPIntralinksAccess(newList,null); } private static void updateSalutationOnCommunicationContent(List<Contact> newContacts, Map<id,Contact> oldContacts){ set<id> contactsToProcess = new set<id>(); for(Contact con : newContacts) { if((String.isNotBlank(con.email) && !con.email.contains('@test.com')) && ((con.Seniority_Rank__c != oldContacts.get(con.Id).Seniority_Rank__c) || (con.FirstName != oldContacts.get(con.id).FirstName)) || (con.International_Salutation_Type__c!= oldContacts.get(con.Id).International_Salutation_Type__c || String.isBlank(oldContacts.get(con.Id).email)) ) { contactsToProcess.add(con.id); } } if(contactsToProcess.size() > 0) { List<Correspondence_Preference__c> corrPrefToProcess = new List<Correspondence_Preference__c>([Select Id, Company__c, RecordType.Name from Correspondence_Preference__c where Recipient_Type__c = 'To' AND Contact__c In :contactsToProcess]); set<string> cpNames = new Set<String>(); set<string> accountNames = new Set<String>(); for(Correspondence_Preference__c cp : corrPrefToProcess) { cpNames.add(cp.RecordType.Name); accountNames.add(cp.Company__c); } List<Communications_Content__c> ccList = new List<Communications_Content__c>([Select Id,Salutation__c,Company__c,Correspondence_Preference__c from Communications_Content__c where Company__c IN :accountNames AND Correspondence_Preference__c IN :cpNames]); CommunicationContentTriggerHandler handler = new CommunicationContentTriggerHandler(true,200,true); handler.updateSalutationField(null,ccList); } private static void updateSortedCorrespondencePreferneceData(List<Contact> newContacts, Map<id,Contact> oldContacts) { set<id> contactsToProcess = new set<id>(); for(Contact con : newContacts) { if((con.Seniority_Rank__c != oldContacts.get(con.Id).Seniority_Rank__c) || (con.Email != oldContacts.get(con.id).Email) ) { contactsToProcess.add(con.id); } } if(contactsToProcess.size() > 0) { List<Correspondence_Preference__c> corrPrefToProcess = new List<Correspondence_Preference__c>([Select Id, Commitment__c, RecordTypeId from Correspondence_Preference__c where Contact__c In :contactsToProcess]); CorrespondenceTriggerHandler.getCommRecTypeData(corrPrefToProcess,null,false); } } private static id fetchRecordTypeId(string sObj, string rt) { System.debug('fetch params>>'+sObj + '<<<rt>>>'+rt); String recordtypeId = Schema.getGlobalDescribe().get(sObj).getDescribe().getRecordTypeInfosByName().get(rt).getRecordTypeId(); return Schema.getGlobalDescribe().get(sObj).getDescribe().getRecordTypeInfosByName().get(rt).getRecordTypeId(); } public static void updateCPIntralinksAccess(List<Contact> newContacts, Map<id,Contact> OldMap){ Map<ID,List<contact>> mapConWithAcc = new Map<ID,List<contact>>(); List<account> accList = new List<account>(); String temp= ''; Map<Id,String> accUpdateMap = new Map<Id,String>(); Set<ID> accid = new Set<ID>(); for(contact con: newContacts){ if(oldMap == null || oldMap.get(con.id).CP_Intralinks_Access__c != con.CP_Intralinks_Access__c ){ accid.add(con.accountid); } } for(Account acc : [Select id,CP_Intralinks_Access__c,(Select id,CP_Intralinks_Access__c,accountid from contacts) from account where id in :accid]) { set<string> val = new set<string>(); String finalVal = '' ; for(Contact ct : acc.contacts) { if(String.isNOtBlank(ct.CP_Intralinks_Access__c)) { } } List<String> valList = new List<String>(); valList.addAll(val); if(valList.size() > 0) { finalVal = String.join(valList,','); } acc.CP_Intralinks_Access__c = finalVal ; accList.add(acc); } if(accList.size() > 0) { update accList ; } } }
- AbhishekJ
- June 13, 2019
- Like
- 0
Custom Button to Check Box on Multiple Contact Records
I am trying to create a custom button that will allow me to select one or more Contacts from the "Contacts" related list on an Account page and then execute JavaScript which will update a specific field (in this case, simply setting a checkbox value to "true") on each of the selected Contacts. I would then use the updating of this checkbox value to trigger a workflow that would send out an email alert to those Contacts.
Here is how I've configured the custom button:
I've done a lot of searching around and found other posts about people trying to do a similar thing but for some reason the script I'm using just won't update that Contact field (doesn't throw an error, just refreshes the page without updating). Any ideas what I might be doing wrong here?
Here is how I've configured the custom button:
I've done a lot of searching around and found other posts about people trying to do a similar thing but for some reason the script I'm using just won't update that Contact field (doesn't throw an error, just refreshes the page without updating). Any ideas what I might be doing wrong here?
- Nicholas Patella
- March 26, 2019
- Like
- 0
Convert Process Builder to trigger
I had created a Process Builder which was working fine in the lower sandboxes. In production however, it is causing errors and giving the following message: The flow tried to update these records: null. This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: pi.LogAccountChange: System.LimitException: Apex CPU time limit exceeded. You can look up ExceptionCode values in the SOAP API Developer Guide [developer.salesforce.com] Flow Details Flow API Name: Opportunity_Recalculate_Rating Type: Record Change Process Version: 4 Status: Active Org: Lifetouch (00D15000000kLl0) Flow Interview Details Interview Label: Opportunity_Recalculate_Rating-5_InterviewLabel Current User: Integration User (005150000073iiO) Start time: 3/22/2019 1:57 AM Duration: 15 seconds How the Interview Started Integration User (005150000073iiO) started the flow interview. Some of this flow's variables were set when the interview started. myVariable_old = Opportunity (0061500000WK2cKAAT) myVariable_current = Opportunity (0061500000WK2cKAAT) ASSIGNMENT: myVariable_waitStartTimeAssignment {!myVariable_waitStartTimeVariable} Equals {!$Flow.CurrentDateTime} Result {!myVariable_waitStartTimeVariable} = "3/22/2019 1:57 AM" DECISION: myDecision Executed this outcome: myRule_1 Outcome conditions: {!formula_myRule_1} (true) Equals true RECORD UPDATE: myRule_1_A1 Find all Opportunity records where: Id Equals {!myVariable_current.Id} (0061500000WK2cKAAT) Update the records’ field values. LPP_Rating__c = {!formula_4_myRule_1_A1_9963437625} (B) Result All records that meet the filter criteria are ready to be updated when the next Screen or Wait element is executed or when the interview finishes. RECORD UPDATE: myRule_1_A2 Find all Account records where: Id Equals {!myVariable_current.AccountId} (0011500001LkYu4AAF) Update the records’ field values. Fall_Rating__c = {!formula_3_myRule_1_A2_9151511649} (B) Result All records that meet the filter criteria are ready to be updated when the next Screen or Wait element is executed or when the interview finishes. RECORD UPDATE: myRule_1_A3 Find all Account records where: Id Equals {!myVariable_current.AccountId} (0011500001LkYu4AAF) Update the records’ field values. Spring_Rating__c = {!formula_2_myRule_1_A3_6475583567} (A) Result Failed to update records that meet the filter criteria.
And this error is just a snippet. It actually gives a page long message with the same thing. After doing research, I found out that PB take twice as long to execute as opposed to Apex triggers. So my goal is to convert this Process Builder to an Apex trigger. Unfortunately, I am not a developer and would love to get some guidance/starting step into converting this PB into Apex trigger. The Process Builder is below:
the build formula is: AND ( NOT(ISBLANK([Opportunity].LPP_Rating__c )), TEXT([Opportunity].Collection_Status__c) <> "Open", [Opportunity].Retake__c = false, OR ( ISCHANGED([Opportunity].Total_Payments__c), ISCHANGED([Opportunity].Sales_Tax_Rate__c), ISCHANGED([Opportunity].Reorder_Payments__c), ISCHANGED([Opportunity].Total_Production_Value__c), ISCHANGED([Opportunity].Discount__c), ISCHANGED([Opportunity].Children_Photographed__c), ISCHANGED([Opportunity].Commissions_Paid__c) ) )
The imediate action is:
and the value section has this written:
Basically, what this process is doing is that there is a Rating field that gets updated based on the Contribution Margin formula. However, if any component value in the contribution formula changes, then it updates the rating field. I am guessing this will be a before update trigger. Any help would be greatly appreciated. Thank you
And this error is just a snippet. It actually gives a page long message with the same thing. After doing research, I found out that PB take twice as long to execute as opposed to Apex triggers. So my goal is to convert this Process Builder to an Apex trigger. Unfortunately, I am not a developer and would love to get some guidance/starting step into converting this PB into Apex trigger. The Process Builder is below:
the build formula is: AND ( NOT(ISBLANK([Opportunity].LPP_Rating__c )), TEXT([Opportunity].Collection_Status__c) <> "Open", [Opportunity].Retake__c = false, OR ( ISCHANGED([Opportunity].Total_Payments__c), ISCHANGED([Opportunity].Sales_Tax_Rate__c), ISCHANGED([Opportunity].Reorder_Payments__c), ISCHANGED([Opportunity].Total_Production_Value__c), ISCHANGED([Opportunity].Discount__c), ISCHANGED([Opportunity].Children_Photographed__c), ISCHANGED([Opportunity].Commissions_Paid__c) ) )
The imediate action is:
and the value section has this written:
Basically, what this process is doing is that there is a Rating field that gets updated based on the Contribution Margin formula. However, if any component value in the contribution formula changes, then it updates the rating field. I am guessing this will be a before update trigger. Any help would be greatly appreciated. Thank you
- Afzaal Hassan
- March 26, 2019
- Like
- 0
Apex Test Class for a Trigger
I have the following trigger and I would need some help in creating the test class. Any help will be appreciated.
trigger listingLocationUpdate on pba__Listing__c (before insert, before update) { //Mantiene actualizado el picklist Location en base al lookup Location List<pba__Listing__c> listings = Trigger.new; Map<Id, pba__Listing__c> oldListings = null; if (!Trigger.isInsert) { oldListings = Trigger.oldMap; } for (pba__Listing__c listing : listings) { if (!Trigger.isInsert) { pba__Listing__c oldListing = oldListings.get(listing.Id); if (oldListing.Location__c == listing.Location__c) { continue; } } if (listing.Location__c == null) { listing.fm_Location__c = null; continue; } pba__Location__c l = [Select Name from pba__Location__c where Id =:listing.Location__c]; if (l != null) { listing.fm_Location__c = l.Name; } } }
- Bogdan Pascu
- March 26, 2019
- Like
- 0
How to optimise Trigger code to avoid exceeding governor limits
Hi,
In my situation I have a Custom Object (Object__c) which can be created in 2 types: TypeA or TypeB, where TypeA is always created first and on a later date TypeB will be created with the same Title and Episode. I created a Trigger that when TypeB is created the Trigger will find a matching TypeA card based on the Title and episode, and fill the new TypeB card with Date1 and Date2 from the matching TypeA card, and it will link TypeA to TypeB with a lookupfield ObjectMatch__c
--------------------------------------------------------
trigger ObjectFindMatch on Object__c (before update) {
for (Object__c newObj : Trigger.new) {
for (Object__c extObj : [SELECT Id, Date1__c, Date2__c FROM Object__c
WHERE Type__c = 'TypeA'
AND Titel_c = :newObj.Titel__c
AND Episode_c = :newObj.Episode__c]) {
IF (newObj.Type__c = 'TypeB') {
newObj.ObjectMatch__c = extObj.Id;
newObj.Date1__c = extObj.Date1__c;
newObj.Date2__c = extObj.Date2__c;
}
}
}
}
--------------------------------------------------------
The Trigger works fine but the cards can also be created in a batch (for example) episodes 1 to 10, then I get a: LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101
I am reading some best practices like:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_bestpract.htm
But I can't figure out how to optimise my code :(
Please help ?
Kind regards,
Marco
In my situation I have a Custom Object (Object__c) which can be created in 2 types: TypeA or TypeB, where TypeA is always created first and on a later date TypeB will be created with the same Title and Episode. I created a Trigger that when TypeB is created the Trigger will find a matching TypeA card based on the Title and episode, and fill the new TypeB card with Date1 and Date2 from the matching TypeA card, and it will link TypeA to TypeB with a lookupfield ObjectMatch__c
--------------------------------------------------------
trigger ObjectFindMatch on Object__c (before update) {
for (Object__c newObj : Trigger.new) {
for (Object__c extObj : [SELECT Id, Date1__c, Date2__c FROM Object__c
WHERE Type__c = 'TypeA'
AND Titel_c = :newObj.Titel__c
AND Episode_c = :newObj.Episode__c]) {
IF (newObj.Type__c = 'TypeB') {
newObj.ObjectMatch__c = extObj.Id;
newObj.Date1__c = extObj.Date1__c;
newObj.Date2__c = extObj.Date2__c;
}
}
}
}
--------------------------------------------------------
The Trigger works fine but the cards can also be created in a batch (for example) episodes 1 to 10, then I get a: LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101
I am reading some best practices like:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_bestpract.htm
But I can't figure out how to optimise my code :(
Please help ?
Kind regards,
Marco
- Marco Pouleyn
- March 26, 2019
- Like
- 0
Code Coverage Failure Your code coverage is 73%. You need at least 75% coverage to complete this deployment
I did run all tests in my sandbox and also tried to run them each individually - the overall avg code coverage is around 88%. However, when i try to validate my change set in prod, it is throwing an error saying "Code Coverage Failure Your code coverage is 73%. You need at least 75% coverage to complete this deployment."
None of the test classes failed. Now i'm stuck at a place where it is unable to show what's causing this error nor any directives.
I would really appreciate your help! Thanks!
None of the test classes failed. Now i'm stuck at a place where it is unable to show what's causing this error nor any directives.
I would really appreciate your help! Thanks!
- SATHISH REDDY.
- October 19, 2020
- Like
- 0
Architecture quest - whats the recommended way to track an opportunity amount being used and reallocate the unused balance
To all the sf experts out here, trying to get your inputs for a use case that i’m trying to incorporate. Use case: We have a currency field called “Amount Owed” on opportunity which holds an $ value. It is calculated by user based on any unused amount for that opportunity. Example if an opp Amount = $1000 and only $800 was spend in reality, then the Amount Owed = $200 which will then be applied to future opportunities under that account. (Note: This Amount Owed can be applied to a single oppty or to multiple opportunities.)
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance
- SATHISH REDDY.
- August 26, 2020
- Like
- 0
Design question - whats the recommended way to track an opportunity amount being used and reallocate the unused balance
To all sf experts out here, trying to get your inputs for a use case that i’m trying to incorporate. Use case: We have a currency field called “Amount Owed” on opportunity which holds an $ value. It is calculated by user based on any unused amount for that opportunity. Example if an opp Amount = $1000 and only $800 was spend in reality, then the Amount Owed = $200 which will then be applied to future opportunities under that account. (Note: This Amount Owed can be applied to a single oppty or to multiple opportunities.)
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance!
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance!
- SATHISH REDDY.
- August 24, 2020
- Like
- 0
Design quest - whats the recommended way to track an opportunity amount being used and reallocate the unused balance
To all the sf experts out here, trying to get your inputs for a use case that i’m trying to incorporate. Use case: We have a currency field called “Amount Owed” on opportunity which holds an $ value. It is calculated by user based on any unused amount for that opportunity. Example if an opp Amount = $1000 and only $800 was spend in reality, then the Amount Owed = $200 which will then be applied to future opportunities under that account. (Note: This Amount Owed can be applied to a single oppty or to multiple opportunities.)
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance!
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance!
- SATHISH REDDY.
- August 24, 2020
- Like
- 0
Visualforce - Expandable table rows showing inner table (No Aura)
Hello everyone,
I'm have a table which shows the list of Opportunities. I want to show an inner table whenever an opportunity row is clicked. Similar to the following. However, i'm unable to achieve this & not sure what i might be missing. Please share your inputs. Thanks in advance!
I'm trying to something similar & even tried the following example which didnt work.
https://www.soliantconsulting.com/blog/multi-tiered-tables-in-visualforce/?unapproved=382305&moderation-hash=7a67877d361da32c66a3507d496a06c3#comment-382305
I'm have a table which shows the list of Opportunities. I want to show an inner table whenever an opportunity row is clicked. Similar to the following. However, i'm unable to achieve this & not sure what i might be missing. Please share your inputs. Thanks in advance!
<table> <thead > <tr> <th>Opportunity</th> <th>Type</th> <th>Start</th> <th>End</th> <th>Budget</th> <th>More ($)</th> </tr> </thead> <tbody> <apex:repeat value="{!wrap}"> <tr> <td>{!wrap.a}</td> <td>{!wrap.b}</td> <td>{!wrap.c}</td> <td>{!wrap.d}</td> <td>{!wrap.e}</td> <td>{!wrap.f}</td> </tr> <!--Inner Table--> <tr> <div> <table id="newtable"> <thead id="newth"> <tr> <th colspan="1">Jan</th> <th colspan="1">Feb</th> <th colspan="1">Mar</th> <th colspan="1">Apr</th> <th colspan="1">May</th> <th colspan="1">Jun</th> <th colspan="1">Jul</th> <th colspan="1">Aug</th> <th colspan="1">Sep</th> <th colspan="1">Oct</th> <th colspan="1">Nov</th> <th colspan="1">Dec</th> </tr> </thead> <tbody> </tbody> </table> </div> </tr> </apex:repeat> </tbody> </table>
I'm trying to something similar & even tried the following example which didnt work.
https://www.soliantconsulting.com/blog/multi-tiered-tables-in-visualforce/?unapproved=382305&moderation-hash=7a67877d361da32c66a3507d496a06c3#comment-382305
- SATHISH REDDY.
- June 18, 2020
- Like
- 0
OpportunityLineItemSchedule calculation are hitting the CPU time limit and aggregate query doesn't support query more
Hello Trailblazers,
I have a visualforce page with 2 date inputs, a table with Oppty's List(as shown) with calculated schedules & custom button. On button click, i'm trying to calculate the lineitemschedules revenue sum by date - per each opportunity. To achieve this, i tried an aggregate soql, however the following exception is thrown. "Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch Error"
I changed the above aggregate query into a normal soql on Lineitemschedule and looped through all the dates & calculated sum by date per each opportunity. But this throws another exception as shown below. "System.LimitException: Apex CPU time limit exceeded"
VFP
Either ways the logic/calculations are consuming most of the CPU time & i'm unable to workaround this. Please share your suggestions.
Thank you!
I have a visualforce page with 2 date inputs, a table with Oppty's List(as shown) with calculated schedules & custom button. On button click, i'm trying to calculate the lineitemschedules revenue sum by date - per each opportunity. To achieve this, i tried an aggregate soql, however the following exception is thrown. "Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch Error"
soqlOliRevSchedStr = 'SELECT sum(Revenue), scheduledate, Opportunitylineitemschedule.Opportunitylineitem.OpportunityId oppId FROM OpportunityLineItemSchedule WHERE Opportunitylineitem.OpportunityId IN: oppIdSet AND Opportunitylineitem.Product2.Name = \'Revenue\''; soqlOliRevSchedStr += ' AND ScheduleDate >=: tempFromDatePicker AND ScheduleDate <=: tempToDatePicker'; soqlOliRevSchedStr += ' GROUP BY OpportunityLineItemSchedule.Opportunitylineitem.OpportunityId, scheduledate ORDER BY ScheduleDate ASC'; for(AggregateResult aggr : Database.query(soqlOliRevSchedStr)){ oppIdRevAmtMap = aggregateResultProcess(aggr, oppIdRevAmtMap); } public Map<Id, Double> aggregateResultProcess(AggregateResult aggr, Map<Id, Double> tempOppIdAmtMap){ Id tempOppId = (Id)aggr.get('oppId'); if(!tempOppIdAmtMap.containsKey(tempOppId)){ tempOppIdAmtMap.put(tempOppId,(Double)aggr.get('expr0')); }else{ Double temp = tempOppIdAmtMap.get(tempOppId); tempOppIdAmtMap.put(tempOppId, temp+(Double)aggr.get('expr0')); } return tempOppIdAmtMap; }
I changed the above aggregate query into a normal soql on Lineitemschedule and looped through all the dates & calculated sum by date per each opportunity. But this throws another exception as shown below. "System.LimitException: Apex CPU time limit exceeded"
soqlOliRevSchedStr = 'SELECT Id, Revenue, ScheduleDate, Opportunitylineitem.OpportunityId FROM OpportunityLineItemSchedule WHERE Opportunitylineitem.OpportunityId IN: oppIdSet AND Opportunitylineitem.Product2.Name = \'Revenue\''; soqlOliRevSchedStr += ' AND ScheduleDate >=: tempFromDatePicker AND ScheduleDate <=: tempToDatePicker'; soqlOliRevSchedStr += ' ORDER BY ScheduleDate ASC'; for(OpportunityLineItemSchedule oliSch : Database.query(soqlOliRevSchedStr)){ oppIdRevAmtMap = aggregateResultProcess(oliSch, oppIdRevAmtMap); } public Map<Id, Double> aggregateResultProcess(OpportunityLineItemSchedule tempOliSched, Map<Id, Double> tempOppIdAmtMap){ Id tempOppId = tempOliSched.OpportunityLineItem.OpportunityId; if(!tempOppIdAmtMap.containsKey(tempOppId)){ tempOppIdAmtMap.put(tempOppId,(Double)tempOliSched.Revenue); }else{ Double temp = tempOppIdAmtMap.get(tempOppId); tempOppIdAmtMap.put(tempOppId, temp+(Double)tempOliSched.Revenue); } return tempOppIdAmtMap; }Dent on the CPU time
VFP
Either ways the logic/calculations are consuming most of the CPU time & i'm unable to workaround this. Please share your suggestions.
Thank you!
- SATHISH REDDY.
- June 16, 2020
- Like
- 0
OpportunityLineItemSchedules group by Date in SOQL
Hi all,
I have a list of products with associated schedules where each schedule has different Revenue and ScheduleDate values. I'm trying to get the get the aggregate of Revenue by DATE across the OpportunityLineItems. However, i'm not sure how to achieve this as i couldn't find any date functions specific to date while DAY_ONLY() will only work for datetime fields. Please share your thoughts & recommendations.
Thanks!
I have a list of products with associated schedules where each schedule has different Revenue and ScheduleDate values. I'm trying to get the get the aggregate of Revenue by DATE across the OpportunityLineItems. However, i'm not sure how to achieve this as i couldn't find any date functions specific to date while DAY_ONLY() will only work for datetime fields. Please share your thoughts & recommendations.
Thanks!
- SATHISH REDDY.
- June 10, 2020
- Like
- 0
Apex Tabs in Visualforce must load data only when clicked
Hello Trailblazers,
I'm trying to design a VFP with TWO apex tabs with each tab having a table with list of records within along with some custom "search" logic. Tab 1 will load the data by default on initial page load but I want tab 2 data to be loaded only when clicked(as a best practice). i also have a custom button within each tab which will just get the specific records onto the table. I'm really having hard time in figuring out how to achieve this as i tried to use the actionfunction ontabenter which didn't work. Please shed some light on what i might be doing wrong or share any examples specific to my use case.
VFP:
Controller:
Thanks in advance!
I'm trying to design a VFP with TWO apex tabs with each tab having a table with list of records within along with some custom "search" logic. Tab 1 will load the data by default on initial page load but I want tab 2 data to be loaded only when clicked(as a best practice). i also have a custom button within each tab which will just get the specific records onto the table. I'm really having hard time in figuring out how to achieve this as i tried to use the actionfunction ontabenter which didn't work. Please shed some light on what i might be doing wrong or share any examples specific to my use case.
VFP:
<apex:page controller="MarginTrackerController" sidebar="false"> <apex:form > <apex:tabPanel title="Margin Tracker" id="tabpanelId" tabClass="activeTab" inactiveTabClass="inactiveTab" value="{!varTabId}"> <apex:tab label="Summary" name="Summary" ontabenter="onClickSummaryTab();" switchType="ajax" id="Summary"> </apex:tab> <apex:tab label="Margin" name="Margin" ontabenter="onClickMarginTab();" switchType="ajax" id="Margin"> <div style="width:800px;float:left;"> <!-- this is the filter used to SearchAction--> <apex:selectList multiselect="false" size="1" value="{!selectedTimeframe}"> <apex:selectOptions value="{!timeframeList}"></apex:selectOptions> </apex:selectList> <apex:commandButton value="Go" action="{!searchAction}" status="status" rerender="formId,oppsPanel"> </apex:commandButton> </div> <p><div class="oppstbldiv"> <table class="oppstbl" id="myOppsTable"> <thead> <tr> <th colspan="1">Opportunity</th> <th colspan="1"> Type</th> <th colspan="1"> Start</th> <th colspan="1"> End</th> <th colspan="1">Net Budget</th> <th colspan="1">Sold Margin ($)</th> <th colspan="1">Sold Margin (%)</th> <th colspan="1">Booking Margin ($)</th> <th colspan="1">Booking Margin (%)</th> <th colspan="1">Revised Margin ($)</th> <th colspan="1">Revised Margin (%)</th> </tr> </thead> <tbody> <apex:repeat value="{!oppList}" var="opp"> <tr> <td style="text-align:left">{!opp.Name}</td> <td>{!opp.Market__c}</td> <td> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!opp.Start_Date__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!opp.End_Date__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Net_Budget__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Sold_Margin__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Sold_Margin_Percentage__c))}"> <apex:param value="{!opp.Sold_Margin_Percentage__c}"/> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Booked_Margin__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Booked_Margin_Percentage__c))}"> <apex:param value="{!opp.Booked_Margin_Percentage__c}"/> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Revised_Margin__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Revised_Margin_Percentage__c))}"> <apex:param value="{!opp.Revised_Margin_Percentage__c}"/> </apex:outputText> </td> </tr> </apex:repeat> </tbody> </table> </div></p> </apex:tab> <apex:actionFunction action="{!SummaryTab}" name="onClickSummaryTab"/> <apex:actionFunction action="{!MarginTab}" name="onClickMarginTab"/> </apex:tabPanel> </apex:form> </apex:page>
Controller:
public class MarginTrackerController { public List<Opportunity> oppList{get; set;} public Opportunity opp{get;set;} public List<SelectOption> timeframeList{get;set;} public String selectedTimeframe { get; set; } public String varTabId { get; set; } public MarginTrackerController(){ } public pageReference SummaryTab(){ varTabId = 'Summary'; /*some logic to fetch records*/ return null; } public pageReference MarginTab(){ varTabId = 'Margin'; opp = new Opportunity(); timeframeList = new List<SelectOption>(); timeframeList.add(new SelectOption('', '--None--')); selectedTimeframe = ''; oppList = new List<Opportunity>(); oppList = [SELECT Id, Name,Market__c, Start_Date__c, End_Date__c, Net_Budget__c, Sold_Margin__c, Sold_Margin_Percentage__c, Booked_Margin__c, Booked_Margin_Percentage__c, Revised_Margin__c, Revised_Margin_Percentage__c FROM Opportunity ORDER BY createdDate DESC LIMIT 100]; return null; } public void searchAction(){ timeframeList.add(new SelectOption('', '--None--')); timeframeList.add(new SelectOption('Q1', 'Q1')); timeframeList.add(new SelectOption('Q2', 'Q2')); timeframeList.add(new SelectOption('Q3', 'Q3')); timeframeList.add(new SelectOption('Q4', 'Q4')); timeframeList.add(new SelectOption('Date', 'Date')); /*fetch the filtered records here*/ } }
Thanks in advance!
- SATHISH REDDY.
- June 04, 2020
- Like
- 0
Unable to save one field at a time using inlineeditsupport on Visualforce page
Hi,
I'm unable to save one field at a time using inlone edit on visualforce page.
VFP:
When i try to inlineedit a single field at a time & save, the save is unsuccessful. While it works fine when all fields are edited at once and saved at the end. Not sure what is missing here, please shed some light on the missing piece here. Thanks in advance!
I'm unable to save one field at a time using inlone edit on visualforce page.
VFP:
<apex:page standardController="Account" extensions="MoreFieldsUpdate_AC" sidebar="false" showHeader="false" lightningStylesheets="true"> <style> .multiSelectPicklistRow select { max-width: 300px; } </style> <apex:form id="formId"> <apex:pagemessages escape="false"/> <apex:slds /> <!--<div style="text-align: center"><br/><br/> <apex:commandButton action="{!save}" id="saveButton" value="Save" status="status" rerender="formId" rendered="true" styleClass="buttonStyle" style="background:LightBlue;width:150px;"/> <apex:commandButton action="{!cancel}" id="cancelButton" value="Cancel" rendered="true" styleClass="buttonStyle" style="background:LightBlue;width:150px;"/> </div>--> <apex:sectionHeader subtitle="{!Account.Name}"/> <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton action="{!edit}" id="editButton" value="Edit" rendered="true" styleClass="buttonStyle" style="background:LightBlue;width:150px;"/> <apex:commandButton action="{!save}" id="saveButton" value="Save" status="status" rerender="formId" rendered="true" styleClass="buttonStyle" style="background:LightBlue;width:150px;"/> <apex:commandButton action="{!cancel}" id="cancelButton" value="Cancel" rendered="true" styleClass="buttonStyle" style="background:LightBlue;width:150px;"/> </apex:pageBlockButtons> <apex:pageBlockSection title="General Info"> <apex:outputField value="{!Account.Beachhead_Attributes__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:outputField value="{!Account.Primary_Lead_Source__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:outputField value="{!Account.Estimated_Budget__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:outputField value="{!Account.Campaign__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:outputField value="{!Account.Estimated_Campaign_Timing__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:outputField value="{!Account.Prospect_s_target_audience_s__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> </apex:pageBlockSection> <apex:pageBlockSection title="Additional Info"> <apex:outputField value="{!Account.Benefit_Sought__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:outputField value="{!Account.Pain_points_with_alternative__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> <apex:inputText style="width: 200px;" value="{!otherBenefitSought}"> <apex:outputLabel styleClass="labelCol vfLabelColTextWrap"><!--This is from Inspect Element--> Benefit Sought (Other) </apex:outputLabel> </apex:inputText> <apex:inputText style="width: 200px;" value="{!otherPainPointsWithAlternatives}"> <apex:outputLabel styleClass="labelCol vfLabelColTextWrap"><!--This is from Inspect Element--> Pain Points with Alternatives (Other) </apex:outputLabel> </apex:inputText> <apex:outputField value="{!Account.Additional_information__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> </apex:pageblockSection> </apex:pageBlock> </apex:form> </apex:page>Controller:
public with sharing class MoreFieldsUpdate_AC{ public String otherBenefitSought { get; set; } public String otherPainPointsWithAlternatives { get; set; } public Account acc { get; set; } public MoreFieldsUpdate_AC(ApexPages.StandardController controller){ acc = (Account)controller.getRecord(); } public void save(){ system.debug('Benefit Sought----'+acc.Benefit_Sought__c); update acc; } public pageReference cancel(){ PageReference reloadOnCancel = new PageReference('/apex/MoreFieldsUpdate_VF?Id='+acc.Id+'&core.apexpages.devmode.url=1'); reloadOnCancel.setRedirect(true); return reloadOnCancel; } }Pic:
When i try to inlineedit a single field at a time & save, the save is unsuccessful. While it works fine when all fields are edited at once and saved at the end. Not sure what is missing here, please shed some light on the missing piece here. Thanks in advance!
- SATHISH REDDY.
- March 24, 2020
- Like
- 0
Checkbox selection using Wrapper is not passed to controller
Hi All,
This might have been posted several times but i'm unable to workaround this issue using apex & I also looked at all the existing questions similar to this. I have a list of Opps with checkboxes in wrapper and i'm unable to retrieve the selections in apex where it always show false. Any help is really appreciated.
VFP:
Controller:
This might have been posted several times but i'm unable to workaround this issue using apex & I also looked at all the existing questions similar to this. I have a list of Opps with checkboxes in wrapper and i'm unable to retrieve the selections in apex where it always show false. Any help is really appreciated.
VFP:
<apex:page controller="ForecastQuotaUpdateController" sidebar="false" docType="html-5.0"> <apex:form > <apex:pagemessages /> <apex:pageblock > <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search by Acc/Owner/Parent..." title="Type in an Account Name"/> Year : <apex:inputField value="{!history.Year__c}"/> User <apex:selectList multiselect="false" size="1" value="{!selectedUser}"> <apex:selectOptions value="{!userOptionsList}"></apex:selectOptions> </apex:selectList> Team <apex:inputCheckbox value="{!isTeam}"/> Confidence % <apex:inputCheckbox value="{!isOppConfidence}"/> Exclude S1 <apex:inputCheckbox value="{!isS1Exclude}"/> Exclude S2 <apex:inputCheckbox value="{!isS2Exclude}"/> Exclude S3 <apex:inputCheckbox value="{!isS3Exclude}"/> <apex:commandButton value="Search" action="{!searchAction}" status="status" rerender="formId"/> </apex:pageblock> </apex:form> <apex:form id="formId"> <!-- List of Opps --> <div id="oppstblDiv"> <table class="oppstbl" id="myTable"> <thead> <tr> <th colspan="1" style="width:50px;">Select</th> <th colspan="1">Opp Name</th> <th colspan="1">Stage</th> <th colspan="1">Budget</th> <th colspan="1">Owner</th> <th colspan="1">End Date</th> </tr> </thead> <tbody> <apex:repeat value="{!forecastOppWrapList}" var="oppWrap"> <tr> <td><apex:inputCheckbox value="{!oppWrap.selected}"/></td> <td>{!oppWrap.opp.Opportunity_Number__c}</td> <td>{!oppWrap.opp.StageName}</td> <td>{!oppWrap.opp.Budget__c}</td> <td>{!oppWrap.opp.Owner.Name}</td> <td>{!oppWrap.opp.End_Date__c}}</td> </tr> </apex:repeat> </tbody> </table> </div> </apex:form> </apex:page>
Controller:
public class ForecastQuotaUpdateController { public String selectedUser { get; set; } public Boolean isTeam { get; set; } public Boolean isOppConfidence { get; set; } public Boolean isS1Exclude { get; set; } public Boolean isS2Exclude { get; set; } public Boolean isS3Exclude { get; set; } public ForecastQuotaUpdateController(){ isTeam = false; isOppConfidence = false; isS1Exclude = false; isS2Exclude = false; isS3Exclude = false; selectedUser = ''; userOptionsList = new List<SelectOption>(); userOptionsList.add(new SelectOption('', '--None--')); history = new Quota_History__c(); yearCurrent = String.valueOf(System.Today().year()); searchUtility('', yearCurrent,'', false, false, false, false, false, new List<ForecastOpportunityListWrapper>()); } //Search Button public void searchAction(){ List<SelectOption> userOptionsListTemp = new List<SelectOption>(); if(!userOptionsList.isEmpty()){ userOptionsListTemp.addAll(userOptionsList); } if(history.year__c != null) yearCurrent = history.year__c; if(String.isBlank(selectedUser) && isTeam) ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, 'Select a User')); else //Here i'm expecting "forecastOppWrapList" to have "selected" = true after selection on VFP (which isNOT working) searchUtility('', yearCurrent, selectedUser, isTeam, isOppConfidence, isS1Exclude, isS2Exclude, isS3Exclude, forecastOppWrapList); if(!userOptionsListTemp.isEmpty()){ userOptionsList.clear(); userOptionsList.addAll(userOptionsListTemp); } } public void searchUtility(String AccountId, String yearStr, String sltUser, Boolean isTeamUser, Boolean isOppConfidenceSet, Boolean isS1ExcludeSet, Boolean isS2ExcludeSet, Boolean isS3ExcludeSet, List<ForecastOpportunityListWrapper> tempforecastOppWrapList){ for(Some accs query){ ... ... //Opportunities List S1 S2 S3 forecastOppWrapList = new List<ForecastOpportunityListWrapper>(); for(Opportunity tempOpp : tempClosedWon.Values()){ ForecastOpportunityListWrapper wrapOpp = new ForecastOpportunityListWrapper(tempOpp); forecastOppWrapList.add(wrapOpp); } } if(!tempforecastOppWrapList.isEmpty()){ for(ForecastOpportunityListWrapper selectedOpp : tempforecastOppWrapList){ if(selectedOpp.selected){ ...//Capture the selected opps logic } } } } //Wrapper Class public List<ForecastOpportunityListWrapper> forecastOppWrapList { get; set; } public Class ForecastOpportunityListWrapper{ public Id oppId { get; set; } public Opportunity opp {get; set;} public Boolean selected {get; set;} public ForecastOpportunityListWrapper(Opportunity o){ opp = o; selected = false; } } }
- SATHISH REDDY.
- February 06, 2020
- Like
- 0
Hierarchy Custom setting value not working as expected in validation rule
Hi All,
The detailed question is posted here. Please take a look & give you suggestions.
https://salesforce.stackexchange.com/questions/269679/hierarchy-custom-setting-in-validation-rule
Thanks,
Sathish
The detailed question is posted here. Please take a look & give you suggestions.
https://salesforce.stackexchange.com/questions/269679/hierarchy-custom-setting-in-validation-rule
Thanks,
Sathish
- SATHISH REDDY.
- July 16, 2019
- Like
- 0
Long text area data split into multiple inputfields on visualforce page
Hi All,
I have a VFP with list of accounts where i capture weekly account updates. Im trying to capture answers(which will be a lengthy one) for 10 questions on that VFP and store that on a single long text area field on account with a separation between each QA.
Then i want to retrieve that longtext area field and do the reverse of what i did earlier, which is to split all the question and answers and show them on respective locations.
As im not storing each question separately instead storing all in one field. What would be the better way to do this as i dont want to create too many long text area fields to capture each Q&A nor i want to go for custom object. Pls let me know your inputs.
Thanks in Advance!
I have a VFP with list of accounts where i capture weekly account updates. Im trying to capture answers(which will be a lengthy one) for 10 questions on that VFP and store that on a single long text area field on account with a separation between each QA.
Then i want to retrieve that longtext area field and do the reverse of what i did earlier, which is to split all the question and answers and show them on respective locations.
As im not storing each question separately instead storing all in one field. What would be the better way to do this as i dont want to create too many long text area fields to capture each Q&A nor i want to go for custom object. Pls let me know your inputs.
Thanks in Advance!
- SATHISH REDDY.
- April 04, 2019
- Like
- 0
View State Error while working on 200+ records which are editable
Hi All,
Hope someone could help me resolve this issue. I have an Accounts List visualforce page with 3 tabs which shows 200+ records each which are editable from this vf page. However am hitting the view state error which am unable to get around with. Below is the VF page & Controller
Hope someone could help me resolve this issue. I have an Accounts List visualforce page with 3 tabs which shows 200+ records each which are editable from this vf page. However am hitting the view state error which am unable to get around with. Below is the VF page & Controller
public with sharing class AccListMassUpdateStatusTABController_AC { public List<cContact> contactsList { get; set; } public List<userWrapper> usersList { get; set; } public String passSelectedContactId { get; set; } public String passSelectedContact { get; set; } public String passSelectedContactTitle { get; set; } public List<Contact> contacts; public List<User> users; public Boolean view { get; set; } public Boolean edit { get; set; } public List<aAccount> lstaAccs { get; set; } public Id accId { get; set; } public Account agencyAcc; public Id selaccId { get; set; } public String passSelectedUserId { get; set; } public String passSelectedUser { get; set; } public emailWrapper emailWrap { get; set; } public String varTabId { get; set; } public AccListMassUpdateStatusTABController_AC() { varTabId = 'Directx'; view = true; edit = false; contactsList = new List<cContact >(); usersList = new List<userWrapper>(); lstaAccs = new List<aAccount>(); if(Apexpages.currentPage().getParameters().containsKey('Id')){ accId = Apexpages.currentPage().getParameters().get('Id'); } else{ fetchlstaAccs(); } } public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again fetchlstaAccs(); } public String sortDir { get { if(sortDir == null) { sortDir = 'desc'; } return sortDir; } set; } public String sortField { get { if(sortField == null) { sortField = 'CreatedDate'; } return sortField; } set; } /* public String tabName { get { if (tabName == null) {tabName = 'Primary'; } return tabName; } set; } */ public List<aAccount> fetchlstaAccs() { //get{ String SOQL = ''; // if (!lstaAccs.isEmpty()) lstaAccs.clear(); Id ownerid = Userinfo.getUserId(); system.debug('lstaAccsBeforeQuery == ' + varTabId + ' lstaAccs == ' + lstaAccs); if(varTabId == 'Primary') { SOQL = 'SELECT Id,Name,Contacts__c,current_status__c,Background__c,Next_Steps__c, Activity_Type__c, Meeting_Type__c,'; SOQL += 'lastmodifieddate FROM Account WHERE OwnerId=:ownerid '; SOQL += ' order by ' + sortField + ' ' + sortDir + ' LIMIT 500'; }else if(varTabId == 'Secondary') { SOQL = 'SELECT Id,Name,Contacts__c,current_status__c,Background__c,Next_Steps__c, Activity_Type__c, Meeting_Type__c,'; SOQL += 'lastmodifieddate FROM Account WHERE Secondary_Account_Owner__c != \'\' and Secondary_Account_Owner__c=:ownerid '; SOQL += ' order by ' + sortField + ' ' + sortDir + ' LIMIT 500'; }else if(varTabId == 'Directx'){ SOQL = 'SELECT Id,Name,Contacts__c,current_status__c,Background__c,Next_Steps__c, Activity_Type__c, Meeting_Type__c,'; SOQL += 'lastmodifieddate FROM Account WHERE Direct_Beta_Client__c = true'; SOQL += ' order by ' + sortField + ' ' + sortDir + ' LIMIT 500'; } lstaAccs.clear(); for(Account a: database.query(SOQL)) { lstaAccs.add(new aAccount(a, a.Id, a.Name, a.current_status__c, a.Background__c, a.Next_Steps__c, a.Activity_Type__c, a.Meeting_Type__c, string.ValueOf(a.lastmodifieddate))); } } public pageReference setActiveDirectxTab() { varTabId = 'Directx'; if(!lstaAccs.isEmpty()) lstaAccs.clear(); system.debug('varTabIdActive == ' + varTabId); fetchlstaAccs(); return null; } public pageReference setActiveSecondaryTab() { varTabId = 'Secondary'; if(!lstaAccs.isEmpty()) lstaAccs.clear(); system.debug('varTabIdActive == ' + varTabId); fetchlstaAccs(); return null; } public pageReference setActiveTab() { varTabId = 'Primary'; if(!lstaAccs.isEmpty()) lstaAccs.clear(); system.debug('varTabIdActive == ' + varTabId); fetchlstaAccs(); return null; } public class aAccount { public Id AccId { get; set; } public Account Acc { get; set; } public String AccName { get; set; } public String currentstatus { get; set; } public String Background { get; set; } public String NextSteps { get; set; } public String ActivityType { get; set; } public String MeetingType { get; set; } public string LastModified { get; set; } public aAccount(Account acct, Id aAccountId, string aAccName, string acurrentstatus, string aBackground, string aNextSteps, string aActivityType, string aMeetingType, string LastModifiedDate) { system.debug('acct == ' + acct); system.debug('aContacts == ' + aContacts); this.AccName = aAccName; this.Acc = acct; this.AccId = aAccountId; this.currentstatus = acurrentstatus; this.Background = aBackground; this.NextSteps = aNextSteps; this.ActivityType = aActivityType; this.MeetingType = aMeetingType; this.LastModified = LastModifiedDate; } } public pagereference save() { view = true; edit = false; List<Account> lstAccsToUpdate = new List<Account>(); Map<Id, aAccount> mapOrgaAccs = new Map<Id, aAccount>(); List<aAccount> oldaAccs = new List<aAccount>(); String SOQL = ''; if(varTabId == 'Primary') { SOQL = 'SELECT Id,Name,Contacts__c,current_status__c,Background__c,Next_Steps__c, Activity_Type__c, Meeting_Type__c,'; SOQL += 'lastmodifieddate FROM Account WHERE OwnerId = \'' + UserInfo.getUserId() + '\''; SOQL += ' order by ' + sortField + ' ' + sortDir + ' LIMIT 500'; } else if(varTabId == 'Secondary') { SOQL = 'SELECT Id,Name,Contacts__c,current_status__c,Background__c,Next_Steps__c, Activity_Type__c, Meeting_Type__c,'; SOQL += 'lastmodifieddate FROM Account WHERE Secondary_Account_Owner__c != \'\' and Secondary_Account_Owner__c= \'' + UserInfo.getUserId() + '\''; SOQL += ' order by ' + sortField + ' ' + sortDir + ' LIMIT 500'; } else if(varTabId == 'Directx') { SOQL = 'SELECT Id,Name,Contacts__c,current_status__c,Background__c,Next_Steps__c, Activity_Type__c, Meeting_Type__c,'; SOQL += 'lastmodifieddate FROM Account WHERE Direct_Beta_Client__c = true'; SOQL += ' order by ' + sortField + ' ' + sortDir + ' LIMIT 500'; } List<Account> oldAccounts = database.query(SOQL); for(Account a: oldAccounts) { oldaAccs.add(new aAccount(a, a.Id, a.Name, a.current_status__c, a.Background__c, a.Next_Steps__c, a.Activity_Type__c, a.Meeting_Type__c, string.ValueOf(a.lastmodifieddate))); } try { for(aAccount a : lstaAccs){ mapOrgaAccs.put(a.acc.Id, new aAccount(a.acc, a.acc.Id, a.acc.Name, a.acc.current_status__c, a.acc.Background__c, a.acc.Next_Steps__c, a.acc.Activity_Type__c, a.acc.Meeting_Type__c, string.ValueOf(a.acc.lastmodifieddate))); } for(aAccount a: oldaAccs) { if (mapOrgaAccs.containsKey(a.acc.Id) && (mapOrgaAccs.get(a.Acc.Id).currentstatus != a.Acc.Current_Status__c || mapOrgaAccs.get(a.Acc.Id).Background != a.Acc.Background__c || mapOrgaAccs.get(a.Acc.Id).NextSteps != a.Acc.Next_Steps__c || mapOrgaAccs.get(a.Acc.Id).ActivityType != a.Acc.Activity_Type__c || mapOrgaAccs.get(a.Acc.Id).MeetingType != a.Acc.Meeting_Type__c )) { lstAccsToUpdate.add(mapOrgaAccs.get(a.Acc.Id).acc); } } if(!lstAccsToUpdate.isEmpty()) { System.debug('lstAccsToUpdate*** '+lstAccsToUpdate); update lstAccsToUpdate; fetchlstaAccs(); } } catch (DMlException e) { ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Error: Save Failed Due to :' + e); ApexPages.addMessage(myMsg); return null; } return null; } public pagereference cancel() { edit = false; view = true; return null; } public pagereference Edit() { edit = true; view = false; return null; } }
- SATHISH REDDY.
- November 08, 2018
- Like
- 0
System.EmailTemplateRenderException: UNKNOWN_EXCEPTION: StringPlusClobField: clob inconsistent with varchar, and unable to clean varchar
Hi,
I am seeing this error in the recent times when clicked on an image on VF page which calls the following method previewEmail(). (This error was never seen befoere since the past 2 years). Also please find the error message screen shots received by multiple users while clicking the image. This error is inconsistent & hard to replicate.
Error Line as per logs - "emailBody = Messaging.renderStoredEmailTemplate(templateId, con.Id, accId);"
for User 2:
Any help is really appreciated.
Thanks,
Sathish
I am seeing this error in the recent times when clicked on an image on VF page which calls the following method previewEmail(). (This error was never seen befoere since the past 2 years). Also please find the error message screen shots received by multiple users while clicking the image. This error is inconsistent & hard to replicate.
Error Line as per logs - "emailBody = Messaging.renderStoredEmailTemplate(templateId, con.Id, accId);"
public PageReference previewEmail(){ Id accId = ApexPages.currentPage().getParameters().get('accId'); Messaging.SingleEmailMessage emailBody; Id templateId = [SELECT DeveloperName,Id,IsActive,Name FROM EmailTemplate where DeveloperName =: 'Account_Mass_Info'].Id; string[] sendingTo = new String[]{}; for (Email_to_users_List__c cs : Email_to_users_List__c.getall().values()){ sendingTo.add(cs.Email_List__c); } Contact con = new Contact(); con.FirstName = 'Test'; con.LastName = 'Contact'; con.Email = 'no-reply@organization.com'; con.Title = 'Test Title'; insert con; /*Line 271*/ emailBody = Messaging.renderStoredEmailTemplate(templateId, con.Id, accId); emailWrap = new emailWrapper(sendingTo, emailBody.getHTMLBody()); //Use Delete to delete the 'Test Contact' Delete con; Return null; }Error Log:
01:10:45.0 (760618096)|EXCEPTION_THROWN|[271]|System.EmailTemplateRenderException: UNKNOWN_EXCEPTION: StringPlusClobField: clob inconsistent with varchar, and unable to clean varchar 01:10:45.0 (760973008)|SYSTEM_MODE_EXIT|false 01:10:45.0 (761229722)|FATAL_ERROR|System.EmailTemplateRenderException: UNKNOWN_EXCEPTION: StringPlusClobField: clob inconsistent with varchar, and unable to clean varchar Class.AccListMassUpdateStatusTABController_AC.previewEmail: line 271, column 1for User 1:
for User 2:
Any help is really appreciated.
Thanks,
Sathish
- SATHISH REDDY.
- May 26, 2018
- Like
- 0
Matrix Report Subtotals and Totals issue
Hi all,
I am trying to create a Matrix Report on Opportunity with Products and Schedules with a formula on report level.
I want the report subtotals to show the SUM of above values, which is not the case here for Budget(Confidence) subtotals.
I
I have the Budget (Confidence) as a formula field where it is the multiplication of Scheduled Amount (from lineitemshcedules)* confidence percentage (which is a formula field whose field type is percentage holds values like 35%,50%,70%,90%). The summary fields for both are SUM and AVG respectively. Where I understand that the above issue on report is due to mentioning "AVG" on confdence percentage.
I want to achieve just the SUM of all the above Budget Confidences. Any suggestion is really helpful. Thanks!
I am trying to create a Matrix Report on Opportunity with Products and Schedules with a formula on report level.
I want the report subtotals to show the SUM of above values, which is not the case here for Budget(Confidence) subtotals.
I
I have the Budget (Confidence) as a formula field where it is the multiplication of Scheduled Amount (from lineitemshcedules)* confidence percentage (which is a formula field whose field type is percentage holds values like 35%,50%,70%,90%). The summary fields for both are SUM and AVG respectively. Where I understand that the above issue on report is due to mentioning "AVG" on confdence percentage.
I want to achieve just the SUM of all the above Budget Confidences. Any suggestion is really helpful. Thanks!
- SATHISH REDDY.
- July 03, 2017
- Like
- 0
VFP scrolls - Set Focus/landing on the last edited record instead of setting it to top record in the scrollable table
Hi, We have a VF page with scrollable table with some Account records and a Save button at the top of the Table. If we scroll to the middle and try editing any record there, and then click Save, the page redirects the focus position to the top of that table. I want to keep the focus where the last Scroll was left or at the last edited record. Please let me know if anybody faced this issue and were able to get through it.
In the below code, I have removed all the fields shown in the image except for the Activity Date.
In the below code, I have removed all the fields shown in the image except for the Activity Date.
<apex:page sidebar="false" controller="Test" standardStylesheets="true"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/JavaScript" /> <style> .table-container { Width: 100.5%; height: 400px; border: 1px solid black; margin: 10px auto; background-color: #FFFFED; position: relative; /* or absolute */ padding-top: 30px; /* matches height of header */ } .table-container-inner { overflow-x: hidden; overflow-y: auto; height: 100%; Width: auto; } .heading-bg { background-color: #66C87D; height: 30px; /* matches padding of table-container */ position: absolute; top: 0; right: 0; left: 0; border-bottom: 1px solid black; } table { width: auto; } .heading { position: absolute; top: 0; font-weight: bold; text-align: center; } </style> <apex:form id="formId"> <apex:pageMessages id="msgId"/> <apex:pageBlock Title="Accounts List" mode="inlineEdit" id="acc_list" > <apex:pagemessages /> <apex:pageBlockButtons > <apex:commandButton action="{!Edit}" id="editButton" value="Edit"/> <apex:commandButton action="{!save}" id="saveButton" value="Save"/> <apex:commandButton action="{!cancel}" onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/> </apex:pageBlockButtons> <!-- ***Detail Mode*** --> <apex:outputpanel rendered="{!view}" id="view"> <apex:actionStatus id="loading" > <apex:facet name="start" > <center><img src="/img/loading32.gif" /> Loading.... Please Wait... </center> </apex:facet> </apex:actionStatus> <div class="table-container"> <div class="heading-bg"></div><div class="table-container-inner"> <table id="schTable" > <thead><tr><td><div class="heading" style="width: 60px;word-wrap:break-word;">Activity Date</div></td></tr></thead> <tbody> <apex:repeat value="{!lstaAccs}" var="a"><tr onmouseover="this.style.backgroundColor='#e3f3ff';" onmouseout="this.style.backgroundColor='#ffffff';"> <td><div style="width: 80px;word-wrap:break-word;"> <apex:outputField value="{!a.Acc.Due_Date__c}" title="Due Date"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField></div> </td></tr></apex:repeat> </tbody> </table> </div></div> </apex:outputpanel> </apex:pageBlock> </apex:form> <script> var $ = jQuery.noConflict(); $(document).ready(function(){ $("#toggleId").click(function(){ $("#detailTblId").toggle(); if($("#detailTblId").css('display')=='none'){ $('#linkTextId').html('Click here to show the Contact information in the Tabular form.'); }else{ $('#linkTextId').html('Click here to Hide.'); } }); }); </script> </apex:page>
- SATHISH REDDY.
- May 18, 2017
- Like
- 0
Datepicker position issue
On our page we have a scrollable table with date input fields. However, whenever we scroll the table up and down and select date input field, the date picker pops up in the position where the table row would have started on the page(which would be obviously at the bottom with out scroll). So, often that is outside of the bounds of our scrollable table.
The Activity Date aka Due_Date__c datepicker shows at the bottom of the page outside of the scrollable table as show in the images. Can some one help with this pls.
The Activity Date aka Due_Date__c datepicker shows at the bottom of the page outside of the scrollable table as show in the images. Can some one help with this pls.
<apex:page sidebar="false" controller="Test" standardStylesheets="true"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/JavaScript" /> <style> .table-container { Width: 100.5%; height: 400px; border: 1px solid black; margin: 10px auto; background-color: #FFFFED; position: relative; /* or absolute */ padding-top: 30px; /* matches height of header */ } .table-container-inner { overflow-x: hidden; overflow-y: auto; height: 100%; Width: auto; } .heading-bg { background-color: #66C87D; height: 30px; /* matches padding of table-container */ position: absolute; top: 0; right: 0; left: 0; border-bottom: 1px solid black; } table { width: auto; } .heading { position: absolute; top: 0; font-weight: bold; text-align: center; } </style> <apex:form id="formId"> <apex:pageMessages id="msgId"/> <apex:pageBlock Title="Accounts List" mode="inlineEdit" id="acc_list" > <apex:pagemessages /> <apex:pageBlockButtons > <apex:commandButton action="{!Edit}" id="editButton" value="Edit"/> <apex:commandButton action="{!save}" id="saveButton" value="Save"/> <apex:commandButton action="{!cancel}" onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/> </apex:pageBlockButtons> <!-- ***Detail Mode*** --> <apex:outputpanel rendered="{!view}" id="view"> <apex:actionStatus id="loading" > <apex:facet name="start" > <center><img src="/img/loading32.gif" /> Loading.... Please Wait... </center> </apex:facet> </apex:actionStatus> <div class="table-container"> <div class="heading-bg"></div><div class="table-container-inner"> <table id="schTable" > <thead><tr><td><div class="heading" style="width: 60px;word-wrap:break-word;">Activity Date</div></td></tr></thead> <tbody> <apex:repeat value="{!lstaAccs}" var="a"><tr onmouseover="this.style.backgroundColor='#e3f3ff';" onmouseout="this.style.backgroundColor='#ffffff';"> <td><div style="width: 80px;word-wrap:break-word;"> <apex:outputField value="{!a.Acc.Due_Date__c}" title="Due Date"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField></div> </td></tr></apex:repeat> </tbody> </table> </div></div> </apex:outputpanel> </apex:pageBlock> </apex:form> <script> var $ = jQuery.noConflict(); $(document).ready(function(){ $("#toggleId").click(function(){ $("#detailTblId").toggle(); if($("#detailTblId").css('display')=='none'){ $('#linkTextId').html('Click here to show the Contact information in the Tabular form.'); }else{ $('#linkTextId').html('Click here to Hide.'); } }); }); </script> </apex:page>
- SATHISH REDDY.
- May 17, 2017
- Like
- 1
Datepicker position issue
On our page we have a scrollable table with date input fields. However, whenever we scroll the table up and down and select date input field, the date picker pops up in the position where the table row would have started on the page(which would be obviously at the bottom with out scroll). So, often that is outside of the bounds of our scrollable table.
The Activity Date aka Due_Date__c datepicker shows at the bottom of the page outside of the scrollable table as show in the images. Can some one help with this pls.
The Activity Date aka Due_Date__c datepicker shows at the bottom of the page outside of the scrollable table as show in the images. Can some one help with this pls.
<apex:page sidebar="false" controller="Test" standardStylesheets="true"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/JavaScript" /> <style> .table-container { Width: 100.5%; height: 400px; border: 1px solid black; margin: 10px auto; background-color: #FFFFED; position: relative; /* or absolute */ padding-top: 30px; /* matches height of header */ } .table-container-inner { overflow-x: hidden; overflow-y: auto; height: 100%; Width: auto; } .heading-bg { background-color: #66C87D; height: 30px; /* matches padding of table-container */ position: absolute; top: 0; right: 0; left: 0; border-bottom: 1px solid black; } table { width: auto; } .heading { position: absolute; top: 0; font-weight: bold; text-align: center; } </style> <apex:form id="formId"> <apex:pageMessages id="msgId"/> <apex:pageBlock Title="Accounts List" mode="inlineEdit" id="acc_list" > <apex:pagemessages /> <apex:pageBlockButtons > <apex:commandButton action="{!Edit}" id="editButton" value="Edit"/> <apex:commandButton action="{!save}" id="saveButton" value="Save"/> <apex:commandButton action="{!cancel}" onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/> </apex:pageBlockButtons> <!-- ***Detail Mode*** --> <apex:outputpanel rendered="{!view}" id="view"> <apex:actionStatus id="loading" > <apex:facet name="start" > <center><img src="/img/loading32.gif" /> Loading.... Please Wait... </center> </apex:facet> </apex:actionStatus> <div class="table-container"> <div class="heading-bg"></div><div class="table-container-inner"> <table id="schTable" > <thead><tr><td><div class="heading" style="width: 60px;word-wrap:break-word;">Activity Date</div></td></tr></thead> <tbody> <apex:repeat value="{!lstaAccs}" var="a"><tr onmouseover="this.style.backgroundColor='#e3f3ff';" onmouseout="this.style.backgroundColor='#ffffff';"> <td><div style="width: 80px;word-wrap:break-word;"> <apex:outputField value="{!a.Acc.Due_Date__c}" title="Due Date"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField></div> </td></tr></apex:repeat> </tbody> </table> </div></div> </apex:outputpanel> </apex:pageBlock> </apex:form> <script> var $ = jQuery.noConflict(); $(document).ready(function(){ $("#toggleId").click(function(){ $("#detailTblId").toggle(); if($("#detailTblId").css('display')=='none'){ $('#linkTextId').html('Click here to show the Contact information in the Tabular form.'); }else{ $('#linkTextId').html('Click here to Hide.'); } }); }); </script> </apex:page>
- SATHISH REDDY.
- May 17, 2017
- Like
- 1
Code Coverage Failure Your code coverage is 73%. You need at least 75% coverage to complete this deployment
I did run all tests in my sandbox and also tried to run them each individually - the overall avg code coverage is around 88%. However, when i try to validate my change set in prod, it is throwing an error saying "Code Coverage Failure Your code coverage is 73%. You need at least 75% coverage to complete this deployment."
None of the test classes failed. Now i'm stuck at a place where it is unable to show what's causing this error nor any directives.
I would really appreciate your help! Thanks!
None of the test classes failed. Now i'm stuck at a place where it is unable to show what's causing this error nor any directives.
I would really appreciate your help! Thanks!
- SATHISH REDDY.
- October 19, 2020
- Like
- 0
Design quest - whats the recommended way to track an opportunity amount being used and reallocate the unused balance
To all the sf experts out here, trying to get your inputs for a use case that i’m trying to incorporate. Use case: We have a currency field called “Amount Owed” on opportunity which holds an $ value. It is calculated by user based on any unused amount for that opportunity. Example if an opp Amount = $1000 and only $800 was spend in reality, then the Amount Owed = $200 which will then be applied to future opportunities under that account. (Note: This Amount Owed can be applied to a single oppty or to multiple opportunities.)
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance!
Question: That said, business needs a way to track where, when and to which Opportunities was this $200 got applied to as a credit. Also they want the ability to run reports showing this.
My Idea: Thinking on to create a custom object named “AmountHeld” which would hold the actual amount owed on the oppty record and then have a child record associated to “Amount Held” called “AmountDistributed” which would then hold the credited amount value along with oppty name to which credit was applied to.
Please let me know if i’m thinking in the right direction in regards to business logic implementation & also reporting perspective? if not pls share your inputs. Thanks in advance!
- SATHISH REDDY.
- August 24, 2020
- Like
- 0
Visualforce - Expandable table rows showing inner table (No Aura)
Hello everyone,
I'm have a table which shows the list of Opportunities. I want to show an inner table whenever an opportunity row is clicked. Similar to the following. However, i'm unable to achieve this & not sure what i might be missing. Please share your inputs. Thanks in advance!
I'm trying to something similar & even tried the following example which didnt work.
https://www.soliantconsulting.com/blog/multi-tiered-tables-in-visualforce/?unapproved=382305&moderation-hash=7a67877d361da32c66a3507d496a06c3#comment-382305
I'm have a table which shows the list of Opportunities. I want to show an inner table whenever an opportunity row is clicked. Similar to the following. However, i'm unable to achieve this & not sure what i might be missing. Please share your inputs. Thanks in advance!
<table> <thead > <tr> <th>Opportunity</th> <th>Type</th> <th>Start</th> <th>End</th> <th>Budget</th> <th>More ($)</th> </tr> </thead> <tbody> <apex:repeat value="{!wrap}"> <tr> <td>{!wrap.a}</td> <td>{!wrap.b}</td> <td>{!wrap.c}</td> <td>{!wrap.d}</td> <td>{!wrap.e}</td> <td>{!wrap.f}</td> </tr> <!--Inner Table--> <tr> <div> <table id="newtable"> <thead id="newth"> <tr> <th colspan="1">Jan</th> <th colspan="1">Feb</th> <th colspan="1">Mar</th> <th colspan="1">Apr</th> <th colspan="1">May</th> <th colspan="1">Jun</th> <th colspan="1">Jul</th> <th colspan="1">Aug</th> <th colspan="1">Sep</th> <th colspan="1">Oct</th> <th colspan="1">Nov</th> <th colspan="1">Dec</th> </tr> </thead> <tbody> </tbody> </table> </div> </tr> </apex:repeat> </tbody> </table>
I'm trying to something similar & even tried the following example which didnt work.
https://www.soliantconsulting.com/blog/multi-tiered-tables-in-visualforce/?unapproved=382305&moderation-hash=7a67877d361da32c66a3507d496a06c3#comment-382305
- SATHISH REDDY.
- June 18, 2020
- Like
- 0
OpportunityLineItemSchedules group by Date in SOQL
Hi all,
I have a list of products with associated schedules where each schedule has different Revenue and ScheduleDate values. I'm trying to get the get the aggregate of Revenue by DATE across the OpportunityLineItems. However, i'm not sure how to achieve this as i couldn't find any date functions specific to date while DAY_ONLY() will only work for datetime fields. Please share your thoughts & recommendations.
Thanks!
I have a list of products with associated schedules where each schedule has different Revenue and ScheduleDate values. I'm trying to get the get the aggregate of Revenue by DATE across the OpportunityLineItems. However, i'm not sure how to achieve this as i couldn't find any date functions specific to date while DAY_ONLY() will only work for datetime fields. Please share your thoughts & recommendations.
Thanks!
- SATHISH REDDY.
- June 10, 2020
- Like
- 0
Apex Tabs in Visualforce must load data only when clicked
Hello Trailblazers,
I'm trying to design a VFP with TWO apex tabs with each tab having a table with list of records within along with some custom "search" logic. Tab 1 will load the data by default on initial page load but I want tab 2 data to be loaded only when clicked(as a best practice). i also have a custom button within each tab which will just get the specific records onto the table. I'm really having hard time in figuring out how to achieve this as i tried to use the actionfunction ontabenter which didn't work. Please shed some light on what i might be doing wrong or share any examples specific to my use case.
VFP:
Controller:
Thanks in advance!
I'm trying to design a VFP with TWO apex tabs with each tab having a table with list of records within along with some custom "search" logic. Tab 1 will load the data by default on initial page load but I want tab 2 data to be loaded only when clicked(as a best practice). i also have a custom button within each tab which will just get the specific records onto the table. I'm really having hard time in figuring out how to achieve this as i tried to use the actionfunction ontabenter which didn't work. Please shed some light on what i might be doing wrong or share any examples specific to my use case.
VFP:
<apex:page controller="MarginTrackerController" sidebar="false"> <apex:form > <apex:tabPanel title="Margin Tracker" id="tabpanelId" tabClass="activeTab" inactiveTabClass="inactiveTab" value="{!varTabId}"> <apex:tab label="Summary" name="Summary" ontabenter="onClickSummaryTab();" switchType="ajax" id="Summary"> </apex:tab> <apex:tab label="Margin" name="Margin" ontabenter="onClickMarginTab();" switchType="ajax" id="Margin"> <div style="width:800px;float:left;"> <!-- this is the filter used to SearchAction--> <apex:selectList multiselect="false" size="1" value="{!selectedTimeframe}"> <apex:selectOptions value="{!timeframeList}"></apex:selectOptions> </apex:selectList> <apex:commandButton value="Go" action="{!searchAction}" status="status" rerender="formId,oppsPanel"> </apex:commandButton> </div> <p><div class="oppstbldiv"> <table class="oppstbl" id="myOppsTable"> <thead> <tr> <th colspan="1">Opportunity</th> <th colspan="1"> Type</th> <th colspan="1"> Start</th> <th colspan="1"> End</th> <th colspan="1">Net Budget</th> <th colspan="1">Sold Margin ($)</th> <th colspan="1">Sold Margin (%)</th> <th colspan="1">Booking Margin ($)</th> <th colspan="1">Booking Margin (%)</th> <th colspan="1">Revised Margin ($)</th> <th colspan="1">Revised Margin (%)</th> </tr> </thead> <tbody> <apex:repeat value="{!oppList}" var="opp"> <tr> <td style="text-align:left">{!opp.Name}</td> <td>{!opp.Market__c}</td> <td> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!opp.Start_Date__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!opp.End_Date__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Net_Budget__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Sold_Margin__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Sold_Margin_Percentage__c))}"> <apex:param value="{!opp.Sold_Margin_Percentage__c}"/> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Booked_Margin__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Booked_Margin_Percentage__c))}"> <apex:param value="{!opp.Booked_Margin_Percentage__c}"/> </apex:outputText> </td> <td> <apex:outputText value="{0, number, currency}"> <apex:param value="{!opp.Revised_Margin__c}" /> </apex:outputText> </td> <td> <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Revised_Margin_Percentage__c))}"> <apex:param value="{!opp.Revised_Margin_Percentage__c}"/> </apex:outputText> </td> </tr> </apex:repeat> </tbody> </table> </div></p> </apex:tab> <apex:actionFunction action="{!SummaryTab}" name="onClickSummaryTab"/> <apex:actionFunction action="{!MarginTab}" name="onClickMarginTab"/> </apex:tabPanel> </apex:form> </apex:page>
Controller:
public class MarginTrackerController { public List<Opportunity> oppList{get; set;} public Opportunity opp{get;set;} public List<SelectOption> timeframeList{get;set;} public String selectedTimeframe { get; set; } public String varTabId { get; set; } public MarginTrackerController(){ } public pageReference SummaryTab(){ varTabId = 'Summary'; /*some logic to fetch records*/ return null; } public pageReference MarginTab(){ varTabId = 'Margin'; opp = new Opportunity(); timeframeList = new List<SelectOption>(); timeframeList.add(new SelectOption('', '--None--')); selectedTimeframe = ''; oppList = new List<Opportunity>(); oppList = [SELECT Id, Name,Market__c, Start_Date__c, End_Date__c, Net_Budget__c, Sold_Margin__c, Sold_Margin_Percentage__c, Booked_Margin__c, Booked_Margin_Percentage__c, Revised_Margin__c, Revised_Margin_Percentage__c FROM Opportunity ORDER BY createdDate DESC LIMIT 100]; return null; } public void searchAction(){ timeframeList.add(new SelectOption('', '--None--')); timeframeList.add(new SelectOption('Q1', 'Q1')); timeframeList.add(new SelectOption('Q2', 'Q2')); timeframeList.add(new SelectOption('Q3', 'Q3')); timeframeList.add(new SelectOption('Q4', 'Q4')); timeframeList.add(new SelectOption('Date', 'Date')); /*fetch the filtered records here*/ } }
Thanks in advance!
- SATHISH REDDY.
- June 04, 2020
- Like
- 0
Checkbox selection using Wrapper is not passed to controller
Hi All,
This might have been posted several times but i'm unable to workaround this issue using apex & I also looked at all the existing questions similar to this. I have a list of Opps with checkboxes in wrapper and i'm unable to retrieve the selections in apex where it always show false. Any help is really appreciated.
VFP:
Controller:
This might have been posted several times but i'm unable to workaround this issue using apex & I also looked at all the existing questions similar to this. I have a list of Opps with checkboxes in wrapper and i'm unable to retrieve the selections in apex where it always show false. Any help is really appreciated.
VFP:
<apex:page controller="ForecastQuotaUpdateController" sidebar="false" docType="html-5.0"> <apex:form > <apex:pagemessages /> <apex:pageblock > <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search by Acc/Owner/Parent..." title="Type in an Account Name"/> Year : <apex:inputField value="{!history.Year__c}"/> User <apex:selectList multiselect="false" size="1" value="{!selectedUser}"> <apex:selectOptions value="{!userOptionsList}"></apex:selectOptions> </apex:selectList> Team <apex:inputCheckbox value="{!isTeam}"/> Confidence % <apex:inputCheckbox value="{!isOppConfidence}"/> Exclude S1 <apex:inputCheckbox value="{!isS1Exclude}"/> Exclude S2 <apex:inputCheckbox value="{!isS2Exclude}"/> Exclude S3 <apex:inputCheckbox value="{!isS3Exclude}"/> <apex:commandButton value="Search" action="{!searchAction}" status="status" rerender="formId"/> </apex:pageblock> </apex:form> <apex:form id="formId"> <!-- List of Opps --> <div id="oppstblDiv"> <table class="oppstbl" id="myTable"> <thead> <tr> <th colspan="1" style="width:50px;">Select</th> <th colspan="1">Opp Name</th> <th colspan="1">Stage</th> <th colspan="1">Budget</th> <th colspan="1">Owner</th> <th colspan="1">End Date</th> </tr> </thead> <tbody> <apex:repeat value="{!forecastOppWrapList}" var="oppWrap"> <tr> <td><apex:inputCheckbox value="{!oppWrap.selected}"/></td> <td>{!oppWrap.opp.Opportunity_Number__c}</td> <td>{!oppWrap.opp.StageName}</td> <td>{!oppWrap.opp.Budget__c}</td> <td>{!oppWrap.opp.Owner.Name}</td> <td>{!oppWrap.opp.End_Date__c}}</td> </tr> </apex:repeat> </tbody> </table> </div> </apex:form> </apex:page>
Controller:
public class ForecastQuotaUpdateController { public String selectedUser { get; set; } public Boolean isTeam { get; set; } public Boolean isOppConfidence { get; set; } public Boolean isS1Exclude { get; set; } public Boolean isS2Exclude { get; set; } public Boolean isS3Exclude { get; set; } public ForecastQuotaUpdateController(){ isTeam = false; isOppConfidence = false; isS1Exclude = false; isS2Exclude = false; isS3Exclude = false; selectedUser = ''; userOptionsList = new List<SelectOption>(); userOptionsList.add(new SelectOption('', '--None--')); history = new Quota_History__c(); yearCurrent = String.valueOf(System.Today().year()); searchUtility('', yearCurrent,'', false, false, false, false, false, new List<ForecastOpportunityListWrapper>()); } //Search Button public void searchAction(){ List<SelectOption> userOptionsListTemp = new List<SelectOption>(); if(!userOptionsList.isEmpty()){ userOptionsListTemp.addAll(userOptionsList); } if(history.year__c != null) yearCurrent = history.year__c; if(String.isBlank(selectedUser) && isTeam) ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, 'Select a User')); else //Here i'm expecting "forecastOppWrapList" to have "selected" = true after selection on VFP (which isNOT working) searchUtility('', yearCurrent, selectedUser, isTeam, isOppConfidence, isS1Exclude, isS2Exclude, isS3Exclude, forecastOppWrapList); if(!userOptionsListTemp.isEmpty()){ userOptionsList.clear(); userOptionsList.addAll(userOptionsListTemp); } } public void searchUtility(String AccountId, String yearStr, String sltUser, Boolean isTeamUser, Boolean isOppConfidenceSet, Boolean isS1ExcludeSet, Boolean isS2ExcludeSet, Boolean isS3ExcludeSet, List<ForecastOpportunityListWrapper> tempforecastOppWrapList){ for(Some accs query){ ... ... //Opportunities List S1 S2 S3 forecastOppWrapList = new List<ForecastOpportunityListWrapper>(); for(Opportunity tempOpp : tempClosedWon.Values()){ ForecastOpportunityListWrapper wrapOpp = new ForecastOpportunityListWrapper(tempOpp); forecastOppWrapList.add(wrapOpp); } } if(!tempforecastOppWrapList.isEmpty()){ for(ForecastOpportunityListWrapper selectedOpp : tempforecastOppWrapList){ if(selectedOpp.selected){ ...//Capture the selected opps logic } } } } //Wrapper Class public List<ForecastOpportunityListWrapper> forecastOppWrapList { get; set; } public Class ForecastOpportunityListWrapper{ public Id oppId { get; set; } public Opportunity opp {get; set;} public Boolean selected {get; set;} public ForecastOpportunityListWrapper(Opportunity o){ opp = o; selected = false; } } }
- SATHISH REDDY.
- February 06, 2020
- Like
- 0
trigger_on Contact
Both Account and Contact has a picklist field Status_c with values Open,Close,InProgress
account record has 3 child record in contact
if all 3 contact has picklist value = 'close', then account picklist value will get updated to 'close'.
account record has 3 child record in contact
if all 3 contact has picklist value = 'close', then account picklist value will get updated to 'close'.
- himanshu huske 7
- August 07, 2019
- Like
- 0
FieldStatus is a picklist Field. Picklist fields are only supported in certain functions.
Hi, I am trying to set a workflow rule that fires when three of the custom fields on my custom object avaluate as true. This is the formula as I have it now, but I keep recieiving the above error message whenever I check the syntax. Any help would be greatly appreciated.
IF (Status = "Approved"
&& CreatedBy.Profile_Name__c = "IGTD Coronary Area Manager"
&& CreatedBy.UserType = "Hospital")
IF (Status = "Approved"
&& CreatedBy.Profile_Name__c = "IGTD Coronary Area Manager"
&& CreatedBy.UserType = "Hospital")
- Michael McClearn
- August 07, 2019
- Like
- 0
- Anoop Reddy
- August 07, 2019
- Like
- 0
Case_Trigger
In case object there is one custom text field type_c
case has record with any subject, and if we create another record with same subject, type_c field should be populated as 'duplicate'.
and this newly created case should b displayed in related list of previus case record.
case has record with any subject, and if we create another record with same subject, type_c field should be populated as 'duplicate'.
and this newly created case should b displayed in related list of previus case record.
- himanshu huske 7
- August 06, 2019
- Like
- 0
Trigger on Chiled object when parent object field is updated
I Have parent Object and child object
Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)
Need help in writing a trigger :
Scenerio:When ever picklist values are changed ex: IN to OUt or OUT to IN The trigger need to Check the YES filed and immediately and then Uncheck.
Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)
Need help in writing a trigger :
Scenerio:When ever picklist values are changed ex: IN to OUt or OUT to IN The trigger need to Check the YES filed and immediately and then Uncheck.
- KCL
- August 06, 2019
- Like
- 0
I am getting this error when building in Process Builder "The formula expression is invalid: Syntax error. Missing '='". What is wrong with my code?
I am trying to update a record field with type formula. Below is the formula that I have written. Any help?
List<[Order_Item__c> Orders = [SELECT Product_Record_Type__c, Total_Price__c FROM [Order_Item__c]];
Integer total = 0;
for ([Order_Item__c] order : Orders){
IF(order.Product_Record_Type__c == "Building Option",
total += order.Total_Price__c;
)
};
return total;
List<[Order_Item__c> Orders = [SELECT Product_Record_Type__c, Total_Price__c FROM [Order_Item__c]];
Integer total = 0;
for ([Order_Item__c] order : Orders){
IF(order.Product_Record_Type__c == "Building Option",
total += order.Total_Price__c;
)
};
return total;
- Blake Reeves 9
- June 13, 2019
- Like
- 0