• RohanSharma8791
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 4
    Replies
public class APTRequestVFController{
    public APT_Request__c apt {get;set;}
    public APT_Request_Option__c aptPort {get;set;}
    public APT_Request_Option__c aptPorts {get;set;}
    public List<APT_Request_Option__c> aptPortList {get;set;}
    public string urlAptId {get;set;}
    public boolean input {get;set;}
    public boolean showTable {get;set;}
    public boolean error {get;set;}
    public boolean displayModal {get; set;}
    public boolean reqRemApt {get; set;}
    public boolean postponeApt {get; set;}
    public Date postPoneDate {get; set;}
    public Date etaDate {get; set;}
    public Date etdDate {get; set;}
    public String agentPort {get; set;}
    public String addInfoPort {get; set;}
    
    public Date editEtaDate {get; set;}
    public Date editEtdDate {get; set;}
    public String editAgentPort {get; set;}
    public String editAddInfoPort {get; set;}
    public boolean editPortModal {get; set;}
    public boolean askDelPort {get; set;}
    public Integer rowIdRemove {get;set;}
    public String rowDelPort {get;set;}
    public String editIdPort {get;set;}
    
    public String msg {get;set;}
    public APTRequestVFController(){
        input = false;
        showTable = false;
        postponeApt = false;
        displayModal = false;
        //reqRemApt = false;
        //urlAptId = System.currentPagereference().getParameters().get('id');
        //urlAptId = ApexPages.currentPage().getUrl().subStringAfter('?Id=');
        urlAptId = ApexPages.currentPage().getparameters().get('Id');
        
    }
    public PageReference aptSave() {
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('?');
        apt.Status__c = 'Awaiting Scheduling';
        update apt;
        PageReference pageOnLoad = new Pagereference(urlAptIds+'/APTRequestNotAllowed?APTId='+urlAptId+'&msg=true');
        pageOnLoad.setRedirect(true);
        return pageOnLoad;
      
    }
    public PageReference checkValidation(){
        if(urlAptId != NULL){
            system.debug('urlAptIds'+' '+urlAptId);
            apt = [select Id,   Name, Account__c, Parent_Account__c, Status__c, Contact_Email_1__c, Contact_Email_2__c, Postponed_Date_Requested__c from APT_Request__c where Id =: urlAptId];
            system.debug('apt'+apt);
            if(apt.Postponed_Date_Requested__c != null ){
                postPoneDate = apt.Postponed_Date_Requested__c;
            }
            if(apt.Status__c == 'Awaiting Customer Response'){
                input = true;
                
                aptPortList = [select Id, APT_Request__r.Id, Location_of_APT__c, Country_of_APT_location__c, ETA__c, ETD__c, Agent_Details__c, Additional_Information__c from APT_Request_Option__c where APT_Request__r.Id =: urlAptId];
                system.debug('aptPortList'+aptPortList);
                if(aptPortList.size() > 0){
                   showTable = true;
                }
                APT_Request_Option__c aptObj = new APT_Request_Option__c();
                aptObj.APT_Request__c = urlAptId;
                aptPort = aptObj;
            }else{
                input = false;
                showTable = false;
                //msg = 'true';
                String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('?');
                system.debug('url------AptIds'+urlAptIds);
                PageReference pageOnLoad = new Pagereference(urlAptIds+'/APTRequestNotAllowed?APTId='+urlAptId+'&msg=false');
                //system.debug('pageOnLoad'+pageOnLoad);
                pageOnLoad.setRedirect(true);
                return pageOnLoad;
            }
        }
        return null;
    }
    public PageReference closeModal() {
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('APTRequest');
        system.debug('aptPort-cancel');
        PageReference page = new Pagereference(urlAptIds+'APTRequest?Id='+urlAptId);
        page.setRedirect(true);
        return page;  
    }
    public void openPortModal() {
        displayModal = true;
    }
    public PageReference closePortModal() {
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('APTRequest');
        displayModal = false;
        PageReference remoteErrorPg = new Pagereference(urlAptIds+'APTRequest?Id='+urlAptId);
        remoteErrorPg.setRedirect(true);
        return remoteErrorPg;
    }
    public PageReference aptPortSave() {       
        system.debug('aptPort-save');
        system.debug('urlAptIds'+' '+urlAptId);
        system.debug('aptPort-new'+aptPort);
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('APTRequest');
        
        APT_Request_Option__c aptObjs = new APT_Request_Option__c();
        if(aptPort.Id != NULL){
            aptObjs.Id = aptPort.Id;
        }
        aptObjs.APT_Request__c = urlAptId;
        aptObjs.Location_of_APT__c = aptPort.Location_of_APT__c;
        aptObjs.Country_of_APT_location__c = aptPort.Country_of_APT_location__c;
        aptObjs.ETA__c = etaDate;
        aptObjs.ETD__c = etdDate;
        aptObjs.Agent_Details__c = agentPort;
        aptObjs.Additional_Information__c = addInfoPort;
        system.debug('aptObjs'+aptObjs);
        // aptPort = aptObjs;
        insert aptObjs;
        PageReference remoteErrorPg = new Pagereference(urlAptIds+'APTRequest?Id='+urlAptId);
        remoteErrorPg.setRedirect(true);
        return remoteErrorPg;
    }
    public void aptPortSaveNew() {       
        system.debug('aptPort-save');
        system.debug('urlAptIds'+' '+urlAptId);
        system.debug('aptPort-new'+aptPort);
        
        APT_Request_Option__c aptObj = new APT_Request_Option__c();
        aptObj.APT_Request__c = urlAptId;
        aptObj.Location_of_APT__c = aptPort.Location_of_APT__c;
        aptObj.Country_of_APT_location__c = aptPort.Country_of_APT_location__c;
        aptObj.ETA__c = etaDate;
        aptObj.ETD__c = etdDate;
        aptObj.Agent_Details__c = agentPort;
        aptObj.Additional_Information__c = addInfoPort;
        //aptPort = aptObj;
        insert aptObj;
        APT_Request_Option__c aptReq = new APT_Request_Option__c();
        aptReq.APT_Request__c = urlAptId;
        etaDate = null;
        etdDate = null;
        agentPort = null;
        addInfoPort = null;
        aptPort = aptReq;
    }
    public void askDeletePort(){
        askDelPort = true;
        system.debug(rowIdRemove);
        system.debug(rowDelPort);
        system.debug('Del');
    }
    public void closeDelPort(){
        askDelPort = false;
        
    }
    public PageReference deleteAptPort(){
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('APTRequest');
        system.debug(urlAptIds);
        system.debug(rowIdRemove);
        system.debug(rowDelPort);
        rowIdRemove = rowIdRemove-1;
        system.debug(rowIdRemove);
        aptPortList.remove(rowIdRemove);
        system.debug('remove-aptPort'+aptPortList);
        delete [Select Id, Name From APT_Request_Option__c Where Id =: rowDelPort];
        
        PageReference remoteErrorPg = new Pagereference(urlAptIds+'APTRequest?Id='+urlAptId);
        remoteErrorPg.setRedirect(true);
        return remoteErrorPg;
    }
    public void editAptPort(){
        system.debug('editIdPort'+editIdPort);
        APT_Request_Option__c aptP = [select Id, APT_Request__r.Id, Location_of_APT__c, Country_of_APT_location__c, ETA__c, ETD__c, Agent_Details__c, Additional_Information__c from APT_Request_Option__c where Id =: editIdPort];
        if(aptP.ETA__c != null){
            editEtaDate = aptP.ETA__c;
        }
        if(aptP.ETD__c != null){
            editEtdDate = aptP.ETD__c;
        }
        if(aptP.Agent_Details__c  != null){
            editAgentPort = aptP.Agent_Details__c.replaceAll('<[^>]+>',' ');
        }
        if(aptP.Additional_Information__c != null){
            editAddInfoPort =  aptP.Additional_Information__c.replaceAll('<[^>]+>',' ');
        }
        //editEtaDate = aptP.ETA__c;
        //editEtdDate = aptP.ETD__c;
        //editAgentPort = aptP.Agent_Details__c;
        //editAddInfoPort = aptP.Additional_Information__c;
        aptPorts = aptP;
        editPortModal = true;
    }
    /*public void editPortSave(){
        system.debug('editPortSave');
        APT_Request_Option__c aptObjss = new APT_Request_Option__c();
        if(aptPorts.Id != NULL){
            aptObjss.Id = aptPorts.Id;
        }
        aptObjss.APT_Request__c = urlAptId;
        aptObjss.Location_of_APT__c = aptPorts.Location_of_APT__c;
        aptObjss.Country_of_APT_location__c = aptPorts.Country_of_APT_location__c;
        aptObjss.ETA__c = editEtaDate;
        aptObjss.ETD__c = editEtdDate;
        aptObjss.Agent_Details__c = aptPorts.Agent_Details__c;
        aptObjss.Additional_Information__c = aptPorts.Additional_Information__c;
        system.debug('aptObjs'+aptObjss);
        upsert aptObjss;
        editPortModal = false;
    }*/
    public PageReference remoteApt() {       
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('?');
        //msg = 'remtrue';
        apt = [select Id, Status__c from APT_Request__c where Id =: urlAptId];    
        apt.Status__c = 'Remote APT requested';
        update apt;
        PageReference remoteErrorPg = new Pagereference(urlAptIds+'/APTRequestNotAllowed?APTId='+urlAptId+'&msg=true');
        //system.debug('remoteErrorPg'+remoteErrorPg);
        remoteErrorPg.setRedirect(true);
        return remoteErrorPg;
    }
    public void postponeApt() {
        postponeApt = true;
    }
    public PageReference postponeAptSave() {
        String urlAptIds = ApexPages.currentPage().getUrl().substringBefore('?');
        if(postPoneDate != NULL && postponeApt == true){
            apt.Status__c = 'Customer postponed';
            apt.Postponed_Date_Requested__c = postPoneDate;
            update apt;
            PageReference perror = new Pagereference(urlAptIds+'/APTRequestNotAllowed?APTId='+urlAptId+'&msg=true');
            perror.setRedirect(true);
            return perror;
        }
        return null;
    }
}
I want to create a list of account and contact sObject . Whenever I click on the desired object it  will show me all the related records for the sObject

 
I want to create an aura component which will show the respective records for the sObject (Account & Contact)

