+ Start a Discussion
Stevie Burt 7Stevie Burt 7 
I am stuck on Step 4 of the Process Automation Specialist Superbadge. I am receiving the following error:
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: GTJRSNVZ

Here are the Challenge Requirements: 
Create Sales Process and Validate Opportunities
Create a sales process with the required stages and name it RB Robotics Sales Process. Create a record type named RB Robotics Process RT. Add a field to the opportunity page layout as described in the business requirements and create the appropriate validation rule for high-value opportunities.

Hey, nice work on the setup records! Now let’s talk about our sales process. Most of the stages we use are already in Salesforce, but one of the stages we track doesn’t come standard so it would be great if you’d add it. These are the stages we use:  Prospecting, Qualification, Proposal/Price Quote, Negotiation/Review, Awaiting Approval, Closed Won, and Closed Lost. We want all our reps to follow the same process, so everyone should see those stages for every opportunity. 
Oh, and the biggest deals--anything over $100K--have to be approved before they can close. We should have a way to show on the record that the deal is approved--maybe you can add an “Approved” checkbox to the opportunity. Obviously the sales reps shouldn’t be able to check that box. Only system administrators like you and sales managers should be able to check it. By the way, all of us sales managers here have the Custom: Sales Profile in Salesforce.

I have created the following:
  1. Created a new Opportunity Stage: Awaiting Approval (Open, 95%, Pipeline)
  2. Created the following Opportunity Fields:
    1. Approved (Checkbox) Defaulted FALSE
  3. Sales Process:
    1. NAMED: RB Robotics Sales Process
    2. Stages Added:
      1. Prospecting (Open, 10%, Pipeline)
      2. Qualification (Open, 10%, Pipeline)
      3. Proposal/Price Quote (Open, 75%, Pipeline)
      4. Negotiation/Review (Open, 90%, Pipeline)
      5. Awaiting Approval (Open, 95%, Pipeline)
      6. Closed Won (Closed/Won, 100%, Closed)
      7. Closed Lost (Closed/Lost, 0%, Omitted)
  4. Opportunity Record Type:
    1. NAMED: RB Robotics Process RT
    2. Sales Process: RB Robotics Sales Process
    3. This is the only record type and assigned to all profiles. Also using the Opportunity Layout. 
  5. Opportunity Validation Rules:
    1. Approved_Field_Validation
      AND( 
      ISCHANGED(Approved__c), 
      OR( 
      $Profile.Name <> 'System Administrator', 
      $Profile.Name <> 'Custom: Sales Profile' 
      ) 
      )

      2. High_Value_Opportunity_Validation
      AND(
          ISCHANGED( IsClosed ),
          IsClosed = TRUE,
          Amount  > 100000,
          Approved__c  <> TRUE
          )
Im not sure what I am missing. Can anyone assist?
Best Answer chosen by Stevie Burt 7
Apoorv Shukla 8Apoorv Shukla 8
@Stevie, Remove the "ISCHANGED( IsClosed )" form your Validation Rule, I checked the Debug logs and looks like they are inserting a Opportunity with amout as "20000". and this validation rule is not passing in this case. everything else looks perfectly fine for your case.
Please mark this as Best answer if you pass Challenge 4 after this :-)
shra1_devshra1_dev 

Hi,

 

    Please Let me know how to redirect to a page from javascript. This javascript is being called if any event occurs.

 

I was trying with

 

window.location('/apex/Pagename');

 

But it is not working.

 

Please help me...........

 

Regards,

 

shra1

Best Answer chosen by Admin (Salesforce Developers) 
shra1_devshra1_dev

Hey I got it my self

 

It should be :

 

window.Location="someurl";

VarunCVarunC 

Every time I try to run this query i get only 2 results:

 

Attachments[] records = [Select Name, ParentId, OwnerId, Id, Body, ContentType, Description, IsPrivate From Attachment Where Parent.Type IN ('File__c') AND Owner.IsActive = true];

 

I know including "Body" field will limit number of records returned in Eclipse to only 1, BUT I'm using this query in APEX class and in Debug Log as well but I'm only able to read 2 record everytime, but the total count of Attachment record returned from this query Should be 4152 records which it is not giving.

 

Is it some Bug?

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

You'll need to use the query loop syntax, 

 

for (Attachment [] atts : [select name, body from attachment]) {
// do something with atts
system.debug ( atts.size() );
}

Sandra WicketSandra Wicket 
Hi Guys,

this is my code :
public class CreateMultiExtraBoost {

	public List<cBoost> boostList {get; set;}
    Integer listSize {get;set;}
    public Id opportunityId {get;set;}
    public ID finalBoostId {get; set;}
        
    // Constructor 
    public CreateMultiExtraBoost (){
    	opportunityId =  ApexPages.currentPage().getparameters().get('oppId');
    }

