• balraj singh 33
  • NEWBIE
  • 50 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 10
    Replies
i am trying to deactivate the users and send and email for the same , but i am getting the error.Please suggest 

Try{
            
            update Userdeactivated;
            system.debug(Userdeactivated);
            sendemailalert(Userdeactivated);
           
        }
        Catch(Exception e){
            System.debug(e);
        }
        
 }
    Public void sendemailalert(list<user> userr) {
        Integer i =1;
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        List<String> ToAddress = new List<String>();
      
        String[] finalemail = a.email__c.split(','); 
        
        
        system.debug(finalemail.size());
        for(Integer p = finalemail.size();p>0;p--){
            
            Toaddress.add(finalemail[p-1]);

            }
        message.setToAddresses(Toaddress);
        
        message.subject = 'Notification for the users deactivated  Today';
         String plainTextBody = 'List of the Users deactivated due to 90 days of inactivity: ';
                              
        for(Integer n = userr.size();n>0;n--){
               
              plainTextBody += '\n'+i+')Name: '+userr[n-1].name+ ' ,UserName: '+userr[n-1].username+' \n';
               i++;
               system.debug(userr[n-1].name);
               system.debug(userr[n-1].username);
        }
         message.setplainTextBody(plainTextBody);
         
         Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};

         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);

         if (results[0].success) {

         System.debug('The email was sent successfully.');

         } 
         else {

             System.debug('The email failed to send: ' + results[0].errors[0].message);

         

}
 
String plainTextBody = 'The below Users are deactivated due 90 days of inactivity \n';
        
        
        for(Integer n = userr.size();n>0;n--){
               
               plainTextBody += i+')'+userr[n-1].name+'\n';
               i++;
               system.debug(+userr[n-1].name);
               system.debug(userr[n-1].username);
        }
         message.setplainTextBody(plainTextBody);
list<id> accountids;
for(contact con1 : [select id,accountid From contact where lastname = 'TEST'and birthdate = 2019-04-15 and firstname = 'TEST'])

{
   system.debug(con1.accountid);
      
}

system.debug(accountids);
 
<apex:outputPanel id="NewAssessmentscreen">
        <script type="text/javascript">
        function setViewAndEditLink()
{
$("a.actionLink[data-status='Entered in Error'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Incomplete'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Not Eligible'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Discharged'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-status='Continued'][data-button='Edit']").hide();
$("a.actionLink[data-type='DST'][data-showDischarge='false'][data-button='Discharge DST']").hide();
$("a.actionLink[data-type='DST'][data-showContinued='false'][data-button='Continue DST']").hide();
$("a.actionLink[data-type='DST'][data-showEdit='false'][data-button='Edit']").hide();
/*End*/
//DE87019-UAT : Related List needs formatting fixes /*Start*/
$("a.actionLink[data-button='Edit']").addClass('setBorder');
/*End*/
$("a.actionLink[data-type='Assessment'][data-status='Incomplete'][data-button='Edit']").hide();
$("a.actionLink[data-type='Assessment'][data-status='Completed'][data-esignCheck ='false'][data-button='Edit']").hide();
$("a.actionLink[data-type='Assessment'][data-status='Completed'][data-appStatus ='Approved'][data-esignCheck ='true'][data-button='Edit']").hide();

/*
101 SOQL ERROR REMEDY
if('{!JSENCODE(ProfileName)}' == '{!JSENCODE(ClinicalSupportProfile)}')
*/
//START: DE132997- Clinical Indicators:  Continuing an existing assessment does not save change in answers
$("a.actionLink[data-type='Clinical Indicators'][data-esignCheck ='false'][data-status='Completed'][data-button='Edit']").hide();
$("a.actionLink[data-type='Clinical Indicators'][data-status='Completed'][data-appStatus ='Approved'][data-esignCheck ='true'][data-button='Edit']").hide();
if('{!$Profile.Name}' == '{!JSENCODE(ClinicalSupportProfile)}')
{
$("a.actionLink[data-esignCheck ='true'][data-appStatus='Pending Approval'][data-button='Edit']").hide();
}
$("a.actionLink[data-type='Fall Risk'][data-status='Completed'][data-button='Edit']").hide();
//US713529 : Add Discharge Planning & Instructions to SOAP under Discharge Planning
$("a.actionLink[data-type='Discharge'][data-status='Completed'][data-button='Edit']").hide();
//US713529  ends
//US618562  Add MRA Assessment to SOAP note - Assessment Tab
$("a.actionLink[data-type='Mortality Risk'][data-status='Completed'][data-button='Edit']").hide();
//Bug-Id : 326 /*Start*/
var isPortalUserJS = '{!JSENCODE(IF(isPortalUser,"true","false"))}';
if(isPortalUserJS=='true'){
$("a.actionLink[data-button='Edit']").hide();
}
}
 