The sObjects will be in List Type and it will show the search bar for the following sObject and all the records related to that.

the sObject to be shown in the list are :- Account object & Contact Object.
User-added image
After getting the list I want to implement drag and drop functionality for attended and not attended for the following retrieved list .

Thank You.
Below is my Aura Component
<aura:component controller="contactClassController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="conWrapper" type="Object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <div class="slds-box"><h1 align="center" font-size="40px"><b>Active Contacts</b></h1>
        <div ondrop="{!c.onActiveDrop}" ondragover="{!c.onDragOver}">
            <aura:iteration  items="{!v.conWrapper.ActiveContact}" var="con">
                <div draggable="true" ondragstart="{!c.onDragStart}" id="{!con.Id}">
                    <ul class="slds-listbox slds-listbox_horizontal" role="listbox" aria-label="Selected Options:" aria-orientation="horizontal" aria-describedby="listbox-pill-default">
                        <lightning:pill label="{!con.Name}">
                            <aura:set attribute="media">
                                <lightning:icon iconName="standard:contact"  alternativeText="Contact"/>
                            </aura:set>
                        </lightning:pill>  
                    </ul>
                </div>
            </aura:iteration>
        </div>
    </div>
    <br/>
    <div class="slds-box"><h1 align="center" font-size="40px"><b>Inactive Contacts</b></h1>
        <div ondrop="{!c.onInActiveDrop}" ondragover="{!c.onDragOver}">
            <aura:iteration  items="{!v.conWrapper.InActiveContact}" var="con">
                <div draggable="true" ondragstart="{!c.onDragStart}" id="{!con.Id}">
                    <ul class="slds-listbox slds-listbox_horizontal" role="listbox" aria-label="Selected Options:" aria-orientation="horizontal" aria-describedby="listbox-pill-default">
                        <lightning:pill label="{!con.Name}">
                            <aura:set attribute="media">
                                <lightning:icon iconName="standard:contact"  alternativeText="Contact"/>
                            </aura:set>
                        </lightning:pill>  
                    </ul>
                </div>
                
            </aura:iteration>
        </div> 
    </div>
    <lightning:button variant="brand" type="button" name="Save" label="Save" onclick="{!Save}" />