	//Methode
	public List<cBoost> getBoosts() {
		if(boostList == null) {
			boostList = new List<cBoost>();
			for(FinalBoost__c c: [select Id, Name from FinalBoost__c ]) {
				boostList.add(new cBoost(c));
			}
		}
		return boostList;
	}

	public PageReference save() {
 
		List<FinalBoost__c> selectedContacts = new List <FinalBoost__c>();
        List<BoostOpp__c> boostItems = new List <BoostOpp__c>(); 
        pagereference oppPage = new pagereference('/' + opportunityId);

		for(cBoost cCon: getBoosts ()) {
			if(cCon.selected == true ) {
				selectedContacts.add(cCon.con);
			}
		}

		System.debug('These are the selected ...');
		for(FinalBoost__c con: selectedContacts) {
			system.debug(con);
		}
        
        for (FinalBoost__c con: selectedContacts) {
            	boostItems.add(new BoostOpp__c());
            	finalBoostId = con.Id;
            
            		for(BoostOpp__c boostIteminList : boostItems) {
                        boostIteminList.Opportunity__c = opportunityId;
                        boostIteminList.FinalBoost__c = finalBoostId;
       	 }
       }
        insert boostItems;
        return oppPage;
	}
    
   
   // WrapperClass
	public class cBoost {
		public FinalBoost__c con {get; set;}
		public Boolean selected {get; set;}

		// Constructor 
        public cBoost(FinalBoost__c c) {
			con = c;
			selected = false;
		}
	}
}

A visualforcepage shows the table of FinalBoost records. I can select records and use them in the save methode.  The BoostOpp__c object is a junction object. It is related to the opportunity and the FinalBoost Object. 

In my loop, i want to create for each selected record one child record and assign the parent id (FinalBoost) to the masterDetail field. At the moment, it creates for each selection one record but allways with the same finalBoostId.  Is there a simple solution for that ? 


Cheers Sandra
Best Answer chosen by Sandra Wicket
Saket Sharma 30Saket Sharma 30
Hi Sandra,

Please find the solution below.
 
public PageReference save() {

List<FinalBoost__c> selectedContacts = new List <FinalBoost__c>();
List<BoostOpp__c> boostItems = new List <BoostOpp__c>(); 
pagereference oppPage = new pagereference('/' + opportunityId);

for(cBoost cCon: getBoosts ()) {
	if(cCon.selected == true ) {
		selectedContacts.add(cCon.con);
    }
}

for (FinalBoost__c con: selectedContacts) {
	
	BoostOpp__c boost = new BoostOpp__c();
    boost.FinalBoost__c = con.Id;
	boost.Opportunity__c = opportunityId;
	boostItems.add(boost);

	
}
insert boostItems;
return oppPage;
}

 
Justin LargeyJustin Largey 
Hi,

Are there any best practices when it comes to setting up version control (VC) in conjuction with using the Force.com IDE?

For example, should I make one big project in the Force.com IDE that contains all the meta data on my site and commit that?  Then any new classes or triggers should be a part of this project, and committed to VC?  Would this mean that for every feature I deploy, the entire site would be deployed, instead of just the changes I made?  

I'm curious what everyone else is doing.

Thanks




Best Answer chosen by Justin Largey
pconpcon
I just recently wrote a blog post about this [1].  I would maintian a repository that contains ALL of your code and configuration and then deploy that to your development sandbox.  From your develpment sandbox you can then choose to deploy only parts with changesets or using the IDE to do a full deploy back to your production instance.  While the post talks about git from the command-line, you could use git from within the IDE with one of the extensions for it.

[1] http://blog.deadlypenguin.com/blog/2014/07/21/using-git-with-salesforce-and-distributed-teams/
cyberdynebotcyberdynebot 
Fairly new to Apex and I have a trigger that checks if a Task is on a Contact and pulls in 2 fields from the Contact record that will update the Task. 

It works fine for one record at a time but when trying to bulk if there are multiple tasks for the same Contact it will only fire for the last Activity in the Trigger.new list and not all that share the same WhoId.

Looks like the Map is only capturing the Contact Id once and then the SOQL query only returns one result. Just need help figuring out the solution so that each Task will get updated with the Contact fields.
 
