• Neetu_Bansal
  • PRO
  • 4472 Points
  • Member since 2015
  • Team Lead


  • Chatter
    Feed
  • 141
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 502
    Replies
I am doing the following trailhead on big objects and I need to be able to upload zip file from Workbench into this playgound. However, when I login into sandbox, the url is test.salesforce.com. If I try to use my playground username it says that it doesn't exists. If I try to change the url to my playground, it generates and error. So How can I complete this trealhead.
https://trailhead.salesforce.com/modules/big_objects/units/big_objects_define_custom_big_objects
I have the following apex trigger and I need a test class. Can you guys check what I got so far?

Apex Trigger
trigger NOVEMBER2 on OpportunityLineItem( after insert, after update )
{
    List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();
    Set<Id> opptyIds = new Set<Id>();
 
    for( OpportunityLineItem optLineItem: trigger.new )
    {
        if( optLineItem.ProductCode == '00002a' )
        {
            opptyIds.add( optLineItem.OpportunityId );
        }
    }
 
    if( opptyIds.size() > 0 )
    {
        //retrieve the values based on Product list
        List<OpportunityLineItem> lstOpptyLineItems = [ SELECT Opportunity.Pricebook2Id, OpportunityId, Name, ProductCode,
                                                        PricebookEntryId, Quantity, UnitPrice
                                                        FROM OpportunityLineItem
                                                        WHERE OpportunityId IN: opptyIds order by ProductCode ];
 
        Map<Id, List<OpportunityLineItem>> mapOpptyLineItem = new Map<Id, List<OpportunityLineItem>>();
        for( OpportunityLineItem item : lstOpptyLineItems )
        {
            List<OpportunityLineItem> oliList1 = new List<OpportunityLineItem>();
            if( mapOpptyLineItem.containsKey( item.OpportunityId ))
            {
                oliList1 = mapOpptyLineItem.get( item.OpportunityId );
            }
            
            oliList1.add( item );
            mapOpptyLineItem.put( item.OpportunityId, oliList1 );
        }
 
 
        //retrieve PriceBookEntry of the Product B, this is most important
        PricebookEntry pbeProduct2 = [ SELECT Id, Pricebook2Id, UnitPrice, Name, Pass_Through_Percentage_Entry__c
                                        FROM PricebookEntry
                                        WHERE Name ='Car Oil Fee'
                                        AND Pricebook2Id  IN (SELECT Id FROM PriceBook2 WHERE Id ='01sA00000004lbRIAQ')
                                        LIMIT 1 ];
 
         if( trigger.isInsert )
         {
             for( Id oppId : mapOpptyLineItem.keySet() )
             {
                 for( OpportunityLineItem item : mapOpptyLineItem.get( oppId ))
                 {
                     if( item.ProductCode == '00002a' )
                     {
                         oliList.add( new OpportunityLineItem(
                                            OpportunityId = oppId,
                                            PricebookEntryId = pbeProduct2.Id,
                                            Quantity = item.Quantity,
                                            UnitPrice = item.UnitPrice * pbeProduct2.Pass_Through_Percentage_Entry__c * 0.01 )
                                          );
                     }
                 }
             }
             
             if( oliList.size() > 0 )
                 insert oliList;
         }
         else if( trigger.isUpdate )
         {
             for( Id oppId : mapOpptyLineItem.keySet() )
             {
                 OpportunityLineItem itemProductA = new OpportunityLineItem();
                 for( OpportunityLineItem item : mapOpptyLineItem.get( oppId ))
                 {
                     if( item.ProductCode == '00002a' )
                     {
                         itemProductA = item;
                         continue;
                     }
                     if( item.ProductCode == '00002b' )
                     {
                         oliList.add( new OpportunityLineItem( Id = item.Id,
                                            OpportunityId = oppId,
                                            PricebookEntryId = pbeProduct2.Id,
                                            Quantity = itemProductA.Quantity,
                                            UnitPrice = itemProductA.UnitPrice * pbeProduct2.Pass_Through_Percentage_Entry__c * 0.01 )
                                          );
                     }
                 }
             }
             
             if( oliList.size() > 0 )
                 update oliList;
         }
    }
}
Test Class:
@isTest
private class OpportunityLineItemTrigger_Test{
  static testMethod void test_OpportunityLineItemTrigger(){
   test.startTest();
    OpportunityLineItem opportunitylineitem_Obj = new OpportunityLineItem(OpportunityId = opportunity_Obj[0].id, PricebookEntryId = pricebookentry_Obj[0].id, Quantity = 9, UnitPrice = 13, Package_Delivery_Date__c = false, Batch_Readiness__c = false);
    Insert opportunitylineitem_Obj; 
   test.stopTest();
  }

