• Plainview
  • NEWBIE
  • 25 Points
  • Member since 2014
  • Salesforce Platform Manager
  • O'Reilly Media Inc.


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 38
    Replies
Hello,

We use MicroSoft Word documents for our Sales Agreement Templates, which are held in our Conga Repository.

We have a field in our Salesforce Opportunities, "Discount," that we want to be only visible on the completed and merged Templates if there is a value in the field. In other words, if the client is not receiving a discount, we don't want the discount field on the Sales Agreement.

I'm having a difficult time understanding how "IF" statements and Merge fields that can work in our implementation. I've attached a screenshot of the Discount Field(s) in question from our Sales Agreement template.

Does anyone know the appropriate construction of a conditional "IF" merge field with regard to what we have?

Highlighted in blue below with the field codes toggled is the Discount field as it appears now:

User-added image
I appreciate any guidance on this!

Best wishes,
Julien
Hello,

I have standardized our Opportunity naming convention via a Workflow Rule and  (Formula) Field Update, which works great with regular Accounts:

IF (RecordType.Name  = 'Safari New',
TEXT(YEAR (CloseDate)) & "  -  " & Account.Name & "  -  " & TEXT (Product_Type__c) & "  -  " & TEXT(Type)  & "  -  " & TEXT (Number_of_Users__c) & " Users","")

However, this does not work for Person Accounts - Account Name does not populate.

I'm trying to add to the formula field syntax to account for Opportunites associated with Person Accounts but am having trouble writing the formula field syntax. So far I have:

IF(Account.PersonContact.RecordTypeId = '0120000000099Lo',
&&(AND(RecordType.Name  = 'Safari New',
TEXT(YEAR (CloseDate)) & " - " &  Account.PersonContact.Account.Name & " - " & TEXT (Product_Type__c) & " - " & TEXT(Type)  & " - " & TEXT (Number_of_Users__c) & " Users",""))

... but this does not pass the syntax check. I'm convinced it's something relatively simple, so was hoping for some insight as to what Function or Operator I'm missing or have imput incorrectly.

Thanks so much!

Best,
Julien
Hello all,

So, we have developed a sidebar component that is a pricing calculator for our Sales Rep. It is set-up as a Home Page Componenet and is a Visualforce Page.

On the Home page, it works/functions/appears fine:

View on Home Page Layout

... and looks like this when you click on the other object tabs. But, as soon as we click through to a specific record on the other tabs, it goes wonky:

User-added image
It appears to be displaying a portion of the Home page.

Here's (some of) the code from the VF page:


<apex:page standardController="Opportunity" extensions="OpportunityCustomLayoutExtension" sidebar="false" showHeader="false">
<body>
<style>
body {
font-size: 9px;
background-color: #cfeef8; }
.inputClass {
}
</style>
<apex:form id="theForm">
<table>
(all the table stuff here that creates the input fields etc.)
 </table>
</apex:form>
</body>
</apex:page>

Is there some way I need to wrap the whole thing up so it will display properly?

Thanks for any assistance in advance!


 
Hello All,

I've been assigned the task of creating a custom button on the Contact object to automagically convert Contacts to Person Accounts. I came across a great post online here:

http://www.x2od.com/2008/08/19/convert-between-business-and-person-accounts-b2b-b2c#comment-70797

... which seems like the direction I need to go. I did create the custom button to execute Java - here's the code:

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 
var ContactObj = new sforce.SObject("Account"); 
ContactObj.Id = '{!Account.Id}'; 
ContactObj.RecordTypeId = '0120000000099Lo'; 
sforce.connection.update([ContactObj]); 
location.reload(true);

No syntax errors, created the button, put it on the Contact layout, created a test Contact, hit the button ... and ... zippo; nothing happens, not even an error message.

Anyone have a clue what I might be missing?

Thanks!
I'm just wondering if there is a way to determine which version of Live Agent is implemented in our SF org. It looks like 32.0 is the most recent version of Live Agent available but I'm not sure if we have the most recent version integrated with our implementation.

Thanks!

Best,
Julien

I have an Apex Trigger in our Sandbox that is designed to assign leads to the Sales Rep. who owns the related Account. The requirements are as follows:

1. Automate the routing of leads for existing accounts to the account owner.
2. If a duplicate account/company exists and each have different owners, any new leads created should be assigned to our Sales Manager.

Example:

ABC Company has an existing account where the Account Owner is John Smith
ABC Company has a 2nd existing account where the Account Owner is Jane Doe
A new Lead is submitted for ABC Company
Expected Result: Assign the Account Owner to Sales Manager by default; she will be the tie breaker.

The code I developed:

rigger addAccount on Lead (before Insert, before Update){
  
  final String marjorieUserId = '00500000006pFs8';
  
  List<String> companies = new List<String>();
  
  for (Lead l : trigger.new){
    if (String.isEmpty(l.company)) continue; 
    if (l.ownerId != null) continue;
    companies.add(l.company);
  }

  if (companies.isEmpty()) {
    // we can not pull any accounts without knowing their names
    return ;
  }

  final List<String> nameValues = new List<String>();
  
  for (String companyName : companies) {
    nameValues.add('(Name = \'' + String.escapeSingleQuotes(companyName) + '\')');
  } 

  final List<Account> leadAccountIds = Database.query('Select Id, OwnerId, Name FROM Account WHERE ' + String.join(nameValues, ' OR '));  

  Map<String, Id> acctNameId = new Map<String, Id>();
  Map<String, Id> acctNameOwner = new Map<String, Id>();
  Map<String, Boolean> duplicateAccountMap = new Map<String, Boolean>();
      
  for (Account a : leadAccountIds) {
      acctNameId.put(a.name, a.Id);
      acctNameOwner.put(a.name, a.ownerId);
      if (duplicateAccountMap.containsKey(a.Name)) {
          duplicateAccountMap.put(a.name, true);
      } else {
          duplicateAccountMap.put(a.name, false);
      }
        
  }
  
  for (Lead l2 : trigger.new){
    
    if ((l2.ownerId != null)) {
      //ReportingService.notifyEngineers('lead already has an owner', lead.Email + ' : ' + lead.ownerId);
      continue;
    }
    
    if (marjorieUserId.equals(l2.ownerId)) {
      ReportingService.notifyEngineers('lead is assigned to Marjorie', 'at addAccount triggah line 27');
      continue;
    }
    if(acctNameId.containsKey(l2.company)) {
        l2.Account__c = acctNameId.get(l2.company);
      if (duplicateAccountMap.get(l2.company)) {
        ReportingService.notifyEngineers('assigning lead to Marjorie', 'at addAccount triggah line 33');
            l2.ownerId = marjorieUserId; // Marjorie
        } else {
          if (marjorieUserId.equals(l2.company)) ReportingService.notifyEngineers('lead is assigned to Marjorie', 'at addAccount triggah line 36');
            l2.ownerId = acctNameOwner.get(l2.company);
        }
    
    }
      
  }

}


The issue is that the Trigger is firing again when the Sales Manager tries to reassign the new lead to it's corresponding Account owner; it blocks her out and she is unable to reassign the lead.

I would like to add logic to the code that prevents the Trigger from firing twice.

Thanks,
Julien

Our sales forecasts tend to be off because the renewal opportunity probability default is 65%. We'd like to change these defaults to different percentages based on the Opportunity Amount field for Opps in the proposal stage:

65% for Opp. amounts less than $5K
80% for $5k -15k
85% for $15k - 99k
95% for > $100K


We have an apex trigger that deals with our probabilities. Right now, it has some logic for the Closed opps:

//NEW:
    //changed this trigger to only reset the probability on closed won, lost opps.

    Map<String, Integer> closeMap = new Map<String, Integer>();
    closeMap.put('Closed Won', 100); 
    closeMap.put('Closed Lost', 0);
    closeMap.put('Closed Funnel Purge', 0);    
    
    for (Integer i = 0; i < Trigger.new.size(); i++) {
        if (closeMap.containsKey(Trigger.new[i].StageName)) {
            Trigger.new[i].Probability = closeMap.get(Trigger.new[i].StageName);    
        }
    }    

So, I need to build from here. Any suggestions?

Thanks,

Julien

We have a field on our Opps. layouts, "Reason," which is a dependent picklist field, with the controlling field being "Stage."

We would like the Reason field to be required when the Stage field is set to "Closed Won," "Closed Lost" or "Closed Funnel Purge."

Because of a Visualforce page ("opportunityCustomlayout"), the Reason field is not showing as required, even though it is listed as a dependent field under the Field Dependencies in the field definition settings.

Also, a Validation Rule did not work because of the customization made via the Visualforce page, which overrides the standard functionality; we cannot implement a Validation Rule against a Visualforce page.

I am resourcing for some help to write the code into the Visualforce page to make the Reason field required per the above criteria.

Thanks.
I am new to Apex and need to add an index filter.

The query in question:

"List<Account> leadAccountIds=Select Id, OwnerId, Name FROM Account WHERE Name IN: companies;"

Seeking some syntax advice.

Thanks!
 

Hello,

Have received this error message:

Apex script unhandled exception by user/organization: 00500000006r7Mb/00D00000000hgdL

Visualforce Page: /apex/opportunityButtons

caused by: System.QueryException: List has no rows for assignment to SObject

Class.opportunityButtons.<init>: line 73, column 1


The relevant line from the code; line 73 starts with "theOpp":

public opportunityButtons(ApexPages.StandardController controller) {   
   
    refreshOpp = '';
   
    theOpp = [SELECT
          Id,
          OwnerId, 
          Contract__c,
          Type,
          Name,
          Pay_Option__c,
          StageName,
          Amount,
          Renewal_Opportunity__r.Id,
          Renewal_Opportunity__r.Amount,
          Renewal_Opportunity__r.StageName,
          RenewalWithUpgrade__c,
          RecordTypeId,
          triggerTimeStamp__c,
          Original_Agreement_Date_New__c,
          approvalStatus__c,
          Existing_Service__c,
          Existing_Downloads__c,
          Existing_Slots_per_User__c,
          Existing_Users__c,
          Existing_Max_Users__c,
          Existing_Contract_Term_Months__c,
          Existing_Subscription_Total__c,
          Pricing_Type__c,
          Downloads_Enabled__c,
          Slots_per_User__c,
          Number_of_Users__c,
          Max_Users__c,
          Contract_Term_Months__c,
          Subscription_Total__c,
          Product__c
          FROM Opportunity
          WHERE Id=:((Opportunity)controller.getRecord()).Id];   
     
  
    SAurl = '';
    SSPurl = '';

I haven't made changes, so am confused why this is popping up now? Anybody have an idea?

Thanks,
Julien

Hello,

I'm attempting to add a new field to a VisualForce page but I am receiving this Error Message:

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contract.X18_Digit_Account_Id__c

X18_Digit_Account_Id__c is a custom field on the contract object.

Here's where I'm trying to add it  (in bold):

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Demo ID" for="DemoIDNumber"/>
    <apex:outputText value="{!DemoIDNumber}" id="DemoIDNumber"/>   
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Account ID" for="BOAccountID"/>
    <apex:outputText value="{!contract.BO_Account__c}" id="BOAccountID"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
    <apex:outputLabel value="18 Digit Account ID" for="X18_Digit_Account_Id__c"/>
    <apex:outputText value="{!contract.X18_Digit_Account_Id__c}" id="X18_Digit_Account_Id__c"/>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem >
    <apex:outputLabel value="Creator ID" for="BO_User_ID__c"/>
    <apex:outputText value="{!user.BO_User_ID__c} ({!user.Name})" id="BO_User_ID__c"/>

</apex:pageBlockSectionItem>
       
<apex:pageBlockSectionItem >
    <apex:outputLabel value="Account Name" for="contractAccountName"/>
    <apex:outputText value="{!contract.Account.Name}" id="contractAccountName"/>
</apex:pageBlockSectionItem>

I've also attached a screenshot of how the page looks before my change.

I'm a new Developer - can anyone help me sort out the syntax? This is my first alteration to a VF page. I've searched for this error message and have reviewed the resulting posts but am having difficulty applying the info. to my situation.

Thanks,
Julien

User-added image

Hello,

I am a brand spanking new developer and I have code that is working (!!) for us now in our Production instance - it assigns new Leads to the Owners of matched Existing Accounts.

To level it up a bit, we would like the code to also route leads to a default user (who will function as the tie breaker) when the lead is matched to two Account Records for the same company name that have different owners. I was provided with a helpful suggestion, which was to copy the last logic loop to do this, but have no idea how to write the code myself, although the comment makes sense to me. The comment was:

"I would add some if/then logic to your leadAccountIds loop - use the same containsKey logic you have in the bottom loop to detect if a value is already in the Map for that Account - if so, then do another put (just copy the lines you have) and substitute in the "default user".

The "default user" would be MNeeley with user id 00500000006pFs8.

Can anyone please give a beginner the remaining lines of code that are needed? I really appreciate any help with this!

Here's the code as it is now:

trigger addAccount on Lead (before Insert, before Update){
List<string> companies=new list<string>();

For (lead l:trigger.new){
  companies.add(l.company);

}

List<Account> leadAccountIds=[Select Id, OwnerId, Name FROM Account WHERE Name IN: companies];
Map<String, Id> acctNameId=new Map<String, Id>();
Map<String, Id> acctNameOwner=new Map<String, Id>();

For (Account a:leadAccountIds){
  acctNameId.put(a.name,a.Id);
  acctNameOwner.put(a.name,a.ownerId);

}

For (Lead l2:trigger.new){
  if(acctNameId.containsKey(l2.company)){
    l2.Account__c=acctNameId.get(l2.company);
    l2.ownerId=acctNameOwner.get(l2.company);

  }
  
}

}
Hello,

I found this great code that is working (!!) for us now in our Production instance - it assigns new Leads to the Owners of matched Existing Accounts.

To level it up a bit, we would like the code to also route leads to a default user (who will function as the tiebreaker) when the lead is matched to two Account Records for the same company name that have different owners. Can anyone provide a quick line of logic that might do this?

Here's the code:

trigger addAccount on Lead (before Insert, before Update){
List<string> companies=new list<string>();

For (lead l:trigger.new){
  companies.add(l.company);

}

List<Account> leadAccountIds=[Select Id, OwnerId, Name FROM Account WHERE Name IN: companies];
Map<String, Id> acctNameId=new Map<String, Id>();
Map<String, Id> acctNameOwner=new Map<String, Id>();

For (Account a:leadAccountIds){
  acctNameId.put(a.name,a.Id);
  acctNameOwner.put(a.name,a.ownerId);

}

For (Lead l2:trigger.new){
  if(acctNameId.containsKey(l2.company)){
    l2.Account__c=acctNameId.get(l2.company);
    l2.ownerId=acctNameOwner.get(l2.company);

  }
   
}

}
Assigning Live Chat Leads to Reps who handled the Chat:

For live chat leads, is there a way for the leads generated by the Live Agent Chat to be assigned to the sales rep. that picks up the chat? Currently in our org., if a rep./user picks up a chat and handles it, it gets reassigned to a Sales Manager, who then has to assign it back to them.

Thanks!

Julien
Assignment Rule for New Leads for Existing Accounts. How?

Hello,

I would like to write either a lead assignment rule, workflow rule or Apex Trigger to accomplish this.

We would like our lead assignment, trigger and/or workflow rules to check if the lead's COMPANY already exists as an ACCOUNT, and therefore assign the new lead to the proper ACCOUNT OWNER.

Is there a formula that anyone can provide me to make this happen?

It would be great if the formula would look for CONTAINS "ACCOUNT NAME" rather than a direct match, for cases where a new lead submits their company name in a format slightly different than our existing ACCOUNT NAME.

Thank you greatly for your help.

We have an VF Apex Class called opportunityButtons that controls the behavior of a pane of buttons on our renewal Opportunities layout. Currently, an error message is generated when the user selects the button to create a .pdf of the sales agreement (or selects the other button to create through DocuSign) and the Primary/Contact Role has no mailing address.

We would like to implement a similar error message when the opportunity is a renewal and the Original Agreement Date has not been entered in the record.

If this is something you think you can help with, we can either chat here or do a hangout. I can also share the code through GitHub gist.

Any guidance will be greatly appreciated.

Thanks,

Julien

I'm a new admin and we have a very complicated instance. I've been working to map Conga templates for our Sales Agreements to specific Opp types (Renewal) and Pricing Types, which appear on a picklist.

I would really appreciate some guidance - I have a github gist link if you're interested in helping with this. We'll probably have to do a Hangout and screenshare to fully understand the situation - too much to write here.

Thanks so much for your time!

~Julien


Hello,

We have an Apex Class (opportunityButtons), which is coded to expose a button on our opportunities to only a few specific User Id's. The Security link to the class is set to allow access to this class but not everyone under the listed profiles can see the button; only those whose record Id's appear in the code. I double-checked by adding my own User Id and it worked, so I know this is where this has been set-up.

My question is: what would be the logic to expose the button to everyone under a certain Profile as opposed to having to input each User's Id to allow access to the button.

The button appears on our "upgrade" opps layout for the User whose Id's appear in the code. Here are a couple of screenshots - one showing the button in question and the other, the related code.

Thanks for any help!

Best,
Julien

User-added imageUser-added image
Hello,

I am a new System Admin. obliged to function above my ability - so what else is new?

We use an Apex Class "ProvisioningInfo," which is tied to a Visualforce page button users may select on the Contract object layout that feeds the Billing Contact information into a system called Back Office. I would like to know the "what" and "where" to add some logic to the class so that it returns "null" if the Billing Contact country is not the United States.  Thanks for your time!

Here are some screen shots of what I believe are the relevant areas in the Apex code:

User-added image
User-added image


My company would like to switch all existing 15 digit account ID's to the 18 digit format. Anyone know how to go about this?
Hello,

I have standardized our Opportunity naming convention via a Workflow Rule and  (Formula) Field Update, which works great with regular Accounts:

IF (RecordType.Name  = 'Safari New',
TEXT(YEAR (CloseDate)) & "  -  " & Account.Name & "  -  " & TEXT (Product_Type__c) & "  -  " & TEXT(Type)  & "  -  " & TEXT (Number_of_Users__c) & " Users","")

However, this does not work for Person Accounts - Account Name does not populate.

I'm trying to add to the formula field syntax to account for Opportunites associated with Person Accounts but am having trouble writing the formula field syntax. So far I have:

IF(Account.PersonContact.RecordTypeId = '0120000000099Lo',
&&(AND(RecordType.Name  = 'Safari New',
TEXT(YEAR (CloseDate)) & " - " &  Account.PersonContact.Account.Name & " - " & TEXT (Product_Type__c) & " - " & TEXT(Type)  & " - " & TEXT (Number_of_Users__c) & " Users",""))

... but this does not pass the syntax check. I'm convinced it's something relatively simple, so was hoping for some insight as to what Function or Operator I'm missing or have imput incorrectly.

Thanks so much!

Best,
Julien
Hello all,

So, we have developed a sidebar component that is a pricing calculator for our Sales Rep. It is set-up as a Home Page Componenet and is a Visualforce Page.

On the Home page, it works/functions/appears fine:

View on Home Page Layout

... and looks like this when you click on the other object tabs. But, as soon as we click through to a specific record on the other tabs, it goes wonky:

User-added image
It appears to be displaying a portion of the Home page.

Here's (some of) the code from the VF page:


<apex:page standardController="Opportunity" extensions="OpportunityCustomLayoutExtension" sidebar="false" showHeader="false">
<body>
<style>
body {
font-size: 9px;
background-color: #cfeef8; }
.inputClass {
}
</style>
<apex:form id="theForm">
<table>
(all the table stuff here that creates the input fields etc.)
 </table>
</apex:form>
</body>
</apex:page>

Is there some way I need to wrap the whole thing up so it will display properly?

Thanks for any assistance in advance!


 
Hello All,

I've been assigned the task of creating a custom button on the Contact object to automagically convert Contacts to Person Accounts. I came across a great post online here:

http://www.x2od.com/2008/08/19/convert-between-business-and-person-accounts-b2b-b2c#comment-70797

... which seems like the direction I need to go. I did create the custom button to execute Java - here's the code:

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 
var ContactObj = new sforce.SObject("Account"); 
ContactObj.Id = '{!Account.Id}'; 
ContactObj.RecordTypeId = '0120000000099Lo'; 
sforce.connection.update([ContactObj]); 
location.reload(true);

No syntax errors, created the button, put it on the Contact layout, created a test Contact, hit the button ... and ... zippo; nothing happens, not even an error message.

Anyone have a clue what I might be missing?

Thanks!

I have an Apex Trigger in our Sandbox that is designed to assign leads to the Sales Rep. who owns the related Account. The requirements are as follows:

1. Automate the routing of leads for existing accounts to the account owner.
2. If a duplicate account/company exists and each have different owners, any new leads created should be assigned to our Sales Manager.

Example:

ABC Company has an existing account where the Account Owner is John Smith
ABC Company has a 2nd existing account where the Account Owner is Jane Doe
A new Lead is submitted for ABC Company
Expected Result: Assign the Account Owner to Sales Manager by default; she will be the tie breaker.

The code I developed:

rigger addAccount on Lead (before Insert, before Update){
  
  final String marjorieUserId = '00500000006pFs8';
  
  List<String> companies = new List<String>();
  
  for (Lead l : trigger.new){
    if (String.isEmpty(l.company)) continue; 
    if (l.ownerId != null) continue;
    companies.add(l.company);
  }

  if (companies.isEmpty()) {
    // we can not pull any accounts without knowing their names
    return ;
  }

  final List<String> nameValues = new List<String>();
  
  for (String companyName : companies) {
    nameValues.add('(Name = \'' + String.escapeSingleQuotes(companyName) + '\')');
  } 

  final List<Account> leadAccountIds = Database.query('Select Id, OwnerId, Name FROM Account WHERE ' + String.join(nameValues, ' OR '));  

  Map<String, Id> acctNameId = new Map<String, Id>();
  Map<String, Id> acctNameOwner = new Map<String, Id>();
  Map<String, Boolean> duplicateAccountMap = new Map<String, Boolean>();
      
  for (Account a : leadAccountIds) {
      acctNameId.put(a.name, a.Id);
      acctNameOwner.put(a.name, a.ownerId);
      if (duplicateAccountMap.containsKey(a.Name)) {
          duplicateAccountMap.put(a.name, true);
      } else {
          duplicateAccountMap.put(a.name, false);
      }
        
  }
  
  for (Lead l2 : trigger.new){
    
    if ((l2.ownerId != null)) {
      //ReportingService.notifyEngineers('lead already has an owner', lead.Email + ' : ' + lead.ownerId);
      continue;
    }
    
    if (marjorieUserId.equals(l2.ownerId)) {
      ReportingService.notifyEngineers('lead is assigned to Marjorie', 'at addAccount triggah line 27');
      continue;
    }
    if(acctNameId.containsKey(l2.company)) {
        l2.Account__c = acctNameId.get(l2.company);
      if (duplicateAccountMap.get(l2.company)) {
        ReportingService.notifyEngineers('assigning lead to Marjorie', 'at addAccount triggah line 33');
            l2.ownerId = marjorieUserId; // Marjorie
        } else {
          if (marjorieUserId.equals(l2.company)) ReportingService.notifyEngineers('lead is assigned to Marjorie', 'at addAccount triggah line 36');
            l2.ownerId = acctNameOwner.get(l2.company);
        }
    
    }
      
  }

}


The issue is that the Trigger is firing again when the Sales Manager tries to reassign the new lead to it's corresponding Account owner; it blocks her out and she is unable to reassign the lead.

I would like to add logic to the code that prevents the Trigger from firing twice.

Thanks,
Julien

Our sales forecasts tend to be off because the renewal opportunity probability default is 65%. We'd like to change these defaults to different percentages based on the Opportunity Amount field for Opps in the proposal stage:

65% for Opp. amounts less than $5K
80% for $5k -15k
85% for $15k - 99k
95% for > $100K


We have an apex trigger that deals with our probabilities. Right now, it has some logic for the Closed opps:

//NEW:
    //changed this trigger to only reset the probability on closed won, lost opps.

    Map<String, Integer> closeMap = new Map<String, Integer>();
    closeMap.put('Closed Won', 100); 
    closeMap.put('Closed Lost', 0);
    closeMap.put('Closed Funnel Purge', 0);    
    
    for (Integer i = 0; i < Trigger.new.size(); i++) {
        if (closeMap.containsKey(Trigger.new[i].StageName)) {
            Trigger.new[i].Probability = closeMap.get(Trigger.new[i].StageName);    
        }
    }    

So, I need to build from here. Any suggestions?

Thanks,

Julien

We have a field on our Opps. layouts, "Reason," which is a dependent picklist field, with the controlling field being "Stage."

We would like the Reason field to be required when the Stage field is set to "Closed Won," "Closed Lost" or "Closed Funnel Purge."

Because of a Visualforce page ("opportunityCustomlayout"), the Reason field is not showing as required, even though it is listed as a dependent field under the Field Dependencies in the field definition settings.

Also, a Validation Rule did not work because of the customization made via the Visualforce page, which overrides the standard functionality; we cannot implement a Validation Rule against a Visualforce page.

I am resourcing for some help to write the code into the Visualforce page to make the Reason field required per the above criteria.

Thanks.

Hello,

I'm attempting to add a new field to a VisualForce page but I am receiving this Error Message:

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contract.X18_Digit_Account_Id__c

X18_Digit_Account_Id__c is a custom field on the contract object.

Here's where I'm trying to add it  (in bold):

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Demo ID" for="DemoIDNumber"/>
    <apex:outputText value="{!DemoIDNumber}" id="DemoIDNumber"/>   
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Account ID" for="BOAccountID"/>
    <apex:outputText value="{!contract.BO_Account__c}" id="BOAccountID"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
    <apex:outputLabel value="18 Digit Account ID" for="X18_Digit_Account_Id__c"/>
    <apex:outputText value="{!contract.X18_Digit_Account_Id__c}" id="X18_Digit_Account_Id__c"/>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem >
    <apex:outputLabel value="Creator ID" for="BO_User_ID__c"/>
    <apex:outputText value="{!user.BO_User_ID__c} ({!user.Name})" id="BO_User_ID__c"/>

</apex:pageBlockSectionItem>
       
<apex:pageBlockSectionItem >
    <apex:outputLabel value="Account Name" for="contractAccountName"/>
    <apex:outputText value="{!contract.Account.Name}" id="contractAccountName"/>
</apex:pageBlockSectionItem>

I've also attached a screenshot of how the page looks before my change.

I'm a new Developer - can anyone help me sort out the syntax? This is my first alteration to a VF page. I've searched for this error message and have reviewed the resulting posts but am having difficulty applying the info. to my situation.

Thanks,
Julien

User-added image

Hello,

I found this great code that is working (!!) for us now in our Production instance - it assigns new Leads to the Owners of matched Existing Accounts.

To level it up a bit, we would like the code to also route leads to a default user (who will function as the tiebreaker) when the lead is matched to two Account Records for the same company name that have different owners. Can anyone provide a quick line of logic that might do this?

Here's the code:

trigger addAccount on Lead (before Insert, before Update){
List<string> companies=new list<string>();

For (lead l:trigger.new){
  companies.add(l.company);

}

List<Account> leadAccountIds=[Select Id, OwnerId, Name FROM Account WHERE Name IN: companies];
Map<String, Id> acctNameId=new Map<String, Id>();
Map<String, Id> acctNameOwner=new Map<String, Id>();

For (Account a:leadAccountIds){
  acctNameId.put(a.name,a.Id);
  acctNameOwner.put(a.name,a.ownerId);

}

For (Lead l2:trigger.new){
  if(acctNameId.containsKey(l2.company)){
    l2.Account__c=acctNameId.get(l2.company);
    l2.ownerId=acctNameOwner.get(l2.company);

  }
   
}

}
Assigning Live Chat Leads to Reps who handled the Chat:

For live chat leads, is there a way for the leads generated by the Live Agent Chat to be assigned to the sales rep. that picks up the chat? Currently in our org., if a rep./user picks up a chat and handles it, it gets reassigned to a Sales Manager, who then has to assign it back to them.

Thanks!

Julien