• Musunuru Surekha
  • 5 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 15
I have a custom object trigger that has a logic of sending emails to ids based on criteria. It uses email template and org wide address.

So when the record is inserted, the trigger should send emails. I am not recieving any emails. Any idea how to solve this? 

The code is as follows.

Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(emailtemplate.Id, UserInfo.getUserId(), record.Id);
                        List<string> toAddress = new List<string>{"valid address"};

The above code is in @future method.

Not receiving any emails? how to resolve this?  is there any configuration needs to made in SF?
I am getting follwing error when trying to create a new task and link it to incident.

"mytask13: execution of BeforeUpdatecaused by: System.NullPointerException: Attempt to de-reference a null object()"

I am trying update incident who hasn't assigned any template and attached to task.
Those incident who satisfy above condition I want their task's description to be updated and respected incident's template need to update.   

Following is the code I am using .

trigger mytask13 on BMCServiceDesk__Task__c(after update,before update)

        List<BMCServiceDesk__Incident__c> myinc{get;set;}
    for(BMCServiceDesk__Task__c myobject :Trigger.new)
      List<BMCServiceDesk__Task__c> mytask = [SELECT id,name,BMCServiceDesk__FKIncident__c FROM BMCServiceDesk__task__c where BMCServiceDesk__FKIncident__c !='' and BMCServiceDesk__FKIncident__r.BMCServiceDesk__FKTemplate__c = ''];
               myobject.BMCServiceDesk__taskDescription__c = 'task description updated through trigger';
               myobject.BMCServiceDesk__FKIncident__r.BMCServiceDesk__FKTemplate__c= 'a3k7F0000004UNvQAM';
I have two object Offer discount matrix (Custom object) and Order Product (Standard).Offer discount matrix is master table with Discount code and Discount% field. Oreder Product object have Total Discount% field.
whenever any new Order product add how to campare Total discount% in Order Product and Discount% in Offer discount matrix and if it matches populate discount code in Order Project object field.
Note  :There is no any relationship between these two object 
How to achive this requirement? need your expertise.

Thank you in advance.
Hi, I am trying to get all workflow rules and its status(Active or not).I am able to get only Workflow name.Need help......
I have already posted this twice but nobody has been able to help me resolve it. I keep running into an error message "The ActionId specified was invalid for ActionType QuickAction", when I try to deploy an unmanaged package from a Sandbox environment to a Developer Org. I have enabled Chatter and Notes in the Developer org. 

I have been looking for answers / help with this for almost a week. 
  • January 15, 2018
  • Like
  • 0
Hello Community,
I am the marketing and business developer of a German iP Law Company. After our developer left, I was given the task to maintain our SF enterprise platform.
I turn to you with the following problem, that I encounter whenever I try to set a new task or send an e-mail. I assume that the error comes from a project that was started long before I joined the company, and was never really resolved and is now sitting there crippling our SF. Since I want to use SF for marketing campaigns, it is vital to me to have a working e-mail solution.

This is the error message:
Apex script unhandled trigger exception by user/organization: 005Dxxxxxx/00Dxxxxxxx

onTask: execution of AfterInsert

caused by: System.NullPointerException: Argument cannot be null.

Class.System.EncodingUtil.urlDecode: line 25, column 1
Class.TaskHandlers.AfterInsertHandler.handle: line 58, column 1
Class.Triggers.manage: line 58, column 1
Trigger.onTask: line 9, column 1

This is the on-screen error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger onTask caused an unexpected exception, contact your administrator: onTask: execution of AfterInsert

caused by: System.NullPointerException: Argument cannot be null.: Class.System.EncodingUtil.urlDecode: line 25, column 1

This is what I believe is the offending code:

trigger onTask on Task(after delete, after insert, after undelete, 
after update, before delete, before insert, before update) {
    new Triggers()
        .bind(Triggers.Evt.afterinsert, new TaskHandlers.AfterInsertHandler())
        .bind(Triggers.Evt.afterupdate, new TaskHandlers.AfterUpdateHandler())
        .bind(Triggers.Evt.beforeupdate, new TaskHandlers.BeforeUpdateHandler())
        .bind(Triggers.Evt.afterdelete, new TaskHandlers.AfterDeleteHandler()) 

SF support team suggested that I might post this error to the community, hoping to get help. I am not a developer, but I have experience in HTML5, JS, CSS3 and PHP.

Any help is highly appreciated! Thank you very much!
best regards,
I have a custom object called Incentive_Management__c.This custom object has a lookup to the User object.

I  have a lookup relationship incentive__c  in the lead object with Incentive_Management__c.
I want to auto populate the incentive__c field in the lead if the Lead Owner and the User in the custom object Incentive_Management__c matches.
Finished Step 3 already. And also wrote all tests in Step 8. When clicked on "Check Challenge", it gave me this error. Regular error messages specific to the steps usually include a little more information. But this one doesn't. 

I do not remember making any changes that impact the functionality. I tried to take a look into it but could not identify the issue. Here is my code at this time.

User-added image

Product2New page
<apex:page standardcontroller="Product2" extensions="Product2Extension">
    <apex:sectionHeader title="New Product" subtitle="Add Inventory" />
    <apex:pageMessages id="pageMessages" />
    <apex:form id="form" >
        <apex:actionRegion >
            <apex:pageBlock title="Existing Inventory" id="existingInv">
                <apex:chart data="{!Inventory}" width="600" height="400">
                    <apex:axis type="Category" fields="name" position="left" title="Product Family"/>
                    <apex:axis type="Numeric" fields="val" position="bottom" title="Quantity Remaining"/>
                    <apex:barSeries axis="bottom" orientation="horizontal" xField="val" yField="name"/>
            <apex:pageBlock title="New Products" >
                <apex:pageBlockButtons location="top">
                    <apex:commandButton action="{!save}" value="Save" reRender="existingInv, orderItemTable, pageMessages"/>
                <apex:pageBlockButtons location="bottom">
                    <apex:commandButton action="{!addRows}" value="Add" reRender="orderItemTable, pageMessages" />

                <apex:pageBlockTable value="{!productsToInsert}" var="p" id="orderItemTable" >
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.Name.Label}" >
                        <apex:inputText value="{!p.productRecord.Name}" />
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.Family.Label}" >
                        <apex:selectList value="{!p.productRecord.Family}" size="1" multiselect="false">
                            <apex:selectOptions value="{!FamilyOptions}"></apex:selectOptions>
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.IsActive.Label}" >
                        <apex:inputField value="{!p.productRecord.isActive}" />
                    <apex:column headerValue="{!$ObjectType.PricebookEntry.Fields.UnitPrice.Label}" >
                        <apex:inputText value="{!p.pricebookEntryRecord.UnitPrice}" />
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.Initial_Inventory__c.Label}" >
                        <apex:inputField value="{!p.productRecord.Initial_Inventory__c}" />

Product2Extension class
public class Product2Extension {

    public List<ProductWrapper> productsToInsert {get;set;}

    public Product2Extension(ApexPages.StandardController controller){
        productsToInsert = new List<ProductWrapper>();
    public List<SelectOption> GetFamilyOptions() {
		List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE));
        for(PickListEntry eachPicklistValue : Constants.PRODUCT_FAMILY) {
			options.add(new SelectOption(eachPicklistValue.getValue(), eachPicklistValue.getLabel()));
            return options;
    public void AddRows(){
        for (Integer i=0; i<Constants.DEFAULT_ROWS; i++ ){
            productsToInsert.add(new ProductWrapper());

    public List<ChartHelper.ChartData> GetInventory(){
        return ChartHelper.GetInventory();

    public PageReference Save(){
        SavePoint sp = Database.setSavepoint();
        Integer insertedCount = 0;
        try {
            List<Product2> newProducts = new List<Product2>();
            List<PriceBookEntry> pbeList = new List<PriceBookEntry>();
            List<ProductWrapper> filteredProductWrappers = new List<ProductWrapper>();
            for(ProductWrapper eachPW : productsToInsert) {
            	if(!String.isBlank(eachPW.productRecord.Name) && !String.isBlank(eachPW.productRecord.Family) && 
                   eachPW.productRecord.Family!=Constants.SELECT_ONE && eachPW.productRecord.isActive &&
                   eachPW.pricebookEntryRecord.UnitPrice!=null && eachPW.productRecord.Initial_Inventory__c!=null && 
                   eachPW.productRecord.Initial_Inventory__c!=0 && eachPW.pricebookEntryRecord.UnitPrice!=0) {
            for(ProductWrapper eachPW : filteredProductWrappers) {
            Database.SaveResult[] productSaveResults = Database.insert(newProducts, false);
            for(Integer i=0; i<productSaveResults.size(); i++) {
                if(productSaveResults[i].isSuccess()) {
                    PriceBookEntry pbe = filteredProductWrappers[i].pricebookEntryRecord;
                    pbe.Product2Id = productSaveResults[i].getId();
                    pbe.IsActive = true;
                    pbe.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            Database.SaveResult[] pbeSaveResults = Database.insert(pbeList, false);
            //If successful clear the list and display an informational message
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,insertedCount + ' Inserted'));
            productsToInsert.clear();   //Do not remove
            addRows();  //Do not remove
        catch (Exception e){
			System.debug('Exception occured:'+e.getMessage());
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, Constants.ERROR_MESSAGE));            
        return null;
    public class ProductWrapper {
        public Product2 productRecord {get;set;}
        public PriceBookEntry pricebookEntryRecord {get;set;}
        public ProductWrapper() {
            productRecord = new Product2();
            pricebookEntryRecord = new PricebookEntry();

Any advice on how to resolve this or see more error information would be appreciated.

I'm stuck at Advanced Apex Specialist Step #5. I have ccreated SetupTestData() method in OrderTest which calls TestDataFactory.InsertTestData();
However, when I check the status I get error as:

Ensure the setupTestData method is declared properly and inserts data using your testDataFactory method.

There is an assertion failing as well in the log.
Any idea how to solve this?
Hi all,

I'm getting an error while verifying the step 3:
  • Ensure that page performance is improved by only rerendering the table and error messages when a use clicks the Add button.
I have rerender attribute on the Add button but it doesn't work.
Anyone have an answer?

Thank you.
HI All,

Q). What is a Batch Apex,Queueable Apex and @Future methods?, What are the differences between them and when we are going to use these classes?
Can anyone explain these classes.......