  static testMethod void test_UseCase2(){
   test.startTest();
    OpportunityLineItem opportunitylineitem_Obj = new OpportunityLineItem(OpportunityId = opportunity_Obj[0].id, PricebookEntryId = pricebookentry_Obj[0].id, Quantity = 9, UnitPrice = 13, Package_Delivery_Date__c = false, Batch_Readiness__c = false);
    opportunitylineitem_Obj.ProductCode='UseCase1-0';
    Insert opportunitylineitem_Obj; 
    test.stopTest();
}
}


 
  • November 22, 2017
  • Like
  • 0
Is there a way to send an email notification that there is an inbound change set added to the environment?  We have several developer sandboxes for each department.  Each department is responsible for testing and deploying to a staging sandbox to test against in environment with other department's workflows and code.  After testing in staging, the code can be deployed into production.  We would like a notification to be sent whenever a department deploys into staging.
I refershed a sandbox yesterday at around 8 (~26 hours ago) and am still waiting.  We're a small org (< 2 GB of total storage).  Is everyone else seeing similar wait times?
I'm working on the Build an Autmoated Workshop Management System Project and I'm on the second challenge (Automate Pre-Workshop Tasks with Process Builder). I need to create a campaign, but I do not see the New button on the Campaign tab. I've look for it when I'm logged in as an admin and when logged in as a user with a marker profile, and still not New button.

Where do I have to go to give myself access to the create new campaign feature?
Cannot request (and install) the MySalesforce managed package as per instructions in "Test and Submit the App" section. When I enter "mysalesforce" in the Setup quick find nothing comes up. Thoughts?
Thanks!

User-added image
Hi!

We have customer service cases related to the lead object. I am trying to write a trigger that updates any cases associated to leads that have been deleted. Below is my code. 

I get the error message: System.NullPointerException: Attempt to de-reference a null object: ()".
Any help is greatly appreciated!

Thanks, 
Tasia

trigger UpdateCaseWhenLeadDeleted on Lead (before delete) {
if(Trigger.isBefore && Trigger.isDelete)
    {
       List<Case> listCase = new List<Case>();
        Set<Id> DeletedLeads = new Set<Id>();
        for(Lead objLead : Trigger.new)
        {
            if(objLead.isDeleted)
                DeletedLeads.add(objLead.Id);
        }
        for(Case objCase : [SELECT Lead__c FROM Case WHERE Lead__c IN : DeletedLeads])    
        {
            objCase.Lead__c = null;
            objCase.Status = 'Declined';
            listCase.add(objCase);
        }
        update listCase;
    }
}
Hello,

is it possible in Apex class or Trigger to detect if there is an mass update on Assets ?

Thank you for reply
Hi,

Please can you help me :( I'm trying to implement a VF page that displays (via a section on an Account page) a Google Maps view of where a customer is based based on their shipping address. I have the below page written up but it's just not working - I'm simply getting a grey box where the map should be.
(NB: API key has been redacted, but there is a valid key in there)

I've tried several methods of troubleshooting this but getting no joy, appreciate your help.

Thanks in advance,
Dan
 
<apex:page standardController="Account">
<apex:pageBlock >
<head>
 
<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=[REDACTED-API-KEY]&sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?key=[REDACTED-API-KEY]"></script>
<script type="text/javascript"> 
 
$(document).ready(function() {
  
  var myOptions = {
    zoom: 13,
    mapTypeId: google.maps.MapTypeId.roadmap,
    mapTypeControl: false
  }
  
  var map;
  var marker;
  
  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.ShippingStreet}, " + "{!Account.ShippingCity}, " + "{!Account.ShippingPostalcode}";
  
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b>"
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
      
        //center map
        map.setCenter(results[0].geometry.location);
        
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });
        
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
        
      }
      
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>
 
<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:500px;
  background:transparent;
}
</style>
 
</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:pageBlock>
</apex:page>

 
Not a duplicate question guys. Different aspect of the code.

Goal of the code:
Auto add product B once product A is added to the opportunity

Issue:
Adding product B to a different opportunity and not to the opportunity that product A is being added to.

Any idea why? or what part of the code that I should focus on to test different solutions?

