• Iswarya Sekar
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 14
    Replies
Hi Everyone!

I have a requirement where i cannot find an solution. Can anyone pls help me on this.

Requirement - I have a number field in Account and if this account has 3 child accounts, then the assets related to these 3 accounts should be calculated and updated in parent account field.

Example - Account name - ABC
if ABC has 2 child accounts 
child 1 - has 3 assets varies by record type
child 2 - has 2 assets varies by record type

Then ABC account custom field should be populated with the value as "5" if all 5 assets falls under same record Type
global class UserDeactivateAlert_V1 implements Database.Batchable<SObject>
{         
    public String query = 'SELECT Name, Id, email, IsActive, lastlogindate, IsPortalEnabled from user where lastlogindate < LAST_N_DAYS:8 AND IsActive = true';      
    
    //public String query = 'select id, name, lastlogindate,IsPortalEnabled,email from user where id =\'0059E0000074xx4\'';
    global Database.querylocator start(Database.BatchableContext bc)
    {
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc,List<User> scope)
    {
        system.debug('The list of Users :'+scope);
        Date todayDate = date.today();
 
        Date deactivateInternalDt = date.today().addDays(-180);
        Date deactivatePartnerDt = date.today().addDays(-90);
        Date finalInternalDt = date.today().addDays(-178);
        Date finalPartnerDt = date.today().addDays(-88);
        Date initialDt = date.today().addDays(60);
        
        Map<String, Job_Schedulers__c> DoNotDeactivate = Job_Schedulers__c.getAll();
        system.debug('DoNotDeactivate '+DoNotDeactivate );
                
        system.Debug(deactivateInternalDt +'deactivateInternalDt ');
        system.Debug(deactivatePartnerDt +'deactivatePartnerDt ');
        system.Debug(finalInternalDt +'finalInternalDt ');
        system.Debug(finalPartnerDt +'finalPartnerDt ');
        system.Debug(initialDt +'initialDt');
        
        map<String,List<User>> MapofUsers = new map<String,List<User>>();
        Set<Id> deactivateUsers = new Set<Id>();
                
        for(User usr :scope){
         Date userDate = usr.lastlogindate.date();
         system.debug(userDate + 'userDate');
        
            if(userDate <= initialDt && !DoNotDeactivate.containskey(usr.Id)){
            system.debug(userDate+'userDate');
                if(userDate == initialDt){
                    system.debug(userDate+'userDate');
            system.debug(initialDt+'initialDt');
                    //initialAlertPartnerUsers
                    if(usr.IsPortalEnabled==true){
                        if(!MapofUsers.containsKey('Alert_Mail_for_Partner_User')){
                            MapofUsers.put('Alert_Mail_for_Partner_User', new List<User>{usr});
                        }else{
                            MapofUsers.get('Alert_Mail_for_Partner_User').add(usr);
                        }
                        system.debug(usr +'initialAlertPartnerUsers');
                    }else{
                        //initialAlertInternalUsers
                        if(!MapofUsers.containsKey('Alert_Mail_for_Internal_Users')){
                            MapofUsers.put('Alert_Mail_for_Internal_Users', new List<User>{usr});
                        }else{
                            MapofUsers.get('Alert_Mail_for_Internal_Users').add(usr);
                        }system.debug(usr +'initialAlertInternalUsers');
                    }
                }
                //finalAlertPartnerUsers
                else if(userDate == finalPartnerDt && usr.IsPortalEnabled==true){
                    if(!MapofUsers.containsKey('Deactivation_email_for_External_Users')){
                            MapofUsers.put('Deactivation_email_for_External_Users', new List<User>{usr});
                        }else{
                            MapofUsers.get('Deactivation_email_for_External_Users').add(usr);
                        }
                     system.debug(usr +'finalAlertPartnerUsers');   
                }
                //finalAlertInternalUsers
                else if(userDate == finalInternalDt && usr.IsPortalEnabled==false){
                    if(!MapofUsers.containsKey('Deactivation_email_for_Internal_Users')){
                            MapofUsers.put('Deactivation_email_for_Internal_Users', new List<User>{usr});
                        }else{
                            MapofUsers.get('Deactivation_email_for_Internal_Users').add(usr);
                        }
                       system.debug(usr +'finalAlertInternalUsers'); 
                }
                else if(userDate <= deactivatePartnerDt && usr.IsPortalEnabled==true){
                    deactivateUsers.add(usr.Id);
                }  
                else if(userDate <= deactivateInternalDt && usr.IsPortalEnabled==false){
                    deactivateUsers.add(usr.Id);
                } 
            }    
        } 
        system.debug(deactivateUsers.size()+'deactivateUsers');    
        if(deactivateUsers.size()>0){
        UserAlertAndDeactivation_Handler.UserDeactivation(deactivateUsers);
        }
        system.debug(MapofUsers +'MapofUsers');
        if(MapofUsers.size()>0){
            UserAlertAndDeactivation_Handler.sendEmailToUsers(MapofUsers);
        }        
    }    
    global void finish(Database.BatchableContext bc)
    {  
    }  
}



