• Shyama B S
  • SMARTIE
  • 615 Points
  • Member since 2015


  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 0
    Questions
  • 80
    Replies
All, need help with a trigger. This trigger copies record from Contacts standard object to Strategic Contacts custom object. I want this code to copy all Contacts in account and create Strategic Contacts. For example, if account has 4 contacts, then 4 strategic contacts should be created. Code is currently inserting only 1 record. Can someone pls help?
 
trigger StrategicContactAutoCr on Account (after update) {

      List<Dev_che_123__Strategic_Contacts__c> STToInsert = new List<Dev_che_123__Strategic_Contacts__c>();
    
    Map <Id,Contact> ContactMaps = New Map <Id,Contact> ();
    Set <Id> accids = New Set <ID> ();
    for (Account acc: Trigger.New ) {
        if (acc.Strategic_Account__c != null ) {
            accids.add(acc.id);
				    system.debug('total strt accs' + accids);
            
        }
        
    }  
    
    List <Contact> Con = [SELECT AccountID, FirstName, LastName FROM Contact WHERE AccountID IN :accids ];
    system.debug('total Con List' + Con);

    For (Contact C : Con ) {
        If (C.AccountID != null) {
            ContactMaps.put(C.AccountID, c);
                system.debug('total Con List after Put Id and Contact in Map' + Con);
               
                
            }
            
        }
    
          
    
    for (Account acct: Trigger.New ) {
        if (acct.Strategic_Account__c != False ) {
            
            
                Dev_che_123__Strategic_Contacts__c SC = new Dev_che_123__Strategic_Contacts__c ();
  				SC.Dev_che_123__Account__c = acct.id;
				SC.Dev_che_123__First_Name__c = ContactMaps.get(acct.Id).FirstName;
				SC.Dev_che_123__Last_Name__c = ContactMaps.get(acct.Id).LastName;
				STToInsert.add(sc);
            
        }
        		
    }
    
        insert STToInsert;

       
    }

 
I must be doing something very basic wrong.  I'm having a problem creating a connected app.  Step 1 in the  instructions at https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm&language=en_US#basicinfo (https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm&language=en_US#basicinfo) say

"From Setup, enter Apps in the Quick Find box, then select Apps." 

but I can't find the Quick Find box!  When I click on Setup, I'm taken immediately to Force.com setup page, (https://na34.salesforce.com/setup/forcecomHomepage.apexp?setupid=ForceCom&retURL=%2Fhome%2Fhome.jsp). 

I don't see anything marked "Quick Fix."  There is a box that says "Search All Setup"  but when I type Apps in that box, it says it can't find anything.  . 

Can someone tell me what I'm doing wrong?  

Thanks.
 
I'm working on the Creating Wizards with Visualforce Flows challenge and I am getting an error on the Opportunity Name formula that I created. 

The error is: OpportunityName (Formula): The formula expression is invalid: Syntax error. Found 'Company_Name'

Here is my formula (I have it set to Text): ​{!Company_Name} "-" {!Last_Name}
e.g. trading since (year)

I've been told to start with a number field (4 digit limit) but need a hint on where to start with the sytax! Any help appreciated.
HI All,

Please help me for test class for the below Trigger im getting just 62% coverage
trigger ContactTrig on Account(after update) {
List<Contact> ListContact = new List<Contact>();
Set<ID> acctIds = new set<ID>();
    for(Account acct : trigger.new) {
        if(Trigger.oldMap.get(acct.id).Name != acct.Name){
             acctIds.add(acct.Id);
        }
    }
    if(acctIds.size() > 0){
        for(Contact con : [SELECT id,Email,FirstName,LastName,phone,Title__c,Account.Name,status__c, AccountId FROM Contact WHERE AccountId IN : acctIds AND RecordTypeid = '034D0000000CVERt'])
          WebServiceCallout.sendNotification(con.Id,con.Email,con.FirstName,con.LastName,con.phone,con.Title__c,con.Account.Name,con.status__c);
        }
    }
}
My Test class is as below please let me know what im missing 
@istest
public class ContactTrig2TestClass{
 static void Accountcreate(){
Account c =new Account();
c.Name = 'Testcon';
c.Type = 'Agency';
insert c;
c.Name = 'Testcontract';
update c;
}
 }



 