trigger TaskTrigger on Task (before insert, before update) {

    Map<Id, List<Task>> conIdsMap = new Map<Id, List<Task>>();

    for (Task t : Trigger.new) {
            //Search for Contact on Task
        if (t.whoid != null && t.whoid.getsObjectType().getDescribe().getName() == 'Contact') {
                    List<Task> temp = new List<Task>();
                    temp.add(t);
                    conIdsMap.put(t.whoid, temp);
        }
    }

    if (conIdsMap.size() > 0) {
            for(Contact con : [Select Id, Name, Status__c, Corp_Lead_Score__c from Contact where Id in :conIdsMap.keySet()]) {
                for(Task t :conIdsMap.get(con.Id)){
                    t.Stage__c = con.Status__c;
                    t.Corp_Lead_Score__c = con.Corp_Lead_Score__c;
                }
            }  
        }
}

 
Best Answer chosen by cyberdynebot
Alain CabonAlain Cabon
Hi,
 
    for (Task t : Trigger.new) {
        //Search for Contact on Task
        if (t.whoid != null && t.whoid.getsObjectType().getDescribe().getName() == 'Contact') {
            if (conIdsMap.containsKey(t.whoid)) {
                List<Task> temp = (List<Task>)conIdsMap.get(t.whoid);
                temp.add(t);
            } else {
                List<Task> temp = new List<Task>();
                temp.add(t);
                conIdsMap.put(t.whoid, temp);
            }          
        }
    }

 
sayanasreekanth@gmail.comsayanasreekanth@gmail.com 

Hi All

 

I am getting this error when i write the ontabenter function on the tab.

<apex:tab label="Billing" name="billName" id="tabBilling" ontabenter="callCon('Billing');" style="background-color:white;"  rendered="{!IF(strSearchlevel='1',false,true)}">

<apex:outputText value="{!IF(lstDisputeInfo.size>0,'Yes','No')}" label="Account In Dispute" />

 <apex:actionFunction name="callCon" oncomplete="callCon1();">
                        <apex:param name="firstParam" value="" assignTo="{!Tabselected}"/>
                        </apex:actionFunction>

 

Below is the error. when i remove the ontabenter action it is not throwing the error, but i need to write the ontabenter action in order to capture the clicks on the tab. Please let me know your taughts on this.Appreciate your time and help.

 

The value 'null' is not valid for operator '>'

Error is in expression '{!IF(lstDisputeInfo.size>0,'Yes','No')}' in component <apex:outputText> in page summarypage

 

Best Answer chosen by Admin (Salesforce Developers) 
kiran_mutturukiran_mutturu

try this

 

<apex:outputText value="{!IF(AND(NOT(ISBLANK(lstDisputeInfo)),lstDisputeInfo.size>0),'Yes','No')}" label="Account In Dispute" />

Vatsal GorVatsal Gor 
I have done the exact same thing as they have said in the module. But some how I am getting error like this: 
Challenge Not yet complete... here's what's wrong: 
Can't find the forceContent:fileUpload Lightning component in the 'New Lead' flow. Make sure the field’s unique name is 'Upload_File'
Though I have named the field as 'Upload_File'!!!

I am attaching the screen shot of how I have done it below..
My flow is also active and is also inclued in the page named "Process Automation Home". I don't know what is wrong. Kindly help me. 

User-added imageUser-added image
User-added image
Best Answer chosen by Vatsal Gor
Chris DuarteChris Duarte
I am sorry about this. We discovered that the challenge checker is looking for the second screen name to be Upload_Files (with an s on the end) rather than the lightning component being called Upload_File. We're getting it fixed. In the meantime, if you change the second screen name unique name to Upload_Files, you should be able to get through it.

We made a knowledge article on this (see below). My apologies again. 

https://force.desk.com/customer/portal/articles/2932027-lightning-flow-workaround-for-challenge-guide-users-through-your-business-processes-with-cloud-flow-designer?b_id=13478
Best Answer chosen by Marshall Priest
Ashlie Miller 8Ashlie Miller 8
Looks like you need to go back and do this module first:
https://trailhead.salesforce.com/modules/platform_dev_basics/units/platform_dev_basics_intro

It will then import the data that we're missing.  For some reason though it still didn't create the users Angela Agent or Randy Realtor so you will just need to create those manually then go back and add them to the chatter stream. 

