• aparna kantu
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 6
    Replies
I wrote a trigger, trigger handler, and a class to check permissions of a user before they are able to create,edit, or delete an oppy team member. I am new to Apex and am struggling with the test code coverage. Here is my code(ignore the ugly error messages those are going to change). Any help would be much appreciated.

public class OppyTeamMemberCheckPerms {
    
    Public void CheckPerms(List<OpportunityTeamMember> newRecords, List<OpportunityTeamMember> oldRecords, System.TriggerOperation triggerEvent){
        Id OppyRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Rocket Pro Loan').getRecordTypeId();
        Boolean hasCustomPerm = FeatureManagement.checkPermission('Opportunity_Team_Member_Access');
        string triggerType = string.valueOf(triggerEvent);
        List<Id> OppyList = new List<Id>();
        List<Id> InvalidOppyList = new List<Id>();    
        
        if (triggerType == 'BEFORE_DELETE'){
            for (OpportunityTeamMember tm : oldRecords){
                OppyList.add(tm.OpportunityId);
            }
            for(Opportunity o : [SELECT recordtypeid FROM Opportunity WHERE id IN:OppyList]){
                if(o.RecordTypeId == OppyRecordTypeId){
                    InvalidOppyList.add(o.Id);
                }
            }
            for (OpportunityTeamMember tm : oldRecords){
                if(InvalidOppyList.contains(tm.OpportunityId) && hasCustomPerm == false){
                    tm.adderror('Cant delete team member2');
                }
            }
        }
        if (triggerType == 'BEFORE_UPDATE'){
            for (OpportunityTeamMember tm : newRecords){
                OppyList.add(tm.OpportunityId);
            }
            for(Opportunity o : [SELECT recordtypeid FROM Opportunity WHERE id IN:OppyList]){
                if(o.RecordTypeId == OppyRecordTypeId){
                    InvalidOppyList.add(o.Id);
                }
            }
            for (OpportunityTeamMember tm : newRecords){
                if(InvalidOppyList.contains(tm.OpportunityId) && hasCustomPerm == false){
                    tm.adderror('Cant update team member2');
                }
            }
        }
        if (triggerType == 'BEFORE_INSERT'){
            for (OpportunityTeamMember tm : newRecords){
                OppyList.add(tm.OpportunityId);
            }
            for(Opportunity o : [SELECT recordtypeid FROM Opportunity WHERE id IN:OppyList]){
                if(o.RecordTypeId == OppyRecordTypeId){
                    InvalidOppyList.add(o.Id);
                }
            }
            for (OpportunityTeamMember tm : newRecords){
                if(InvalidOppyList.contains(tm.OpportunityId) && hasCustomPerm == false){
                    tm.adderror('Cant insert team member2');
                }
            }
        }
    }
}
Hi Team,

Where exactly we can use 'inputHidden' tag-input fields. {scenario} ?
Hi all,

We configure data loader to perform an update operation and gets a success result with the 'Item updated' message back. However, we can't see changes reflected at the web interface for some fields. Any idea what may blocking update operations ? What we observe that troubled fields are being used in various logic inside (triggering, picklist?). Other fields, insert and delete operations work as expected.

Hope that somebody can shed light on this weird behaviour.

Kind regards
Tev
I am looking for some part-time Salesforce support for my organization. We are a nonprofit that helps veterans get access to mental healthcare. Please let me know if you are interested!
So I have a flow that we use via button and it takes the  contactID related to a community user. I want to run the flow whenever the community user logs in. I have tried to run a PB that should fire on last login field on user which doesnt work. When a user logs in it creates a record in the userLogin object, is there any way to use that in PB or flow ?
Need a freelance developer for a few jobs relating to lighting. Need JS & Apex experience.
It is not recommended to include any statements between the sections of  ‘try’, ‘catch’, and ‘finally’ blocks, since they form one whole unit of the exception handling mechanism. 
try
{
    //Code which is monitored for exceptions.
}
//You can’t keep statements here
catch(Exception ex)
{
    //Catch the exceptions thrown by try block, if any.
}
//You can’t keep statements here
finally
{
    //This block is always executed irrespective of exceptions.
}

https://plumbingadvice24.com/how-to-install-abs-pipe-and-fitting/
I have a requirement where I need to create a salesforce case using perl script. The perl script will do an automation process on daily basis, if the automation wasn't done due to any mappings, we need to create a salesforce case.