public class UserAlertAndDeactivation_Handler { 
    
    public static void sendEmailToUsers(map<String, List<User>> MapofUsers){
        
        List<EmailTemplate> listEmailTemplate = [select Id,DeveloperName from EmailTemplate where DeveloperName IN : MapofUsers.keySet()];
        Map<string, Id> mapEmailTemplate = new Map<string, Id>();
       
        for(EmailTemplate et : listEmailTemplate){
            mapEmailTemplate.put(et.DeveloperName,et.Id);
        }
        
        List<Messaging.SingleEmailMessage> allMessages = New List<Messaging.SingleEmailMessage>();
        
        for(String tempName: MapofUsers.keyset()){
            List<User> userList= MapofUsers.get(tempName);
            for(User u: userList){
                Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage();
                m.setTemplateId(mapEmailTemplate.get(tempName));
                m.setTargetObjectId(u.Id);
                m.saveAsActivity = false;
                allMessages.add(m);
            }
        }     
        system.debug(allMessages);
        //Messaging.sendEmail(allMessages); 
    }
    
    public static void UserDeactivation(Set<Id> deactivateUsers)
    {
        List<user> deactivatingUserList= new List<user>();
        for(User us : [select Id, IsActive from User where Id IN : deactivateUsers]){
            us.isActive=false;
            deactivatingUserList.add(us);
        }
        system.debug(deactivatingUserList+'deactivatingUserList');
        //database.update(deactivatingUserList);
    }
}
Hi Guys,

I have created a formula field to display image if a candidatte is also a lead. But the image is not displaying in lightning. can anyone help me with this?
Please see the formula which i used,
IF( Candidate__c !='', 
IMAGE("sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Png&versionId=06817000000Mp0y&operationContext=CHATTER&contentId=05T17000000XNXe", "" ),NULL )
Hello guys,

I have a requirement like if the candidate is also a lead, then in leads i have to insert a flag field. this i have done for the records which were inserting newly.

now for the existing records i have to update the field value with a flag. for that i have to run my trigger in anonymous window.
may i know how should i call trigger in anonymous window
I have a requirement of creating a timesheet for my company without using any managed or unmanaged packages from appexchange. can anyone please suggest me the ideas or overflow to complete this task.
<apex:page extensions="updateoppclass2" standardController="Opportunity">
    <apex:form > 
        <apex:pageblock title="Step 2 - select the field to be updated">
            <span>Fields: </span>
            <apex:selectList multiselect="false" size="1">
                <apex:selectOptions value="{!OppNames}">
                </apex:selectOptions>
            </apex:selectList>
            <apex:pageblockbuttons >
                <apex:commandButton value="previous" action="{!gotopage1}"/>
                <apex:commandButton value="Next" action="{!gotostep3}"/>
                <apex:commandButton value="Cancel"/>
            </apex:pageblockbuttons>
        </apex:pageblock>
    </apex:form>
