• dbruce
  • NEWBIE
  • 30 Points
  • Member since 2012
  • Consultant
  • ACF Solutions


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
I have a simple update trigger that populates a related lookup and works fine but fails in the test class. The error is "FIELD_FILTER_VALIDATION_EXCEPTION". Looking through the logs I see an earlier SOQL statement that looks like the trigger's tempvar1 is not being properly populated. Does anyone have any insight on this?

Here is the object, code and coverage information:

Parent Object: Agreement__c with fields: ID, Name, Account__c (lookup), etc...
Child Object: Approved_Product__c with fields: ID, Name, Agreement__c(lookup), Account__c(lookup), etc...

Trigger to update Approved_Product__c.Account__c when Approved_Product__c.Agreement__c is entered:

trigger getAcct4AppvdProdTrigger on Approved_Product__c (before insert, before update){
   set<Id> agreementIdSet = new set<Id>();
   for(Approved_Product__c ap: trigger.new){
      if(ap.Agreement__c != null){
         agreementIdSet.add(ap.Agreement__c);
      }
   }
   map<id, Agreement__c> AgreementMap = new map<id, Agreement__c>([
      SELECT id, Account__c
      FROM Agreement__c
      WHERE Id IN: agreementIdSet
   ]);
   for(Approved_Product__c ap: trigger.new){
      if(AgreementMap.containsKey(ap.Agreement__c)){
         ap.Account__c = AgreementMap.get(ap.Agreement__c).Account__c;
      }      
   }
}

Test Class:

@isTest
private class Test_Trigger_ApprovedProductAccount {
   static testMethod void testApprovedProductAccountTrigger() {

//FIRST create test data
   Account a = new Account(Name='TestApProdTriggers Account-A');
   insert a;
   Account b = new Account(Name='TestApProdTriggers Account-B');
   insert b;
   Agreement__c p = new Agreement__c(
      Name='TestRenewTrigger Parent',
      Account__c = a.ID
   );
   insert(p);
//END Create test data. BEGIN tests
   Approved_Product__c ap = new Approved_Product__c(
      Name='TestAcctTriggers ap',
      Agreement__c = p.ID
   );
   insert(ap);   
   System.debug('Verifying getAcct4AppvdProdTrigger.trigger updated the account to ID '+ap.ID);
   ap = [
      SELECT Account__c
      FROM Approved_Product__c
      WHERE ID = :ap.ID
   ];
   System.assertEquals(a.ID,ap.Account__c,'Account not inserted. getAcct4AppvdProdTrigger.trigger failed');
   }
}

Selected Log Info (in decending order): 

15:55:37:462 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [Agreement__c]

15:55:37:420 CODE_UNIT_FINISHED getAcct4AppvdProdTrigger on Approved_Product trigger event BeforeInsert for [new]

15:55:37:416 SOQL_EXECUTE_BEGIN [22]|Aggregations:0|select id, Account__c from Agreement__c where Id = :tmpVar1


Observation: 
Am I possibly not instanciating tmpVar1 properly in my test class?
  • January 04, 2014
  • Like
  • 0
Hi All,
   In the Trailhead,
                   Process Automation Module,
                   Unit No 5.Customize How Records Get Approved with Approvals

I am unable to complete this challenge,I added Picklist values to Type field in the Account.Can anyone Suggest me where I am wrong..

User-added image

Thanks,
Jyothsna 
I have a simple update trigger that populates a related lookup and works fine but fails in the test class. The error is "FIELD_FILTER_VALIDATION_EXCEPTION". Looking through the logs I see an earlier SOQL statement that looks like the trigger's tempvar1 is not being properly populated. Does anyone have any insight on this?

Here is the object, code and coverage information:

Parent Object: Agreement__c with fields: ID, Name, Account__c (lookup), etc...
Child Object: Approved_Product__c with fields: ID, Name, Agreement__c(lookup), Account__c(lookup), etc...

Trigger to update Approved_Product__c.Account__c when Approved_Product__c.Agreement__c is entered:

trigger getAcct4AppvdProdTrigger on Approved_Product__c (before insert, before update){
   set<Id> agreementIdSet = new set<Id>();
   for(Approved_Product__c ap: trigger.new){
      if(ap.Agreement__c != null){
         agreementIdSet.add(ap.Agreement__c);
      }
   }
   map<id, Agreement__c> AgreementMap = new map<id, Agreement__c>([
      SELECT id, Account__c
      FROM Agreement__c
      WHERE Id IN: agreementIdSet
   ]);
   for(Approved_Product__c ap: trigger.new){
      if(AgreementMap.containsKey(ap.Agreement__c)){
         ap.Account__c = AgreementMap.get(ap.Agreement__c).Account__c;
      }      
   }
}

