• Travis Lee 6
  • NEWBIE
  • 65 Points
  • Member since 2015
  • Sr. Salesforce Administrator
  • TubeMogul

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
In "Using the Report Builder" under the "Reports and Dashboards" module, I am having trouble setting the filters for a report.

The challenge asks that I set a filter for stages that are not equal to Closed Won or Closed Lost. I have set and reset these filters within the report but Trailhead keeps telling me that I have to add them. 

I have provided pictures here to show what I am referring to. Thank you!This shows the filter I placed for closed won and closed lost opportunitiesThis is the message that is displayed when I check my work
Hey there,

I'm trying to create a class that I can invoke with a process. The process exists on the Opportunity and needs to invoke a class that will unsync the current quote. I'm a new developer, but this is what I've researched so far. Based on this blog post (http://salesforcekings.blogspot.com/2014/09/how-to-automatically-sync-new-quote.html), I can't use a trigger. I found an example of a class that I think will accomplish what I need, but it's a future class (not required for my scenario, I don't think). Here is that example that I'm pilfering:
public class QuoteAutoSyncUtil
{
    @future
    public static void syncQuote(Map<Id, Id> quoteMap)
    {
        Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>();
        for(Id currentQuote : quoteMap.keyset())
        {
            Opportunity opp = new Opportunity();
            opp.Id = quoteMap.get(currentQuote);
            opp.SyncedQuoteId = currentQuote;
            oppMap.put(opp.Id, opp);
        }
        update oppMap.values();
    }
}

Since I need it to be invocable by a process, I believe I need to include the @InvocableMethod annotation. When I do, I get an error that says the Map<Id, Id> is an unsupported parameter type and I have to use List instead. So I started switching the Maps over to Lists and this is where I get stuck because the "get" parameter on line 11 below isn't compatible with List methods I guess? This is where my knowledge starts to drop off.
 
public class QuoteAutoSyncUtil
    {
        @InvocableMethod
        public static void syncQuote(List<Quote> quoteList)
        {
            List<Opportunity> oppList = new List<Opportunity>();
           
            for(Id currentQuote : quoteList.keyset())
            {
                Opportunity opp = new Opportunity();
                opp.Id = quoteList.get(currentQuote);
                opp.SyncedQuoteId = currentQuote;
                oppList.add(opp);
            }
           
            Integer oppSize = oppList.size();
            update oppList[oppSize -1 ];
     
        }
       
    }

Any advice on the code above would be great, but I'd also like to understand a bit more about why I'm experiencing these errors with Maps vs. Lists. Thanks in advance!

Travis
Hey everyone,

I'm trying to create a class that I can invoke with a process but I'm having some trouble. The process exists on the Opportunity and needs to invoke a class that will unsync the current quote. I found a blog post that gave me a headstart on the framework for the class but apparently there's a conflict between future and invocable methods and it definitely must be invocable. I'm not a very experienced developer so any advice would be appreciated! Code below
 
public class QuoteAutoSyncUtil
{
    @future
    public static void syncQuote(Map<Id, Id> quoteMap)
    {
        Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>();
        for(Id currentQuote : quoteMap.keyset())
        {
            Opportunity opp = new Opportunity();
            opp.Id = quoteMap.get(currentQuote);
            opp.SyncedQuoteId = currentQuote;
            oppMap.put(opp.Id, opp);
        }
        update oppMap.values();
    }
}
Thanks!

Travis
 
Hey Everyone, 
I'm a novice developer trying to set up an integration between the Salesforce REST API and our platform. Since we utilize OneLogin for SSO, this is the flow that I was using https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm . I've followed all the steps concerning appending the security token to the end of the password, relaxed IP restrictions on the connected app, and configured the permitted users to "admin approved users are pre-authorized" but I'm still receiving the following error:

"error": "invalid_grant",
"error_description": "authentication failure"
}
Which I believe refers to the credentials being incorrect from what I've googled thus far. But, I'm confident that the credentials are correct because I used them to successfully log in to the Apex dataloader. 


