• Gita Borovsky
  • NEWBIE
  • 30 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
I have a button that allows me to clone an existing oppotunity.  It currently pulls in the amount from the original opportunity.  I'd actually like to add some code that would default Amount to 0.  It seems that I cannot find the field id for Standard opportunity fields.  Any ideas?  Here's the code:

/{!Opportunity.Id}/e?clone=1&
cloneli=0&
opp9={!month( Opportunity.Subscription_End_Date__c )}/{!day( Opportunity.Subscription_End_Date__c )}/
{!year( Opportunity.Subscription_End_Date__c +1)}&
retURL={!Opportunity.AccountId}&
saveURL={!Opportunity.AccountId}&
00N50000001zTKO=Renewals&
opp3={!Opportunity.Account}+{!Opportunity.Services__c}+renewal+2015&
opp6=Renewal&
opp11=Renewal&
opp12=90&
00N50000002abEN=1&
00N50000002Z8wQ=false&
00NP0000000jn5p=1&
00N50000002ZktF=false&
00NP0000000jcOq=false&
00N500000021Fmt=&
00N500000021Fmy=&
00N500000021FqR=&
00N500000021FnI=&
00N50000002ZhWN=&
00N50000002ZhWS=&
00NP0000000jrqp=&
00NP0000000jrqk=&
00NP0000000jrqu=&
opp10=&
00N50000002ZXXB=Annually&
00N500000021Fl7=false&
00N500000021FqR=&
00N500000021FlC=&
00N50000002aanM=&
00N50000002abFV=&
00N50000002aanH=&
00N50000002aZCe=&
00N50000002aZ3m=&
00N50000002aZ3S=&
00N50000002aSii=&
00N50000001y6OR=&
00N50000002aaoo=&
00N50000002aaoj=&
00N50000002afIT=&
00N50000002acHw=&
00N50000002aX6U=&
00N5000000216cQ=&
00N50000002amEi=&
00N50000002abDt=&
00N50000002bOt0=&
00N50000002Zkto=&
00N50000002amEd=&
00N50000002aSii=&
00N50000002bSIc=&
00N50000002bSIw=&
00N50000002a2pQ=false&
00N50000002a2pV=&
00N50000001z0gp={!month( Opportunity.Subscription_End_Date__c +1 )}/{!day( Opportunity.Subscription_End_Date__c +1)}/
{!year( Opportunity.Subscription_End_Date__c +1)}&
00N50000001z0gu={!month( Opportunity.Subscription_End_Date__c )}/{!day( Opportunity.Subscription_End_Date__c )}/
{!year( Opportunity.Subscription_End_Date__c )+1}&
00N50000002022y=&
00N50000001z0TR=&
CF00N50000002av1f="Me"&
CF00N50000002av1f_lkid={!Opportunity.Id}&
00N50000001y6OR=


Thanks!
Hi All,

This trigger has been running just fine with no no errors, then yesterday starting throwing back "UpdateLeadOwner: System.LimitException: Too many SOQL queries: 101"

Here's the code:

trigger UpdateLeadOwner on Lead (before insert,before update) {
    for (Lead leadInLoop : Trigger.new) {
   
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain__c = :leadInLoop.Domain__c AND Owner.UserRoleId != '00E50000000t0Bf' Limit 2];
        if (acct.size() == 1) {

    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}

Any idea how to track down what changed so I can fix?  Thanks!
Hi All,

I currently have a simple little trigger that is a "before insert" on Leads that looks up an account owner based on domain and transfers the Leads automatically to them.  The problem is that because of the order of operations, Triggers run before Web to Lead assignment rules and this causes the correctly assigned Lead (based on the trigger) to immediately be reassigned to to Web to Lead default Lead owner.  Here is the code:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
   
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain__c = :leadInLoop.Domain__c AND Owner.UserRoleId != '00E50000000t0Bf' Limit 2];
        if (acct.size() == 1) {

    //the next line is for debugging, to check that you are getting a result back from the query
    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}
}

Since it is an order of operations issue, I decided to change the "before insert" to "after insert" and got the following error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateLeadOwner caused an unexpected exception, contact your administrator: UpdateLeadOwner: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.UpdateLeadOwner: line 11, column 1

Anyone know how to fix this?  I'm happy with either correcting the "after insert" code or figuring out a way to stop the web to lead default assignment from kicking in.  Thanks!