</apex:page>
 
public with sharing class updateoppclass2 {
    public updateoppclass2(ApexPages.Standardcontroller controller){
    } 
    public PageReference gotopage1(){
        PageReference pref2=New PageReference('/apex/oppupdatepage');
        pref2.setRedirect(True);
        return pref2;
    }
    public PageReference gotostep3(){
        PageReference pref3=New PageReference('/apex/entervalues');
        pref3.setRedirect(True);
        return pref3;
    }
    
    public PageReference gotoVF(){
        PageReference pref4=New PageReference('/apex/confmationpage');
        pref4.setRedirect(True);
        return pref4;
    }
    
    public List<selectOption> oppflds;
    public updateoppclass2(){}
        public List<selectOption> getOppNames() {
            oppflds = new List<selectOption>();
            oppflds.add(new selectOption('--none--','--none--'));
            Schema.DescribeSObjectResult opp_desc = Opportunity.sObjectType.getDescribe();
            Map<String, Schema.SObjectField> opp_fields = opp_desc.fields.getMap();
            for(Schema.sObjectField fld:opp_fields.values())
            {
                    String oppfldName = String.valueOf(fld);
                    oppflds.add(new selectOption(oppfldName,oppfldName));
            }
            System.debug('stdObjectNames: ' + oppflds);
            return oppflds;
        }
}

 
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: PPIHOVJD

I created new trailhead playgrounds, but i couldn,t complete the chanllenge. anyone help me..
<apex:page standardController="CPL_Protocols__c" renderAs="pdf" applyBodyTag="false" docType="html-5.0" standardStylesheets="false" applyHtmlTag="false" extensions="PrintPageController" showHeader="false">
    
    <apex:form >
        <apex:pageBlock title="CPL Request Information Detail">  
            <br></br>
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left" >
            <apex:pageBlockSection title="Status" columns="1">
                
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.OwnerId}"/></table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Protocol_Number__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Approval_Step_Status__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Status_Date_Time_Stamp__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Protocol_Status__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labels_Due_Date__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Number_of_Labels_to_Printed__c}"/> </table> 
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Contact__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.user_email__c}"/>  </table>
            </apex:pageBlockSection>
        </table>
    </apex:pageBlock>
    
    <apex:pageblock >
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left" >
            <apex:pageBlockSection title="Study Information" columns="2" >
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Name}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Number_of_Study_Sites__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Type__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Treatment_Period__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Country__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Phase__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Protocol_Description__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.No_of_Treatment_Grp__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Enrollment_Period__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Duration__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Dosing_Regimen__c}"/>  
            </apex:pageBlockSection>
        </table>
    </apex:pageblock>
    
    
    <apex:pageblock >
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left" >
            <apex:pageBlockSection title="Product Information" columns="2">
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Primary_Packaging__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Secondary_Packaging__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Label_Information__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labeling_Lot_Number__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Storage_Requirements__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Max_Exposure_Time__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Label_Expiration_Date__c}"/>   
            </apex:pageBlockSection>
        </table>
    </apex:pageblock>
    
    <apex:pageblock >
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left">
            <apex:pageBlockSection title="Packaging/Labeling Operation" columns="2" >
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Packaging_Site__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labeling_Site__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Quantity_Required__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Sampling_Requirements__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.CreatedById}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labeling_Package_Instructions__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Calculated_Qty_to_be_Prepared__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Randomization__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Randomization_File_Acknowledgement__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.LastModifiedById}"/>   
            </apex:pageBlockSection>
        </table>
    </apex:pageblock>
    
</apex:form>

<apex:relatedList list="Parts__r" /> <br></br>
<apex:relatedList subject="{!CPL_Protocols__c}" list="Histories" /> 
<apex:relatedList subject="{!CPL_Protocols__c}" list="ProcessSteps" /> 

