• jrotenstein
  • NEWBIE
  • 250 Points
  • Member since 2008

  • Chatter
    Feed
  • 9
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 237
    Replies

Hi, I am new to writing apex triggers and I'm currently running into a wall trying to find out why this isn't updating. 

 

Basically i have three formula fields as each one becomes 100 percent i would like to have the trigger update my probability field to that percentage. My code is currently throwing no errors but never updates the probability field. 

 

Here is my trigger 

 

trigger UpdateOpportunity on Opportunity (after update , after insert) {  
  for (Opportunity a : Trigger.new) {  
    if(a.Probability < 0.8 ){ 
        if (a.X25_Complete__c != 1 ) {
         
         if (a.X50__c != 1 ){
          
          if (a.X75__c != 1 ){
          a.Probability = .75;
          update a;
          }
         
         else
         a.Probability = .50;
         update a;
         }
        
        else
        a.Probability = .25;
        update a;
        }
      
       } 
  
   }
 }

 

Many thanks. 

Hi all,

 

I am helping out a Non Profit with their Salesforce implementation. The process they want to put into Salesforce related to recurring donations is for the system to automatically create the Donation records for all the active recurring donations at the end of each month. They then send a report to each credit entity (Visa, Amex, etc...) so that they collect the money.

 

The credit entities produce back a report of what was actually collected and what wasn´t and at this point, they would like to find the automatically created Donations that did not go through and make them enter a recovery process.

 

So the question is: what is the best way to have Salesforce actually run a bit of code that creates all those donations? I know how to do the Apex bit what I am not sure how to accomplish is to have Salesforce automatically execute a script on a specific point in time. Any ideas much appreciated, it is for a good cause :smileywink:

 

Thanks,

 

J

 

PS: I know I can use a Visualforce page and make the users click a button but I would rather not follow that route if possible.

 

  • March 11, 2009
  • Like
  • 0

I am using Salesforce's email services to populate a Contact record with information submitted through a web form. A user fills out the web form, all of the information from the form is sent as an email, the Apex class parses the email, and populates the Contact record.