</aura:component>
My lightning pills are arranged vertically and also I want my data to be changed when I click Save button.
Right now they are changing as soon as I DRAG N DROP the pills.

My Controller is
({      doInit : function(component, event, handler) {
    var action = component.get("c.getConStatus");
    //action.setParams({ firstName : component.get("v.firstName") });
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            component.set('v.conWrapper',response.getReturnValue());      
        }
        else if (state === "INCOMPLETE") {
        }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " +
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
    });
    
    
    $A.enqueueAction(action);
},
  onDragStart :function(component, event, helper) {
      console.log(event.target.id);
      event.dataTransfer.setData('String',event.target.id);
  },
  onDragOver :function(component, event, helper) {
      event.preventDefault();
  },
  onActiveDrop :function(component, event, helper) {
      console.log(event.dataTransfer.getData('String',event.target.id));
      helper.updateDraggedCon(component, event, helper, event.dataTransfer.getData('String',event.target.id),'Active');
      
  },
  onInActiveDrop :function(component, event, helper) {
      console.log(event.dataTransfer.getData('String',event.target.id));
      helper.updateDraggedCon(component, event, helper, event.dataTransfer.getData('String',event.target.id),'InActive');
  },
 })
Apex Class :-
public class contactClassController
{
    @AuraEnabled
    public static ContactWrapper getConStatus(){
        List<Contact> ActiveContact = new List<Contact>();
        List<Contact> InActiveContact = new List<Contact>();
        List<Contact> conList = [SELECT Id, Name, ks82__isActive__c FROM Contact];
        if(conList!=null && conList.size()>0){
            for(Contact con : conList){
                if(con.ks82__isActive__c=='Active'){
                    ActiveContact.add(con);
                }else if (con.ks82__isActive__c=='InActive'){
                    InActiveContact.add(con);
                }
            }
            ContactWrapper cw = new ContactWrapper();
            cw.ActiveContact = ActiveContact;
            cw.InActiveContact = InActiveContact;
            return cw;
        }
        return null;
    }
    public class ContactWrapper{
        @AuraEnabled
        public List<Contact> ActiveContact;
        @AuraEnabled
        public List<Contact> InActiveContact;
    }
    @AuraEnabled
    public static ContactWrapper updateCon(Id conId, String status){
        Contact c= new Contact();
        c.Id = conId;
        c.ks82__isActive__c = status;
        update c;
        return getConStatus();
    }
}

