• Adila Hilal 9
  • NEWBIE
  • 0 Points
  • Member since 2019

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

We have a requirement where I have to automate a process to assign login access to user as System Admin and after Expiration date the profile should automatically be revoked to original. I have used process builder and a flow just to update profileId with Oriinal.Somehow the flow is not working as the expiration date passes the Profile doesnt revert back to original.So I am trying to write apex code to invoke a method from process builder. This s what I am trying to do.Please need help in writing code.
trigger updateUserProfileTrigger on User (after insert, after update) {
    
 public class updateUserProfile {

 public static ID profile1;
 public static ID profile2;
  
  @future
    
    public static void assignProfileToUser(  for [profile p: [SELECT ID ,Name FROM Profile]){
           if(p.name == 'System Administrator'){
               profile1 = p.id;
           } else if(p.name == 'Last_Profile_Id'){
               profile2 = p.id;
            }
       }       for (User u : userListNew) {
           if (u.User_Admin__c == true) {
               user u = userMap.get(u.id);
               u.profileID = profile1;                        

                u.profileID = profile2;
               usertoUpdate(u);
           }
           
       } 



 
 
Hi All, 
Please, I am trying to update an account field using a trigger based on recordtype. The requirement is if  the Reocrdtype is AccOneA and the Active field on the Account is "Yes" update the description. 
Please see my code below

trigger AccountTriggerB on Account (before insert, before Update) {
    for(Account Acc:Trigger.New){
        if(Acc.RecordType.DeveloperName=='AccOneA' && Acc.Description ==Null){
            Acc.Description ='Please lets us know if there is any concern.Thanks';
        }
    }
    
}
 
Hello Everyone,

i need to copy the old values(Look up field into another field ).
Here whenever i save the record its getting the new id value in another field.
I need to excute this part of code whenver this feilds changes QCC_DSP__c/QAM_DSP__c
Suppose if the field changes happens on any other field is part of code should not execute.


 public void onManagerUpdate(List<Contact> contactList) {
     set<Id> CntIds= new Set<Id>();
     for (Contact Mancontacts : contactList){
        if (Mancontacts.QCC_DSP__c != null || Mancontacts.QAM_DSP__c!=null) 
        {
            Mancontacts.Manager_Login__c = Mancontacts.QCC_DSP__c;
            Mancontacts.Manager_Login__c = Mancontacts.QAM_DSP__c;
            Mancontacts.QAM_DSP_End_Date__c=system.today();
            
        }
      }
       //update ManagerUpdate;
  }

Thanks for all the help.

Regards,
Jyo