Here's a screenshot of the request I'm attemping with the error message (minus the user credentials): User-added image


Any help or advice would be much appreciated!
Hi All,

Trying to improve the code coverage of a test class I've written. The trigger is meant to unset a checkbox on the opportunity after the opportunity line items are updated, the checkbox is True and the line items have revenue schedules. Right now it's at 31% but I'm unsure how to replicate the necessary actions to push it beyond that? Any advice is appreciated! I'm trying to avoid becoming one of those developers whose code barely makes it to production. Here's the trigger I'm trying to cover and below that is the class that I've written so far. 

Trigger:
trigger unsetScheduler on OpportunityLineItem (after update) 
{
	Set<Id> setId = new Set<Id>();
	for (OpportunityLineItem allLineItems : trigger.new) 
	{
		if(allLineItems.HasRevenueSchedule == true)
		{
			setId.add(allLineItems.OpportunityId);
		}	
	}
	
	if(setId.size() > 0 )
	{
		Map<Id,Opportunity> mapOpp = new Map<Id,Opportunity>( [select id,Scheduling__c from Opportunity where id in :setId and Scheduling__c = true]);
		List<Opportunity> lstOppToUpdate = new List<Opportunity>();
		
		for (OpportunityLineItem allLineItems: trigger.new)
		{
			if(allLineItems.HasRevenueSchedule == true && mapOpp.containsKey(allLineItems.OpportunityId) )
			{ 
				Opportunity opp = mapOpp.get(allLineItems.OpportunityId);
				
				opp.Scheduling__c = false;
				lstOppToUpdate.add(opp);
			} 
		}
		if(lstOppToUpdate.size()>0)
		{
			update lstOppToUpdate;
		}
	}	
	
}

Class:
@isTest
public class testUnsetScheduler {
    static testMethod void updateLineItem() {
        
        Account acc = new Account();
        acc.Name = 'Test Account';
        
        insert acc;
        
        Opportunity opp = new Opportunity();
        opp.Name = 'TestOpportunity';
        opp.AccountId = acc.Id;
        opp.CloseDate = System.Today().addDays(10);
        opp.StageName = 'Negotiation';
        opp.Projected_Start_Date__c = System.Today().addDays(15);
        opp.Projected_End_Date__c = System.Today().addDays(20);
        opp.Type = 'Media';
        opp.Programmatic_TV_Rev__c = 'No';
        opp.Scheduling__c = True;
        
        insert opp;
                  
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.OpportunityId = opp.Id;
        oli.Budget__c = 10000;
        oli.New_Rate__c = 0.05;
        oli.UnitPrice = 0;
        oli.Quantity = 1;
        oli.PricebookEntryId = '01u7000000GB8I1';
        
        insert oli;
        
        oli.Budget__c = 15000;
        oli.New_Rate__c = 0.10;
        update oli;
       
    } 
}

 
Attempting to write a trigger that will unset a checkbox on the opportunity after an opportunity line item has been updated. We have a complex Flow/Process relationship and this checkbox needs to be after update (as far as I can tell) to hit at the right time according to order of operations. I've never come across this error before, but I'm a relatively novice developer. Hoping I'm not missing something obvious?
 
trigger unsetScheduler on OpportunityLineItem (after update) {
        for (OpportunityLineItem allLineItems: trigger.new) {
             if (Opportunity.Scheduling__c == TRUE && OpportunityLineItem.HasRevenueSchedule == TRUE)
        { 
        Opportunity.Scheduling__c = FALSE;
        } 
    }
}

 
Hey there,

I'm trying to create a class that I can invoke with a process. The process exists on the Opportunity and needs to invoke a class that will unsync the current quote. I'm a new developer, but this is what I've researched so far. Based on this blog post (http://salesforcekings.blogspot.com/2014/09/how-to-automatically-sync-new-quote.html), I can't use a trigger. I found an example of a class that I think will accomplish what I need, but it's a future class (not required for my scenario, I don't think). Here is that example that I'm pilfering:
public class QuoteAutoSyncUtil
{
    @future
    public static void syncQuote(Map<Id, Id> quoteMap)
    {
        Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>();
        for(Id currentQuote : quoteMap.keyset())
        {
            Opportunity opp = new Opportunity();
            opp.Id = quoteMap.get(currentQuote);
            opp.SyncedQuoteId = currentQuote;
            oppMap.put(opp.Id, opp);
        }
        update oppMap.values();
    }
}