<apex:relatedList subject="{!CPL_Protocols__c}" list="ActivityHistories" /> 
<apex:relatedList subject="{!CPL_Protocols__c}" list="OpenActivities" /> 
<apex:relatedList subject="{!CPL_Protocols__c}" list="AttachedContentDocuments" />

</apex:page>

 
public class UpdateUser {
    Public static void method1(List<case> caseList){
        set<id> parentcaseId = new set<Id>();
        for(case cs:caseList){
            if(cs.Defect__c != null){
                parentcaseId.add(cs.Defect__c);
            }
        }
        
        List<Case> caseslistold = [SELECT Id, OwnerId FROM Case WHERE Id in : parentcaseId];
        for(Id csIdtoUpdate:parentcaseId){
            for(Case cas:caseslistold){
                for(case cs:caseList){
                    cs.Product_Lead__c=cas.ownerId;
                }
            }
        }
    }
}
 
trigger updateUsertrig on Case (before insert, before Update) {
    if((trigger.isInsert && trigger.isBefore) || (trigger.isUpdate && trigger.isBefore))
UpdateUser.method1(trigger.new);
}

 
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="dispalyAccountscontroller">
    
    <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
    <aura:attribute name="accounts" type="List" /> 
    
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
        <tr class="slds-text-heading--label">
            
            <th scope="col"><div class="slds-truncate" title="name">Name</div>  </th>
            <th scope="col"><div class="slds-truncate" title="industry">Industry</div></th>
            <th scope="col"><div class="slds-truncate" title="contacts">Contacts</div> </th>
            
        </tr>
        
        <aura:iteration items="{!v.accounts}" var="accs1" >
            
            <tr>  
                <th><div class="slds-truncate" title="{!accs1.Name}"><a href="javascript:void(0);">{!accs1.Name}</a></div>   </th>
                <th> <div class="slds-truncate" title="{!accs1.Industry}">{!accs1.Industry}</div>  </th>
                
                <table>
                    <aura:iteration items="{!accs1.Contacts}" var="con1" >
                        <tr>
                            <th><div class="slds-truncate" title="{!con1.LastName}">{!con1.LastName}</div></th>
                        </tr>
                    </aura:iteration>
                </table>
            </tr> 
            
        </aura:iteration> 
        
    </table>    
</aura:component>

Please help me to achieve this!!
global class scheduledBatchable implements Schedulable {
    
    global void execute(SchedulableContext sc) {
        
        Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
        Case cs = [SELECT id, CLOSED__c, Status FROM Case WHERE CLOSED__C=TRUE];
        
        EmailTemplate template = [SELECT id,Name, DeveloperName, OwnerId FROM EmailTemplate WHERE DeveloperName = 'P1_Followup_Remainder'];
        msg.setTemplateId(template.Id);
        msg.setSenderDisplayName('is@gmail.com');
        msg.setTargetObjectId(cs.Id);
        msg.setSaveAsActivity(false);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { msg });
        
    } 
    
   }

I'm not getting any email notifications. what's wrong in my code?
<apex:page standardController="Case" extensions="newClass" showHeader="false" >
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Case.Status}"/>
                <apex:inputField value="{!Case.Reason}"/>
                <apex:inputField value="{!Case.Priority}"/>
            </apex:pageBlockSection>
            <div>
                <apex:commandButton action="{!redirectToMyVF}" value="CloseCase"/>
            </div>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My page1


<apex:page standardController="Case" extensions="Displayrecord" showHeader="false" >
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Case.Status}"/>
                <apex:inputField value="{!Case.Reason}"/>
                <apex:inputField value="{!Case.Priority}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/> 
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My page 2


public class newClass {
    public newClass (ApexPages.StandardController Cases) {
    }
    public PageReference redirectToMyVF() {
        PageReference pref = new PageReference('/apex/Page');
        pref.setRedirect(true);
        return pref;
    }
    public PageReference save() {  
        try{
            update this.Cases;
        }catch(exception e){
        }
        PageReference page = new Pagereference('/apex/Case_page?Id='+Case.Id);
        page.setRedirect(true);
        return page;
    }
    
}