Hi,

I am trying to complete trail head, and came across Visualforce Pages stuff, I dont see any results when I do a search in quick serach box after going in setup.

Please let me know if I am doing any mistake, any help is really appreciated.
Greetings, I have a formula field in my Salesforce instance that concatenates the contact records first and last names FirstName & LastName. Some of my contacts do not have first names, in the full name formula both fields are taken into account and thus a contact with a last name in this field would appear as " Friend" rather than "Friend." I am wondering if there is a solution to trim the first space in the field.

Hope it helps.
How to Query the child records of parent object on which trigger is running and fetch the respective child records of the enitity.
I'm using a couple of functions for filling a list of contacts.   This is done by passing a list of custom BD__c object records to another function (retrieveTopOneHundred) which, in short, uses the BD__c objects to retrieve a list of contacts.  Problem I'm trying to solve:  I want to keep fetching contacts using the retrieveTopOneHundred function until the contactsListB list reaches 100 contacts.  How can I rewrite the code below so that I can do this without having to write a bunch of nested "if(contactsListB.size() < 100)...find more contacts based on the next set of BD__c records"?  I was hoping to use a Do While loop or something simple, but I just couldn't arrive at anything that worked. Thanks in advance for your help!

CODE:
public String TopOneHundred()
{
    List < sObject > bd = StdSetControllerBD.getRecords();
    List < Contact > contactsListB = retrieveTopOneHundred(bd);
    if (contactsListB.size() < 100)
    {
        StdSetControllerBD.next(); //if we have less than 100 contact records then we will go get more by repeating the process, this time with the next set of bd records in the StdSetControllerBD
        List < BD__c > nextRoundOfBdRecords = new List < BD__c > ();
        for (sObject sob: StdSetControllerBD.getRecords())
        {
            BD__c sobd = (BD__c) sob;
            nextRoundOfBdRecords.Add(sobd);
        }
        contactsListB.addAll(retrieveTopOneHundred(nextRoundOfBdRecords));
        if (contactsListB.size() < 100)
        {
            StdSetControllerBD.next(); //if we have less than 100 contact records then we will go get more by repeating the process, this time with the next set of bd records in the StdSetControllerBD
            List < BD__c > thirdRoundOfBdRecords = new List < BD__c > ();
            for (sObject sob: StdSetControllerBD.getRecords())
            {
                BD__c sobdd = (BD__c) sob;
                thirdRoundOfBdRecords.Add(sobdd);
            }
            contactsListB.addAll(retrieveTopOneHundred(nextRoundOfBdRecords));
        }
    }

    String contactsJSON = JSON.serializePretty(contactsListB);
    return contactsJSON;​
}
Hi there,

I'm very new to Apex Triggers, so apologies if this is a silly question...

I'm trying to get a Rich Text field on my Campaign object - Extra_Info_for_Reminder__c - to populate a Rich Text field on my Campaign Member object - Course_Email_Info_2__c​. As far as I understand, copying the fields via a workflow strips the text of any HTML (which we need to retain).

In Developer Console the following code doesn't show up with any errors, but it not currently providing the desired affect...
 
trigger richtextupdate on Campaign (after update, after insert) {

for(Campaign C:trigger.new){
    if(C.Extra_Info_for_Reminder__c!=null){
CampaignMember.Course_Email_Info_2__c=C.Extra_Info_for_Reminder__c;
}
}
}

Hopefully there's a very simple explaination. As I say, bit of a fish out of water with this stuff, so any help is much appreciated.

Thanks very much.
I'm following a Trailhead excerise in creating a custom object. In the tutorial it advices to create a help page for the custom object. The action to carry out is:

From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.

However, when I type Visualforce into the setup > search box nothing appears. 

I did a search on these forums and it seems I need to enable developer mode, so I followed a link to v34 of the Visualforce guide which has a step by step guide on how to enable developer mode. Incidentally this guide is badly out of date as none of the links in any of the steps are correct. I messed around and eventually found the screen in which I could activate developer mode. Saved. 

I still cannot see Visualforce in Settings > Search.  What am I doing wrong?

Thanks in advance.
I have the current field formula in place  - (Score_of_A+Score_of_B+Score_of_C+ Score_of_D) / 4
What I am looking to do is modify the formula to divide by the number of fields that are actually populated. For example
If 3 out of the 4 fields are populated divide by 3
If 2 out of the 4 fields are populated divide by 2
If 1 our of the 4 fields are poulated divide by 1
I'm not even sure where to start. Any suggestions would be appreciated.
  • August 26, 2015
  • Like
  • 0
I am trying to complete the Trailhead Module "Data Security: Controlling Access to Fields"

Create a Profile and Permission Set to properly handle field access

The Marketing Coordinator and Account Manager both require access to view and update Account Records, but only the Account Manager should be able to see and edit certain fields. Specifically, only the Account Manager should be able to see and edit the Rating field. The Marketing Coordinator should not be able to see or edit the Rating field. Create one profile and one permission set with the appropriate field-level security to solve for this use case.The profile must be named 'Basic Account User' and result in an API name of 'Basic_Account_User'. It should use the 'Salesforce' user license type.
The permission set must be named ‘Account Rating’ and result in an API name of 'Account_Rating'.



This is driving me absolutely insane.  

I created a custom profile named Basic Account User, it is Read on the Account Object and the Rating field is unchecked for both Read and Edit.  
I created a permission set named Account Rating, it is Read & Edit on the Account Object and the Rating field is checked for both Read & Edit.  
I have both the profile and permission set assigned to the other user in my Dev Org.  I logged in as this user and the permission set is functioning as expected.  With the permission set he can see and edit the rating field, without the permission set he can't see it at all.

Yet I keep receiving the "The 'Basic Account User' profile did not have the appropriate object and field-level security for the Account object" error message.

What am I missing? I have tried every conceivable combination.

I read the thread titled "Create and enable a compact layout : Trailhead Challenge" and I thought that was my answer but I did the link to the Contact page correctly and I am still getting the error.  I have refreshed my developer version of Salesforce and I have refreshed my Salesforce1 app on my phone.  

CompactLayout1
The actual compact layout I built in the wizard but could not locate the place to set it as the default until I search by title and it was already set as default in teh Contact page.
Contact Compact Layout
Below is the screenshot from my phone showing the page layout is working properly.
Cell Phone Screen Shot of compact Layout

Any suggestions?
 

Sam
 

Hi,
I am trying the Trailhead challange for Formula fields at https://developer.salesforce.com/trailhead/point_click_business_logic/formula_fields#challenge

and the challenge is to add a formula field on the Case object referencing the Last Activity Date of the Account object.

But the Account object doesn't have a Last Activity Date (and neither does the Case object) - so how can I complete that challenge?
Error:
User-added image
I performed all these steps :
First Step is to creat Profile Basic Account User
Setup->Manage Users->Profiles->New Profile->Basic Account User(select any pre-existing profile with user license type"salesforce")
Once you click on Save-> Object Setting-> Account-> Object Permissions-> select Read and Edit
In the Field Permissions deselect  Read and Edit Permissions of Rating Field....
Assign this profile to a user and check 
Next Step to create permission set 
Setup->Manage Users->Permission Sets->New->Account Rating(select user license type"salesforce")
Once you click on Save-> Object Setting-> Account-> Object Permissions-> In the Field Permissions select  Read and Edit Permissions of Rating Field....
 
Hello,

