• Alexander Placidi 86
  • NEWBIE
  • 30 Points
  • Member since 2016
  • Salesforce Developer

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

I'm attempting to write a test method to test a piece of code where a user is attempting to create a custom object record that has an Opportunity lookup on the page layout.  What I'm trying to test is to display an error if the user creating the custom object record does not have access to the related Opportunity.  The error should be displayed when the user clicks 'Save' to save the custom object record.  

What I'm having difficulty with is being able to write the test method and tell it to insert the custom object record but also to make sure that the user does not have access to the Opportunity in the lookup field.  Also, this test class has isTest(SeeAllData=true).

Can someone please point me in the right direction on how this may be accomplished?  Any responses would be greatly appreciated!

sniper of code being tested:
for (Internal_Request__c ir : newInternalRequestList) {
            Opportunity myOpp = oppMap.get(ir.Opportunity__c);
            if (myOpp == null) {
                    ir.addError('You do not have access to this Opportunity or the Opportunity does not exist');
            } else if (invalidStageNameSet.contains(oppMap.get(ir.Opportunity__c).StageName)) {
                    ir.addError('Unable to associate an Opportunity with a "Closed Lost" or "Closed:  No Bid" with an Internal Request.');
                }
            }
  • September 26, 2016
  • Like
  • 0
Hello, 

Currently I have some trouble with the platform cache. I noticed, that the get operation fails after a time-based flow interview has resumed and creates a record. The trigger due to the insert operation leads to the error. 

This is the stack trace:

Class.cache.PlatformCacheDelegateWrapper.getOrgPartitionDelegate: line 19, column 1 Class.cache.OrgPartition.<init>: line 20, column 1 Class.cache.Org.getPartition: line 20, column 1 Class.CacheManager.get: line 27, column 1 Class.TriggerSelector.getTrigger: line 54, column 1 Class.TriggerManager.manage: line 33, column 1 Trigger.CaseTr: line 11, column 1 18:02:28.650 (705134620)|FATAL_ERROR|System.UnexpectedException: Salesforce System Error: 1855979781-250306 (-904646074) (-904646074)

Does anyone has experience with the platform cache and this error?

Best regards
Hello,

I'm attempting to write a test method to test a piece of code where a user is attempting to create a custom object record that has an Opportunity lookup on the page layout.  What I'm trying to test is to display an error if the user creating the custom object record does not have access to the related Opportunity.  The error should be displayed when the user clicks 'Save' to save the custom object record.  

What I'm having difficulty with is being able to write the test method and tell it to insert the custom object record but also to make sure that the user does not have access to the Opportunity in the lookup field.  Also, this test class has isTest(SeeAllData=true).

Can someone please point me in the right direction on how this may be accomplished?  Any responses would be greatly appreciated!

sniper of code being tested:
for (Internal_Request__c ir : newInternalRequestList) {
            Opportunity myOpp = oppMap.get(ir.Opportunity__c);
            if (myOpp == null) {
                    ir.addError('You do not have access to this Opportunity or the Opportunity does not exist');
            } else if (invalidStageNameSet.contains(oppMap.get(ir.Opportunity__c).StageName)) {
                    ir.addError('Unable to associate an Opportunity with a "Closed Lost" or "Closed:  No Bid" with an Internal Request.');
                }
            }
  • September 26, 2016
  • Like
  • 0