• Rashed Yaqubi 10
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 11
    Replies
Hi there, I am relatively new to apex coding and need to write a trigger handler for the following Trigger.  I understand the general logic and reason for why I need to do it, but unsure on how exacty it needs to be done. i.e. do I leave my definition of the ID sets in the trigger and move everything else to the class? Do I need to pass anything from the trigger to the class when I call it (specially if the id sets are defined/declared in the trigger)? Your help is greatly appreciated!

trigger AgreementHasAttachment on ContentDocumentLink (after insert) {
    Set<Id> setParentId = new Set<Id>();
    Set<Id> setGrandParentId = new Set<Id>();
      
    for (ContentDocumentLink cdl : trigger.new)  {
        setParentId.add(cdl.LinkedEntityId);      
    }
    
    List<Agreement__c> Agreementlst = new List<Agreement__c>();
    Agreementlst = [select Id, HasAttachment__c, MDU_Referral_Contact__c from Agreement__c where Id IN :setParentId];    
    For (Agreement__c a : Agreementlst) 
    {
        a.HasAttachment__c = True;
        setGrandParentId.add(a.MDU_Referral_Contact__c);
    }
    
    List<Contact> Contlst = new List<Contact>();
    Contlst = [Select Id, Contract_Uploaded__c from Contact where Id IN :setGrandParentId];
    For (Contact c : Contlst){
        c.Contract_Uploaded__c = true;
    }
    
    if(Agreementlst.size() > 0) update Agreementlst;
    if(Contlst.size() > 0) update Contlst;
}
Hey guys, there is a text field that I want to restrict so it only accepts 10 digit phone numbers separated by commas. 

So far I have this, but it does not specify how many digits the numbers must be.  So it allows any number of digits separated by commas (i.e. 123,12,1234,12345,etc).  But I want to restrict it to comma separated 10-digit numbers (i.e. 4161231234,6470987657,9051231234,etc…).  I know I need a “{10}” somewhere, but can’t seem to figure out where. 

Your help is greatly appreciated.


AND(
NOT(ISBLANK(Text_Field__c)),
NOT(REGEX(Text_Field__c,"^[0-9,.*]+$"))
)
Hi there,

I am trying to disable the ability to comment in chatter groups based on profile ID.  I have 3 groups: one public and two private.  I want to disable all users with an "agent" profile from being able to comment in those specific groups. I am assuming this is a simple piece of code, but I am not able to create it on my own.  

I have tried the following trigger, but it doesn't seem to be working.  When i try to log in as an agent and do a post to a group the agent is a memeber of, it goes through.  I also noticed this code does not include the name of the group that the user cannot post in. Anyone have any ideas? Thanks! 

trigger ChatterCommentsDisabled on FeedComment (before insert) {
Id profileUser = UserInfo.getProfileId();

profile AnnuityProfile = [select id from profile where name ='D2D Agent User - Atlantic' or name ='D2D Agent User - Central'];
    for(FeedComment fc : trigger.new)
        if(fc.CommentType== 'ContentComment' && ProfileUser == AnnuityProfile.Id)
            fc.addError('you dont have permissions to Comment');
}
Hi there.  I am trying to use a simple Visualforce page as a lightning component, but unable to make it available in the Lightning App Builder.  I have added lightningStylesheets="true" to the <apex:page> tag and ticked off the box  "Add Available for Lightning Experience, Lightning Communities, and the mobile app". What am I doing wrong here? The VF page is a simple marquee that we intend to use as a news ticker across the top of the home page. Please help.
Hi there.  I am trying to use a simple Visualforce page as a lightning component, but unable to make it available in the Lightning App Builder.  I have added lightningStylesheets="true" to the <apex:page> tag and ticked off the box  "Add Available for Lightning Experience, Lightning Communities, and the mobile app". What am I doing wrong here? The VF page is a simple marquee that we intend to use as a news ticker across the top of the home page. Please help.
Hi there, I am relatively new to apex coding and need to write a trigger handler for the following Trigger.  I understand the general logic and reason for why I need to do it, but unsure on how exacty it needs to be done. i.e. do I leave my definition of the ID sets in the trigger and move everything else to the class? Do I need to pass anything from the trigger to the class when I call it (specially if the id sets are defined/declared in the trigger)? Your help is greatly appreciated!

trigger AgreementHasAttachment on ContentDocumentLink (after insert) {
    Set<Id> setParentId = new Set<Id>();
    Set<Id> setGrandParentId = new Set<Id>();
      
    for (ContentDocumentLink cdl : trigger.new)  {
        setParentId.add(cdl.LinkedEntityId);      
    }
    
    List<Agreement__c> Agreementlst = new List<Agreement__c>();
    Agreementlst = [select Id, HasAttachment__c, MDU_Referral_Contact__c from Agreement__c where Id IN :setParentId];    
    For (Agreement__c a : Agreementlst) 
    {
        a.HasAttachment__c = True;
        setGrandParentId.add(a.MDU_Referral_Contact__c);
    }
    
    List<Contact> Contlst = new List<Contact>();
    Contlst = [Select Id, Contract_Uploaded__c from Contact where Id IN :setGrandParentId];
    For (Contact c : Contlst){
        c.Contract_Uploaded__c = true;
    }
    
    if(Agreementlst.size() > 0) update Agreementlst;
    if(Contlst.size() > 0) update Contlst;
}
Hey guys, there is a text field that I want to restrict so it only accepts 10 digit phone numbers separated by commas. 

So far I have this, but it does not specify how many digits the numbers must be.  So it allows any number of digits separated by commas (i.e. 123,12,1234,12345,etc).  But I want to restrict it to comma separated 10-digit numbers (i.e. 4161231234,6470987657,9051231234,etc…).  I know I need a “{10}” somewhere, but can’t seem to figure out where. 

Your help is greatly appreciated.


AND(
NOT(ISBLANK(Text_Field__c)),
NOT(REGEX(Text_Field__c,"^[0-9,.*]+$"))
)
Hi there,

I am trying to disable the ability to comment in chatter groups based on profile ID.  I have 3 groups: one public and two private.  I want to disable all users with an "agent" profile from being able to comment in those specific groups. I am assuming this is a simple piece of code, but I am not able to create it on my own.  

I have tried the following trigger, but it doesn't seem to be working.  When i try to log in as an agent and do a post to a group the agent is a memeber of, it goes through.  I also noticed this code does not include the name of the group that the user cannot post in. Anyone have any ideas? Thanks! 

trigger ChatterCommentsDisabled on FeedComment (before insert) {
Id profileUser = UserInfo.getProfileId();

profile AnnuityProfile = [select id from profile where name ='D2D Agent User - Atlantic' or name ='D2D Agent User - Central'];
    for(FeedComment fc : trigger.new)
        if(fc.CommentType== 'ContentComment' && ProfileUser == AnnuityProfile.Id)
            fc.addError('you dont have permissions to Comment');
}
Hi there.  I am trying to use a simple Visualforce page as a lightning component, but unable to make it available in the Lightning App Builder.  I have added lightningStylesheets="true" to the <apex:page> tag and ticked off the box  "Add Available for Lightning Experience, Lightning Communities, and the mobile app". What am I doing wrong here? The VF page is a simple marquee that we intend to use as a news ticker across the top of the home page. Please help.