I have a custom VF controller that is very simple, but has some valudations built in upon save.  I am trying to run a test to cover the controller, but the test I am running is not covering lines that I think it should.  Lines 12-16, 32 & 33, and 36 & 37 are not covered, but I specifically have the criteria in my test to fire those rules.  Does anyone know what I am missing to cover those lines?  Thanks!

VF Controller:
public class VF_DealSummaryController{

public List<Deal_Summary__c> DS {get; set;}

    private final Opportunity opp;
    public VF_DealSummaryController(ApexPages.StandardController myController){
        DS = new List<Deal_Summary__c>();
        opp=(Opportunity)myController.getrecord();
    }

    public Deal_Summary__c DS2 = new Deal_Summary__c();
        public void DealSummary(){
       
            DS2.Opportunity__c = opp.Id;
            DS2.Legal_Name__c = opp.Account.Id;
            DS.add(DS2);
        }

    public PageReference save() {
    
        Boolean error=false;
        
        IF(DS2.Effective_Date__c == null){
            DS2.Effective_Date__c.addError('You must enter an Effective Date.');
            error = true;
        }
        IF(DS2.Net_Payment_Term_Days__c == null){
            DS2.Net_Payment_Term_Days__c.addError('You must enter the Net Payment terms.');
            error = true;
        }
        IF(DS2.Net_Payment_Term_Days__c < 45){
            DS2.Net_Payment_Term_Days__c.addError('Net Payment Terms cannot be less than 45 days.');
            error = true;
        }
        IF(DS2.Auto_Renewal__c == TRUE && DS2.Notice_To_Terminate_Days__c == null){
            DS2.Notice_To_Terminate_Days__c.addError('Please input the # of days notice.');
            error = true;
        }
        IF (error) {return null;}
    insert DS;
        {
        PageReference RetPage = new PageReference('/apex/DealSummaryViewTest?id=' + DS[0].id + '#RTF');
        RetPage.setRedirect(true);
        return RetPage; 
       }
    }
}

Controller Test:
public class TestDSController {

public static testMethod void testMyController1() {    
       
    Account acct1 = TestCreateRecords.createAcct(0);
    insert acct1;

    Opportunity opp1 = TestCreateRecords.createOppNew(acct1.Id);
    insert opp1;
  
    Deal_Summary__c DS1 = new Deal_Summary__c();
      DS1.Opportunity__c = opp1.Id;
      DS1.Legal_Name__c = opp1.AccountId;
      DS1.Effective_Date__c = date.newinstance(2025,1,31);
      DS1.Net_Payment_Term_Days__c = 30;
      DS1.Auto_Renewal__c = TRUE;
      DS1.Notice_To_Terminate_Days__c = null;
 
    ApexPages.StandardController DealSumm1 = new ApexPages.standardController(opp1);
    VF_DealSummaryController DealSummCont1 = new VF_DealSummaryController(DealSumm1);
    DealSummCont1.DS.add(DS1);
    DealSummCont1.save();
}
}

 
All, need help with a trigger. This trigger copies record from Contacts standard object to Strategic Contacts custom object. I want this code to copy all Contacts in account and create Strategic Contacts. For example, if account has 4 contacts, then 4 strategic contacts should be created. Code is currently inserting only 1 record. Can someone pls help?
 
trigger StrategicContactAutoCr on Account (after update) {

      List<Dev_che_123__Strategic_Contacts__c> STToInsert = new List<Dev_che_123__Strategic_Contacts__c>();
    
    Map <Id,Contact> ContactMaps = New Map <Id,Contact> ();
    Set <Id> accids = New Set <ID> ();
    for (Account acc: Trigger.New ) {
        if (acc.Strategic_Account__c != null ) {
            accids.add(acc.id);
				    system.debug('total strt accs' + accids);
            
        }
        
    }  
    
    List <Contact> Con = [SELECT AccountID, FirstName, LastName FROM Contact WHERE AccountID IN :accids ];
    system.debug('total Con List' + Con);

    For (Contact C : Con ) {
        If (C.AccountID != null) {
            ContactMaps.put(C.AccountID, c);
                system.debug('total Con List after Put Id and Contact in Map' + Con);
               
                
            }
            
        }
    
          
    
    for (Account acct: Trigger.New ) {
        if (acct.Strategic_Account__c != False ) {
            
            
                Dev_che_123__Strategic_Contacts__c SC = new Dev_che_123__Strategic_Contacts__c ();
  				SC.Dev_che_123__Account__c = acct.id;
				SC.Dev_che_123__First_Name__c = ContactMaps.get(acct.Id).FirstName;
				SC.Dev_che_123__Last_Name__c = ContactMaps.get(acct.Id).LastName;
				STToInsert.add(sc);
            
        }
        		
    }
    
        insert STToInsert;

       
    }

 