my apex class

Please help me
Hi Everyone!

I have a requirement where i cannot find an solution. Can anyone pls help me on this.

Requirement - I have a number field in Account and if this account has 3 child accounts, then the assets related to these 3 accounts should be calculated and updated in parent account field.

Example - Account name - ABC
if ABC has 2 child accounts 
child 1 - has 3 assets varies by record type
child 2 - has 2 assets varies by record type

Then ABC account custom field should be populated with the value as "5" if all 5 assets falls under same record Type
global class UserDeactivateAlert_V1 implements Database.Batchable<SObject>
{         
    public String query = 'SELECT Name, Id, email, IsActive, lastlogindate, IsPortalEnabled from user where lastlogindate < LAST_N_DAYS:8 AND IsActive = true';      
    
    //public String query = 'select id, name, lastlogindate,IsPortalEnabled,email from user where id =\'0059E0000074xx4\'';
    global Database.querylocator start(Database.BatchableContext bc)
    {
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc,List<User> scope)
    {
        system.debug('The list of Users :'+scope);
        Date todayDate = date.today();
 
        Date deactivateInternalDt = date.today().addDays(-180);
        Date deactivatePartnerDt = date.today().addDays(-90);
        Date finalInternalDt = date.today().addDays(-178);
        Date finalPartnerDt = date.today().addDays(-88);
        Date initialDt = date.today().addDays(60);
        
        Map<String, Job_Schedulers__c> DoNotDeactivate = Job_Schedulers__c.getAll();
        system.debug('DoNotDeactivate '+DoNotDeactivate );
                
        system.Debug(deactivateInternalDt +'deactivateInternalDt ');
        system.Debug(deactivatePartnerDt +'deactivatePartnerDt ');
        system.Debug(finalInternalDt +'finalInternalDt ');
        system.Debug(finalPartnerDt +'finalPartnerDt ');
        system.Debug(initialDt +'initialDt');
        
        map<String,List<User>> MapofUsers = new map<String,List<User>>();
        Set<Id> deactivateUsers = new Set<Id>();
                
        for(User usr :scope){
         Date userDate = usr.lastlogindate.date();
         system.debug(userDate + 'userDate');
        
            if(userDate <= initialDt && !DoNotDeactivate.containskey(usr.Id)){
            system.debug(userDate+'userDate');
                if(userDate == initialDt){
                    system.debug(userDate+'userDate');
            system.debug(initialDt+'initialDt');
                    //initialAlertPartnerUsers
                    if(usr.IsPortalEnabled==true){
                        if(!MapofUsers.containsKey('Alert_Mail_for_Partner_User')){
                            MapofUsers.put('Alert_Mail_for_Partner_User', new List<User>{usr});
                        }else{
                            MapofUsers.get('Alert_Mail_for_Partner_User').add(usr);
                        }
                        system.debug(usr +'initialAlertPartnerUsers');
                    }else{
                        //initialAlertInternalUsers
                        if(!MapofUsers.containsKey('Alert_Mail_for_Internal_Users')){
                            MapofUsers.put('Alert_Mail_for_Internal_Users', new List<User>{usr});
                        }else{
                            MapofUsers.get('Alert_Mail_for_Internal_Users').add(usr);
                        }system.debug(usr +'initialAlertInternalUsers');
                    }
                }
                //finalAlertPartnerUsers
                else if(userDate == finalPartnerDt && usr.IsPortalEnabled==true){
                    if(!MapofUsers.containsKey('Deactivation_email_for_External_Users')){
                            MapofUsers.put('Deactivation_email_for_External_Users', new List<User>{usr});
                        }else{
                            MapofUsers.get('Deactivation_email_for_External_Users').add(usr);
                        }
                     system.debug(usr +'finalAlertPartnerUsers');   
                }
                //finalAlertInternalUsers
                else if(userDate == finalInternalDt && usr.IsPortalEnabled==false){
                    if(!MapofUsers.containsKey('Deactivation_email_for_Internal_Users')){
                            MapofUsers.put('Deactivation_email_for_Internal_Users', new List<User>{usr});
                        }else{
                            MapofUsers.get('Deactivation_email_for_Internal_Users').add(usr);
                        }
                       system.debug(usr +'finalAlertInternalUsers'); 
                }
                else if(userDate <= deactivatePartnerDt && usr.IsPortalEnabled==true){
                    deactivateUsers.add(usr.Id);
                }  
                else if(userDate <= deactivateInternalDt && usr.IsPortalEnabled==false){
                    deactivateUsers.add(usr.Id);
                } 
            }    
        } 
        system.debug(deactivateUsers.size()+'deactivateUsers');    
        if(deactivateUsers.size()>0){
        UserAlertAndDeactivation_Handler.UserDeactivation(deactivateUsers);
        }
        system.debug(MapofUsers +'MapofUsers');
        if(MapofUsers.size()>0){
            UserAlertAndDeactivation_Handler.sendEmailToUsers(MapofUsers);
        }        
    }    
    global void finish(Database.BatchableContext bc)
    {  
    }  
}