Code:
trigger NOVEMBER1 on OpportunityLineItem (after insert, after update)
    {
        List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();
    
        List<String> lstProductCodes = new List<String>();
     
        for(OpportunityLineItem optLineItem: Trigger.new)
        {
            if(optLineItem.ProductCode == '00002a')
            {
                lstProductCodes.add(optLineItem.ProductCode);
            }
        }
     
        if(lstProductCodes.size()>0)
        {
            System.debug('lstProductCodes=' + lstProductCodes);
     
            //retrieve the values based on Product list
            List<OpportunityLineItem> lstOpptyLineItems = [SELECT Opportunity.Pricebook2Id, Name, ProductCode , PricebookEntryId, Quantity, UnitPrice
                                                            FROM    OpportunityLineItem
                                                            WHERE ProductCode IN:lstProductCodes];
     
            //create a map which contains Product Name and OpportunityLineItem
            Map<String, OpportunityLineItem> mapOpptyLineItem = new Map<String, OpportunityLineItem>();
            for(OpportunityLineItem item:lstOpptyLineItems)
            {
                mapOpptyLineItem.put(item.ProductCode, item);
            }
     
     
            Id pbkId = lstOpptyLineItems[0].Opportunity.Pricebook2Id;
     
            //retrieve PriceBookEntry of the Product B, this is most important
            PricebookEntry pbeProduct2 = [SELECT Id, Pricebook2Id, UnitPrice, Name, Fee_Percentage_Entry__c 
                                            FROM PricebookEntry
                                            WHERE Name ='Car Oil Fee'
                                            AND Pricebook2Id  IN (SELECT Id FROM PriceBook2 WHERE Id ='01sA00000004lbRIAQ')
                                            LIMIT 1];
     
     
            //retrieve Product A item from the map.        
            OpportunityLineItem itemProductA = mapOpptyLineItem.get('00002a');
            System.debug('itemProductA= ' + itemProductA);
     
            if(itemProductA != null)
            {
                if(Trigger.isInsert)
                {
                //now assign Product A items as required, you can retrieve the amount from Product A
                oliList.add(new OpportunityLineItem(
                    OpportunityId = itemProductA.OpportunityId,
                    PricebookEntryId = pbeProduct2.Id,
                    Quantity = itemProductA.Quantity,
                    UnitPrice = itemProductA.UnitPrice * pbeProduct2.Fee_Percentage_Entry__c * 0.01 )
                  );
                System.debug('oliList=' + oliList);
                insert oliList;
            }
            else if (Trigger.isUpdate)
                {
                    //if you need to update PriceBookEntry of Product B
                    pbeProduct2.UnitPrice = itemProductA.UnitPrice * pbeProduct2.Fee_Percentage_Entry__c * 0.01 ;
                    update pbeProduct2;
     
                    //if you need to update OpportunityLineItem of Product B
                    OpportunityLineItem optLIProductB = [SELECT OpportunityId, Opportunity.Pricebook2Id,
                                                            Name, ProductCode , PricebookEntryId,
                                                            Quantity, UnitPrice
                                                            FROM    OpportunityLineItem
                                                            WHERE ProductCode = '00002b'];
     
                    optLIProductB.Quantity = mapOpptyLineItem.get('00002a').Quantity;
                    optLIProductB.UnitPrice = mapOpptyLineItem.get('00002a').UnitPrice * pbeProduct2.Fee_Percentage_Entry__c * 0.01 ;
     
                    update optLIProductB;
                }
        }
    }
    }

 
  • November 14, 2017
  • Like
  • 0
Hi Everyone,

I am just writing a very simple trigger but have got stuck with it.

It needs to evaluate 3 fields on a custom object called course_sale__c and then run a controller, after the controller has ran it needs to then update the field has_confirmation_been_sent__c to True.
 
trigger SendTrainingConfirmationTrigger on Course_Sale__c (after insert, after update) {
  
    for (Course_Sale__c cs : Trigger.new) {
      if (cs.AttachmentId__c != null) && (cs.Send_Confirmation_Automatically__c == True) && (cs.has_confirmation_been_sent__c == FALSE)
      {
            ApexPages.StandardController sc = new ApexPages.StandardController(cs);
			TrainingConfirmationSend obj = new TrainingConfirmationSend(sc);

			obj.emailAtt();
          
            cs.has_confirmation_been_sent__c = true;
      }    
    }
}

Thanks for your help,

Joe

 
 Hi all,

i added for my challenge a contact as contact role as described in the challenge (see text below), but when I let the system check if the task is completed correctly.I always get the error: 

Challenge Not yet complete... here's what's wrong: 
The 'John Smith' contact role for 'Greendot Media' could not be found.​


I don´t understand what I am doing wrong here - while solving the task I followed the description and rechecked with the documentation but I can not find an error.