Since I need it to be invocable by a process, I believe I need to include the @InvocableMethod annotation. When I do, I get an error that says the Map<Id, Id> is an unsupported parameter type and I have to use List instead. So I started switching the Maps over to Lists and this is where I get stuck because the "get" parameter on line 11 below isn't compatible with List methods I guess? This is where my knowledge starts to drop off.
 
public class QuoteAutoSyncUtil
    {
        @InvocableMethod
        public static void syncQuote(List<Quote> quoteList)
        {
            List<Opportunity> oppList = new List<Opportunity>();
           
            for(Id currentQuote : quoteList.keyset())
            {
                Opportunity opp = new Opportunity();
                opp.Id = quoteList.get(currentQuote);
                opp.SyncedQuoteId = currentQuote;
                oppList.add(opp);
            }
           
            Integer oppSize = oppList.size();
            update oppList[oppSize -1 ];
     
        }
       
    }

Any advice on the code above would be great, but I'd also like to understand a bit more about why I'm experiencing these errors with Maps vs. Lists. Thanks in advance!

Travis
Hey everyone,

I'm trying to create a class that I can invoke with a process but I'm having some trouble. The process exists on the Opportunity and needs to invoke a class that will unsync the current quote. I found a blog post that gave me a headstart on the framework for the class but apparently there's a conflict between future and invocable methods and it definitely must be invocable. I'm not a very experienced developer so any advice would be appreciated! Code below
 
public class QuoteAutoSyncUtil
{
    @future
    public static void syncQuote(Map<Id, Id> quoteMap)
    {
        Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>();
        for(Id currentQuote : quoteMap.keyset())
        {
            Opportunity opp = new Opportunity();
            opp.Id = quoteMap.get(currentQuote);
            opp.SyncedQuoteId = currentQuote;
            oppMap.put(opp.Id, opp);
        }
        update oppMap.values();
    }
}
Thanks!

Travis
 
Hey Everyone, 
I'm a novice developer trying to set up an integration between the Salesforce REST API and our platform. Since we utilize OneLogin for SSO, this is the flow that I was using https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm . I've followed all the steps concerning appending the security token to the end of the password, relaxed IP restrictions on the connected app, and configured the permitted users to "admin approved users are pre-authorized" but I'm still receiving the following error:

"error": "invalid_grant",
"error_description": "authentication failure"
}
Which I believe refers to the credentials being incorrect from what I've googled thus far. But, I'm confident that the credentials are correct because I used them to successfully log in to the Apex dataloader. 


Here's a screenshot of the request I'm attemping with the error message (minus the user credentials): User-added image


Any help or advice would be much appreciated!
Hi there,

I'm attempting to cobble together some code for a lead convert trigger that will (after update, after insert) ensure the resulting Account's name is the Last Name plus the last 4 digits of the phone number and I'm a little stuck. For example, if you were converting a lead named John Smith and his phone number was 123-456-7890, the resulting account would be called "Smith-7890". The piece for the trigger to autoconvert works fine, but the portion updating the account is giving me from trouble. Any advice would be appreciated!
trigger LeadConvert on Lead (after insert,after update) {
//Bulkified
    List<String> LeadNames = new List<String>{};
        for(Lead myLead: Trigger.new){
         if((myLead.isconverted==false) && (myLead.Status == 'Scheduled Appointment')) {
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(myLead.Id);
            lc.convertedStatus = 'Scheduled Appointment';
        //Database.ConvertLead(lc,true);
            lc.setDoNotCreateOpportunity(true);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            System.assert(lcr.isSuccess());
            }
        }
        List <Account> account = [SELECT acc.Id, acc.Description FROM Account acc WHERE acc.Id = :Trigger.new.ConvertedAccountId];
        for (Account acc: account) {
    	acc.Name = Trigger.new.LastName + Trigger.new.RIGHT(Phone, 4);
        update acc;
    }
}

 
Hi All,