Test Class:

@isTest
private class Test_Trigger_ApprovedProductAccount {
   static testMethod void testApprovedProductAccountTrigger() {

//FIRST create test data
   Account a = new Account(Name='TestApProdTriggers Account-A');
   insert a;
   Account b = new Account(Name='TestApProdTriggers Account-B');
   insert b;
   Agreement__c p = new Agreement__c(
      Name='TestRenewTrigger Parent',
      Account__c = a.ID
   );
   insert(p);
//END Create test data. BEGIN tests
   Approved_Product__c ap = new Approved_Product__c(
      Name='TestAcctTriggers ap',
      Agreement__c = p.ID
   );
   insert(ap);   
   System.debug('Verifying getAcct4AppvdProdTrigger.trigger updated the account to ID '+ap.ID);
   ap = [
      SELECT Account__c
      FROM Approved_Product__c
      WHERE ID = :ap.ID
   ];
   System.assertEquals(a.ID,ap.Account__c,'Account not inserted. getAcct4AppvdProdTrigger.trigger failed');
   }
}

Selected Log Info (in decending order): 

15:55:37:462 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [Agreement__c]

15:55:37:420 CODE_UNIT_FINISHED getAcct4AppvdProdTrigger on Approved_Product trigger event BeforeInsert for [new]

15:55:37:416 SOQL_EXECUTE_BEGIN [22]|Aggregations:0|select id, Account__c from Agreement__c where Id = :tmpVar1


Observation: 
Am I possibly not instanciating tmpVar1 properly in my test class?
  • January 04, 2014
  • Like
  • 0

I finally got around to watching the adv testing and debugging webinar.  The new developer console looks to be greatly improved from the old one (which I was never able to make heads or tails of).  However, I noticed that some of the windows have scroll bars that will auto-magically scroll back up to the top of the window.  I am seeing this in the window when I look at class or trigger source code...scroll down by dragging the bar and when you let it go it scrolls back up to the top.  In fact it does this even if you do not let the bar go.  It is annoying and makes it almostt impossible to inspect the code, code coverage results, etc.

 

I am using Chrome on Windows.  Any one else seeing this?

We've been struggling with getting a zipped static resource to work for weeks now. We got Salesforce Support involved from the beginning, but they've gotten us nowhere. If we can't get a resolution to this issue soon, we might just find a platform that wastes less of our time...

 

Here is the situation - we are trying to upload a portion of the YUI library as a static resource, but no matter what we try, we can't get the files to render in our VisualForce pages. Salesforce Support can get it to work (sometimes), but we can't. The difference seems to be around the MIME Type that is set when the file is uploaded. When we upload the file, it gets set to a MIME Type of 'application/zip', but when SFDC Support uploads the file, it gets set to a MIME Type of 'application/x-zip-compressed' or 'application/octet-stream'. Salesforce can't explain to us exactly why or how these different MIME Types get set. They're looking into why our uploads don't work, but I'm not expecting much from them at this point.

 

To reproduce our steps:

 

Download the file from here after clicking the radio button labeled "Full developer kit":

Steps:
  1. Download "Full developer kit"
  2. Open zip and remov the documentation and examples folders (to reduce size)
  3. Change file name from "yui_3.0.0.zip" to "yui.zip"
  4. Upload as a static resource named "testyui"
  5. In component "header" (where all other JS files are included) add:
    • <apex:includeScript value="{!URLFOR($Resource.testyui, 'yui/build/yui/yui-min.js')}" />
  6. If we refresh the page we get a 404 error for this resource.
 
If anyone has experienced a similar issue, any help you could provide would be greatly appreciated.
I have a static resource that contains a style sheet. It's defined with <style type="text/css"> at the top.

When I upload the file for this resource, Salesforce creates it with a MIME type of text/plain. It doesn't pick up the MIME type from the file's contents. It doesn't let me specify the MIME type when I upload the file. There doesn't seem to be a way to change the MIME type of an existing static resource.

This is a problem because Firefox doesn't want to load a style sheet whose MIME type isn't text/css.

How can I define or change the MIME type of a static resource?

Thanks,

Jeri.

PS. If there was a better place to post this message, please let me know. Thanks!