• Head In Cloud
  • NEWBIE
  • 358 Points
  • Member since 2016

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 87
    Replies
I'm attempting to create an APEX test class with the below syntax but receive the error shown in the image.
 
@isTest
public class TestCAPdataTiers {
    static testMethod void insertNewCAPdata() {
    
        CAPdata__c capdataToCreate = new CAPdata__c();
        
        capdataToCreate.Business_Review_Form_Owner__c = '005d0000002vay0';
        capdataToCreate.TierElitePreferredJobs__c = 36;
        capdataToCreate.Points__c = 100000;
        capdataToCreate.Account__r.Volume_Market__c = 'A';
    
        insert capdataToCreate;
        }
}

User-added image
This is my APEX Trigger shown below. Any help to resolve is appreciated. 

Thanks!
 
trigger CAPdataTiers on CAPdata__c (before insert,before update) {
    for (CAPdata__c CAP : Trigger.new) {
        if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Midwest'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Midwest'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 25;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Northeast'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 50;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Northeast'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 25;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Pacific Northwest'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 50;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Pacific Northwest'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 50;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('South/West'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('South/West'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
    }
}

 
What is wrong with the syntax in this statement?  I have a syntax error on the first if statement line saying unexpected token:

public pagereference savesamp()
        //Prevent user from entering a sample request using an Inactive account or one without an address line 1 -07/19/16 MT
    {    
        if({!ISPICKVAL(Account.Account_Status__c, "Inactive")} || {!Account.Address_Line_1__c} == '')
        
        ApexPages.Message SampleNotAllowed = new ApexPages.Message(ApexPages.Severity.ERROR,'Account must be active and contain           an address in order to raise a sample request.'); 
        ApexPages.addMessage(SampleNotAllowed);
        return null;

try{
          
        upsert samObj;
        
      }Catch(Exception ex)
      {
         ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,ex.getMessage());
         ApexPages.addMessage(errorMessage);
        return null;
      }
     return new pagereference('/'+samObj.id);
    }
 
Hello,

I'm trying to filter a SOQL subquery (in the SELECT section) to be not null, but I hadn't had any luck so far.
The query:
SELECT (SELECT AccountId, ActivityDate, CreatedDate, CreatedById FROM OpenActivities WHERE ActivityDate = LAST_N_WEEKS:8 Order by ActivityDate desc) FROM Account

The query is showing some OpenActivies results, but far more null results that I don't need

Any ideas ?

Results

 
Hello,

a custom object is Private.
For a certain profile i have give access read, write, edit

but still the user of this profile is not able to see a record which is created(owner) by some other user

bothe the user in context have no roles assigned.

Am i missing some basic concepts here ?
 
Hello,

I have a number field in Contact Object(Parent).
I want to create multiple records in Case Object(child)  based on the value in  number field in Contact Object.

Thanks,
Tejas
Hi,
I am trying simple example of SOQL, to diaplay name of all the accounts, using below statements:-
Account act = [Select name from Account];
for (List <Account> a: act)
{
system.debug('Account Name'+ a);
}
It thorws an error-Loop must iterate over a collection type: Account
What, I am missing here?
Want to utilize HTML Email templates when sending email via Salesforce1, but I don't see how to do that.  Any ideas?
I've uploaded vfimagetest and I'm pretty sure my code is ok (I saw the other static resources trailhead issue on the forum)

Am I missing something in the code or is trailhead acting funny?

User-added image
User-added image

Thanks for any/all help!

best,
Jacob

I just want to iterate through the list I create and set a field stating whether there are attachments on the object to no  when conditions are met via a before delete trigger.  I'm getitng variable does not exist


if(parentObjId.startsWith('a0x')&& Trigger.isdelete)
             List<CRM_Outreach__c> CRMNoList = [select id, Attachment_Added__c from CRM_Outreach__c where id =: Trigger.New[0].ParentId];  
             // query to see if there are still attachments under the object
             // If there were less than two, i.e. 1 attachment, then there will be zero after the after delete trigger.
           if(CRMNolist.size()<2){
               for (CRM_Outreach__c CRM : CRMNoList)
             {
                   CRM.Attachment_Added__c = 'No';

I am creating a VF page with a custom controller which upserts a Contact record, then allows navigation to a new VF page (called SurveyQuestion1). This works fine; however, I would also like to pass the ID of the Contact into it through the URL, but no matter what syntax I use (using this page: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_system_pagereference.htm) I run into problems.
The following works without passing the Contact ID; can someone suggest how I can amend it to pass the ID?

public class EnterDetailsController {

    public Contact contact { get; private set; }

    public EnterDetailsController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        contact = (id == null) ? new Contact() : 
            [SELECT FirstName, LastName, Email FROM Contact WHERE Id = :id];
    }
 
    public PageReference save() {
        try {
            upsert(contact);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
   
        }
        //  After successful Save, navigate to SurveyQuestion1 page
            PageReference NextPage = Page.SurveyQuestion1;
                NextPage.setRedirect(true);
            return NextPage;
        
    }
}
Hi,

When trying to add our production environment to Eclipse force.com API, I'm running into a error (See screenshot). Never encountered this and have no idea what it means. Anyone knows? Please advise.

Many thanks,
Eran

User-added image

 
HiGuys,

I have a checkbox in accounts called "rating".

I have output text in vf page to display the rating.

when the checkbox is checked in account i want to display the rating in vf page.

please help me to achieve this.

Thanks,
Suresh kumar.
 
Hello
        I am new in Salesforce .I created VF page controller class.In that I got the month year and want to convert month which is in Number format into string so for this I wrote the method Getmonth() but having error.Please help.
public class UploadCSVFileController
{
    private final Account acct;
    public id accountid{get;set;}
    public string Mon{get;set;}
    public string Yrs{get;set;}
    Public Period__c cp;
    Public String Monthinletter;
    Public String MonthWithZero;
    public UploadCSVFileController(apexpages.standardcontroller stdcontroller)
    {
        system.debug('Inside Constructor');
        acct=(Account)stdcontroller.getrecord();
        accountid=acct.id;
        System.debug('The account id'+accountid);
        Mon = ApexPages.currentPage().getParameters().get('mm');
        Yrs = ApexPages.currentPage().getParameters().get('yyyy');
        System.debug('The current month is:'+Mon);
        System.debug('The current year is:'+Yrs);   
        MonthWithZero=Mon.leftpad(2,'0');
        string monthyear=MonthWithZero+'-'+yrs;
        cp=[select id,name,Month_Year__c from Period__c WHERE name=:monthyear];
        system.debug(cp);
    }
    public String GetMonth(MonthWithZero)
    {
        if(MonthWithZero=='01')
        {
            Monthinletter='January';
            return Monthinletter;    
        }    
    }
}
I'm attempting to create an APEX test class with the below syntax but receive the error shown in the image.
 
@isTest
public class TestCAPdataTiers {
    static testMethod void insertNewCAPdata() {
    
        CAPdata__c capdataToCreate = new CAPdata__c();
        
        capdataToCreate.Business_Review_Form_Owner__c = '005d0000002vay0';
        capdataToCreate.TierElitePreferredJobs__c = 36;
        capdataToCreate.Points__c = 100000;
        capdataToCreate.Account__r.Volume_Market__c = 'A';
    
        insert capdataToCreate;
        }
}

User-added image
This is my APEX Trigger shown below. Any help to resolve is appreciated. 

Thanks!
 
trigger CAPdataTiers on CAPdata__c (before insert,before update) {
    for (CAPdata__c CAP : Trigger.new) {
        if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Midwest'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Midwest'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 25;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Northeast'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 50;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Northeast'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 25;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Pacific Northwest'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 50;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Pacific Northwest'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 75;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 50;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('A') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('South/West'))
        {
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('South/West'))
        {
            CAP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 50;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
    }
}

 
I Think this trigger  would be  easy, but I'm struggling.

This is my requirement i am trying to accomplish with trigger and below is where i got it till.
 How would I write a trigger to set the  active price book on opportunity creation.?
also,other conditions to be satisfied are:
1.If only one pricebook is active,select that.
2.If more than 1 pricebook are active,then select standard pricebook(if its active) if not then select next pricebook based on created date.

My problem is with second point.How can i check if list contains 'Standard pricebook',?  list.contains is not working.
Please suggest.

Below is my code:
 
trigger PBTrigger  on Opportunity (before insert) {

     List<Pricebook2> PBList =  [select id,name from Pricebook2];
     
     if(PBList.Size() <1){
         for(opportunity o:trigger.new){
             if(o.Pricebook2 == null){
                 o.PriceBook2Id =PBList[0].id;
              }
            }
        }
}

 
I have a flow that I am launching from a custom button on the account page, which launches a visualforce page in a new window. For some reason my flow isn't showing a Finish button. It shows the Previous and Next buttons in the flow, and they are selected to show in the Flow itself which makes me think my custom button page isn't written correctly. When the flow is at the end, I click next and it does end the flow and opens the account page in that same window (which is another separate issue because i want it to close the current window and bring me to the accoutn page where i started - in my instance I have the account page open where I started my flow, and then another duplicate window at the end of the flow.) Any help regarding the finish button would be appreciated!

<apex:page standardController="Account"> <apex:variable var="varGuest" value="{!Account.ID}"></apex:variable> <flow:interview name="Call_Script" finishlocation="{!URLFOR('/'+varGuest)}"> <apex:param name="varGuest" value="{!Account.ID}"/> </flow:interview> </apex:page>
 
I use Apex about once a year or so, so I still struggle every time...

Trying to update Billing Address fields on a Person Account based on a Lookup field that refers to another account record.

Basically, I have a lookup field called Employer and I want to pull in the address from the Employer account into the related person account. I've tried searching for some code to start with, but haven't had any luck. 

Any help is appreciated!
Brian
What is wrong with the syntax in this statement?  I have a syntax error on the first if statement line saying unexpected token:

public pagereference savesamp()
        //Prevent user from entering a sample request using an Inactive account or one without an address line 1 -07/19/16 MT
    {    
        if({!ISPICKVAL(Account.Account_Status__c, "Inactive")} || {!Account.Address_Line_1__c} == '')
        
        ApexPages.Message SampleNotAllowed = new ApexPages.Message(ApexPages.Severity.ERROR,'Account must be active and contain           an address in order to raise a sample request.'); 
        ApexPages.addMessage(SampleNotAllowed);
        return null;

try{
          
        upsert samObj;
        
      }Catch(Exception ex)
      {
         ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,ex.getMessage());
         ApexPages.addMessage(errorMessage);
        return null;
      }
     return new pagereference('/'+samObj.id);
    }
 
Hello,

I'm trying to filter a SOQL subquery (in the SELECT section) to be not null, but I hadn't had any luck so far.
The query:
SELECT (SELECT AccountId, ActivityDate, CreatedDate, CreatedById FROM OpenActivities WHERE ActivityDate = LAST_N_WEEKS:8 Order by ActivityDate desc) FROM Account

The query is showing some OpenActivies results, but far more null results that I don't need

Any ideas ?

Results

 
I have a query inside a trigger and one of the conditions is that a reference field (lookup) is not null. My query is:
List<Contract> contratti=[Select Id,Opportunitl__c from Contract 
        where Id IN: Trigger.new AND Opportunitl__c !=null ];

where Opportunitl__c is the reference field, but it's not working. The list "contratti" contains Contracts with an empty Opportunitl__c. What is wrong in this query?
plz help me with this.
1) I am having an User (let’s say Stephan). Who has a custom Field called : Immediate Manager. (Hierarchy Field)
2) We have an Account (let’s Say : Google). Whose owner is Stephan.
3) Whenever I will deactivate that user, then that User’s Immediate manager will become owner of all Account, which Stephan owned. Code with all best practices. (Bulkifying).
Also write Test method for this , which should cover at least 85%. functionality should be checked if working or not in test Class also.

trigger RecordOwnerChangeEx on User (after update) {   
 list<user> u=[select id, isActive, ManagerId from user where id in:trigger.new];
  // list<account> acc=[select id, ownerId from Account where ownerId in: ids ];
    list<account> ac=new list<account>();
    for(User uu:u){
        if(uu.IsActive == false && uu.ManagerId != null){
        for(account a:[select id, ownerId from Account where ownerId =:uu.id ]){
            a.ownerId = uu.ManagerId;
            ac.add(a);
        }
    }
    }
    update ac;

Tried with this but not working.