Trying to improve the code coverage of a test class I've written. The trigger is meant to unset a checkbox on the opportunity after the opportunity line items are updated, the checkbox is True and the line items have revenue schedules. Right now it's at 31% but I'm unsure how to replicate the necessary actions to push it beyond that? Any advice is appreciated! I'm trying to avoid becoming one of those developers whose code barely makes it to production. Here's the trigger I'm trying to cover and below that is the class that I've written so far. 

Trigger:
trigger unsetScheduler on OpportunityLineItem (after update) 
{
	Set<Id> setId = new Set<Id>();
	for (OpportunityLineItem allLineItems : trigger.new) 
	{
		if(allLineItems.HasRevenueSchedule == true)
		{
			setId.add(allLineItems.OpportunityId);
		}	
	}
	
	if(setId.size() > 0 )
	{
		Map<Id,Opportunity> mapOpp = new Map<Id,Opportunity>( [select id,Scheduling__c from Opportunity where id in :setId and Scheduling__c = true]);
		List<Opportunity> lstOppToUpdate = new List<Opportunity>();
		
		for (OpportunityLineItem allLineItems: trigger.new)
		{
			if(allLineItems.HasRevenueSchedule == true && mapOpp.containsKey(allLineItems.OpportunityId) )
			{ 
				Opportunity opp = mapOpp.get(allLineItems.OpportunityId);
				
				opp.Scheduling__c = false;
				lstOppToUpdate.add(opp);
			} 
		}
		if(lstOppToUpdate.size()>0)
		{
			update lstOppToUpdate;
		}
	}	
	
}

Class:
@isTest
public class testUnsetScheduler {
    static testMethod void updateLineItem() {
        
        Account acc = new Account();
        acc.Name = 'Test Account';
        
        insert acc;
        
        Opportunity opp = new Opportunity();
        opp.Name = 'TestOpportunity';
        opp.AccountId = acc.Id;
        opp.CloseDate = System.Today().addDays(10);
        opp.StageName = 'Negotiation';
        opp.Projected_Start_Date__c = System.Today().addDays(15);
        opp.Projected_End_Date__c = System.Today().addDays(20);
        opp.Type = 'Media';
        opp.Programmatic_TV_Rev__c = 'No';
        opp.Scheduling__c = True;
        
        insert opp;
                  
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.OpportunityId = opp.Id;
        oli.Budget__c = 10000;
        oli.New_Rate__c = 0.05;
        oli.UnitPrice = 0;
        oli.Quantity = 1;
        oli.PricebookEntryId = '01u7000000GB8I1';
        
        insert oli;
        
        oli.Budget__c = 15000;
        oli.New_Rate__c = 0.10;
        update oli;
       
    } 
}

 
In "Using the Report Builder" under the "Reports and Dashboards" module, I am having trouble setting the filters for a report.

The challenge asks that I set a filter for stages that are not equal to Closed Won or Closed Lost. I have set and reset these filters within the report but Trailhead keeps telling me that I have to add them. 

I have provided pictures here to show what I am referring to. Thank you!This shows the filter I placed for closed won and closed lost opportunitiesThis is the message that is displayed when I check my work
Attempting to write a trigger that will unset a checkbox on the opportunity after an opportunity line item has been updated. We have a complex Flow/Process relationship and this checkbox needs to be after update (as far as I can tell) to hit at the right time according to order of operations. I've never come across this error before, but I'm a relatively novice developer. Hoping I'm not missing something obvious?
 
trigger unsetScheduler on OpportunityLineItem (after update) {
        for (OpportunityLineItem allLineItems: trigger.new) {
             if (Opportunity.Scheduling__c == TRUE && OpportunityLineItem.HasRevenueSchedule == TRUE)
        { 
        Opportunity.Scheduling__c = FALSE;
        } 
    }
}