• Morgan Marchese
  • NEWBIE
  • 130 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 37
    Replies

Am I alone here? I feel like, as a developer, VS Code is making it harder for me to do my job.

Pulling new objects and updates from a Salesforce Org is a nightmare. 

'Go To Definition' and 'Find All References' don't work to navigate to method definitions in other classes/objects or find references to methods/classes across objects.

When I try to open a class, it replaces the other class I already had opened, instead of opening it in a new tab. I can't open in a new tab unless I drag the class up to the tab area manually

I have to press a series of windows key + button commands just to pop a class out of the VS Code window into its own separate window to view it on another screen.

The list of problems I am having with this solution is staggering. How is Salesforce shipping this as the new replacement for the Force.com IDE? It does not feel like it's anywhere near ready for supporting rapid, agile Salesforce development.

First and foremost, we are not trying to be unethical. I am in the middle of vetting Salesforce CPQ+ and Salesforce Billing as potential replacements for our existing quoting and billing systems. We are in constant communication with our CPQ team at Salesforce as we continue to evaluate the solution, and I'm going to ask as many people as I can about this.

Long story short, we are looking to build an "App Store", built on Force.com, to host API-connected apps for our own Cloud product. Think of it like our own version of AppExchange. Customers would be authenticated into the website as Customer Community Users via Single Sign-On from our Cloud Product. We haven't decided on Lightning or Visualforce yet. 

A small portion of the overall solution would be Contract/Subscription Self Service, basically this workflow:
  •  Create Amendment Opp
  •  Create Amendment Quote 
  •  Add/Remove Products to the Quote 
  •  Calculate the Quote Pricing 
  •  Order 
  •  Contract
  •  Other small things like viewing previous Invoices and changing default payment methods. 

If we move to Salesforce CPQ, then that action would require creating, reading, and updating SBQQ__ managed objects from users without SBQQ__ licenses.

What I think I know:
  1. According to https://salesforce.stackexchange.com/questions/10518/access-managed-package-object-records-via-unlicensed-user, an apex class without sharing will return an empty result set when executed by an un-licensed user.
  2. Apex natively ignores CRUD and FLS, but honors sharing rules IF the apex class is run with sharing.
  3. According to the chosen answer on the aforementioned question, this CAN be done by leveraging the Ajax Proxy to call a custom Apex REST API