I wish they would add a notice to this module that will inform people to do that first. Good luck :)
IntegrationGuyIntegrationGuy 
global class PublicEmailPreferencesURLRewriter implements Site.UrlRewriter {
    public static final String EMAIL_PROFILE_FRIENDLY = '/profile/';
    public static final String EMAIL_PROFILE_VF_PAGE_BASE = '/PublicEmailPreferences';
    public static final String EMAIL_PROFILE_VF_PAGE = EMAIL_PROFILE_VF_PAGE_BASE + '?' + PublicEmailPreferencesController.URL_PARM_ID + '=';

    global PageReference[] generateUrlFor(PageReference[] urls) {
        
        System.debug('generateUrlFor has been invoked for ' + urls);
        PageReference[] pageRefs = new List<PageReference>();
        
        Set<Id> cIds = new Set<Id>();
        for (PageReference pRef : urls) {
            String urlStr = pRef.getUrl();
            if (urlStr.startsWith(EMAIL_PROFILE_VF_PAGE_BASE)) {
                cIds.add(urlStr.substring(EMAIL_PROFILE_VF_PAGE.length()));
            }
        }
        
        Map<Id, Contact> contactsById = new Map<Id, Contact>([SELECT Id, HashId__c FROM Contact WHERE Id IN :cIds]);
        for (PageReference pRef : urls) {
            String urlStr = pRef.getUrl();
            pageRefs.add(
                urlStr.startsWith(EMAIL_PROFILE_VF_PAGE_BASE) ?
                new PageReference(EMAIL_PROFILE_FRIENDLY + contactsById.get(urlStr.substring(EMAIL_PROFILE_VF_PAGE.length())).HashId__c) :
                pRef
            );
        }
         return pageRefs;
    }
    
    global PageReference mapRequestUrl(PageReference url) {
        
        PageReference pageRef = null;
        
        String urlStr = url.getUrl();
        System.debug('mapping url=' + urlStr);
        
        if (urlStr.startsWith(EMAIL_PROFILE_FRIENDLY)) {
            String hashId = urlStr.substring(EMAIL_PROFILE_FRIENDLY.length());
            if (hashId != '') {
                List<Contact> contacts = [SELECT Id FROM Contact WHERE HashId__c = :hashId];
                if (!contacts.isEmpty()) {
                    pageRef = new PageReference(EMAIL_PROFILE_VF_PAGE + contacts[0].Id);
                } else {
                    pageRef = new PageReference(EMAIL_PROFILE_VF_PAGE);
                }
            }
        }
        return pageRef; 
    }
}
Best Answer chosen by IntegrationGuy
IntegrationGuyIntegrationGuy

This test class worked like a charm :)
<pre>

@IsTest
public class PublicEmailPreferencesURLRewriter_T1{
  @testSetup
  static void setupTestData(){
    test.startTest();
    Contact contact_Obj = new Contact(LastName = 'LastName194', HasOptedOutOfEmail = false);
    Insert contact_Obj; 
    test.stopTest();
  }
  static testMethod void test_generateUrlFor_UseCase1(){
    List<Contact> contact_Obj  =  [SELECT LastName,HasOptedOutOfEmail from Contact];
    
    System.assertEquals(true,contact_Obj.size()>0);
    PublicEmailPreferencesURLRewriter obj01 = new PublicEmailPreferencesURLRewriter();
    obj01.generateUrlFor(new List<PageReference>());
  }

    static testMethod void test_generateUrlFor_UseCase3(){
    List<Contact> contact_Obj  =  [SELECT LastName,HasOptedOutOfEmail from Contact];
    System.assertEquals(true,contact_Obj.size()>0);
    PublicEmailPreferencesURLRewriter obj01 = new PublicEmailPreferencesURLRewriter();
    contact_Obj[0].LastName='test';
    contact_Obj[0].HasOptedOutOfEmail=false;
    Update contact_Obj[0];
    obj01.generateUrlFor(new List<PageReference>());
  }
  
  static testMethod void testURLrewriter()
     {     // I try to create the internal saleforce pageReference<br><br>      
         pageReference myPage = new pageReference('/apex/myPage');
       Test.setCurrentPage(myPage);
       myPage.setRedirect(true);
       List<PageReference> res = new List<PageReference>();
       res.add(myPage);
       res.add(new PageReference('/apex/myPage2' )); 
       // now call the methods<br><br>  
        PublicEmailPreferencesURLRewriter urlClass = new PublicEmailPreferencesURLRewriter ();
        urlClass.mapRequestUrl(myPage);
        urlClass.generateUrlFor(res);
    }
  

    static testMethod void test_mapRequestUrl_UseCase1(){
    PageReference pageRef = Page.PublicEmailPreferences;
    Test.setCurrentPage(pageRef);
    List<Contact> contact_Obj  =  [SELECT LastName,HasOptedOutOfEmail, HashId__c from Contact];
    System.assertEquals(true,contact_Obj.size()>0);
    ApexPages.StandardSetController sc = new ApexPages.StandardSetController(contact_Obj);
    PublicEmailPreferencesURLRewriter obj01 = new PublicEmailPreferencesURLRewriter();
    
    contact_Obj[0].LastName='test';
    contact_Obj[0].HasOptedOutOfEmail=false;
    Update contact_Obj[0];
    obj01.mapRequestUrl(new PageReference('/profile/generatesome random hash code'));
  }
  
  
   static testMethod void test_mapRequestUrl_UseCase2(){
    List<Contact> contact_Obj  =  [SELECT LastName,HasOptedOutOfEmail from Contact];
    System.assertEquals(true,contact_Obj.size()>0);
    PublicEmailPreferencesURLRewriter obj01 = new PublicEmailPreferencesURLRewriter();
    
    obj01.mapRequestUrl(new PageReference('https://fakesite.com'));
  }
  
}

</pre>