public class UserAlertAndDeactivation_Handler { 
    
    public static void sendEmailToUsers(map<String, List<User>> MapofUsers){
        
        List<EmailTemplate> listEmailTemplate = [select Id,DeveloperName from EmailTemplate where DeveloperName IN : MapofUsers.keySet()];
        Map<string, Id> mapEmailTemplate = new Map<string, Id>();
       
        for(EmailTemplate et : listEmailTemplate){
            mapEmailTemplate.put(et.DeveloperName,et.Id);
        }
        
        List<Messaging.SingleEmailMessage> allMessages = New List<Messaging.SingleEmailMessage>();
        
        for(String tempName: MapofUsers.keyset()){
            List<User> userList= MapofUsers.get(tempName);
            for(User u: userList){
                Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage();
                m.setTemplateId(mapEmailTemplate.get(tempName));
                m.setTargetObjectId(u.Id);
                m.saveAsActivity = false;
                allMessages.add(m);
            }
        }     
        system.debug(allMessages);
        //Messaging.sendEmail(allMessages); 
    }
    
    public static void UserDeactivation(Set<Id> deactivateUsers)
    {
        List<user> deactivatingUserList= new List<user>();
        for(User us : [select Id, IsActive from User where Id IN : deactivateUsers]){
            us.isActive=false;
            deactivatingUserList.add(us);
        }
        system.debug(deactivatingUserList+'deactivatingUserList');
        //database.update(deactivatingUserList);
    }
}
<apex:page standardController="CPL_Protocols__c" renderAs="pdf" applyBodyTag="false" docType="html-5.0" standardStylesheets="false" applyHtmlTag="false" extensions="PrintPageController" showHeader="false">
    
    <apex:form >
        <apex:pageBlock title="CPL Request Information Detail">  
            <br></br>
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left" >
            <apex:pageBlockSection title="Status" columns="1">
                
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.OwnerId}"/></table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Protocol_Number__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Approval_Step_Status__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Status_Date_Time_Stamp__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Protocol_Status__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labels_Due_Date__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Number_of_Labels_to_Printed__c}"/> </table> 
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Contact__c}"/> </table>
                <table> <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.user_email__c}"/>  </table>
            </apex:pageBlockSection>
        </table>
    </apex:pageBlock>
    
    <apex:pageblock >
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left" >
            <apex:pageBlockSection title="Study Information" columns="2" >
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Name}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Number_of_Study_Sites__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Type__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Treatment_Period__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Country__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Phase__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Protocol_Description__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.No_of_Treatment_Grp__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Enrollment_Period__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Study_Duration__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Dosing_Regimen__c}"/>  
            </apex:pageBlockSection>
        </table>
    </apex:pageblock>
    
    
    <apex:pageblock >
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left" >
            <apex:pageBlockSection title="Product Information" columns="2">
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Primary_Packaging__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Secondary_Packaging__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Label_Information__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labeling_Lot_Number__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Storage_Requirements__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Max_Exposure_Time__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Label_Expiration_Date__c}"/>   
            </apex:pageBlockSection>
        </table>
    </apex:pageblock>
    
    <apex:pageblock >
        <table width="60%" cellspacing="0" cellpadding="0" border="0" align="left">
            <apex:pageBlockSection title="Packaging/Labeling Operation" columns="2" >
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Packaging_Site__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labeling_Site__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Quantity_Required__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Sampling_Requirements__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.CreatedById}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Labeling_Package_Instructions__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Calculated_Qty_to_be_Prepared__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Randomization__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.Randomization_File_Acknowledgement__c}"/> 
                <apex:outputfield style="width:150px;height:25px; background:#B4C3D1;" value="{!CPL_Protocols__c.LastModifiedById}"/>   
            </apex:pageBlockSection>
        </table>
    </apex:pageblock>
    