HELPER Controller :-
({
    updateDraggedCon : function(component, event, helper, conId, status ) {
        var action = component.get("c.updateCon");
        action.setParams({ 'conId' : conId,
                          'status' : status});
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.ContactWrapper", response.getReturnValue());
            }
            else if (state === "INCOMPLETE") {
            }
                else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + 
                                        errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
        });
        
        $A.enqueueAction(action);
        var action = component.get("c.getConStatus");
        //action.setParams({ firstName : component.get("v.firstName") });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.conWrapper',response.getReturnValue());      
            }
            else if (state === "INCOMPLETE") {
            }
                else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + 
                                        errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
        });
        
        
        $A.enqueueAction(action);
    }
})

Please change it accordingly as I want my pill to be arranged Horizontally and everything should change when I click on Save/Submit button
 
You have to implement the drag and drop functionality in Aura. In UI, there will be two sections that will contain active and inactive contacts in the form of pill(lightning-pill).

1) When we drag an active contact from the active section and drop it to the inactive section, the contact should become inactive. 

2) In the same way, when we drag an inactive contact from the inactive section and drop it to the active section, the contact should become active.

The changes will be done when we click on save button..
I want to create an aura component to display the account details page and its related contacts.

Thanks
I want to create a popup in account object .
The popup will be fired when the user clicks on the custom EMAIL quick action button on Account object.
both the headers in the popup is to be clickable .