I would really appreciate help. Thanks.

Task
Your VP just connected you to a new contact, but the contact works with two different companies. To pass this challenge, relate the new contact to the two different accounts. Then, add yourself to the account team. In order to complete this challenge, you need to have Contacts to Multiple Accounts and Account Teams enabled. The Related Contacts and Account Teams related lists must be on the Account page layout. The Related Accounts related list must be on the Contact page layout.

Create an account with the Account Name 'Acme Corporation'.
Create an account with the Account Name 'Greendot Media'.
Create a contact with First Name = 'John', Last Name = 'Smith'. In the Account Name field, enter 'Acme Corporation'.
From the Greendot Media account record, use the Related Contacts related list to add a relationship with John Smith.
Add yourself to the account team for the 'Acme Corporation' account with the Team Role of 'Account Manager'.
 
Hello.

I'm trying to create a filter in reports to show a relactive Google Doc.
How can I do this?
I am using a trigger to create a task on an Account record.  The task should be created when a "notice" date on the account equals today's date.  I have the trigger working but every time I edit the account, it creates another task.  I only want one task for when the date criteria is met.  The notice date will change to a future date so the process will start all over once the new notice date equals today.  I read a few of the posts but I am not seeing something that matches what I am trying to do.  I am an admin but working to get more involved with developing. Thanks for any help.

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
trigger WaiveTaskCreate on Account (after update) {
   for (Account acct : Trigger.new){
   if(acct.Date_Notice__c==System.Today()){
       Task t = new Task();
       t.Subject    = 'Subject';
       t.OwnerID = acct.OwnerID;
       t.Priority   = 'High';
       t.Description    = 'Comment';
       t.WhatID     = acct.Id;
       t.ActivityDate = (acct.Exp_Date__c + 15);
       insert t;
}
}
}

 
Hi I am new to Saleforce after many years. 

I am trying to create a rule that if Stage in Opportunity is Partner then a partner name field pops up to type in.  

Any advice on how to do this? I am back in the SF game and very rusty. 

Thanks, 

Nathalie 
1) @RestResource(urlMapping='/trippleInteger/')
 2)  global class MyService {
   3)  @HttpGet
   4)  global static Integer trippleIt() {
    5)     String someNumber = RestContext.request.params.get('yourInteger');
   6)      return someNumber *3;
    }
}
Here is the delema, I have a workflow that works great except for one thing, it checks the box when the first email comes in, below is a picture of my criteria, what I need to do is create this in a formula format, so that I can add this logic.

(Date/Time_Opened < Message_Date)

The above needs to be true as well as the Filtered Criteria, I am jut unsure of how to write this up in a Formula format.
User-added image
the filter logic on this which has been cropped is 1 AND (2 OR 3) AND 4 AND 5 

Ignore 6 that was just me trying to figure this out.

If anyone can help me that would be great.
Hello team I have the following: 
public void mergeOwners()
        { 
            String a1;
            String a2;
            
            a1 = sGetOwnerOne;
            a2 = sGetOwnerTwo;
            
            Account src = [SELECT Owner.Id FROM Account where Name like :a1];
            Account dest = [SELECT Id, Owner.Id FROM Account where Name like :a2];
            dest.OwnerId = src.OwnerId;
            update dest;
           
        }

These variables are taken from a two different selectLists
 
public static String sGetOwnerOne{set;get;}
    	public static String sGetOwnerTwo{set;get;}

But at clicking the button in visual force the system shows me the following error: 
List has no rows for assignment to SObject
Does somebody know why this happens?
Thanks in advance. 
 
i have one custom field i.e., Intreste_Courses__c in am given 'JAVA,Oracle,Sap' for one Record 'JAVA,Oracle,Sap,.Net' for another record so how i can seacrh only one value Like 'Java'.
if i seach with value name 'java'  i want to display related java value record.
Hi

I am new to process builder, and with some help I managed to create 2 processes. 

I have a process whereby i would like to populate the primary filed of an object to be equal to the lookup value of contacts from an account. Here is the structure:

Object - Work Request Resource
Case if Work_Request_Resource.Contact__c is not blank 

Action - update and edit Work_Request_Resource.Resource_Name_cc to equal Work_Request_Resource.Contact__c

I was also thinking of a trigger but I can't get the trigger to update the primary field. 

The reason why I am taking this round about way is so that I can see the Contact Name on lookup lists, and  not just an ID

My preference would be to use Process Builder, however I am open to triggers