Can someone please help me write a test class for an after insert trigger. I am newbie to Salesforce and trying to figure out the promote the trigger from Sandbox to Production. Below is the trigger source code.
 
trigger SetUserExpirationDate on User (after insert) {    
    List<User> ul = new List<User>();
    for (User u : Trigger.new) {    
        User usertoUpdate = new User(Id = u.Id, Expiration_Date__c = u.CreatedDate.addYears(3));
        ul.add(usertoUpdate);            
    }
    update ul;
}

 
I must be doing something very basic wrong.  I'm having a problem creating a connected app.  Step 1 in the  instructions at https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm&language=en_US#basicinfo (https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm&language=en_US#basicinfo) say

"From Setup, enter Apps in the Quick Find box, then select Apps." 

but I can't find the Quick Find box!  When I click on Setup, I'm taken immediately to Force.com setup page, (https://na34.salesforce.com/setup/forcecomHomepage.apexp?setupid=ForceCom&retURL=%2Fhome%2Fhome.jsp). 

I don't see anything marked "Quick Fix."  There is a box that says "Search All Setup"  but when I type Apps in that box, it says it can't find anything.  . 

Can someone tell me what I'm doing wrong?  

Thanks.
 
i am trying to loop thu an object 2 ways . the wrong way with a lop and the right way with a list.
neither one works.

the wrong way, with a loop looks like this.

// First get the new invoice statement
integer i = 0;
for (invoice_statement__c[] inv : [SELECT id FROM Invoice_Statement__c]);
     {
//WHERE Description__c='My new invoice'];
   system.debug(inv.id );
     }

i get this error message.
Line: 7, Column: 14
Variable does not exist: inv.id

i am too confused to write the syntax with a list. and could use some help.

 
Hi,

I am getting error like this : Unknown method 'Incident__cStandardController.SaveRecord()'

Below is my code:
*************************


Apex Page :
******************
<apex:page standardController="Incident__c" extensions="IncGetParmAdminClass" sidebar="false" showHeader="false">
.....
.....
.....

<apex:commandButton value="Submit" action='{!SaveRecord}'/>

Apex Class:
*******************
public class IncGetParmAdminClass
{
  Public Incident__c param {get; set;}
  private ApexPages.StandardController standard_Controller;
    public IncGetParmAdminClass(ApexPages.StandardController standard_Controller)
    {
        param = new Incident__c();
        .................
       ..................
      public PageReference SaveRecord(){
            insert param;
            
            return null; 
        }


For some of my earlier requerement, I have done in the same way and it is working perfect. but for the above senario, I am getting error like this. 
Am I doing any mistake on declaring custom action name inside standard controller page tag. Please help me out.

Thanks in advance.
SAKTI


 
I'm working on the Creating Wizards with Visualforce Flows challenge and I am getting an error on the Opportunity Name formula that I created. 

The error is: OpportunityName (Formula): The formula expression is invalid: Syntax error. Found 'Company_Name'

Here is my formula (I have it set to Text): ​{!Company_Name} "-" {!Last_Name}
I'm creating a formula field that determins the number of days between today and the last activity date for a case's account. I've created a Number formula of TODAY() - Last_Activity_Date__c. It's telling me the Challenge is not complete because "The 'Days_Since_Last_Update__c' formula field did not return the correct number of days between an Account’s Last Activity Date and today." 

Can someone help? Is my formula wrong?
Thanks in advance!
I am getting an error when i run the trigger shown below.  The error I get is:
"Error:Apex trigger acctTeamUpdate caused an unexpected exception, contact your administrator: acctTeamUpdate: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.acctTeamUpdate: line 23, column 1" 

and my trigger:
 
trigger acctTeamUpdate on Account (after update, after insert) {
    for (Account a : Trigger.new)
    {

        Territory__c t;
    
        try {                                                    // get the Territory record for the territory specified in the Account Record
            t = [SELECT ID, Name, ASD_Sales_Rep__c, PSD_Sales_Rep__c, Service_Sales_Rep__c, Switch_Sales_Rep__c, Transmission_Sales_Rep__c, Rep_Agency__c
                FROM Territory__c
                WHERE ID=:a.Territory__c LIMIT 1];
        }
        catch(exception ex){ 
            System.debug(' Failed Territory Record Retrieval');
        }
        if(Trigger.isInsert)
        {
            
        }
        if(Trigger.isUpdate)
        {
            try
            {
                a.Rep_Agency__c = t.Rep_Agency__c;
                
            }
            catch(exception ex)
            { 
                System.debug(' Failed Account Update');
            }
        }
    }
}

it says that the
a.Rep_Agency__c field is read only?  And the Rep_Agency__c field is of type Lookup(Account)
Any idea why I might be getting this error?

Thanks.
  • October 01, 2015
  • Like
  • 0
Can anyone tell me how to search for a '%' inserted as text at the end of a Text string?

    LIKE '%[%]'  

This works fine in SQL. How would this work in SOQL?
I need to map a custom text area field from the lead object to the opportunity (currently mapped) as well as the contact object.  All the same field type and name.

 
Lucid is a fast growing market research technology firm based in New Orleans focused on bringing efficiency and automation to online survey sampling. By using our technology infrastructure, our clients gain global access to survey respondents while maintaining control and quality.

Lucid is looking for a Salesforce Administrator to join the Technology team in the New Orleans office. The Salesforce Administrator is technically savvy, analytical, process-oriented individual andl will work closely with our business development team, finance team, and Business Analysts to provide the day-to-day configuration, support, maintenance and improvement of Lucid’s Salesforce.com platform. The successful candidate will embrace the challenge of solving critical business problems in a fast paced environment.

http://lucid.applytojob.com/apply

Responsibilities

Manage and administer all aspects Salesforce.com and products within the Salesforce ecosystem, including Pardot and Desk.com.
Manage the configuration and re-architecting of our Salesforce instance to align with our new corporate structure.
Act as the primary product manager as we develop a Salesforce integration with our flagship product, Fulcrum. Work with users of the Fulcrum platform, external consultants, and internal developers to design, test, and implement the integration.
Work with users to make sure that processes and configuration conforms to best practices.
Manage change requests from all business units; lead regular meetings with representatives from each business unit to discuss upcoming changes and potential conflicts.
Develop reports and dashboard.
Act as help desk for all users of Salesforce, Pardot, and Desk, as well as products that integrate with Salesforce (e.g. DocuSign).
Develop training for users and keep training materials up to date.
Participate in and serve as a resource for any Salesforce related projects and projects that touch or use Salesforce data.

Qualifications

Bachelors Degree and 2+ years administering Salesforce.
Salesforce.com Administrator or Advanced Administrator certification preferred.
Strong understanding of the Salesforce platform, with the ability to build objects, formula fields, workflows, custom views, and other content.
High degree of proficiency in Excel, including expertise with IndexMatch, Vlookup, and Pivot Tables
Proven ability to analyze and understand business requirements, offer suggestions, and implement solutions.
Hot new company exploding with growth needs a self motivated, client facing Senior Developer!!  Full benefits and more!  Contact me at nancy@tech2resources.com