<div class="slds-size--1-of-1 slds-grid slds-wrap">
                                        <div class="slds-col--padded slds-size--1-of-2  slds-m-top--small">
                                            <span class="colorRed">* </span><label class="slds-form-element__label" for="GUTOA">Update Date</label>
                                            <div class="slds-form-element__control slds-input-has-icon">
                                                <apex:inputtext value="{!ifUpDate}" html-data-rule-required="true" id="ifUpDate" styleClass="slds-input ifUpDate"/>
                                                <apex:image id="calendarImgUp" styleClass="absolute-calendar" value="{!$Resource.calendar_icon}" height="25px" width="27px" onmouseover="fnInitCalendar(this, '{!$Component.ifUpDate}', 'close=true')" />
                                            </div>
                                        </div>
 
<apex:page standardcontroller="quote" extensions="quotequery" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true" >
    <apex:pageBlock title="Export Results" >
        <apex:pageBlockTable value="{!cs}" var="quote">
            <apex:column value="{!quote.ID}"/>
            <apex:column value="{!quote.Name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
public class assignment {
    public list<account>var;
    public string var2{get;set;}   

 public void mymethod()
    {
        system.debug(vAR2);
        If(var2!=nULL)
        {
            List<List<SObject>> searchList= [find :var2 in all fields RETURNING account(name,id)];
            var = searchlist[0];        }
        else{
               
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter ant keyword'));
        
        }



page:

<apex:inputtext value="{!var2}"/>
    <apex:commandbutton value="Search" action="{!mymethod}" rerender="B"></apex:commandbutton>
MY VISUALFORCE PAGE CONATINS
<apex:pageblocktable value="{!var21}" var="a" ID="B">
                <apex:column >
                <apex:commandlink Value="EDIT" action="{!editaccount}" target="_blank">
                 <apex:param value="{!a.id}" assignTo="{!idvariable}"></apex:param>

                    </apex:commandlink>
                </apex:column>
                 <apex:column value="{!a.name}"/>
             </apex:pageblocktable>

MY CONTROLLER APEX:

 public string idvariable{get;set;}  

 public pagereference editaccount()
    {
        PageReference newPage = new PageReference('/'+idvariable+'/e');

  newPage.setRedirect(true);

  return newPage;
    }
how can we save the data inserted through query in test class and use it again for testing
String sch1 = '0 0/10 * 1/1 * ? *';
System.schedule('Scheduled Job 3', sch1, new myScheduleClass());

I generated the cron expression using tool cronmaker.

ERROR:System.StringException: Seconds and minutes must be specified as integers: 0 0/10 * 1/1 * ? *
i am getting the error when i try to insert multiple records from data loader. It is working for single record.
User-added image
<div class="slds-size--1-of-1 slds-grid slds-wrap">
                                        <div class="slds-col--padded slds-size--1-of-2  slds-m-top--small">
                                            <span class="colorRed">* </span><label class="slds-form-element__label" for="GUTOA">Update Date</label>
                                            <div class="slds-form-element__control slds-input-has-icon">
                                                <apex:inputtext value="{!ifUpDate}" html-data-rule-required="true" id="ifUpDate" styleClass="slds-input ifUpDate"/>
                                                <apex:image id="calendarImgUp" styleClass="absolute-calendar" value="{!$Resource.calendar_icon}" height="25px" width="27px" onmouseover="fnInitCalendar(this, '{!$Component.ifUpDate}', 'close=true')" />
                                            </div>
                                        </div>
 
public class assignment {
    public list<account>var;
    public string var2{get;set;}   

 public void mymethod()
    {
        system.debug(vAR2);
        If(var2!=nULL)
        {
            List<List<SObject>> searchList= [find :var2 in all fields RETURNING account(name,id)];
            var = searchlist[0];        }
        else{
               
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter ant keyword'));
        
        }



page:

<apex:inputtext value="{!var2}"/>
    <apex:commandbutton value="Search" action="{!mymethod}" rerender="B"></apex:commandbutton>
MY VISUALFORCE PAGE CONATINS
<apex:pageblocktable value="{!var21}" var="a" ID="B">
                <apex:column >
                <apex:commandlink Value="EDIT" action="{!editaccount}" target="_blank">
                 <apex:param value="{!a.id}" assignTo="{!idvariable}"></apex:param>

                    </apex:commandlink>
                </apex:column>
                 <apex:column value="{!a.name}"/>
             </apex:pageblocktable>

MY CONTROLLER APEX:

 public string idvariable{get;set;}  

 public pagereference editaccount()
    {
        PageReference newPage = new PageReference('/'+idvariable+'/e');

  newPage.setRedirect(true);

  return newPage;
    }
String sch1 = '0 0/10 * 1/1 * ? *';
System.schedule('Scheduled Job 3', sch1, new myScheduleClass());

I generated the cron expression using tool cronmaker.

ERROR:System.StringException: Seconds and minutes must be specified as integers: 0 0/10 * 1/1 * ? *
i am getting the error when i try to insert multiple records from data loader. It is working for single record.
User-added image