I've been looking into this most of the day and have the following questions:
  1. If I'm running a query in an Apex Class (without sharing) as an unlicensed user, and it returns an empty record set, why would running the same query via custom REST API via the Ajax proxy return results if it's authenticating as the same unlicensed user? (per the answer given on https://salesforce.stackexchange.com/questions/10518/access-managed-package-object-records-via-unlicensed-user)
  2. Can you call an Apex REST API directly from the same org without using Ajax proxy, or is that the recommended method?
  3. Could I use Javascript Remoting to work with the managed package data instead?
Developer console is Salesforce's way for us to check debug logs, track governor limit issues, run queries, and generally just debug all of our developer stuff.... and yet, it's TERRIBLE.

It freezes constantly, it often says it couldn't finish "long running operations", switching perspectives causes the whole browser to lock up, and then once the perspective finally changes it takes a huge amount of time to go from tab to tab (if you can go at all). Once it freezes/crashes, good luck getting it back up because it takes forever to load (if it even loads at all).

This thing is supposed to be our lifeline, our tool to help figure out what's wrong, and I can't even get it to work. Is there an alternative to this poorly implemented program? I can't stand this anymore, I've been trying to suffer through it for 3-4 years now and enough is enough. Why do more people not complain about this tool, and why has Salesforce not released something better by now?
trigger ba on Task (after update, after insert) {
    
    GetMaxActivityDate ad= new GetMaxActivityDate();
    
    
    
    Set<ID> ids = Trigger.newMap.keySet();
    
    List<Task> tk = [select id, whoId,OwnerId from Task where id = :ids limit 1000];
    System.debug('b tasks:'+ tk+ ' size:'+tk.size());
    List<ID> idzz = new List<ID>{};
        
        for(Task a: tk)
    {
        idzz.add(a.whoId);
    }
        
    
    List<Lead> ldz = [select name,id, Sales_Last_Activity_Date__c, Sales_First_Activity_Date__c, OwnerId, IsConverted from Lead where id = :idzz limit 1000];
    
    System.debug('b ids:'+ idzz+'. leads:' + ldz + ' size:' + ldz.size());
    
    List<Lead> updateld = new List<Lead>{};
    
    
    for(Lead a : ldz)
    {
        
        
    
    
    
    
    
                    String ldd = a.id;
        
        if(ldd!=null)
        {
           
        String lds = ldd.subString(0,3);
        
        System.debug('lds: '+ lds);
        
        if(lds.equals('00Q'))
        {
            
             List<aggregateResult> dates = new List <aggregateResult>();
        

        
        
        
       // Lead ld = [select name,id, Sales_Last_Activity_Date__c, Sales_First_Activity_Date__c, IsConverted from Lead where id = :a.WhoId limit 1];
        
        
        
        if(a!=null)
        {
            System.debug('b ' + lds);
            
			Set<ID> taskset = new Set<ID>();
			List<ID>result = new List<ID>();            
            taskset.addAll(idzz);
            result.addAll(taskset);
            System.debug('taskset:'+ taskset.size()+' result:'+result.size());
            
            
            for(ID b:result)
            {
            
            if(b == a.Id)
                {
                     dates = ad.getMaxActivity(b);
                    System.debug('b triggered:  max:'+ (Date)dates[0].get('myMax') + ' min: '+ (Date)dates[0].get('myMin') + 'last activity date:'+ a.Sales_Last_Activity_Date__c + ' first activity date ' +  a.Sales_First_Activity_Date__c+  ' isconverted:'+ a.IsConverted );
                        System.debug('b triggered: lead:'+ a);
                    if(a.IsConverted == false && (dates[0].get('myMax')!=null) && dates[0].get('myMin')!=null && (a.Sales_Last_Activity_Date__c != (Date)dates[0].get('myMax')||a.Sales_First_Activity_Date__c != (Date)dates[0].get('myMin')))
                    {
                        System.debug('Activity_date updated');
                        
                        a.Sales_Last_Activity_Date__c = (Date)dates[0].get('myMax');
                        a.Sales_First_Activity_Date__c = (Date)dates[0].get('myMin');
                        
                        updateld.add(a);
                    }
                    
                    
                }
                
            }
            
        }
        }

        }
    }
    
    update updateld;
    
    
    
    
    
    for(Task a: Trigger.New)
    {

      
        
        
        
    }

}

  public  List<aggregateResult> getMaxActivity(ID who)
    {
        List<aggregateResult> maxDates = [Select Max(Sales_Activity_Date__c) myMax, Min(Sales_Activity_Date__c) myMin from Task 
         where whoid = :who and status = 'Completed'];
            System.debug('Max is:  ' + maxDates[0].get('myMax') + 'min '+maxDates[0].get('myMin'));  
     
        return maxDates;
    }
I was getting this governor limit error in the past, and I rewrote most of the trigger to hopefully fix that, yet I still occasionally see this error. And from personally inserting a bunch of data, i can't seem to reproduce so its having a hard time debug. 

I'm thinking its due to getMaxActivity though because techinically its a select in a for loop? I'm not sure how else logically I can address this though.

thanks!
 
Hey everyone,

I have a VisualForce page embedded within our standard Opportunity layout. Up until now this VF page has just been a table with custom checkbox fields using "inputCheckbox". When a user went to an Opportunity the page would open as normal at the top of the Opportunity page.

However, I've since added an "inputField" to the VF page, which allows the user to fill in one of our existing Lookup fields. The problem is that whenever the user goes to an Opportunity now, the Opportunity will open and then the user is directed down to the VF page instead of staying at the top of the Opportunity.

Is there a reason why the "inputField" parameter causes the screen to immediately redirect down to the VF page?

Thanks,
Greg
We have a ligthning community created using Community Builder. We are trying to mask the URL (https://unfriendlyUrl.force.com/path) with our own corporate URL (https://commsite.harms123.com). I have been following this salesforce help documentation, as well as various posts on the dev forum and Salesforce Stack Exchange. Here is the official SFDC documentation:
https://help.salesforce.com/HTViewHelpDoc?id=siteforce_domains.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=siteforce_domains.htm&language=en_US)

So far this is what we've done:
  1. We created a CNAME subdomain on our corporate website, lets call it community.corpsite.com.
  2. We pointed that CNAME to community.corpsite.com.OUR-18-DIGIT-ORGID.live.siteforce.com as instructed in the guide
  3. We went to Site Configuration | Domains in Set​up and created community.corpsite.com as a domain.
  4. We went to Site.com Studio, Site Configuration | Domains and made sure that the custom domain (community.corpsite.com) was listed.
  5. We published the site through both Site.com Studio AND Community Builder

When I go to my browser and go to community.corpsite.com, it redirects me to https://unfriendlyUrl.force.com/path, but doesn't mask the URL. This results in our customers having a poor branding experience, since we ask them to go to community.corpsite.com but they are being redirected to the force.com URL.

What am I doing wrong? From what I read online in their documentation, they seem to indicate that this is possible, but I can't get it to work. Is this possible? Where do I start, what is my best place for documentation on this? Could use some help, been struggling with this all day.

Thanks for your time
Hoping someone can help me here, I'm getting a de-reference null object error on some code. This code has been working perfectly up until now so I'm kind of scratching my head on this one, we haven't made any code changes recently to this class. I know that a de-reference means that I am making a call to a null list or variable, and that to combat that you should do checks for .size > 0 before proceeding with any implementation, but, as far as I can tell, we've already done that?

Salesforce reports the error at line 106 which when looking in Salesforce is this line:
 
System.debug('KLE spc per account : '+accToSPCMap.get(account.id).size() + ' for acc: '+account.id);

That line comes directly after a size check:
if(accToSPCMap.size() > 0){

So, I'm making it past the .size() > 0 check, but then still de-referencing on the System.debug line directly below it. I'm having trouble tracking down WHAT the null is at this point. Anybody see anything I missed or have any suggestions on tracking the null better?  

Thanks for your time.
 
public with sharing class SendAlertForRelatedProductPlans
{
    // Make the constructor private since this is a utility class that should not be instantiated
    private SendAlertForRelatedProductPlans() 
    {
    }

    public static void checkNewSubscriptionProductCharges(List<Zuora__SubscriptionProductCharge__c> newSubscriptionProductCharges) 
    {
       // The below code will query for the accounts related to the SPCs that are being inserted
        Set<Id> accountIdSet = new Set<Id>();
        List<Messaging.SingleEmailMessage> messages = new List<Messaging.SingleEmailMessage>();

        for(Zuora__SubscriptionProductCharge__c spc : newSubscriptionProductCharges)
        {
            if(spc.Zuora__Account__c != null && spc.Zuora__Subscription__c != null) // Make sure the SPCs are related to an account and subscription
            {
                accountIdSet.add(spc.Zuora__Account__c);
            }
        }

        if(accountIdSet.size() == 0)
        {
            System.debug('The SPCs being inserted were not associated with accounts, quitting early.');
            return; // If none of the SPCs are related to accounts, quit early 
        }

        List<Account> accounts = [SELECT Id, Name, Customer_Number__c FROM Account WHERE Id IN :accountIdSet];

        // For each account, we'll need to query for *all* the related active subscriptions.
        Map<Id, Zuora__Subscription__c> subscriptions = new Map<Id, Zuora__Subscription__c>([SELECT Id, Name, Zuora__Account__c
                                                                                             FROM Zuora__Subscription__c 
                                                                                             WHERE Zuora__Account__c IN: accountIdSet 
                                                                                             AND Zuora__Status__c = 'Active'
                                                                                             AND Name != null]);

        // If there are no active subscriptions associated with the accounts specified, we should not continue.
        if(subscriptions.size() == 0)
        {
            System.debug('There were no active subscriptions associated with the SPCs being inserted. Quitting early.');
            return;
        }

        Set<Id> subscriptionIdSet = subscriptions.keySet();

        // We also need to query for all SPCs associated with the above active subscriptions.
        // Retrieve any SPCs that are:
        // (a) Associated with the set of subscriptions ids
        // (b) The subscriptions must be active
        // (c) Associated with the set of account ids within this trigger context 
        // (d) The SPC isn't a Discount Record
        // (e) The SPC has a Rate Plan Classification
        Map<Id,Zuora__SubscriptionProductCharge__c> spcsAssociatedWithActiveSubscription = new Map<Id,Zuora__SubscriptionProductCharge__c>(
                                                                                         [SELECT Id, RatePlanClassification__c, Zuora__Account__c, Zuora__Subscription__c
                                                                                          FROM Zuora__SubscriptionProductCharge__c
                                                                                          WHERE Name != 'Discount' 
                                                                                          AND RatePlanClassification__c != null
                                                                                          AND Zuora__Subscription__c IN : subscriptionIdSet
                                                                                          AND Zuora__Subscription__r.Zuora__Status__c = 'Active' 
                                                                                          AND Zuora__Account__c IN :accountIdSet]);

        Map<Id, List<Zuora__SubscriptionProductCharge__c>> accToSPCMap = new Map<Id, List<Zuora__SubscriptionProductCharge__c>> ();
        for(Zuora__SubscriptionProductCharge__c zs: spcsAssociatedWithActiveSubscription.values()){
            List<Zuora__SubscriptionProductCharge__c> sub = accToSPCMap.get(zs.Zuora__Account__c);
            if(sub == null){
                sub = new List<Zuora__SubscriptionProductCharge__c>();
                sub.add(zs);
                accToSPCMap.put(zs.Zuora__Account__c, sub);
            }else{
                sub.add(zs);
            }

        }

        // The below two maps will capture whether a subscription has:
        // (a) at least one 'Support' related SPC 
        // (b) at least one 'Software' related SPC

        Integer count = 0;

        System.debug('KLE accounts : '+accounts.size());

        for(Account account : accounts){
            Set<ID> subscriptionIdHasSupportSPCs = new Set<ID>();
            Set<ID>  subscriptionIdHasSoftwareSPCs = new Set<ID>();
            Set<ID>  subscriptionIdHasCommSPCs = new Set<ID>();

            if(accToSPCMap.size() > 0){
            System.debug('KLE spc per account : '+accToSPCMap.get(account.id).size() + ' for acc: '+account.id);
                for(Zuora__SubscriptionProductCharge__c spc : accToSPCMap.get(account.id))
                {
                    if(spc.RatePlanClassification__c == 'Support')
                    {
                        subscriptionIdHasSupportSPCs.add(spc.Zuora__Subscription__c);
                        
                    }
                    else if(spc.RatePlanClassification__c == 'Software')
                    {
                        subscriptionIdHasSoftwareSPCs.add(spc.Zuora__Subscription__c);
                        
                    }
                    else if(spc.RatePlanClassification__c == 'Communication')
                    {
                        subscriptionIdHasCommSPCs.add(spc.Zuora__Subscription__c);
                        
                    }
                    count++;

                } // End of loop through SPCs
           }

 
I need help. Not very good at javascript...yet.

I need a button that will reference a URL that is located within the Account record. Sounds simple right? Maybe it is, but it complicates things for me because of the way that it is constructed.

We have two fields on the record: RRID# and RRID URL. The RRID# is a specific number that we need to assign through dataloader (e.g. 12345). The RRID URL is a complex formula field that refers tot eh RRID#:

"https://prod.vendor.com/Report/Index/?rrid="& text(RRID__c) &"&hash=" &
text(CASE(month(today()), 1, 49*1, 2, 48*2, 3, 50*3, 4, 57*4, 5, 50*5, 6, 48*6, 7, 49*7, 8, 53*8, 9, 80*9, 10, 101*10, 11, 110*11, 12, 115*12, 0) + DAY(today()) + mod( RRID__c , DAY(today())))
&"&partnerkey=1234567PenYs"

So basically, the URL would end up looking something like this:

https://prod.vendor.com/Report/Index/?rrid=15&hash=93&partnerkey=1234567PenYs (https://prod.vendor.com/Report/Index/?rrid=15&hash=93&partnerkey=1234567PenYs)

We want users to be able to click a button as opposed to the link in the body of the record. How would I accomplish this?

Thanks in advance for your help!

Shannon
How can I modify this code to prohibit custom button from functioning while record is within the approval process? See image for code detail. Also fire alert "Cannot use button while record is within the approval process"

thank you-

User-added image
I have created the code via the Chat Button design, but am unable to add it to the current Communities page. Community Builder does not allow anything be added in, and Site.com does not allow the template to be edited (as it mentions the page is a Lightning template.) Lightning Components can be built, but do not allow for this sort of scripting. How does something scripted get added via Community Builder or Site.com Studio?
Hi All - We have a custom object, called "Subscription Product & Charge", and we have a trigger on it that executes many different apex classes, called "SubscriptionProductChargeTrigger". Sometimes bulk inserts by a third party cause CPU limits on some old bulky code, and I usually end up editing the trigger in sandbox, commenting out the line that causes the limit issue, deploying to prod, running the bulk insert, and then editing the trigger again in sandbox to remove the comment and deploy to prod again. This is of course time consuming.

So, just this weekend I added a Custom Setting (List) called "MSI_TriggerControl" and created 7 checkbox fields with the intention of being able to "De-activate" the trigger by setting them to true, without doing what I just did above ^

I added to the trigger to get the instance of 'TriggerControl' from my MSI_TriggerControl Custom Setting under the alias 'settings', and then directly following that I attempt to create and set 7 distinct Boolean values using the respective true/false value of the corresponding checkbox in MSI_TriggerControl__c('TriggerControl'). This works perfectly in dev and properly disables sections of the trigger during all testing, but during deployment it throws a de-reference null exception on line 6 which is the first Boolean I am trying to set (Disable_AlertForRelatedSPC). Yes the 'TriggerControl' record is created and yes I deployed all 7 checkbox fields w/ the same API names to Production already... All I can say is that every time one of my test classes attempts to insert an SPC I get a de-reference on line 6 of this trigger.

I modified the trigger using some help and resources from: http://www.sfdc99.com/2014/03/02/change-your-code-on-the-fly-using-custom-settings/

Here is my new code:
trigger SubscriptionProductChargeTrigger on Zuora__SubscriptionProductCharge__c (after insert, after update)
{

// Grab Custom Setting values
    MSI_TriggerControl__c settings = MSI_TriggerControl__c.getInstance('TriggerControl');
    Boolean Disable_AlertForRelatedSPC = settings.Disable_SPCTrigger_AlertForRelatedSPC__c;
    Boolean Disable_SetAnniversaryDate = settings.Disable_SPCTrigger_SetAnniversaryDate__c;   
    Boolean Disable_UpdateSupportLevel = settings.Disable_SPCTrigger_UpdateSupportLevel__c;   
    Boolean Disable_InsertCasesUsingSPC = settings.Disable_SPCTrigger_InsertCasesUsingSPC__c;  
    Boolean Disable_UpdateTrainingMinutes = settings.Disable_SPCTrigger_UpdateTrainingMinutes__c;    
    Boolean Disable_UpdateAccountRecord = settings.Disable_SPCTrigger_UpdateAccountRecord__c;  
    Boolean Disable_CreateUpdateSPC = settings.Disable_SPCTrigger_CreateUpdateSPC__c;
    
    // ********************
    // *** AFTER INSERT ***
    //*********************

    /*
    if(TriggerControl__c.getValues('runSubscriptionProdChargeTrigger') != null)
        return;
    */
    if(trigger.isAfter && trigger.isInsert){

        //Account update map moved here so Accounts will be updated only once
        Map<ID, Account> accountsMap = new Map<ID, Account>();
        if(Disable_AlertForRelatedSPC == false){
        SendAlertForRelatedProductPlans.checkNewSubscriptionProductCharges(trigger.new); // No objects are modified
        }
        if(Disable_SetAnniversaryDate == false){
        AccountUpdateHandler.updateAnniversaryDateUsingSPCList(trigger.new, accountsMap); // This updates accounts
        }
        if(Disable_UpdateSupportLevel == false){
        AccountUpdateHandler.updateSupportLevelUsingSPCList(trigger.new, accountsMap); // This updates accounts
        }
        if(!ZuoraUtilityClass.isZuoraSyncRunning()){
            // Note: The below two method calls should not be separated.  If we insert cases, we must update accounts as well
            if(Disable_InsertCasesUsingSPC == false){
            CaseHandler.insertCasesUsingSPCList(trigger.new); // This inserts cases 
            }
           // AccountUpdateHandler.updateInstallTypeUsingSPCList(trigger.new, accountsMap); // This updates accounts
        }
        if(Disable_UpdateTrainingMinutes == false){
        AccountUpdateHandler.updateTotalTrainingMinutes(trigger.new, accountsMap); // This updates accounts        
        }
        if(Disable_UpdateAccountRecord == false){
        AccountUpdateFromSPC.updateAccountRecord(trigger.New, accountsMap); //Updates Billing Status, Active and Platform Application fields on the Account
        }
        try{
            //one account update instead of many
            update accountsMap.values();
        }
        catch(DmlException e){
            System.debug('The following exception has occurred: ' + e.getMessage());

        } 

        if(Disable_CreateUpdateSPC == false){
        CRAHandlerUsingSPCClass.CreateUpdateCRARecord(trigger.New); //This creates/updates CRA (Account Administration Record)
        }
    }
}
Help me Salesforce Developer forum, you're my only hope!
 
I have 3 different doFind's on my Pre-Chat form, one to find Accounts by Account Number (Auto Number field), one is to find customers by email field, and one is to find cases by case field.

When I had only one doFind in my prechat form for accounts by account number, it would automatically open up a sub-tab within the Service Console and display the correct account when the customer gave us their number in the form. However, when I introduced my 2 additional doFinds (customers by email and cases by case number), I expected it to give me 3 separate sub-tabs, one for each match. One account subtab, one contact subtab, and one case subtab. Instead, I am just receiving one sub-tab called "Search Results" which displays one account that matched, one contact that matched, and one case that matched:

User-added image

My user has to physically click on each of these 3 search results to open each in its own subtab.

I expected each of my 3 doFinds to open in its own tab since that was the result when my form had only one doFind. They are separate finds for different records so I figured it would work the same way - is this not the case? Is the functionality I am experiencing considered correct, or am I doing something wrong? My ideal solution would be that if the customer fills out all 3 fields, we get 3 subtabs within the Live Agent session in the console, specific to each record that we found that matched.

I hope this makes sense, please let me know if I can clarify any further.

Thanks!
I am working on a PreChat VisualForce page. On that page, the customer enters the following info into the perchat form:
First Name (FirstNameDetail), Last Name(LastNameDetail), Email(EmailDetail), and Customer Number (CustomerNumber).

I am trying to do 2 separate isExactMatch hidden fields:
  1. Open the Account if CustomerNumber in the form is an exact match to Customer_Number__c custom field on Account
  2. Open the Contact if EmailDetail in the form is an exact match to Email on Contact AND the CustomerNumber field in the form is an exact match to the Customer_Number__c field on the Contact.
Note: The Customer_Number__c field on the Contact is a text based Formula field that just displays 'Account.Customer_Number__c' on each Contact Record.

I know that INDIVIDUALLY, each of my ExactMatches work. I know this because I tested the Account ExactMatch by itself by removing the Contact ExactMatch from the page, and I also did the reverse and tested the Contact ExactMatch by removing the Account ExactMatch. In each scenario, the Account or Contact record was successfully opened as an Exact Match in a subtab in the console. However, when adding both together to the page, it doesn't open 2 sub-tabs as I'm hoping it would.

Desired Result:
  1. If Customer Number matches on the Account but Email/Customer Number doesn't match on the contact - I want to load the Account Page only.
  2. If Customer Number matches on Account AND Email/Customer Number on Contact matches, I want to have the Account Page AND the Contact Page loaded as 2 separate sub-tabs within the Service Console window for the live agent session.

Current Result:
Right now with my current implementation, desired result #1 works as expected. I enter a customer number and an incorrect email, and it loads up the correct account and no contact record.
However, desired result #2 is not working as expected. If I enter a customer number and a CORRECT email of a contact linked to that account, it loads up a Search Results page that displays the Account and the Contact, rather than loading the account and contact into their own subtabs, as seen in the screenshot below:
User-added image
My desired result is that when it exact matches all criteria, it opens up the Account in a Subtab, and the Contact in another subtab, instead of just giving me a search results page like I'm getting now.

Reason:
The reason I am doing this is because in our specific Salesforce Instance, it is possible for a contact to exist more than once with the same email address, but under different accounts, because one contact may own or operate multiple accounts. Each of our accounts is identified by a unique number called Customer Number, and so I need to match for contacts of THAT specific account, rather than just contacts as a whole. If I limit myself to searching only Email, I could end up with 20+ different contact results of the same person on 20+ different accounts.

Code:
<apex:page showHeader="false"> 
<!-- CSS and SCRIPTS removed to save space on Dev Forum Post-->
<div>
    <form method='post' id='prechatForm'> 
        <table class="formTable">
            <tr>
                <td><b>First Name:</b></td>
                <td><input type='text' name='liveagent.prechat:FirstNameDetail' /> </td>
            </tr>
            <tr>
                <td><b>Last Name:</b></td>
                <td><input type='text' name='liveagent.prechat:LastNameDetail' /></td>
            </tr>
            <tr>
                <td><b>Email Address:</b></td>
                <td><input type='text' name='liveagent.prechat:EmailDetail' /></td>
            </tr>
            <tr>
                <td><b>Customer Number:</b></td>
                <td><input type='text' name='liveagent.prechat:CustomerNumber' /></td>
            </tr>
            <tr><td>&nbsp;</td></tr>
            <tr>
                <td><b>Department:</b></td>
                <td>
                        <select name="liveagent.prechat.buttons">
                        <!-- Values are LiveChatButton IDs. -->
                        <option value="573U0000000TTKV">ABC Support</option>
                        <option value="573U0000000TTzY">XYZ Support</option>
                        <!--<option value="573U0000000TTzY,573U0000000TTKV">XYZ Support If Available,
                        otherwise ABC Support</option>-->
                        </select>
                </td>
            </tr>
            <tr><td>&nbsp;</td></tr>
            <tr>
                <td><input type='submit' value='Start Chat' id='prechat_submit'/></td>
            </tr>
        </table>

<!--Save Email Address to Chat Transcript-->
<input type="hidden" name="liveagent.prechat.save:EmailDetail" value="Email__c" />
<!--Save Customer Number to Chat Transcript-->
<input type="hidden" name="liveagent.prechat.save:CustomerNumber" value="Customer_Number__c" />

<!--POP OUTS-->

    <!-- ACCOUNT -->
        <!--Map To an Account if CustomerNumber variable in form equals Customer_Number__c custom field on account -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Account"
        value="Customer_Number__c,CustomerNumber" />
        
        <!--doFind where Customer_Number__c match = true -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account"
        value="Customer_Number__c,true" />
        
        <!--Open the Account when we find an Exact Match -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account"
        value="Customer_Number__c,true" />

    <!-- CONTACT -->
        <!--Map to a Contact if CustomerNumber variable and EmailDetail variable in form match to Customer_Number__c and Email field on contact-->
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Contact"
        value="Customer_Number__c,CustomerNumber;Email,EmailDetail" />
        
        <!--doFind where Customer_Number__c match = true and Email match = true -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact"
        value="Customer_Number__c,true;Email,true" />
        
        <!--Open the Contact whne we find an Exact Match-->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact"
        value="Customer_Number__c,true;Email,true" />

</form> 
</div>
</apex:page>


I've been racking my brain on this all morning and not getting any farther - could use some extra brain power from the community. All thoughts and input appreciated. Thanks!
Hi all, I'm new to apex but currently going through some online courses but haven't quite grasped how I can achieve this yet...

Scenario: We have a custom object from our Zuora managed package called 'Quote Charge'. Within this object are many records. Two of these records are technically 'associated' with each other, but not using a lookup field or any traditional SFDC linking. Instead, they have a custom field that shares a unique value between these 2 'associated' records. So, both of these records have a field where the value is "20150814ABCD" for example - that field is unique to these TWO records and will never be found on any other records of this object. One of these 2 records is named "Discount", and the other one can have any varying name.

Goal: I need to, using apex I presume, find these 2 matching records based on that custom field being an exact match between the 2, and then take the discount % from a field on the record named "Discount" and apply it to another custom field on the record that isn't named "Discount"

Can anyone give me a good starting point for this/point me in the right direction? I started writing some code in a class to play around with the idea, but I don't think I'm going about it the best way. Would appreciate some feedback from the SFDC Gurus.

Many thanks,

Morgan