The problem I have is that I have picklist values on the form that have an apostrophe(') in them. They are "Bachelor's" and "Master's" . When the email class parses the information, the field on the Salesforce side is populated with"Bachelor&#039;s" or"Master&#039;s". Here is the Apex code that parses that line:

 

contact.Highest_Degree_Earned__c = getFieldValue(myPlainText,'Education:');

 

How can I account for a value returned with an apostrophe? This seemed to just started happening when we were upgraded to Spring 09 release.

Thanks

  • February 18, 2009
  • Like
  • 0

We have a custom field called WAITING_FOR on the case level with 4 options:

 

SUPPORT

DEVELOPMENT

PRODUCTION

CUSTOMER 

 

We'd like to populate 4 additional fields on the case level indicating the time spent in each status in days.

 

How can we achieve this with triggers? 

Hi,

 

I have created a custom object that has a couple text and picklist fields on it.  The custom object is a child of the Opportunity object.  Whenever an opportunity is created I would like to automatically create a couple new custom objects with the same data in them every time.  Any sample code to get me started would be greatly appreciated.


Thank you

Hi,

 

    I just want to know what are the file format's I can read and write through my Apex/Visual force code.

 

 

Thanks in Advance

ravi

Pl's can you explain "how to import .text file to salesforce?". I think we can use Apex code. but i haven't clear idea. pl's help me.

 

Thank you

  • February 10, 2009
  • Like
  • 0

Hi All,

 

Is it possible to create a custom S-Control using URL to open a pop up window? If so, can anyone send me the example. Thanks.

Hello

I am trying to delete some Apex triggers from our production org through Eclipse and keep getting the following error (from the force-ide.log):

ERROR [2008-12-01 14:49:30,051] (DeleteRefactorController.java:performRemoteDelete:253) - Remote delete failed with the following message.  Delete will be aborted.
  package.xml: null
  Attendence_updateScore: null

Also I can't delete the triggers from the salesforce web interface. It works in our Sandbox but I need to get rid of the triggers in the production org so I can deploy a new object.

Any help would be hugely appreciated

Thanks
Matt

Alas! My favourite Mass Update Anything utility (wiki | Appexchange) seems unhappy under Mac OS X with Java 1.5.0_19.

 

Admittedly, it is over two years old and is officially unsupported, I'd appreciate it if the pixies out there could pass a message ot its author (hint, SimonF?). :smiley:

 

Looks like I'll have to try Mass Update Wizard instead. Anyone had problems with that one?

I had a bit of fun building an S-Control using AJAX that shows Contacts with similar email addresses.

I've posted the code on the wiki if anyone is interested. Feedback/suggestions welcome.

John Rotenstein
Sydney, Australia

I am trying to install IDE (force.com-ide-installer-win32.exe). First I had some trouble with the proxy settings in pulse explorer. I manage to overcome this. Then the installer stops with an error in forceide.exe:

JVM terminated. Exit code=-1

-Dfile.encoding=UTF-8

-Xms256m

-Xmx1024m

-XX:PermSize=128M

-XX:MaxPermSize=512M

-Djava.class.path=C:\Programme\salesforce.com\Force.com IDE\../Common/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar

-os win32

-ws win32

-arch x86

-showsplash

-launcher C:\Programme\salesforce.com\Force.com IDE\forceide.exe

-name Forceide

--launcher.library C:\Programme\salesforce.com\Force.com

IDE\../Common/plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519\eclipse_1206.dll

-startup C:\Programme\salesforce.com\Force.com IDE\../Common/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar

-install C:\Programme\salesforce.com\Force.com IDE

-configuration C:\Programme\salesforce.com\Force.com IDE\configuration

-clean

-vm C:/Programme/Java/jre6/bin\client\jvm.dll

-vmargs

-Dfile.encoding=UTF-8

-Xms256m

-Xmx1024m

-XX:PermSize=128M

-XX:MaxPermSize=512M

-Djava.class.path=C:\Programme\salesforce.com\Force.com IDE\../Common/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar

 

Any idea how to fix it?

 

Thanks in advance.

Hi, I am new to writing apex triggers and I'm currently running into a wall trying to find out why this isn't updating. 

 

Basically i have three formula fields as each one becomes 100 percent i would like to have the trigger update my probability field to that percentage. My code is currently throwing no errors but never updates the probability field. 

 

Here is my trigger 

 

trigger UpdateOpportunity on Opportunity (after update , after insert) {  
  for (Opportunity a : Trigger.new) {  
    if(a.Probability < 0.8 ){ 
        if (a.X25_Complete__c != 1 ) {
         
         if (a.X50__c != 1 ){
          
          if (a.X75__c != 1 ){
          a.Probability = .75;
          update a;
          }
         
         else
         a.Probability = .50;
         update a;
         }
        
        else
        a.Probability = .25;
        update a;
        }
      
       } 
  
   }
 }

 

Many thanks. 

Does using the Apex Data Loader app count against my allotted number of API calls?  It didn't seem to before, but I used it yesterday for some mass updates to my data and I hit the API ceiling this morning.

 

TIA,

-Bob

I was wondering how I would go about deleting Chatter Feed data.  In an org of a client where auto-follow is on, it auto-followed way too many records and now the feed is unusable and takes up a lot of space.

 

Curious if there's a way to delete the Chatter feed records.  According the to API, I am seeing objects as selectable and deletable, but when I try through the System Log, I get errors that those objects don't support that.

 

How can I go about running a quick System Log script to delete Chatter feed records?

  • August 16, 2010
  • Like
  • 0

I have a object called Insertion Order which have child objects Flights. The Flights have a Look Up relationship to the Insertion Order object.

 

I want to lock down the Insertion Order object and it's children Flights when it is reviewed by the finance team. I set up an approval process and change the Insertion Order object's record type to "Reviewed". I also changed the RecordType of the Flight to "Reviewed" also.

 

The issue is how do I remove the "Edit","Delete" links from the related list  of Flights which show up on the Insertion Order?

 

 

Hello.

 

I'm currently updating my Salesforce data from a mySQL database utilizing a 3rd party integration tool. There are some records, though, that may exist in the mySQL database that I don't want updated in Salesforce. Is there some way to perhaps set a flag in a Salesforce record that would prevent updated information from populating in Salesforce? Perhaps comparing Trigger.Old and Trigger.New and rolling back to the previous values?

 

Thanks.

 

-Greg

Message Edited by bca321 on 03-12-2009 10:06 AM
  • March 11, 2009
  • Like
  • 0

Hi all,

 

I am helping out a Non Profit with their Salesforce implementation. The process they want to put into Salesforce related to recurring donations is for the system to automatically create the Donation records for all the active recurring donations at the end of each month. They then send a report to each credit entity (Visa, Amex, etc...) so that they collect the money.

 

The credit entities produce back a report of what was actually collected and what wasn´t and at this point, they would like to find the automatically created Donations that did not go through and make them enter a recovery process.

 

So the question is: what is the best way to have Salesforce actually run a bit of code that creates all those donations? I know how to do the Apex bit what I am not sure how to accomplish is to have Salesforce automatically execute a script on a specific point in time. Any ideas much appreciated, it is for a good cause :smileywink:

 

Thanks,

 

J

 

PS: I know I can use a Visualforce page and make the users click a button but I would rather not follow that route if possible.

 

  • March 11, 2009
  • Like
  • 0

Hi,

 

Can any one help me "How To print the Log message in console using Apex or Trigger"

 

System.debug('text') wast not working or printing in "System Log"  link, even iadded the user in setup ===> monitoring ===> debug logs.. No Use..

 

Thnx KarthiVB

hey,

 

I am looking for a way to read data from our Salesforce data without the SOAP Api. As we are a small company , we don't have the license to access the soap api. It is a pity I know. I can export data to xls files, but this is not very convenient. Is there another way to do a data export? thanx.

 

 

 

 Hi,

 

if ((purgeType == 'LAST_N_DAYS') && (nDays <= 365)) {
List<ConnectCompiere_Log__c> lastNDays = new List<ConnectCompiere_Log__c>([SELECT Id FROM ConnectCompiere_Log__c WHERE CreatedDate >: System.now().addDays(-nDays)]);
// for(ConnectCompiere_Log__c rec:lastNDays) {
// delete rec;
// }
System.debug('Selecting' + lastNDays.size() + ' log records');
delete lastNDays;
}

 

Im getting the below error for the above code. 

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Purging caused an unexpected exception, contact your administrator: Purging: execution of AfterInsert caused by: System.Exception: Too many DML rows: 440: 

 

Above code selecting 440 rows to delete from the object. While deleting I am getting above error.

 

 Please help me to delete the mass records.

 

Thanks in advance.

 

Please Please help me!!!!!!!!!!!!!!!!!! :smileysad: 

Message Edited by venkatesh on 03-03-2009 12:32 AM
Hey guys.
 
I have a Before Update trigger on the Opportunity Object that runs an Apex class which:
 
1. Checks if the Opportunity Status has been changed to a particular stage.
If it has, it then:
2. Checks the Opportunity Products (specifically if there are certain families of products in there)
If Opportunity Products from a specific family (A) are there, without a particular Opportunity Product from another family (B):
3. It automatically works out how much the Opportunity Product from family (B) should cost, given the overall sale cost of the Opportunity
4. Reduces the overall cost of the products of family (A) by the cost of the product from family (B)
5. Updates the Products from Family (A)
6. Inserts the product from Family (B)
 
At the end of the process, the overall Opportunity sale price remains the same, with the new product inserted. It was working a treat, until I added some roll-up formula fields that gather information about the products (An overall sales cost, an overall list price and a formula working out the overall Reduction against List Price)
 
When I tried that, I got the following error:
 
Code:
Apex trigger MyOpportunityUpdate caused an unexpected exception, contact your administrator: 
MyOpportunityUpdate: execution of BeforeUpdate caused by: System.DmlException: Update failed. 
First exception on row 0 with id 00oS0000000KsjwIAC; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, 
Object (id = 006S0000002JnAw) is currently being updated in trigger 
MyOpportunityUpdate: [Id]: Class.MyRFFCreator.CreateRFF: line 35, column 29

 
Interestingly, the error I am getting implies that I've defined a validation formula that's upsetting the system. However, there are no validation rules that get their information from any of the fields being affected by the update. Also, the error arises when I try to update the Opportunity Product from family (A), having reduced it by the appropriate amount.
 
The section of the APEX class that's causing the error is as follows:
Code:
for (OpportunityLineItem cli : FamilyA){
 OpportunityLineItem LineItemToChange = [select id, UnitPrice, Quantity, TotalPrice, (select id, ScheduleDate, Revenue from OpportunityLineItemSchedules order by ScheduleDate asc nulls last limit 1)from OpportunityLineItem where id = :cli.id];
 OpportunityLineItemSchedule LineItemScheduleToChange = LineItemToChange.OpportunityLineItemSchedules;
 LineItemScheduleToChange.Revenue = LineItemScheduleToChange.Revenue - NewRFF.UnitPrice;
 LineItemScheduleToChange.Description = 'This has been auto-edited by Apex';
 update LineItemScheduleToChange; THIS LINE CAUSES THE ERROR           
} 

 I'm really confused.
 
Is the problem that changing a formula field counts as an update, and therefore the trigger is being recursively triggered?
Or that by altering the value of the revenue arising from the Opportunity Product, I'm causing a validation problem with the roll-up field? That would surprise me, as I've been able to add/remove and change Opportunity Products and the Roll-up formula fields deal with it with ease.
 
Or am I just making an obvious error and asking Salesforce/Apex to do something which it isn't able to?
 
Thank you for all your help, in advance. I hope I've been clear enough.
Hi,

need help regariding my trigger below. Get this error code (SOQL does not contain results):

Severity and Description    Path    Resource    Location    Creation Time    Id
System.DmlException: Update failed. First exception on row 0 with id 00620000005uHyQAAU; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, simpleTrigger02: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject Trigger.simpleTrigger02: line 77, column 61    SFDC_Ph01_deploy_Renewal_Trigger/src/unpackaged/classes    simpleTrigger02testClass03.cls    line 138    1220262381688    2940

Question: Red marked code is causing error (below: Oli1). Why does APEX does not find my Opportunity ID? The log tells me that oppty1.id and oppty2.id is existing!
 
CODE:

trigger simpleTrigger02 on Opportunity (after update) {
    
    OpportunityLineItem oli1 =                         new OpportunityLineItem();
    OpportunityLineItem oli2 =                         new OpportunityLineItem();
    OpportunityLineItem oli3 =                         new OpportunityLineItem();
    OpportunityLineItem oli4 =                         new OpportunityLineItem();
    
    Opportunity oppty2 =                                  new Opportunity();
    Opportunity oppty3 =                                  new Opportunity();
    Opportunity oppty4 =                                  new Opportunity();
            
    List<OpportunityLineItem> oliList2 =         new List<OpportunityLineItem>();
     List<OpportunityLineItem> oliList3 =        new List<OpportunityLineItem>();
     List<OpportunityLineItem> oliList4 =        new List<OpportunityLineItem>();
     List<OpportunityLineItem> oliListX =        new List<OpportunityLineItem>();
     
     List<Opportunity> T_new =                      Trigger.new;
     ID oid1 =                                                    T_new.get(0).id;
     
     List<Opportunity> T_old =                        Trigger.old;
     ID oid2 =                                                    T_old.get(0).id;
          
    for (Opportunity oppty1 : Trigger.new){
                             
        if (oppty1.renew__c == true){
                                 
            for (Opportunity opptytest1 : Trigger.old) {
                                       
            Double cdate =                                                oppty1.RenewalTermCalcDouble__c;
            Integer i =                                                         cdate.intValue();
                            
            oppty2.accountid =                                                         oppty1.accountid;
            oppty2.CustomerOrderDate__c =                                 oppty1.CustomerOrderDate__c;
            oppty2.CustomerOrderedBy_del__c =                          oppty1.CustomerOrderedBy_del__c;
            oppty2.CustomerOrderID__c =                                      oppty1.CustomerOrderID__c;
            oppty2.CustomerOrderNumberAdditonal__c =              oppty1.CustomerOrderNumberAdditonal__c;
            oppty2.DateOfDelivery__c =                                             oppty1.DateOfDelivery__c;
            oppty2.Description =                                                         'Angelegt am: ' + dit.addhours(2);
            oppty2.GMDRetention__c =                                             oppty1.GMDRetention__c;
            oppty2.OpportunityInitial__c  =                                         oppty1.id;
            oppty2.InvoiceDate__c =                                                 oppty1.InvoiceDate__c;
            oppty2.name =                                                                    'Renewal 1.Jahr';
             oppty2.OwnerId =                                                             oppty1.OwnerId;
            oppty2.Pricebook2Id =                                                     oppty1.Pricebook2Id;
            oppty2.Probability =                                                         oppty1.Probability;
            oppty2.Product__c =                                                         oppty1.Product__c;
            oppty2.ProductOther__c =                                                 oppty1.ProductOther__c;
            oppty2.RecordTypeId =                                                     '012200000000ZErAAM';
            oppty2.Type =                                                                     'Renewal';
            oppty2.RenewalTerm__c =                                                 oppty1.RenewalTerm__c;
            oppty2.RenewalType__c =                                                    oppty1.RenewalType__c;
            oppty2.RequirementsDescription__c =                                 oppty1.RequirementsDescription__c;
            oppty2.StageName =                                                              'Renewal Open';
             oppty2.Service__c =                                                             oppty1.Service__c;              
            oppty2.CloseDate =                                                                 oppty1.CloseDate.addMonths(12);
         
             System.debug('DIE OPPTY1.ID:                     **********************' + oppty1.id);                          
            
            oli1.opportunityId =                             oppty1.id;
            oli1.quantity =                                 200.0;
             oli1.unitprice =                                 20.0;
             oli1.PricebookEntryId =                         '01u20000000fK10AAE';    
             
             oliListX.add(oli1);
            /*
            insert oliList2;
            */
            
            oli1 =                                             [Select quantity, unitprice, pricebookentryid, opportunityid from OpportunityLineItem where PricebookEntry.product2.ActivateRenewal__c =                                                                     TRUE AND PriceBookEntryID <> '01u20000000fK11AAE' AND OpportunityID = :oppty1.id limit 1];                                          
          insert oppty2;
                
          System.debug('OPPTY1.ID:                 **********************' + oppty1.id);                          
          System.debug(' OPPTY2.ID:                 **********************' + oppty2.id);                          
                            
                 oli2.opportunityId =                         oppty2.id;
                 oli2.quantity =                             oli1.quantity;
                 oli2.unitprice =                             oli1.unitprice;
                 oli2.pricebookentryid =                     oli1.pricebookentryid;
                 
                 oliList2.add(oli2);     
                         
                  insert oliList2;
                                 
            }
        }
        
    }
}

I have created a batch process that will export data from the account object using the CLI for the data loader. 

I want the job to extract data that has been modified since the job was last run.

How can I leverage the last run properties file in the pull the date time into the SOQL statement so I do not need to mnually modify the process-conf.xml each time.

Here is a copy of the processfile:


Code:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="MDRAccountExtractProcess"
          class="com.salesforce.lexiloader.process.ProcessRunner"
          singleton="false">
      <description>MDRAccountExtract job gets account info from salesforce and saves info into a CSV file."</description>
        <property name="name" value="MDRAccountExtract"/>
        <property name="configOverrideMap">
            <map>
                <entry key="sfdc.debugMessages" value="False"/>
                <entry key="sfdc.debugMessagesFile" value="D:\SFDC\DataLoader\conf\MVJTrace.log"/>
                <entry key="sfdc.endpoint" value="https://test.salesforce.com"/>
                <entry key="sfdc.username" value="xxxxxxxxxxx"/>
                <entry key="sfdc.password" value="xxxxxxxxxxx"/>
                <entry key="sfdc.timeoutSecs" value="600"/>
                <entry key="sfdc.loadBatchSize" value="200"/>
                <entry key="sfdc.entity" value="Account"/>
                <entry key="sfdc.extractionRequestSize" value="500"/>
                <entry key="sfdc.extractionSOQL" 
    value="
    Select Id,MDR_Account_Size__c,AnnualRevenue,MDR_Contract_Data_Lease__c,BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet,MDR_Bubble_Up__c,
    MDR_Bubble_Up_Expiration__c,MDR_Bubble_Up_Original_Account_Owner__c,MDR_Bubble_Up_Start__c,MDR_CDL_Contract_End_Date__c,CreatedDate,Description,Fax,Industry,
    LastModifiedById,LastModifiedDate,MDR_Account_Status__c,MDR_Customer_No__c,MDR_Territory_Code__c,Name,OwnerId,Phone,ShippingCity,ShippingCountry,
    ShippingPostalCode,ShippingState,ShippingStreet,Type,Website,MDR_Market__c,
    Competitive_Account__c from Account where LastModifiedDate > 2008-05-01T10:12:25Z and 
    Owner.Employee_Type__c like 'MDR%'
    "/>
            <entry key="sfdc.proxyHost" value="bastion2.us.dnb.com"/>
      <entry key="sfdc.proxyPort" value="8080"/>
                <entry key="process.operation" value="extract"/>
                <entry key="process.mappingFile" value="D:\SFDC\DataLoader\conf\MDRaccountExtractMap.sdl"/>
                <entry key="process.encryptionKeyFile" value="D:\SFDC\DataLoader\conf\MVJ.key"/>
      <entry key="process.enableExtractSuccessOutput" value="True"/>
           <entry key="process.outputSuccess" value="D:\sfdc\DataLoader\conf\MDRAccountExtractSuccessFile.csv"/>
                <entry key="dataAccess.type" value="csvWrite"/>
                <entry key="dataAccess.name" value="D:\SFDC\DataLoader\conf\MDRextract.csv"/>
            </map>
        </property>
    </bean>
</beans>

 

Thanks in advance

Mike
  • July 08, 2008
  • Like
  • 0