</apex:form>

<apex:relatedList list="Parts__r" /> <br></br>
<apex:relatedList subject="{!CPL_Protocols__c}" list="Histories" /> 
<apex:relatedList subject="{!CPL_Protocols__c}" list="ProcessSteps" /> 

<apex:relatedList subject="{!CPL_Protocols__c}" list="ActivityHistories" /> 
<apex:relatedList subject="{!CPL_Protocols__c}" list="OpenActivities" /> 
<apex:relatedList subject="{!CPL_Protocols__c}" list="AttachedContentDocuments" />

</apex:page>

 
public class UpdateUser {
    Public static void method1(List<case> caseList){
        set<id> parentcaseId = new set<Id>();
        for(case cs:caseList){
            if(cs.Defect__c != null){
                parentcaseId.add(cs.Defect__c);
            }
        }
        
        List<Case> caseslistold = [SELECT Id, OwnerId FROM Case WHERE Id in : parentcaseId];
        for(Id csIdtoUpdate:parentcaseId){
            for(Case cas:caseslistold){
                for(case cs:caseList){
                    cs.Product_Lead__c=cas.ownerId;
                }
            }
        }
    }
}
 
trigger updateUsertrig on Case (before insert, before Update) {
    if((trigger.isInsert && trigger.isBefore) || (trigger.isUpdate && trigger.isBefore))
UpdateUser.method1(trigger.new);
}

 
<apex:page standardController="Case" showHeader="false" >
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Case.Status}"/>
                <apex:inputField value="{!Case.Reason}"/>
                <apex:inputField value="{!Case.Priority}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="save"/> 
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

when giving reason and status for the case object and saving it. this saved record should be displayed in another new VF page
<apex:page standardController="Case" extensions="newClass" showHeader="false" >
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Case.Status}"/>
                <apex:inputField value="{!Case.Reason}"/>
                <apex:inputField value="{!Case.Priority}"/>
            </apex:pageBlockSection>
            <div>
                <apex:commandButton action="{!redirectToMyVF}" value="CloseCase"/>
            </div>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My page1


<apex:page standardController="Case" extensions="Displayrecord" showHeader="false" >
    <apex:form >
        <apex:pageBlock title="Case Status">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Case.Status}"/>
                <apex:inputField value="{!Case.Reason}"/>
                <apex:inputField value="{!Case.Priority}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/> 
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My page 2


public class newClass {
    public newClass (ApexPages.StandardController Cases) {
    }
    public PageReference redirectToMyVF() {
        PageReference pref = new PageReference('/apex/Page');
        pref.setRedirect(true);
        return pref;
    }
    public PageReference save() {  
        try{
            update this.Cases;
        }catch(exception e){
        }
        PageReference page = new Pagereference('/apex/Case_page?Id='+Case.Id);
        page.setRedirect(true);
        return page;
    }
    
}

my apex class

Please help me