First Step

Second Step

Please Help
I am getting this error in my code.

I want to write a Batch Class that will automatically sends an EMAIL to the account in which there is a total number of contacts created in last 7 days realated to that account on weekly basis.

my code is below
 
public class batchEmailProcess implements Database.Batchable<sObject> {
    public Database.QueryLocator start(Database.BatchableContext bc) {
        String stringofRecords = ('SELECT Id,Name,Email__c,(Select Id,Name, CreatedDate From Contacts) FROM Account');
        return Database.getQueryLocator(stringofRecords);
    }
    public void execute(Database.BatchableContext bc, List<Account> records){
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
        {
            Date D = date.today(); 
            DateTime DT = Datetime.newInstance(D.year(), D.month(),D.day(),0,0,0); 
            integer i;
            List<String> sendTo = new List<String>();
            for(Account acc :records){
                String s ='';
                for(Contact Con :acc.contacts){ 
                    if(con.CreatedDate.daysbetween(DT)<=7){
                        sendTO.add(acc.Email__c);
                        i+=1;
                        s= acc.Name+'Contacts Created'+i+ ',';
                    }
                }
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setSenderDisplayName('Email Alert');
                String body = 'Account Related Contacts==> '+s.removeEnd(',');
                mail.setSubject('Account Related Contacts');
                mail.setToAddresses(sendTo);
                mail.setHtmlBody(body);
                mails.add(mail);
                acc.Description =  s.removeEnd(',');
            }
            Messaging.SendEmail(mails);
        }
    }
    public void finish(Database.BatchableContext bc){
        Id job = bc.getJobId();
    }
}


I am getting the following error "Method does not exist or incorrect signature: void daysbetween(Datetime) from the type Datetime"

Can someone please rectify the code
 
I want to write a batch class which send email to the account with the list of all related contacts which were created in last 7 days along with date of creation .
  1. Create a new object Time Tracking with the following fields:
Name
Hours(Decimal)
Date(Date)
Description(Text)
User(Lookup)

Write a trigger on insert and update to show an error to the user when the total number of hours for a specific date is greater than 24.
 
I want to create a list of account and contact sObject . Whenever I click on the desired object it  will show me all the related records for the sObject

 
You have to implement the drag and drop functionality in Aura. In UI, there will be two sections that will contain active and inactive contacts in the form of pill(lightning-pill).

1) When we drag an active contact from the active section and drop it to the inactive section, the contact should become inactive. 

2) In the same way, when we drag an inactive contact from the inactive section and drop it to the active section, the contact should become active.

The changes will be done when we click on save button..
I want to write a batch class which send email to the account with the list of all related contacts which were created in last 7 days along with date of creation .
  1. Create a new object Time Tracking with the following fields:
Name
Hours(Decimal)
Date(Date)
Description(Text)
User(Lookup)

Write a trigger on insert and update to show an error to the user when the total number of hours for a specific date is greater than 24.