Best,
Gita
I have a bit of code that checks to see if an account already exists based on a domain and reassigns the incoming lead based on Account owner. I need to update the trigger to leave a particular Account Owner Role out of the process but I can't figure out where to put the code.  Any help would be appreciated, thanks!  Here's the owner role id: 00E50000000t0Bf and here's the trigger:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
   
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
        if (acct.size() == 1) {

    //the next line is for debugging, to check that you are getting a result back from the query
    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}
}
Hi,

I've got this Trigger on Leads:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
        if (acct.size() == 1) {

    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}

I need to update the trigger so that the Lead source field  "LeadSource" does not contain either of these picklist values, "Contact Us" or "Reprint" but I can't figure out where it should go.  Help, please?  Thanks!

The below code creates a new opportunity record from a custom button.  We also have a checkbox on the opportunity layout called "renewal"  I can't figure out how to edit the code to set the renewal checkbox to true.  Help, please?  Thanks!

 

<apex:page StandardController="Opportunity" sidebar="false" standardStylesheets="true" showHeader="false" id="page" >


<script>
// copyright 2011 SalesLogistix Corporation
// look at the SLX_License_Text file in your APEX Classes areas for details of your license
//
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="/soap/ajax/22.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/22.0/apex.js" type="text/javascript"></script>

<script>

if ('{!Opportunity.CreateRenewal__c}' == "true" && 
   '{!Opportunity.RecordTypeID}' == "012500000009YZoAAM" && 
   '{!$user.ID}' != "005500000016hUGAAY" &&
   '{!$user.ID}' != "005500000017MfAAAU") 
{

window.open('\
/{!Opportunity.Id}/e?clone=1&cloneli=0&\
opp9={!Opportunity.Penultimate__c}&\
retURL={!Opportunity.AccountId}&\
saveURL={!Opportunity.AccountId}&\
00N50000001zTKO=Renewal&\
opp3={!Opportunity.Name}+renewal+for+--->>>+{!year(TODAY())+1}&\&\
opp11=Renewal&\
opp12=90&\
00N50000001z0gp={!month( Opportunity.Subscription_End_Date__c )}/{!day( Opportunity.Subscription_End_Date__c )}/\
{!year( Opportunity.Subscription_End_Date__c )}&\
00N50000001z0gu={!month( Opportunity.Subscription_End_Date__c )}/{!day( Opportunity.Subscription_End_Date__c )}/\
{!year( Opportunity.Subscription_End_Date__c )+1}&\
00N50000002022y=&\
00N50000001z0TR=&\
00N50000001y6OR=&\
','renewal for {!Opportunity.Account.Name}');

//cloneli=1 clones the product line items

// reset the variable back to false
var updater= new sforce.SObject("Opportunity");
updater.Id = '{!Opportunity.ID}';
updater.CreateRenewal__c = 'FALSE';
result = sforce.connection.update([updater]);
}

</script>

</apex:page>
Hi All,

I currently have a simple little trigger that is a "before insert" on Leads that looks up an account owner based on domain and transfers the Leads automatically to them.  The problem is that because of the order of operations, Triggers run before Web to Lead assignment rules and this causes the correctly assigned Lead (based on the trigger) to immediately be reassigned to to Web to Lead default Lead owner.  Here is the code:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
   
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain__c = :leadInLoop.Domain__c AND Owner.UserRoleId != '00E50000000t0Bf' Limit 2];
        if (acct.size() == 1) {

    //the next line is for debugging, to check that you are getting a result back from the query
    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}
}

Since it is an order of operations issue, I decided to change the "before insert" to "after insert" and got the following error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateLeadOwner caused an unexpected exception, contact your administrator: UpdateLeadOwner: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.UpdateLeadOwner: line 11, column 1

Anyone know how to fix this?  I'm happy with either correcting the "after insert" code or figuring out a way to stop the web to lead default assignment from kicking in.  Thanks!

Best,
Gita
I have a bit of code that checks to see if an account already exists based on a domain and reassigns the incoming lead based on Account owner. I need to update the trigger to leave a particular Account Owner Role out of the process but I can't figure out where to put the code.  Any help would be appreciated, thanks!  Here's the owner role id: 00E50000000t0Bf and here's the trigger:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
   
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
        if (acct.size() == 1) {

    //the next line is for debugging, to check that you are getting a result back from the query
    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}
}
Hi,

I've got this Trigger on Leads:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
        if (acct.size() == 1) {

    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}

I need to update the trigger so that the Lead source field  "LeadSource" does not contain either of these picklist values, "Contact Us" or "Reprint" but I can't figure out where it should go.  Help, please?  Thanks!