• Dhruv Gour 14
  • 0 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
  • 10
email not sent to user .

Trigger : 

trigger checkDuplicateValue on Account (after insert)
        //Get list of Users
        Map<Id,User> userMap = new Map<Id,User>([SELECT Name, Email FROM User]);
        //Get all Ids in order to do a query
        //and bulkify the trigger
        Set<Id> accIdSet = new Set<Id>();
        for(Account a : Trigger.new)
        List<Account> accList = [Select ID, owner.Id, Name, fax, phone 
                                 From Account 
                                 Where Id in :accIdSet];
            //Create a map with the Name and the Owner Id
            //With the Owner Id I can look for the User in the first Map
            Map<String, Id> accMap = new Map<String, Id>();
            for(Account acc : accList)
                accMap.put(acc.Name, acc.owner.Id);
            for(Account acc : Trigger.new)
                String accName = acc.Name;
                    //Double check the name for the new account
                    Id userId = accMap.get(accName);
                    acc.adderror('Account already exists in your Organization with name ' + acc.Name);
                    //Retrieve the owner's email
                    String theEmail = userMap.get(userId).Email;

Class :

public with sharing class EmailHelper
    public static void sendEmail(String theEmail)
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(new String[] {theEmail});
        mail.setSenderDisplayName('My Email');
        mail.setSubject('My email subject');
        mail.setPlainTextBody('Process fails duplicate value');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Hi All,
I am getting error in test class as constructor not defined.
Here is my code
public class myClass_Test
public static testMethod void testMethod() {
        account acc = new account();
        acc.Name = 'test account';
        insert acc ;
        contact con=new contact();
        Obj1__c o = new Obj1__c ();
        o.F1__c = acc.Id;
        o.F2__c= con.LastName;
        insert o;
    PageReference myPage = Page.myPage;
    myPage.getParameters().put('id', o.Id);  
    ApexPages.StandardSetController control = new ApexPages.StandardSetcontroller(o);
    myClass pageControl = new myClass(control); 

Controller Class
public with sharing class myClass 
    private ApexPages.StandardSetController standardController;

    public myClass(ApexPages.StandardSetController standardController)
        this.standardController = standardController;

    public PageReference bumpCases()
        // Get the selected records (optional, you can use getSelected to obtain ID's and do your own SOQL)
        List<Obj1__c> selectedCases = (List<Obj1__c>) standardController.getSelected();

        // Update records       
        for(obj1__c selectedCase : selectedCases)
            if(selectedCase.status__c == 'Saved') 
                selectedCase.status__c = 'Cancelled';

        return null;        

    public PageReference updateCases()
        // Call StandardSetController 'save' method to update (optional, you can use your own DML)
        return standardController.save();   
Visualforce page
<apex:page standardController="obj1__c" extensions="myController" recordSetVar="Items" action="{!bumpCases}">
   <apex:form >
       <apex:pageBlock title="Bump Selected Items">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!updateCases}" value="Confirm"/>
            <apex:pageBlockTable value="{!selected}" var="o">
                <apex:column value="{!o.status__c}"/>

Please help me in this error
What change I need to do
Thanks in Advance

We are developing a system which generates quotes and the sales rep can send them to their clients, We are also selling our products to this company apart from selling the system

The requirement here is the sales rep should be able to upload the third party products in to the system and we should not be able to see them (Even though we are admins as we might look at competitions products)

In short the question is can we avoid admins to see this data?
Hello Experts,

Need your inputs on how we can assign particular records created by this trigger to specific user. Say the record "Website Audit Report and Recommendations" will be assign to User A and the record "Optimize keywords in footer links" will be assign to User B. 


trigger AutoCreateProductionTask on SFDC_Project__c (after insert) {

   List<Production_Task__c> newRecord = new List<Production_Task__c>(); 

   List<String> namePT = new List<String>();
   namePT.add('Website Audit Report and Recommendations');
   namePT.add('Keyword Research');
   namePT.add('Competitor Research');
   namePT.add('Run page speed loading test and make improvements');
   namePT.add('Run site on validator and fix broken links and html errors');
   namePT.add('Run crawl test and redirect any obsolete urls');
   namePT.add('Keyword mapping, meta data creation and implementation');
   namePT.add('Text content creation');
   namePT.add('Upload optimized text content, insert and highlight ketwords');
   namePT.add('Optimize keywords in footer links');
   namePT.add('Optimize alt tags of images');
   namePT.add('Create or improve HTML sitemap page');
   namePT.add('Add breadcrumbs navigation on inner pages');
   namePT.add('Create Google Places listing');
   namePT.add('URL and Directory Submission');
   namePT.add('Create Google Webmaster Tools profile');
   namePT.add('Create Google Analytics profile');
   namePT.add('Create Google Analytics Contact Forms Goal Setup');
   namePT.add('Add in AI Directory');   
   namePT.add('Create and submit xml sitemap to Google');
   namePT.add('Create and publish 1 Press Release');
    for (SFDC_Project__c aim : Trigger.new) {
        if (aim.RecordTypeID == Schema.SObjectType.SFDC_Project__c.getRecordTypeInfosByName().get('AIM Project').getRecordTypeId())
        if (aim.Product_Service__c == 'SEO - Premium'|| aim.Product_Service__c == 'SEO - Pro'|| aim.Product_Service__c == 'SEO - Starter'|| aim.Product_Service__c == 'SEO - Plus')

          for(Integer i = 0; i < namePT.size(); i++){
            Production_Task__c aimTask = new Production_Task__c();
            aimTask.recordTypeId = Schema.SObjectType.Production_Task__c.getRecordTypeInfosByName().get('AIM').getRecordTypeId();
            aimTask.Name = namePT [i];
            aimTask.Due_Date__c = Date.today().addDays(30);
            aimTask.Project__c = aim.Id;
            aimTask.Instructions__c = 'test';
            insert newRecord;


Any assistance is highly appreciated. Thank you. 

I have an requirement that i am tryong to insert Records in to  object after completing insertation operation i want to display reports in vf page 

For example i am inserted 200 records in to x object after completing operation i want to generate report on insertation of 200 records which are successfully inserted and which records failed to insert

Thanks In Advance
Sampath Palli
I have account(parent)
 and contact and address(both are child)
i want to create account,contact,addres in one visual force page and i want to save respected data in respected objects?
How to do pleaser help me.
I want to check in apex whether Lightning is enabled for current Org?
Hi Guys,
I was integrating Instagram  with Salesforce,and getting access_tokek in url like this


i dont know how to get the access token attached with'#'