• David Jobe
  • NEWBIE
  • 50 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 5
    Replies
I am trying to find a way to make accounts a related list item for Opportunity. It doesn't look like that functionaility is available out of the box with Lightning. 
I have built a viauslforce page using the code that Salesforce has provided for Prechat Survey.
It is asking for the client to log into salesforce to see the page. How do I make it so the page in question (in sandbox) is able to be viewed by the general public on the internet and not require a log in?
I am trying to rewrite the prechat apex that Salesforce gives you to link your chat with a contact to link it to an account. If it doesn't find a link, then not to create an account. I have to admit that I am a little out of my depth on how to change the code to fit that need. Any help would be appreciated. What I have built so far is below.

<apex:page showHeader="false"> <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form --> <script type='text/javascript'> (function() { function handlePageLoad() { var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)"); document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1].replace("javascript:", ""))); } if (window.addEventListener) { window.addEventListener('load', handlePageLoad, false); } else { window.attachEvent('onload', handlePageLoad, false); }})(); </script> <h1>Live Agent Pre-Chat Form</h1> <!-- Form that gathers information from the chat visitor and sets the values to Live Agent Custom Details used later in the example --> <form method='post' id='prechatForm'> First name: <input type='text' name='liveagent.prechat:AccountFirstName' id='firstName' /><br /> Last name: <input type='text' name='liveagent.prechat:AccountLastName' id='lastName' /><br /> Email: <input type='text' name='liveagent.prechat:AccountEmail' id='email' /><br /> Phone: <input type='text' name='liveagent.prechat:AccountPhone' id='phone' /><br /> Issue: <input type='text' name='liveagent.prechat:CaseSubject' id='subject' /><br /> <!-- Hidden fields used to set additional custom details --> <input type="hidden" name="liveagent.prechat:CaseStatus" value="New" /><br /> <!-- This example assumes that "Chat" was added as picklist value to the Case Origin field --> <input type="hidden" name="liveagent.prechat:CaseOrigin" value="Chat" /><br /> <!-- This example will set the Case Record Type to a specific value for the record type configured on the org. Lookup the case record type's id on your org and set it here --> <input type="hidden" name="liveagent.prechat:CaseRecordType" value="012j0000000zM7s" /> <!-- Used to set the visitor's name for the agent in the Console --> <input type="hidden" name="liveagent.prechat.name" id="prechat_field_name" /> <!-- map: Use the data from prechat form to map it to the Salesforce record's fields --> <input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="FirstName,AccountFirstName;LastName,AccountLastName;Email,AccountEmail;Phone,AccountPhone" /> <input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Subject,CaseSubject;Status,CaseStatus;Origin,CaseOrigin;RecordTypeId,CaseRecordType" /> <!-- doFind, doCreate and isExactMatch example for a Contact: Find a contact whose Email exactly matches the value provided by the customer in the form If there's no match, then create a Contact record and set it's First Name, Last Name, Email, and Phone to the values provided by the customer --> <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="Email,true" /> <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="Email,true" /> <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="FirstName,true;LastName,true;Email,true;Phone,true" /> <!-- doCreate example for a Case: create a case to attach to the chat, set the Case Subject to the value provided by the customer and set the case's Status and Origin fields --> <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Subject,true;Status,true;Origin,true;RecordTypeId,true" /> <!-- linkToEntity: Set the record Contact record, found/created above, as the Contact on the Case that's created --> <input type="hidden" name="liveagent.prechat.findorcreate.linkToEntity:Account" value="Case,AccountId" /> <!-- showOnCreate: Open the Contact and Case records as sub-tabs to the chat for the agent in the Console --> <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true" /> <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" /> <!-- saveToTranscript: Associates the records found / created, i.e. Contact and Case, to the Live Chat Transcript record. --> <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="AccountId" /> <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="CaseId" /> <!-- displayToAgent: Hides the case record type from the agent --> <input type="hidden" name="liveagent.prechat.findorcreate.displayToAgent:CaseRecordType" value="false" /> <!-- searchKnowledge: Searches knowledge article based on the text, this assumes that Knowledge is setup --> <input type="hidden" name="liveagent.prechat.knowledgeSearch:CaseSubject" value="true" /> <input type='submit' value='Chat Now' id='prechat_submit' onclick="setName()"/> <!-- Set the visitor's name for the agent in the Console to first and last name provided by the customer --> <script type="text/javascript"> function setName() { document.getElementById("prechat_field_name").value = document.getElementById("firstName").value + " " + document.getElementById("lastName").value; } </script> <style type="text/css"> p {font-weight: bolder } </style> </form> </apex:page>

I am trying to build a "fast flow", but have never designed anything with a loop. I can make it work on an individual basis, but turning into a bulkify process I am struggling with.

I have two Objects. 
1. Opportunities (standard object)
2. Client_Details__c (custom)

On both objects there is a custom field called Client_Number__c.
I need a flow that kicks off every morning that checks for any Client_Details__c records that do not have the look up field Opportunity__c field filled out. It then takes those records and compares the Client__Number field on the Client_Detials record against the Client_Number on all the Opportunity records to find a match. Once found it takes the ID for the Opportunity and inputs it to the Opportunity__c field on the Client_Detials record. After all have been processed, it updates all the records as one action. 

 

Any assistance would be great.

I have built the below code. I got the too many DML statements, but I'm drawing a blank on how to bulkify this. 
Any help would be appreciated. 

trigger CreateOpportunity on Revenue_Marketing__c (after insert) {
    for (Revenue_Marketing__c acc :Trigger.new) {
        Opportunity app                             = new Opportunity();
        app.ARVACT__c                                   = acc.ARVACT__c;
        app.tel_business__c                             = acc.Business_Phone__c;
        app.Call_Date__c                                = acc.Call_Date__c;
        app.tel_home__c                                 = acc.Home_Phone__c;
        app.FirstName__c                                = acc.First_Name__c;
        app.LastName__c                                 = acc.Last_Name__c;
        app.LastPurchaseDate__c                         = acc.Last_Purchase_Date__c;
        app.OwnerLevel__c                               = acc.Owner_Level__c;
        app.Points__c                                   = acc.Points__c;
        app.Rep_Assigned__c                             = acc.Rep_assignment__c;
        app.Address1__c                                 = acc.Address__c;
        app.State__c                                    = acc.State__c;
        app.zip_code__c                                 = acc.Zip__c;
        app.StageName                                   ='Prospecting';
        app.Name                                        = acc.Last_Name__C+date.today();
        app.CloseDate                                   = date.Today()+14;
        insert app;
    }
}
I've gone all the way through to where I need to add on a nonmanged app. No matter what I do, it won't let me log into the trailhead org built for me. I've changed the password 3 times just to make sure I typed everything right. I've gone incognito like the help sheet says, but it still doesn't recognize my log in. 

I am building a custom button that is to clone the case details, change the record type, and now they would like to remove the Contract reference field. I can't seem to get it to take. here is what I have built.

/{!Case.Id}/e?RecordType=0124C000000GrXz&{!Case.ParentId}={!Case.Id}&clone=1&cas28={!Case.CaseNumber}&cas14={!Case.Subject}&{!Case.ContactId}=NULL

 

I've also tried change NULL to a blank space, or even " ", but none seem to be able to remove the contact info.

Any assistance would be appreciated.

I wrote this code, but every now and again I get the Too many DML statements error. I am thinking if I just have it batch at 150 a pop, I should be good, but none of my attempts seem to work. Any suggestions would be appreciated.

trigger NewOwnerWelcome on BXG_Contract__c (after update) {
    for (BXG_Contract__c acc :Trigger.new) {
    if(acc.timedelay__c == True){
        Case welcomecall                  = new Case();
        welcomecall.Description           = 'Give Owner Welcome Call';
        welcomecall.Routing__c            = 'Welcome Call';
        welcomecall.Area_Responsible__c   = 'Customer Care';
        welcomecall.Department__c         = 'UNO';
        welcomecall.Origin                = 'BXG Contracts';
        welcomecall.Contract_Number__c    = acc.BG_Contract_Number__c;
        welcomecall.BXGContracts__c = acc.id;
        insert welcomecall;
        }
}
}
I am trying to develop a validation that checks a date field against the create date. The idea is to make sure the agents are putting in dates after (or on) the date teh case was created. The problem I have discovered is that the createdate field doesn't populate until after save, so a validation referencing it at the creation of a case will not stop an agent. And building a code that references today, may cause a validation error where one shouldn't exist. Is there any way to reference a create date, before the case is officially created?
I built a custom button to clone a case and give it a new record type.
It isn't making the clone copy a parent or the clone as child. I've researched and can't seem to find a reason why it doesn't work.
It also isn't copying the subject details, but I am not sure if they are related issues.

My code is below. Detail Page Button/content source URL
/{!Case.Id}/e?RecordType=0124C0000004Rmh&clone=1
Hello,
I am trying to build a custom button for my case object that changes the record type when cloning. I have read online various methods, but am having no luck recreating one that works.
The record type id is 0124C0000004Rmh
Any help would be greatly appreciated.
Original question:
I have a trigger I am working on, but I am drawing a blank on how to build a test for it. Any suugestions?
Below is the code for the trigger.

trigger InsertContracts on Account(after update) { 
List<string> contractNum = new List<string>();
Map<String,Account>  contractMap = new Map<String,Account>();
List<BXG_Contract__c> contUpdList = new List<BXG_Contract__c>();

for(Account acc:trigger.new)
{

 contractNum.add(acc.Contract_Number__c);
 contractMap.put(acc.Contract_Number__c,acc);
 
}

for(BXG_Contract__c cont :[select Id, Account__c,BG_Contract_Number__c from BXG_Contract__c where BG_Contract_Number__c IN:contractNum])
{
 if(contractMap.containsKey(cont.BG_Contract_Number__c))
 {
  
  cont.Account__c =contractMap.get(cont.BG_Contract_Number__c).Id;
  contUpdList.add(cont);
 
 }

}
if(contUpdList!=null && contUpdList.size()>0)
{
 Database.Update(contUpdList);

}



//List<BXG_Contract__c> ContractToInsert = new List<BXG_Contract__c>();

    
  /*  for (Account acct : trigger.new) { 
        BXG_Contract__c con =new  BXG_Contract__c();
        
        
        con.Account__c = acct.id;
        
        con.status__c= 'Draft';
        
        con.BG_Contract_Number__c ='7558378' ;
        
        ContractToInsert.add(con);
    } 
    
    Insert ContractToInsert;
    */
    
    
    
   // List<Contract> contracts = [SELECT Id, BG_Contract_Number__c FROM Contract WHERE BG_Contract_Number__c IN: contractNumbersToAccountIds.keySet()];
    //Map<Integer, Id> contractNumberToContractId = new Map<Integer, Id>(); 
  //  for (Contract cont : contracts) { 
  //      cont.AccountId = contractNumbersToAccountIds.get(cont.BG_Contract_Number__c); 
   // } 
   // update contracts; 

}
Hello,
I am making the transition from Admin to Developer, and I am working on building an Apex Class. Still very new at it. Very.
What I am trying to do is to build code that when a new Account is added, that the system goes and checks the Contracts Object to see if there is a matching Contract to that Account (sometimes Accounts will not have a contract). Normally, I would do this with Access beforehand, but the base files are getting to large for both contracts and accounts. 
What I need is that the code pulls the new account, checks that it has something in the Contract Number Custom Field (Contract_Number__c). If it does, it pulls all the Contracts and does basically a VLOOKUP against the custom field Bg Contract Number (BG_Contract_Number__c). If it finds a match, it fills in the Account lookup field on Contracts. 
Any help would be greatly appreciated.

Hello,
Is there a way to set the default value on a picklist by the user's profile?

I know that I can set it by the Record Type, but different groups use same record type. 

Any suggestions would be appreciated.

Respectfully,
David Jobe

I have two objects linked with a lookup field. 
On each object is a field called "reciept number" (that is unique).
On one object the information comes in through an automated process. My hope is to build something that compares the two "reciept number" fields and if it finds a match, it populates the look upfield with the Salesforce Unique ID number for that record (to link the two records).
Try as I might, I haven't been able to find anything that discusses how this can be done.
Any help in pointing me in the right direction would be greatly appreciated. 

I am building a custom button that is to clone the case details, change the record type, and now they would like to remove the Contract reference field. I can't seem to get it to take. here is what I have built.

/{!Case.Id}/e?RecordType=0124C000000GrXz&{!Case.ParentId}={!Case.Id}&clone=1&cas28={!Case.CaseNumber}&cas14={!Case.Subject}&{!Case.ContactId}=NULL

 

I've also tried change NULL to a blank space, or even " ", but none seem to be able to remove the contact info.

Any assistance would be appreciated.

Hello,
I am trying to build a custom button for my case object that changes the record type when cloning. I have read online various methods, but am having no luck recreating one that works.
The record type id is 0124C0000004Rmh
Any help would be greatly appreciated.