Many thanks in advance 
trigger PreventCustomertDeletion on Customer__c (before delete){
    Set<Id> allowedProfileIds = null;
	
	allowedProfileIds = new Map<id,profile>([SELECT ID FROM PROFILE WHERE NAME = 'Manager1']).keyset();
	
	for(Customer__c a : trigger.old){
		IF(allowedProfileIds.Contains(userInfo.getProfileId())){
			 a.addError('You do not have permission to delete the Customer');
		}
		
	}
}

Thanks in advance,
Dj
  • December 04, 2017
  • Like
  • 0
I created a visualforce page for the opportunity object. I turned it into a force.com. My issue is when I open the visualforce add updates to any field and click the save button the record information doesnt change. I have the code below. If anyone could help me find a solution, i would appreciate it. 
 
<apex:page standardcontroller="Opportunity" showheader="false"   >



<style type="text/CSS">


body{
color:ffffff;
}

h2{
   font-size:14px; 
   font-family:Arial, Sans-Serif, Garamond;  
   border-bottom-width: 0px;
   border-bottom-style: solid;
   padding:13px,0px,13px,0px;
   
   color:#fff;
   
   
}

th{
   padding-top: 13px;
   margin-bottom: 25px;
}
   
td{
   padding-bottom: 10px;
}
div{
background-color:#000000;
font-color:#ffffff;
height:20px;
}

.title{
   font-size:20px; 
   font-family:Arial, Sans-Serif, Garamond;  
}
</style>


<apex:form >

           
<table align="center" style="text-align:center" width="400px" styleClass="hd">
    <tr ><td class="title">Request for Special Payment </td></tr><tr><td><apex:commandButton immediate="true" action="{!save}"  value="Save"/></td></tr></table>
   
        <table>
         <tr>
           <div> <h2>Opportunity Information</h2></div>
        </tr>
            <tr>
                <th>Date:</th> <th>Opportunity Name:</th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.LastModifiedDate}"/></td><td><apex:outputText value="{!Opportunity.Name} "/></td>
            </tr>



    </table>

    <table>
         <tr>
           <div> <h2>Terms Adjustment Information</h2></div>
        </tr>
            <tr>
                <th>Opportunity Account Address:</th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Account.BillingStreet}"/><br /><apex:outputText value="{!Opportunity.Account.BillingCity}"/>,&nbsp;<apex:outputText value="{!Opportunity.Account.BillingState}"/>&nbsp;&nbsp;<apex:outputText value="{!Opportunity.Account.BillingPostalCode}"/></td>
            </tr>
            
            
            <tr>
                <th>Robot Model or Product Name:</th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Robot_Model_or_Product_Name__c}"/></td>
            </tr>
            <tr>
                <th>Quoted Total Price:</th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Total_Quoted_Amount__c}"/></td>
            </tr>
            <tr>
                <th>Required Payment Term:</th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Required_Payment_Terms__c}"/></td>
            </tr>
            <tr>
                <th>Detailed Reason:</th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Detailed_Reason__c}"/></td>
            </tr>



    </table>

    <table>
         <tr>
           <div> <h2>Special Instructions</h2></div>
        </tr>
            <tr>
                <th>Special Instructions</th></tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Special_Instructions__c}"/></td>
            </tr>



    </table>

    <table>
         <tr>
           <div> <h2>Requestor Information:</h2></div>
        </tr>
            <tr>
                <th>Requestor:</th> &nbsp;<th>Submitted Date: </th>
            </tr>
            <tr>                 
                <td><apex:outputText value="{!Opportunity.Request_Submitted_By__c}"/></td>&nbsp;&nbsp;<td><apex:outputText value="{!Opportunity.Date_Submitted__c}"/></td>
            </tr>

</table>

<table>
         <tr>
           <div> <h2>DNB Results</h2></div>
        </tr>
            <tr>
                <th>DNB Results:</th>
            </tr>
            <tr>                 
                <td><apex:inputText value="{!Opportunity.DNB_Results__c}" style="width: 300px; height: 30px" /></td>
            </tr>
            <tr>
                <th>Controller Approve Request:</th> 
            </tr>
            <tr>                 
                <td><apex:inputCheckbox value="{!Opportunity.Request_Submitted_By__c}"/></td>
            </tr>

           
            <tr>
                <th>Controller’s Comments:</th>
            </tr>
            <tr>                 
                <td><apex:inputTextarea value="{!Opportunity.Controller_s_Comments__c}" style="width: 400px; height: 150px" /></td>
            </tr>
 </table>
    
 </apex:form>
</apex:page>

 
  • December 04, 2017
  • Like
  • 0
