• Hermes Yan
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Can anyone tell me the proper syntax for the fieldsToNull value?

Problem:
I need to null out three custom date fields; Term_Date__c, Audit_Date__c, Benefit_Ineligibility_Date__c

Current Workaround:
I currently pass all records from my source to Salesforce and call the fieldsToNull for each record in the source and I can only populate one value in the fieldsToNull each time. This results in me having to run the entire data set through 3 times to null out all three fields.

Attempted Tweak:
I attempted to tweak my code a bit and reduced the data set down so I only call the records that actually need these fields nulled but now I am getting this error message.
false Adeptia_ID__c Duplicate external id specified: pio000010006 DUPLICATE_VALUE false 
false Adeptia_ID__c Duplicate external id specified: pio000010006 DUPLICATE_VALUE false 
false Adeptia_ID__c Duplicate external id specified: pio000010006 DUPLICATE_VALUE false

Hopefull Resolution:
I want to be able to call fieldsToNull one time for each record and pass a value of 'Term_Date__c, Audit_Date__c, Benefit_Ineligibility_Date__c'

I seem to run into this situation a lot and have been using a brute force way around it.  For example, I query a bunch of contacts for their accounts and put the results into a list.  But this list has duplicate accounts.  I want the list de-duped.  I've tried using the GROUP BY clause of the query but the query results are then aggregate result objects that I have to convert into the object in question.

I've settled on this code which is pretty concise but is a shotgun approach.  I'm thinking there has to be an easier way (using Maps?).  Any comments?

Thanks!!

for (Opportunity anOpp1 : FullListOfOpps) {
        FOUND = false;  // boolean
        for (Opportunity anOpp2 : ListOfOppsWithoutDuplicates) {
           if (anOpp2.Id == anOpp1.Id) {
             FOUND = true;
           }
        }
        if (!FOUND) {
           Opportunity newOpp = new Opportunity();      
           newOpp.id = anOpp1.id;
           ListOfOppsWithoutDuplicates.add(newOpp);
        }
      }
hello, I'd like to create a trigger that compiles the sum of a number field on all order records, and updates the sum with each subsequent edit of the existing field on a record.  We need a running sum of the number field on all orders, and it needs to update every time we edit the number field on existing orders.  Any suggestions on how to write this trigger.  

Example: we have number field A with a value of 10 on order 1.  we have number field A with a value of 20 on order 2.  The sum is 30.  we go back and edit the number field on order 2 from 20 to 30.  we need the sum to change from 30 to 40.  instead it is changing from 30 to 60.  we need it to replace the old value with the new, not add the new value to the old.

Any suggestions will be greatly appreciated.