I am implementing a request to throw an error message to the user instead of going to the edit page if the object is in a certain status. My plan was to create a visualforce page and display the error if the object meets the criteria for the error message, and route to the edit page if not.

Is it possible to do this without the VF page, directly through the onclick javascript for the button click? How might I implement that? 

I just want to replace the standard edit button with a custom that would throw the error before the user gets to the edit page, instead of it throwing an error upon saving the modified data.
  • December 04, 2017
  • Like
  • 0
Hello

I have a problem with "Create a Forecasting Reports" Trailhead:
The following error ocurrs even I have done everything correctly:

There was an unhandled exception. Please reference ID: CKIGBGTA. Error: Faraday::ClientError. Message: FORBIDDEN: The report type Forecasting_Details__c is invalid, is undeployed, or is based on an entity you do not have access to.

User-added image

Any idea why I can not pass the module?

Thank you.
I need to unassign a permission set to over 140+ users. Is there a way I can do this with workbench or dev console? Thanks!
Hi guys! I'm new on Salesforce, can anybody help me with this ?
 
  1. Create a custom object called Case_Products__c (junction object between Case and Product2 standard objects.
  2.  Implement a lightning component with a text field where the agent will input the order number. Once he presses on Search, the controller will search the order in the system and:Display Order details such as Order Number, Status, Amount (read only fields
  3.  Display a list of the associated Order products. Each product must be selectable (checkbox)
  4.  Create a button to identify all selected items and for each item, create a Case Product record.
  5.  Make sure there is a Select All button, too.
  6.  Lightning Design system must be used and all CSS or JS code must be added to Static Resources.
I am doing the following trailhead on big objects and I need to be able to upload zip file from Workbench into this playgound. However, when I login into sandbox, the url is test.salesforce.com. If I try to use my playground username it says that it doesn't exists. If I try to change the url to my playground, it generates and error. So How can I complete this trealhead.
https://trailhead.salesforce.com/modules/big_objects/units/big_objects_define_custom_big_objects
I have the following apex trigger and I need a test class. Can you guys check what I got so far?

Apex Trigger
trigger NOVEMBER2 on OpportunityLineItem( after insert, after update )
{
    List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();
    Set<Id> opptyIds = new Set<Id>();
 
    for( OpportunityLineItem optLineItem: trigger.new )
    {
        if( optLineItem.ProductCode == '00002a' )
        {
            opptyIds.add( optLineItem.OpportunityId );
        }
    }
 
    if( opptyIds.size() > 0 )
    {
        //retrieve the values based on Product list
        List<OpportunityLineItem> lstOpptyLineItems = [ SELECT Opportunity.Pricebook2Id, OpportunityId, Name, ProductCode,
                                                        PricebookEntryId, Quantity, UnitPrice
                                                        FROM OpportunityLineItem
                                                        WHERE OpportunityId IN: opptyIds order by ProductCode ];
 
        Map<Id, List<OpportunityLineItem>> mapOpptyLineItem = new Map<Id, List<OpportunityLineItem>>();
        for( OpportunityLineItem item : lstOpptyLineItems )
        {
            List<OpportunityLineItem> oliList1 = new List<OpportunityLineItem>();
            if( mapOpptyLineItem.containsKey( item.OpportunityId ))
            {
                oliList1 = mapOpptyLineItem.get( item.OpportunityId );
            }
            
            oliList1.add( item );
            mapOpptyLineItem.put( item.OpportunityId, oliList1 );
        }
 
 
        //retrieve PriceBookEntry of the Product B, this is most important
        PricebookEntry pbeProduct2 = [ SELECT Id, Pricebook2Id, UnitPrice, Name, Pass_Through_Percentage_Entry__c
                                        FROM PricebookEntry
                                        WHERE Name ='Car Oil Fee'
                                        AND Pricebook2Id  IN (SELECT Id FROM PriceBook2 WHERE Id ='01sA00000004lbRIAQ')
                                        LIMIT 1 ];
 
         if( trigger.isInsert )
         {
             for( Id oppId : mapOpptyLineItem.keySet() )
             {
                 for( OpportunityLineItem item : mapOpptyLineItem.get( oppId ))
                 {
                     if( item.ProductCode == '00002a' )
                     {
                         oliList.add( new OpportunityLineItem(
                                            OpportunityId = oppId,
                                            PricebookEntryId = pbeProduct2.Id,
                                            Quantity = item.Quantity,
                                            UnitPrice = item.UnitPrice * pbeProduct2.Pass_Through_Percentage_Entry__c * 0.01 )
                                          );
                     }
                 }
             }
             
             if( oliList.size() > 0 )
                 insert oliList;
         }
         else if( trigger.isUpdate )
         {
             for( Id oppId : mapOpptyLineItem.keySet() )
             {
                 OpportunityLineItem itemProductA = new OpportunityLineItem();
                 for( OpportunityLineItem item : mapOpptyLineItem.get( oppId ))
                 {
                     if( item.ProductCode == '00002a' )
                     {
                         itemProductA = item;
                         continue;
                     }
                     if( item.ProductCode == '00002b' )
                     {
                         oliList.add( new OpportunityLineItem( Id = item.Id,
                                            OpportunityId = oppId,
                                            PricebookEntryId = pbeProduct2.Id,
                                            Quantity = itemProductA.Quantity,
                                            UnitPrice = itemProductA.UnitPrice * pbeProduct2.Pass_Through_Percentage_Entry__c * 0.01 )
                                          );
                     }
                 }
             }
             
             if( oliList.size() > 0 )
                 update oliList;
         }
    }
}
Test Class:
@isTest
private class OpportunityLineItemTrigger_Test{
  static testMethod void test_OpportunityLineItemTrigger(){
   test.startTest();
    OpportunityLineItem opportunitylineitem_Obj = new OpportunityLineItem(OpportunityId = opportunity_Obj[0].id, PricebookEntryId = pricebookentry_Obj[0].id, Quantity = 9, UnitPrice = 13, Package_Delivery_Date__c = false, Batch_Readiness__c = false);
    Insert opportunitylineitem_Obj; 
   test.stopTest();
  }

  static testMethod void test_UseCase2(){
   test.startTest();
    OpportunityLineItem opportunitylineitem_Obj = new OpportunityLineItem(OpportunityId = opportunity_Obj[0].id, PricebookEntryId = pricebookentry_Obj[0].id, Quantity = 9, UnitPrice = 13, Package_Delivery_Date__c = false, Batch_Readiness__c = false);
    opportunitylineitem_Obj.ProductCode='UseCase1-0';
    Insert opportunitylineitem_Obj; 
    test.stopTest();
}
}


 
  • November 22, 2017
  • Like
  • 0
Is there a way to send an email notification that there is an inbound change set added to the environment?  We have several developer sandboxes for each department.  Each department is responsible for testing and deploying to a staging sandbox to test against in environment with other department's workflows and code.  After testing in staging, the code can be deployed into production.  We would like a notification to be sent whenever a department deploys into staging.
I refershed a sandbox yesterday at around 8 (~26 hours ago) and am still waiting.  We're a small org (< 2 GB of total storage).  Is everyone else seeing similar wait times?
Hi, I'm new to SF, Python and Flask. Wich are the tools I'm using to build up a little web UI for registering (creating anew contact on SF). I found Simple-Salesforce and works pretty well for me. So, right now I have this code wich is working perfectly so far:
 
# User Registration
@app.route('/register', methods=['GET', 'POST'])
def register():
    form = RegisterForm(request.form)
    if request.method == 'POST' and form.validate():
        FirstName = request.form['FirstName']
        LastName = request.form['LastName']
        AccountId = request.form['AccountId']
        Birthdate = request.form['Birthdate']
        #password = sha256_crypt.encrypt(str(form.password.data))
        Home_Endpoint__c = request.form['Home_Endpoint__c']

        # Execute query
        sf.Contact.create({'LastName':LastName,'FirstName':FirstName,'AccountId':AccountId, 'Birthdate':Birthdate, 'Home_Endpoint__c':Home_Endpoint__c, 'Test_User__c':1 })
        
        flash('You are now registered', 'success')

    return render_template('register.html', form=form)


What I need is to catch/read the SF Dictionary JSON response with the new created Id as shown on the simple-salesforce examples section:
 
Record Management

To create a new ‘Contact’ in Salesforce:

sf.Contact.create({'LastName':'Smith','Email':'example@example.com'})

This will return a dictionary such as {u'errors': [], u'id': u'003e0000003GuNXAA0', u'success': True}
So I can keep working with the new registered member on other further processes.

I will appreciate if someone gives me a hand on this.
Hi all,

I'm trying to find out how the Duplicate Record Set/Item objects work.
My scenario:
  1. Create an Account
  2. Create another Account in way that the Duplicate Record warning message pops up
  3. Click Save and Ignore
  4. 2 Duplicate Record Items got created (so far so good)
  5. Change one of the duplicate Accounts, so they are not duplicates anymore
  6. My understanding that the Duplicate Record Items should be deleted now - but they are not
Is my expected behavior incorrect?

Thanks for helping!
Help please.  Not sure what I'm doing wrong but results seem right
User-added image
User-added image

 
Hello All,
I have the following code that only allows a single Primary Contact per Account.  But what I would like to do is set the newly created Contact as Primary(Primary__c==True) if one does not exist.  Can I utilize my existing Class or do I have to create a new one
Thank you for your time and help.
M
public without sharing class ContactTrgHandler 
{
  public static void onBeforeInsert(List<Contact> trgNew)
  {
    Map<Id,Set<Id>> accountIdToNewContactRtMap = new Map<Id,Set<Id>>();
    for(Contact c : trgNew)
    {
      if(String.isNotEmpty(c.AccountId) && c.Primary__c)
      {
        if(!accountIdToNewContactRtMap.containsKey(c.AccountId))
          accountIdToNewContactRtMap.put(c.AccountId,new Set<Id>());
        accountIdToNewContactRtMap.get(c.AccountId).add(c.RecordTypeId);
      }      
    }
    if(!accountIdToNewContactRtMap.isEmpty())
    {
      Map<Id,Set<Id>> existingContactRtMap = new Map<Id,Set<Id>>();
      for(Account a : [SELECT Id,(SELECT RecordTypeId FROM Contacts WHERE Primary__c=true) FROM Account WHERE Id in :accountIdToNewContactRtMap.keySet()])
      {
        existingContactRtMap.put(a.Id,new Set<Id>());
        for(Contact c : a.Contacts)
          existingContactRtMap.get(a.Id).add(c.RecordTypeId);
      }
      for(Contact c : trgNew)
      {
        if(existingContactRtMap.containsKey(c.AccountId) && existingContactRtMap.get(c.AccountId).contains(c.RecordTypeId))
          c.addError('There is already a primary contact for this record type.');
      }
    }
  }
  public static void onBeforeUpdate(List<Contact> trgNew,Map<Id,Contact> oldMap)
  {
    Map<Id,Set<Id>> accountIdToNewContactRtMap = new Map<Id,Set<Id>>();
    for(Contact c : trgNew)
    {
      if(String.isNotEmpty(c.AccountId) && c.Primary__c && !oldMap.get(c.Id).Primary__c)
      {
        if(!accountIdToNewContactRtMap.containsKey(c.AccountId))
          accountIdToNewContactRtMap.put(c.AccountId,new Set<Id>());
        accountIdToNewContactRtMap.get(c.AccountId).add(c.RecordTypeId);
      }
    }
    if(!accountIdToNewContactRtMap.isEmpty())
    {
      Map<Id,Set<Id>> existingContactRtMap = new Map<Id,Set<Id>>();
      for(Account a : [SELECT Id,(SELECT RecordTypeId FROM Contacts WHERE Primary__c=true) FROM Account WHERE Id in :accountIdToNewContactRtMap.keySet()])
      {
        existingContactRtMap.put(a.Id,new Set<Id>());
        for(Contact c : a.Contacts)
          existingContactRtMap.get(a.Id).add(c.RecordTypeId);
      }
      for(Contact c : trgNew)
      {
        if(existingContactRtMap.containsKey(c.AccountId) && existingContactRtMap.get(c.AccountId).contains(c.RecordTypeId))
          c.addError('There is already a primary contact for this record type.');
      }
    }
  }
}

 
We would like to set a default date for a Due date field as "Today plus 3 business days".
Is this possible? If so, what would the formula be?
 
Using a Standard List Controller, create a Visualforce page which displays a list of Accounts with links to their respective record detail pages.The page must be named 'AccountList'.
It must reference the Account standard controller.
It must have a recordSetVar equal to 'accounts'.
It must have a Visualforce apex:repeat component.
The repeater must have the var attribute set to 'a'.
The repeater must use the <li> HTML list tag
The repeater must use the apex:outputLink component to link to the respective record detail page
HINT: Record detail pages can be reached by placing a record ID at the root of the URL (e.g. '/<record id>')

I tried this code i am able to retrieve the records and clicking on each record showing  the detail page of that record.But Still Trail Head is showing error.Can someone guide me if  I am wrong


<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock title="Accounts">
      <apex:repeat value="{!Accounts}" var="a">
      <li>
       <apex:outputLink value="{!URLFOR($Action.Account.view, a.id)}">{!a.Name}
       </apex:outputLink>
     </li>
   </apex:repeat>
   </apex:pageBlock> 
</apex:page>
 
Hello,

I have a custom objects.
There are few rows created for this custom object.

How cna i know where all is this custom object used.