• Jon-Michael Murphey 2
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies
I work for a manufacturing company that handles design specs/CAD designs that need to be reviewed and approved by both the designers and the customer. im needing a solution to have CAD designs uploaded to SF and reviewed by the designers and the customer be able to review and approve in a community portal. Then be able to send back to our OTC system with the approved CAD file.
My company has Salesforce Inbox and we use it but notice that we cant send an email from a custom object's record from Salesforce1 mobile app or from Salesforce inbox. Has anybody else had this issue, if so is there a work around?
I have an apex controller that im using to clone a record and its related records(deepclone). Im having issues getting the attachments to be cloned with it. Let me clarify, im not wanting to clone the attachments im wanting to share them to the new cloned record. Can anybody help? see code below.
public class SRCloneWithItemsController {

    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    private Service_Request__c sr {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}

    // initialize the controller
    public SRCloneWithItemsController(ApexPages.StandardController controller) {

        //initialize the stanrdard controller
        this.controller = controller;
        // load the current record
        sr = (Service_Request__c)controller.getRecord();

    }

    // method called from the VF's action attribute to clone the sr
    public PageReference cloneWithItems() {

         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Service_Request__c newsr;

         try {

              //copy the Service Request - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             sr = [select Id, Opportunity__c, Account__c, OwnerId, Designer__c, Estimator__c, SKNA_Plant__c, Plant_DB_Ident__c, DB_Ident__c, Plant_DB_Ident_Name__c, Plant_No__c, Opportunity_Product__c,Billing_Account__c,Primary_Contact__c,Shipping_Address_Code__c,SKNA_Plant_Executed__c,Customer_Description_Item__c from Service_Request__c where id = :sr.id];
             newsr = sr.clone(false);
             insert newsr;

             // set the id of the new SR created for testing
               newRecordId = newsr.id;

             // copy over the line items - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<Request__c> items = new List<Request__c>();
             for (Request__c req : [Select req.Id, req.Absorb__c , req.Absorb_percentage__c , req.Account__c , req.Actual_Due_Date__c , req.Additional_Comment__c , req.Amtech_Plant_SAP_Customer__c , 
                                    req.Amtech_Sample_Shipping_Address__c , req.Art__c , req.Art_Link__c , req.Art_on_Disk__c , req.Art_on_FTP__c , req.Art_Type__c , req.Artwork__c , req.As_Is_PDF__c , req.Asitrade__c , 
                                    req.Assembled__c , req.Authorized_by__c , req.Blocks__c , req.Blocks_Quantity__c , req.Blocks_Type_Core__c , req.BMC_ECT__c , req.BMC_ECT_Customer_Name__c , req.Box_or_Identifcation__c , 
                                    req.CAD__c , req.CAD_Design_Log__c , req.Change_Description__c , req.Coating__c , req.Color_1__c , req.Color_1_Amtech_Code__c , req.Color_1_percent__c , req.Color_1x__c , req.Color_2__c , 
                                    req.Color_2_Amtech_Code__c , req.Color_2_percent__c , req.Color_2x__c , req.Color_3__c , req.Color_3_Amtech_Code__c , req.Color_3_percent__c , req.Color_3x__c , req.Color_4__c , 
                                    req.Color_4_Amtech_Code__c , req.Color_4_percent__c , req.Color_4x__c , req.Color_5__c , req.Color_5_Amtech_Code__c , req.Color_5_percent__c , req.Color_5x__c , req.Color_6__c , 
                                    req.Color_6_Amtech_Code__c , req.Color_6_percent__c , req.Color_6x__c , req.Color_7__c , req.Color_7_Amtech_Code__c , req.Color_7_percent__c , req.Color_7x__c , req.Color_8__c , 
                                    req.Color_8_Amtech_Code__c , req.Color_8_percent__c , req.Color_8x__c , req.Colors__c , req.Combo_Deal__c , req.Component_Name__c , req.Components__c , req.Corr_Test__c , 
                                    req.CTP_Artwork_Cost__c , req.CTP_Artwork_Sell__c , req.Customer_Laser__c , req.Customer_Product_provided__c , req.Customer_Sample__c , req.Customer_Service__c , req.Customer_Supplied__c , 
                                    req.Cutting_Die__c , req.Cutting_Die_Cost__c , req.Cutting_Die_Quote__c , req.Cutting_Die_Quote_Completed__c , req.Cutting_Die_Sell__c , req.Cutting_Die_Taxable__c , req.Depth__c , 
                                    req.Description__c , req.Description_Item__c , req.Design_Objective__c , req.Design_Request_Type__c , req.Designer__c , req.Digital_Proof__c , req.Disp_of_Sample__c , 
                                    req.Disposition_Ground_Transport__c , req.Disposition_Other__c , req.Drawing__c , req.Eligible_for_Orders__c , req.Estimator__c , req.Existing_Die_or_Old_Sample__c , 
                                    req.Existing_Printing_Plate__c , req.Existing_Printing_Plate_or_Old_Sample__c , req.Existing_Tooling__c , req.Exped_Disposition_5_Samples_Status__c , req.Expedited_Disposition_Approval_Status__c , 
                                    req.Facing_Bottom__c , req.Facings_Top__c , req.Flow__c , req.Flute__c , req.Folding_Carton_Paper_Grade_other__c , req.Folding_Carton_Paper_Grades__c , req.Folding_Carton_to_be_named__c , 
                                    req.GCMI__c , req.Glue_Joint_Type__c , req.Glue_Joint_Type2__c , req.Grade__c , req.Grade_Amtech_Code__c , req.Group_Number__c , req.HAZMAT__c , req.Honeycomb_Skid_Type_Core__c , 
                                    req.Inventory_Flag__c , req.IsDeleted , req.Joint__c , req.Joint_Location_Inside_Outside__c , req.Joint_Location_L_W__c , req.Kraft__c , req.Lab_Testing__c , req.Label_Top_Sheet__c , 
                                    req.Label_Top_Sheet_Color__c , req.Label_Top_Sheet_Full__c , req.Label_Top_Sheet_Length__c , req.Label_Top_Sheet_Spot__c , req.Label_Top_Sheet_Width__c , req.Length__c , req.Liner_Combo__c , 
                                    req.Machine_Affected__c , req.Machine_Erected__c , req.Matched_Sets__c , req.Material__c , req.Material_Certification__c , req.Max_Over_percentage__c , req.Max_Under_percentage__c , 
                                    req.Measurement__c , req.Mock_Up_Required__c , req.Multi_Component__c , req.Multipart__c , req.Multipart_Description__c , req.Mylar__c , req.No_of_Panels__c , req.of_actual_Samples__c , 
                                    req.of_colors__c , req.of_Days__c , req.of_Elements_for_Multiparts__c , req.of_Laser__c , req.of_Proofs__c , req.of_Samples__c , req.Offset_Printing__c , req.Opportunity__c , 
                                    req.Opportunity_Name2__c , req.Order_Comment__c , req.Order_Processing__c , req.Order_Quantity__c , req.Other_Outside_Process__c , req.Outside_Process__c , req.Owner_s_Managers_e_mail__c , 
                                    req.Pallet_Height__c , req.Pallet_Length__c , req.Pallet_Quantity__c , req.Pallet_Wid__c , req.Paper_Core__c , req.Part_Cust_ID__c , req.Part_ID__c , req.Part_Number_per_Set__c , req.PDF__c , 
                                    req.Pdf_cc_1__c , req.Pdf_cc_2__c , req.Pdf_Online_Approval_Request__c , req.Pdf_Online_Approver__c , req.Plant_Amtech_Code__c , req.PMS__c , req.PMS_And_Special_Colors__c , req.PO__c , 
                                    req.Polybag__c , req.Preflight__c , req.Prepress_Type__c , req.Previous_Art_File__c , req.Previous_Estimation_Design__c , req.Price__c , req.Print_Card__c , req.Printcard_CAD__c , req.Printcard_Customer__c , 
                                    req.Printcard_Ident__c , req.Printcard_Spec__c , req.Printed_Before__c , req.Printing__c , req.Printing_Die_Quote__c , req.Printing_Plate_Cost__c , req.Printing_Plate_Sell__c , req.Printing_Plate_Taxable__c , 
                                    req.Printing_Plates__c , req.Printing_Plates2__c , req.Process_Colors__c , req.Project_Item_Number__c , req.Project_Number__c , req.Quantity_per_Bundle__c , req.Quantity_per_Case__c , req.Quote_Quantity__c , 
                                    req.Quote_Quantity_1__c , req.Quote_Quantity_2__c , req.Quote_Quantity_3__c , req.Quote_Quantity_4__c , req.Quote_Quantity_5__c , req.Quote_Request__c , req.Quote_Toolling__c , req.Quoted_Price__c , req.Quoted_Price_2__c , 
                                    req.Quoted_Price_3__c , req.Quoted_Price_4__c , req.Quoted_Price_5__c , req.Record_Type_Name_Formula__c , req.RecordTypeId , req.Related_Order__c , 
                                    req.Request_Keywords__c , req.Request_Type__c , req.Requested_Disposition__c , req.ROS__c , req.Runners__c , req.Runners_Quantity__c , req.Runners_Type_Core__c , req.Sample_Box__c , req.Sample_provided__c , req.Sample_Request_Status__c , 
                                    req.Sample_Requests_Created__c , req.Sample_Shipping_Tracking__c , req.Service_Request__c , req.Shipped_to_Warehouse__c , req.Signed_Quote_Attached__c , req.Sketch__c , req.SKNA_Plant__c , req.Spec__c , req.Spec_Notes__c , req.Special_Core__c , 
                                    req.Special_Instructions__c , req.Split_Delivery__c , req.Standard_Pallet__c , req.Structure__c , req.Style__c , req.Style_Amtech_Code__c , req.Substrate__c , req.Summary_Field__c , req.Tab_Width__c , req.Target_Price_M__c , req.Tooling_Approval_Status__c , 
                                    req.Top_Sheet_Point__c , req.TOPS_C_A_P_E__c , req.Total__c , req.Tracking_link_for_sample_shipment__c , req.Transportation__c , req.Type_Core__c , req.Units_per_Pallet__c , req.UV__c , req.Validation_Depth__c , req.Validation_Length__c , req.Validation_Tab_Width__c , 
                                    req.Validation_Test_for_Zero__c , req.Validation_Width__c , req.Wall__c , req.Warehouse__c , req.WF_Status__c , req.Width__c , req.X4_color_Label__c , req.X5_Samples_Approval_Status__c 
                                    From Request__c req where Service_Request__c = :sr.id]) {
                  Request__c newreq = req.clone(false);
                  newreq.Service_Request__c = newsr.id;
                  items.add(newreq);
             }
             insert items;
             
             
             List<Spec__c> specs = new List<Spec__c>();
             for (Spec__c spc : [Select spc.Id, spc.Amtech_Grade_Code__c , spc.Amtech_Joint_Code__c , spc.Amtech_Part_Item_no__c , spc.Amtech_Spec__c , 
                                spc.Amtech_Style_Code__c , spc.Blank__c , spc.CAD_Design_Log__c , spc.Caliper_Points__c , spc.Color_1_Amtech_Code__c , 
                                spc.Color_1_percent__c , spc.Color_1x__c , spc.Color_2_Amtech_Code__c , spc.Color_2_percent__c , spc.Color_2x__c , 
                                spc.Color_3_Amtech_Code__c , spc.Color_3_percent__c , spc.Color_3x__c , spc.Color_4_Amtech_Code__c , spc.Color_4_percent__c , 
                                spc.Color_4x__c , spc.Color_5_Amtech_Code__c , spc.Color_5_percent__c , spc.Color_5x__c , spc.Color_6_Amtech_Code__c , 
                                spc.Color_6_percent__c , spc.Color_6x__c , spc.Color_7_Amtech_Code__c , spc.Color_7_percent__c , spc.Color_7x__c , 
                                spc.Color_8_Amtech_Code__c , spc.Color_8_percent__c , spc.Color_8x__c , spc.Created_In_Amtech__c , spc.Customer_Description_Item__c , 
                                spc.DB_Ident__c , spc.Depth__c , spc.Grade__c , spc.IsDeleted , spc.Joint__c , spc.Joint_Location_Inside_Outside__c , 
                                spc.Joint_Location_Length_Width__c , spc.Length__c , spc.Max_Over__c , spc.Max_Under__c , spc.Multipart__c , spc.Name , 
                                spc.of_colors__c , spc.of_Elements_for_Multipart__c , spc.of_panels__c , spc.of_Samples__c , spc.Opportunity__c , 
                                spc.Opportunity_Account__c , spc.Part_Name_Multipart_Name__c , spc.Plant_DB_Ident_Name__c , spc.Previous_Estimation_Design__c , 
                                spc.Process_Inks__c , spc.Service_Request__c , spc.Service_Request_Name__c , spc.Service_Request_Status__c , spc.Style__c , 
                                spc.Substrate__c , spc.Tab_Width__c , spc.total_print_coverage__c , spc.Total_Print_Coverage_Calculation__c , spc.Validation_Depth__c , 
                                spc.Validation_Length__c , spc.Validation_Tab_Width__c , spc.Validation_Width__c , spc.Width__c
                            From Spec__c spc where Service_Request__c = :sr.id]) {
                  Spec__c newspc = spc.clone(false);
                  newspc.Service_Request__c = newsr.id;
                  specs.add(newspc);
             }
             insert specs;
           //
           //
           //

            //Get attachment
            Attachment attach = [SELECT Id, Name, Body, ContentType, ParentId From Attachment LIMIT 1 ];//where ParentId = :sr.Id//
 
            //Insert ContentVersion
            ContentVersion cVersion = new ContentVersion();
                cVersion.ContentLocation = 'S'; //S-Document is in Salesforce. E-Document is outside of Salesforce. L-Document is on a Social Netork.
                cVersion.PathOnClient = attach.Name;//File name with extention
                //cVersion.Origin = 'C';//C-Content Origin. H-Chatter Origin.//
                //cVersion.OwnerId = attach.OwnerId;//Owner of the file//
                cVersion.Title = attach.Name;//Name of the file
                cVersion.VersionData = attach.Body;//File content
            Insert cVersion;
 
            //After saved the Content Verison, get the ContentDocumentId
            Id conDocument = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cVersion.Id].ContentDocumentId;
 
            //Insert ContentDocumentLink
            ContentDocumentLink cDocLink = new ContentDocumentLink();
                cDocLink.ContentDocumentId = conDocument;//Add ContentDocumentId
                cDocLink.LinkedEntityId = attach.ParentId;//Add attachment parentId
                cDocLink.ShareType = 'I';//V - Viewer permission. C - Collaborator permission. I - Inferred permission.
                cDocLink.Visibility = 'InternalUsers';//AllUsers, InternalUsers, SharedUsers
            Insert cDocLink;
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //

         } catch (Exception e){
             // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
         }

        return new PageReference('/'+newsr.id+'/e?retURL=%2F'+newsr.id);
    }

}
When we change the language setting in Salesforce all the standard fields update to that language however all custom fields stay in english. How can we get the custom fields to update to the language selected
Im have two picklist fields Action_Frequency__c and Frequency_selection__c, Action freq is a list showing weekly, monthly, quarterly, biannually and annually. Freq Selection is the broken out by the day of the week, the num day of the month  or the month. Ive created two formula fields Dow__c which is turning the text day from Freq selection to a number value, and Dom__c which takes the month text to a number value. Im needing a formula that will create a due date based on the two picklist values. here is my formula so far:

CASE(Action_Frequency__c, 
"Weekly",DATE(MONTH(DATEVALUE(CreatedDate)),Day(DATEVALUE(Text(DOW__c))),YEAR(DATEVALUE(CreatedDate))), 
"Monthly",DATE(MONTH(DATEVALUE(CreatedDate)),Day(DATEVALUE(Text(DOW__c))),YEAR(DATEVALUE(CreatedDate))), 
"Quarterly",DATE(CEILING(MONTH(DATEVALUE(Text(DOM__c))))/3,DAY(DATEVALUE(CreatedDate)),YEAR(DATEVALUE(CreatedDate))), 
"Bi-Annually",DATE(CEILING(MONTH(DATEVALUE(Text(DOM__c))))/6,DAY(DATEVALUE(CreatedDate)),YEAR(DATEVALUE(CreatedDate))), 
"Annually",DATE(CEILING(MONTH(DATEVALUE(Text(DOM__c)))),DAY(DATEVALUE(CreatedDate)),YEAR(DATEVALUE(CreatedDate)))+1, TODAY())
CMPT:
<aura:component controller="DTController">
    <aura:attribute name="parentId" type="Id"/>
    <aura:attribute name="nameFilter" type="string"/>
    <aura:attribute type="FIN_RCSAQ__c[]" name="acctList"/>
    <aura:attribute name="showSaveCancelBtn" type="boolean" default="false" />
    <aura:attribute name="isAsc" type="boolean" default="true" description="boolean flag for pass sorting condition to apex class"/> 
    <aura:attribute name="arrowDirection" type="string" default="arrowup" description="Use for change arrow sign direction on header based on click"/>
    <aura:attribute name="selectedTabsoft" type="string" default="firstName" description="Use for show/hide arraow sign on header based on conditions"/>
     
    <aura:handler name="init" value="{!this}" action="{!c.fetchAcc}"/>
    
    <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer slds-table_edit slds-table_resizable-cols" style="table-layout: fixed; width: 100% !important;">
        <thead>
            <tr class="slds-line-height_reset">
                <th class="slds-is-sortable" scope="col" onclick="{!c.sortName}">
                    <a href="javascript:void(0);" class="slds-th__action slds-text-link--reset">
                        <span class="slds-assistive-text">Sort</span>
                        <span class="slds-truncate" title="Name">Fin-RSCAQ</span>  
                        <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'Name') }">
                            <lightning:icon iconName="utility:arrowdown" alternativeText="Descending" size="xx-small" />
                        </aura:if>  
                        <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Name') }">
                            <lightning:icon iconName="utility:arrowup" alternativeText="Descending" size="xx-small" /> 
                        </aura:if>                        
                    </a>
                </th>
                <th class="slds-is-sortable" scope="col" onclick="{!c.sortControlNumber}">
                    <a href="javascript:void(0);" class="slds-th__action slds-text-link--reset">
                        <span class="slds-assistive-text">Sort</span>
                        <span class="slds-truncate" title="ControlNumber">Control Number</span>  
                        <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'ControlNumber') }">
                            <lightning:icon iconName="utility:arrowdown" alternativeText="Ascending" size="xx-small" />
                        </aura:if>  
                        <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'ControlNumber') }"> 
                            <lightning:icon iconName="utility:arrowup" alternativeText="Descending" size="xx-small" />
                        </aura:if>                        
                    </a>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="ControlObjective">Control Objective</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="ControlledElsewhere">Controlled Elsewhere</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="ControlledElsewhereHFMCode">Controlled Elsewhere HFM Code</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="Frequency">Frequency</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="FrequencySelection">Frequency Selection</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="Preparer">Preparer</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="CreatedBy">Created By</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="FirstApprover">First Approver</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="SecondApprover">Second Approver</div>
                </th>
            </tr>
        </thead>
        <!--table body start, Iterate contact list as a <tr> -->
        <tbody>
            <aura:iteration items="{!v.acctList}" var="acc">  
                <c:InlineEditRow singleRec="{!acc}" 
                                 rcsaqFrequencyVal="{!acc.RCSAQ_Frequency__c}" 
                                 frequencySelectionVal = "{!acc.Frequency_Selection__c}"
                                 firstOwnerNameVal="{!acc.First_Approver__r.Name}" 
                                 secondOwnerNameVal="{!acc.Second_Approver__r.Name}" 
                                 prepareNameVal="{!acc.Preparer__r.Name}" 
                                 showSaveCancelBtn="{!v.showSaveCancelBtn}"/>
            </aura:iteration>
        </tbody>
    </table> 
    
    <aura:if isTrue="{!v.showSaveCancelBtn}">
        <lightning:buttonGroup class="slds-m-around_medium">
            <lightning:button label="Cancel" />
            <lightning:button label="Save" onclick="{!c.handleSaveEdition}" variant="success"/>
        </lightning:buttonGroup>
    </aura:if> 
</aura:component>

Controller:
({
    fetchAcc : function(component, event, helper) {
        helper.fetchAccHelper(component, event, "Name");
    },
    sortName : function(component, event, helper) {
        component.set("v.selectedTabsoft", "Name"); 
        helper.sortHelper(component, event, "Name");
    },
    sortControlNumber : function(component, event, helper) {
        component.set("v.selectedTabsoft", "ControlNumber"); 
        helper.sortHelper(component, event, "Control_Number__c");
    },
    handleSaveEdition: function (cmp, event, helper) {
        var draftValues = cmp.get("v.acctList");
        console.log(draftValues);
        var action = cmp.get("c.updateAccount");
        action.setParams({"acc" : draftValues});
        action.setCallback(this, function(response) {
            console.log(response);
            helper.fetchAccHelper(cmp, event, "Name");
            cmp.set("v.showSaveCancelBtn", false); 
        });
        $A.enqueueAction(action);
    },
})

Helper:
({
    fetchAccHelper : function(component, event, sortFieldName) {
        var action = component.get("c.fetchAccount");
        action.setParams({
            "parentId" : component.get("v.parentId"),
            "sortField": sortFieldName,
            "isAsc": component.get("v.isAsc"),
            "nameLike":component.get("v.nameFilter")
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                console.log(records);
                records.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                component.set("v.acctList", records);
            }
        });
        $A.enqueueAction(action);
    },
    sortHelper: function (component, event, sortFieldName) {
        var currentDir = component.get("v.arrowDirection");
        if (currentDir == 'arrowdown') {
            component.set("v.arrowDirection", 'arrowup'); 
            component.set("v.isAsc", true);
        } else {
            component.set("v.arrowDirection", 'arrowdown');
            component.set("v.isAsc", false);
        }
        this.fetchAccHelper(component, event, sortFieldName);
    }
})
Style:
.THIS .slds-table td th {
    white-space:normal; /* wraps larger stuff like textarea and long text*/
}
.THIS .widthVal {
    max-width:100% !important;
}

Apex Class:
public class DTController{
    @AuraEnabled
    public static List<FIN_RCSAQ__c> fetchAccounts(String parentId) {
        String query = 'SELECT Id, Name, Control_Number__c, Question_Number__c, Risk_Reference__c, Control_Objective__c,';
        query += 'Group_Control_Description__c,Assertions__c,Controlled_Elsewhere__c,Controlled_Elsewhere_HFM_Code__c,';
        query += 'First_Approver__c,First_Approver__r.Name,Second_Approver__c,Second_Approver__r.Name,';
        query += 'Frequency_Selection__c,RCSAQ_Frequency__c,Preparer__r.Name,';
        query += 'Control_Clarification__c,Frequency__c,Control_Type__c,System_Report_SAP__c,System_Report_OTC__c,System_Name__c,';
        query += 'Excel_File_Name__c,Evidence_of_the_Control__c,Notes_Guidance__c,Preparer__c,Supported_By__c FROM ';
        query += 'FIN_RCSAQ__c WHERE Control_Number__c LIKE \'RR%\'';
        if(String.isNotBlank(parentId)) query += ' AND FIN_RCSA__c = \'' + parentId + '\'';
        List<FIN_RCSAQ__c> accList = Database.query(query);
        System.debug(accList);
        return accList;
    }
    
    @AuraEnabled
    public static List<FIN_RCSAQ__c> fetchAccount(String parentId, String sortField, boolean isAsc, String nameLike) {
        String query = 'SELECT Id, Name, Control_Number__c, Question_Number__c, Risk_Reference__c, Control_Objective__c,';
        query += 'Group_Control_Description__c,Assertions__c,Controlled_Elsewhere__c,Controlled_Elsewhere_HFM_Code__c,';
        query += 'Control_Clarification__c,Frequency__c,Control_Type__c,System_Report_SAP__c,System_Report_OTC__c,System_Name__c,';
        query += 'Preparer__r.Name,First_Approver__c,First_Approver__r.Name,Second_Approver__c,Second_Approver__r.Name,';
        query += 'Frequency_Selection__c,RCSAQ_Frequency__c,';
        query += 'Excel_File_Name__c,Evidence_of_the_Control__c,Notes_Guidance__c,Preparer__c,Supported_By__c FROM ';
        query += 'FIN_RCSAQ__c WHERE Control_Number__c LIKE \'' + nameLike + '%\'';
        if(String.isNotBlank(parentId)) query += ' AND FIN_RCSA__c = \'' + parentId + '\'';
        if (sortField != '') {
            query += ' order by ' + sortField;
            query += isAsc ? ' asc' : ' desc';
        }
        
        system.debug('The query is ' + query);
        return Database.query(query);
    }
    
    @AuraEnabled
    public static String getContactName(String conId) {
        String conName;
        List<Contact> conList = [Select Id,FirstName,LastName from Contact Where Id =: conId];
        if(conList.size() > 0)
            conName = String.isNotBlank(conList[0].FirstName) ? conList[0].FirstName + ' ' + conList[0].LastName : conList[0].LastName;
        System.debug(conName);
        return conName;
    }
    
    @AuraEnabled
    public static String getUserName(String conId) {
        String conName;
        List<User> conList = [Select Id,FirstName,LastName from User Where Id =: conId];
        if(conList.size() > 0)
            conName = String.isNotBlank(conList[0].FirstName) ? conList[0].FirstName + ' ' + conList[0].LastName : conList[0].LastName;
        System.debug(conName);
        return conName;
    }
    
    @AuraEnabled
    public static void updateAccount(List<FIN_RCSAQ__c> acc ){
        update acc;
    }
}

 
Im trying to create a Modal or a popup that will have a message when the standard "new" button is clicked on a record. the message is making sure the user's request meets a criteria, if so they click "continue" and it goes through creating a new record as normal. If they click "cancel" and the modal closes and nothing happens.
I have an apex controller that im using to clone a record and its related records(deepclone). Im having issues getting the attachments to be cloned with it. Let me clarify, im not wanting to clone the attachments im wanting to share them to the new cloned record. Can anybody help? see code below.
public class SRCloneWithItemsController {

    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    private Service_Request__c sr {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}

    // initialize the controller
    public SRCloneWithItemsController(ApexPages.StandardController controller) {

        //initialize the stanrdard controller
        this.controller = controller;
        // load the current record
        sr = (Service_Request__c)controller.getRecord();

    }

    // method called from the VF's action attribute to clone the sr
    public PageReference cloneWithItems() {

         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Service_Request__c newsr;

         try {

              //copy the Service Request - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             sr = [select Id, Opportunity__c, Account__c, OwnerId, Designer__c, Estimator__c, SKNA_Plant__c, Plant_DB_Ident__c, DB_Ident__c, Plant_DB_Ident_Name__c, Plant_No__c, Opportunity_Product__c,Billing_Account__c,Primary_Contact__c,Shipping_Address_Code__c,SKNA_Plant_Executed__c,Customer_Description_Item__c from Service_Request__c where id = :sr.id];
             newsr = sr.clone(false);
             insert newsr;

             // set the id of the new SR created for testing
               newRecordId = newsr.id;

             // copy over the line items - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<Request__c> items = new List<Request__c>();
             for (Request__c req : [Select req.Id, req.Absorb__c , req.Absorb_percentage__c , req.Account__c , req.Actual_Due_Date__c , req.Additional_Comment__c , req.Amtech_Plant_SAP_Customer__c , 
                                    req.Amtech_Sample_Shipping_Address__c , req.Art__c , req.Art_Link__c , req.Art_on_Disk__c , req.Art_on_FTP__c , req.Art_Type__c , req.Artwork__c , req.As_Is_PDF__c , req.Asitrade__c , 
                                    req.Assembled__c , req.Authorized_by__c , req.Blocks__c , req.Blocks_Quantity__c , req.Blocks_Type_Core__c , req.BMC_ECT__c , req.BMC_ECT_Customer_Name__c , req.Box_or_Identifcation__c , 
                                    req.CAD__c , req.CAD_Design_Log__c , req.Change_Description__c , req.Coating__c , req.Color_1__c , req.Color_1_Amtech_Code__c , req.Color_1_percent__c , req.Color_1x__c , req.Color_2__c , 
                                    req.Color_2_Amtech_Code__c , req.Color_2_percent__c , req.Color_2x__c , req.Color_3__c , req.Color_3_Amtech_Code__c , req.Color_3_percent__c , req.Color_3x__c , req.Color_4__c , 
                                    req.Color_4_Amtech_Code__c , req.Color_4_percent__c , req.Color_4x__c , req.Color_5__c , req.Color_5_Amtech_Code__c , req.Color_5_percent__c , req.Color_5x__c , req.Color_6__c , 
                                    req.Color_6_Amtech_Code__c , req.Color_6_percent__c , req.Color_6x__c , req.Color_7__c , req.Color_7_Amtech_Code__c , req.Color_7_percent__c , req.Color_7x__c , req.Color_8__c , 
                                    req.Color_8_Amtech_Code__c , req.Color_8_percent__c , req.Color_8x__c , req.Colors__c , req.Combo_Deal__c , req.Component_Name__c , req.Components__c , req.Corr_Test__c , 
                                    req.CTP_Artwork_Cost__c , req.CTP_Artwork_Sell__c , req.Customer_Laser__c , req.Customer_Product_provided__c , req.Customer_Sample__c , req.Customer_Service__c , req.Customer_Supplied__c , 
                                    req.Cutting_Die__c , req.Cutting_Die_Cost__c , req.Cutting_Die_Quote__c , req.Cutting_Die_Quote_Completed__c , req.Cutting_Die_Sell__c , req.Cutting_Die_Taxable__c , req.Depth__c , 
                                    req.Description__c , req.Description_Item__c , req.Design_Objective__c , req.Design_Request_Type__c , req.Designer__c , req.Digital_Proof__c , req.Disp_of_Sample__c , 
                                    req.Disposition_Ground_Transport__c , req.Disposition_Other__c , req.Drawing__c , req.Eligible_for_Orders__c , req.Estimator__c , req.Existing_Die_or_Old_Sample__c , 
                                    req.Existing_Printing_Plate__c , req.Existing_Printing_Plate_or_Old_Sample__c , req.Existing_Tooling__c , req.Exped_Disposition_5_Samples_Status__c , req.Expedited_Disposition_Approval_Status__c , 
                                    req.Facing_Bottom__c , req.Facings_Top__c , req.Flow__c , req.Flute__c , req.Folding_Carton_Paper_Grade_other__c , req.Folding_Carton_Paper_Grades__c , req.Folding_Carton_to_be_named__c , 
                                    req.GCMI__c , req.Glue_Joint_Type__c , req.Glue_Joint_Type2__c , req.Grade__c , req.Grade_Amtech_Code__c , req.Group_Number__c , req.HAZMAT__c , req.Honeycomb_Skid_Type_Core__c , 
                                    req.Inventory_Flag__c , req.IsDeleted , req.Joint__c , req.Joint_Location_Inside_Outside__c , req.Joint_Location_L_W__c , req.Kraft__c , req.Lab_Testing__c , req.Label_Top_Sheet__c , 
                                    req.Label_Top_Sheet_Color__c , req.Label_Top_Sheet_Full__c , req.Label_Top_Sheet_Length__c , req.Label_Top_Sheet_Spot__c , req.Label_Top_Sheet_Width__c , req.Length__c , req.Liner_Combo__c , 
                                    req.Machine_Affected__c , req.Machine_Erected__c , req.Matched_Sets__c , req.Material__c , req.Material_Certification__c , req.Max_Over_percentage__c , req.Max_Under_percentage__c , 
                                    req.Measurement__c , req.Mock_Up_Required__c , req.Multi_Component__c , req.Multipart__c , req.Multipart_Description__c , req.Mylar__c , req.No_of_Panels__c , req.of_actual_Samples__c , 
                                    req.of_colors__c , req.of_Days__c , req.of_Elements_for_Multiparts__c , req.of_Laser__c , req.of_Proofs__c , req.of_Samples__c , req.Offset_Printing__c , req.Opportunity__c , 
                                    req.Opportunity_Name2__c , req.Order_Comment__c , req.Order_Processing__c , req.Order_Quantity__c , req.Other_Outside_Process__c , req.Outside_Process__c , req.Owner_s_Managers_e_mail__c , 
                                    req.Pallet_Height__c , req.Pallet_Length__c , req.Pallet_Quantity__c , req.Pallet_Wid__c , req.Paper_Core__c , req.Part_Cust_ID__c , req.Part_ID__c , req.Part_Number_per_Set__c , req.PDF__c , 
                                    req.Pdf_cc_1__c , req.Pdf_cc_2__c , req.Pdf_Online_Approval_Request__c , req.Pdf_Online_Approver__c , req.Plant_Amtech_Code__c , req.PMS__c , req.PMS_And_Special_Colors__c , req.PO__c , 
                                    req.Polybag__c , req.Preflight__c , req.Prepress_Type__c , req.Previous_Art_File__c , req.Previous_Estimation_Design__c , req.Price__c , req.Print_Card__c , req.Printcard_CAD__c , req.Printcard_Customer__c , 
                                    req.Printcard_Ident__c , req.Printcard_Spec__c , req.Printed_Before__c , req.Printing__c , req.Printing_Die_Quote__c , req.Printing_Plate_Cost__c , req.Printing_Plate_Sell__c , req.Printing_Plate_Taxable__c , 
                                    req.Printing_Plates__c , req.Printing_Plates2__c , req.Process_Colors__c , req.Project_Item_Number__c , req.Project_Number__c , req.Quantity_per_Bundle__c , req.Quantity_per_Case__c , req.Quote_Quantity__c , 
                                    req.Quote_Quantity_1__c , req.Quote_Quantity_2__c , req.Quote_Quantity_3__c , req.Quote_Quantity_4__c , req.Quote_Quantity_5__c , req.Quote_Request__c , req.Quote_Toolling__c , req.Quoted_Price__c , req.Quoted_Price_2__c , 
                                    req.Quoted_Price_3__c , req.Quoted_Price_4__c , req.Quoted_Price_5__c , req.Record_Type_Name_Formula__c , req.RecordTypeId , req.Related_Order__c , 
                                    req.Request_Keywords__c , req.Request_Type__c , req.Requested_Disposition__c , req.ROS__c , req.Runners__c , req.Runners_Quantity__c , req.Runners_Type_Core__c , req.Sample_Box__c , req.Sample_provided__c , req.Sample_Request_Status__c , 
                                    req.Sample_Requests_Created__c , req.Sample_Shipping_Tracking__c , req.Service_Request__c , req.Shipped_to_Warehouse__c , req.Signed_Quote_Attached__c , req.Sketch__c , req.SKNA_Plant__c , req.Spec__c , req.Spec_Notes__c , req.Special_Core__c , 
                                    req.Special_Instructions__c , req.Split_Delivery__c , req.Standard_Pallet__c , req.Structure__c , req.Style__c , req.Style_Amtech_Code__c , req.Substrate__c , req.Summary_Field__c , req.Tab_Width__c , req.Target_Price_M__c , req.Tooling_Approval_Status__c , 
                                    req.Top_Sheet_Point__c , req.TOPS_C_A_P_E__c , req.Total__c , req.Tracking_link_for_sample_shipment__c , req.Transportation__c , req.Type_Core__c , req.Units_per_Pallet__c , req.UV__c , req.Validation_Depth__c , req.Validation_Length__c , req.Validation_Tab_Width__c , 
                                    req.Validation_Test_for_Zero__c , req.Validation_Width__c , req.Wall__c , req.Warehouse__c , req.WF_Status__c , req.Width__c , req.X4_color_Label__c , req.X5_Samples_Approval_Status__c 
                                    From Request__c req where Service_Request__c = :sr.id]) {
                  Request__c newreq = req.clone(false);
                  newreq.Service_Request__c = newsr.id;
                  items.add(newreq);
             }
             insert items;
             
             
             List<Spec__c> specs = new List<Spec__c>();
             for (Spec__c spc : [Select spc.Id, spc.Amtech_Grade_Code__c , spc.Amtech_Joint_Code__c , spc.Amtech_Part_Item_no__c , spc.Amtech_Spec__c , 
                                spc.Amtech_Style_Code__c , spc.Blank__c , spc.CAD_Design_Log__c , spc.Caliper_Points__c , spc.Color_1_Amtech_Code__c , 
                                spc.Color_1_percent__c , spc.Color_1x__c , spc.Color_2_Amtech_Code__c , spc.Color_2_percent__c , spc.Color_2x__c , 
                                spc.Color_3_Amtech_Code__c , spc.Color_3_percent__c , spc.Color_3x__c , spc.Color_4_Amtech_Code__c , spc.Color_4_percent__c , 
                                spc.Color_4x__c , spc.Color_5_Amtech_Code__c , spc.Color_5_percent__c , spc.Color_5x__c , spc.Color_6_Amtech_Code__c , 
                                spc.Color_6_percent__c , spc.Color_6x__c , spc.Color_7_Amtech_Code__c , spc.Color_7_percent__c , spc.Color_7x__c , 
                                spc.Color_8_Amtech_Code__c , spc.Color_8_percent__c , spc.Color_8x__c , spc.Created_In_Amtech__c , spc.Customer_Description_Item__c , 
                                spc.DB_Ident__c , spc.Depth__c , spc.Grade__c , spc.IsDeleted , spc.Joint__c , spc.Joint_Location_Inside_Outside__c , 
                                spc.Joint_Location_Length_Width__c , spc.Length__c , spc.Max_Over__c , spc.Max_Under__c , spc.Multipart__c , spc.Name , 
                                spc.of_colors__c , spc.of_Elements_for_Multipart__c , spc.of_panels__c , spc.of_Samples__c , spc.Opportunity__c , 
                                spc.Opportunity_Account__c , spc.Part_Name_Multipart_Name__c , spc.Plant_DB_Ident_Name__c , spc.Previous_Estimation_Design__c , 
                                spc.Process_Inks__c , spc.Service_Request__c , spc.Service_Request_Name__c , spc.Service_Request_Status__c , spc.Style__c , 
                                spc.Substrate__c , spc.Tab_Width__c , spc.total_print_coverage__c , spc.Total_Print_Coverage_Calculation__c , spc.Validation_Depth__c , 
                                spc.Validation_Length__c , spc.Validation_Tab_Width__c , spc.Validation_Width__c , spc.Width__c
                            From Spec__c spc where Service_Request__c = :sr.id]) {
                  Spec__c newspc = spc.clone(false);
                  newspc.Service_Request__c = newsr.id;
                  specs.add(newspc);
             }
             insert specs;
           //
           //
           //

            //Get attachment
            Attachment attach = [SELECT Id, Name, Body, ContentType, ParentId From Attachment LIMIT 1 ];//where ParentId = :sr.Id//
 
            //Insert ContentVersion
            ContentVersion cVersion = new ContentVersion();
                cVersion.ContentLocation = 'S'; //S-Document is in Salesforce. E-Document is outside of Salesforce. L-Document is on a Social Netork.
                cVersion.PathOnClient = attach.Name;//File name with extention
                //cVersion.Origin = 'C';//C-Content Origin. H-Chatter Origin.//
                //cVersion.OwnerId = attach.OwnerId;//Owner of the file//
                cVersion.Title = attach.Name;//Name of the file
                cVersion.VersionData = attach.Body;//File content
            Insert cVersion;
 
            //After saved the Content Verison, get the ContentDocumentId
            Id conDocument = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cVersion.Id].ContentDocumentId;
 
            //Insert ContentDocumentLink
            ContentDocumentLink cDocLink = new ContentDocumentLink();
                cDocLink.ContentDocumentId = conDocument;//Add ContentDocumentId
                cDocLink.LinkedEntityId = attach.ParentId;//Add attachment parentId
                cDocLink.ShareType = 'I';//V - Viewer permission. C - Collaborator permission. I - Inferred permission.
                cDocLink.Visibility = 'InternalUsers';//AllUsers, InternalUsers, SharedUsers
            Insert cDocLink;
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //
            //

         } catch (Exception e){
             // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
         }

        return new PageReference('/'+newsr.id+'/e?retURL=%2F'+newsr.id);
    }

}
Im have two picklist fields Action_Frequency__c and Frequency_selection__c, Action freq is a list showing weekly, monthly, quarterly, biannually and annually. Freq Selection is the broken out by the day of the week, the num day of the month  or the month. Ive created two formula fields Dow__c which is turning the text day from Freq selection to a number value, and Dom__c which takes the month text to a number value. Im needing a formula that will create a due date based on the two picklist values. here is my formula so far:

CASE(Action_Frequency__c, 
"Weekly",DATE(MONTH(DATEVALUE(CreatedDate)),Day(DATEVALUE(Text(DOW__c))),YEAR(DATEVALUE(CreatedDate))), 
"Monthly",DATE(MONTH(DATEVALUE(CreatedDate)),Day(DATEVALUE(Text(DOW__c))),YEAR(DATEVALUE(CreatedDate))), 
"Quarterly",DATE(CEILING(MONTH(DATEVALUE(Text(DOM__c))))/3,DAY(DATEVALUE(CreatedDate)),YEAR(DATEVALUE(CreatedDate))), 
"Bi-Annually",DATE(CEILING(MONTH(DATEVALUE(Text(DOM__c))))/6,DAY(DATEVALUE(CreatedDate)),YEAR(DATEVALUE(CreatedDate))), 
"Annually",DATE(CEILING(MONTH(DATEVALUE(Text(DOM__c)))),DAY(DATEVALUE(CreatedDate)),YEAR(DATEVALUE(CreatedDate)))+1, TODAY())
CMPT:
<aura:component controller="DTController">
    <aura:attribute name="parentId" type="Id"/>
    <aura:attribute name="nameFilter" type="string"/>
    <aura:attribute type="FIN_RCSAQ__c[]" name="acctList"/>
    <aura:attribute name="showSaveCancelBtn" type="boolean" default="false" />
    <aura:attribute name="isAsc" type="boolean" default="true" description="boolean flag for pass sorting condition to apex class"/> 
    <aura:attribute name="arrowDirection" type="string" default="arrowup" description="Use for change arrow sign direction on header based on click"/>
    <aura:attribute name="selectedTabsoft" type="string" default="firstName" description="Use for show/hide arraow sign on header based on conditions"/>
     
    <aura:handler name="init" value="{!this}" action="{!c.fetchAcc}"/>
    
    <table class="slds-table slds-table_bordered slds-table_col-bordered slds-table_cell-buffer slds-table_edit slds-table_resizable-cols" style="table-layout: fixed; width: 100% !important;">
        <thead>
            <tr class="slds-line-height_reset">
                <th class="slds-is-sortable" scope="col" onclick="{!c.sortName}">
                    <a href="javascript:void(0);" class="slds-th__action slds-text-link--reset">
                        <span class="slds-assistive-text">Sort</span>
                        <span class="slds-truncate" title="Name">Fin-RSCAQ</span>  
                        <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'Name') }">
                            <lightning:icon iconName="utility:arrowdown" alternativeText="Descending" size="xx-small" />
                        </aura:if>  
                        <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Name') }">
                            <lightning:icon iconName="utility:arrowup" alternativeText="Descending" size="xx-small" /> 
                        </aura:if>                        
                    </a>
                </th>
                <th class="slds-is-sortable" scope="col" onclick="{!c.sortControlNumber}">
                    <a href="javascript:void(0);" class="slds-th__action slds-text-link--reset">
                        <span class="slds-assistive-text">Sort</span>
                        <span class="slds-truncate" title="ControlNumber">Control Number</span>  
                        <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'ControlNumber') }">
                            <lightning:icon iconName="utility:arrowdown" alternativeText="Ascending" size="xx-small" />
                        </aura:if>  
                        <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'ControlNumber') }"> 
                            <lightning:icon iconName="utility:arrowup" alternativeText="Descending" size="xx-small" />
                        </aura:if>                        
                    </a>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="ControlObjective">Control Objective</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="ControlledElsewhere">Controlled Elsewhere</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="ControlledElsewhereHFMCode">Controlled Elsewhere HFM Code</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="Frequency">Frequency</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="FrequencySelection">Frequency Selection</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="Preparer">Preparer</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="CreatedBy">Created By</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="FirstApprover">First Approver</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate slds-text-align_center" title="SecondApprover">Second Approver</div>
                </th>
            </tr>
        </thead>
        <!--table body start, Iterate contact list as a <tr> -->
        <tbody>
            <aura:iteration items="{!v.acctList}" var="acc">  
                <c:InlineEditRow singleRec="{!acc}" 
                                 rcsaqFrequencyVal="{!acc.RCSAQ_Frequency__c}" 
                                 frequencySelectionVal = "{!acc.Frequency_Selection__c}"
                                 firstOwnerNameVal="{!acc.First_Approver__r.Name}" 
                                 secondOwnerNameVal="{!acc.Second_Approver__r.Name}" 
                                 prepareNameVal="{!acc.Preparer__r.Name}" 
                                 showSaveCancelBtn="{!v.showSaveCancelBtn}"/>
            </aura:iteration>
        </tbody>
    </table> 
    
    <aura:if isTrue="{!v.showSaveCancelBtn}">
        <lightning:buttonGroup class="slds-m-around_medium">
            <lightning:button label="Cancel" />
            <lightning:button label="Save" onclick="{!c.handleSaveEdition}" variant="success"/>
        </lightning:buttonGroup>
    </aura:if> 
</aura:component>

Controller:
({
    fetchAcc : function(component, event, helper) {
        helper.fetchAccHelper(component, event, "Name");
    },
    sortName : function(component, event, helper) {
        component.set("v.selectedTabsoft", "Name"); 
        helper.sortHelper(component, event, "Name");
    },
    sortControlNumber : function(component, event, helper) {
        component.set("v.selectedTabsoft", "ControlNumber"); 
        helper.sortHelper(component, event, "Control_Number__c");
    },
    handleSaveEdition: function (cmp, event, helper) {
        var draftValues = cmp.get("v.acctList");
        console.log(draftValues);
        var action = cmp.get("c.updateAccount");
        action.setParams({"acc" : draftValues});
        action.setCallback(this, function(response) {
            console.log(response);
            helper.fetchAccHelper(cmp, event, "Name");
            cmp.set("v.showSaveCancelBtn", false); 
        });
        $A.enqueueAction(action);
    },
})

Helper:
({
    fetchAccHelper : function(component, event, sortFieldName) {
        var action = component.get("c.fetchAccount");
        action.setParams({
            "parentId" : component.get("v.parentId"),
            "sortField": sortFieldName,
            "isAsc": component.get("v.isAsc"),
            "nameLike":component.get("v.nameFilter")
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                console.log(records);
                records.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                component.set("v.acctList", records);
            }
        });
        $A.enqueueAction(action);
    },
    sortHelper: function (component, event, sortFieldName) {
        var currentDir = component.get("v.arrowDirection");
        if (currentDir == 'arrowdown') {
            component.set("v.arrowDirection", 'arrowup'); 
            component.set("v.isAsc", true);
        } else {
            component.set("v.arrowDirection", 'arrowdown');
            component.set("v.isAsc", false);
        }
        this.fetchAccHelper(component, event, sortFieldName);
    }
})
Style:
.THIS .slds-table td th {
    white-space:normal; /* wraps larger stuff like textarea and long text*/
}
.THIS .widthVal {
    max-width:100% !important;
}

Apex Class:
public class DTController{
    @AuraEnabled
    public static List<FIN_RCSAQ__c> fetchAccounts(String parentId) {
        String query = 'SELECT Id, Name, Control_Number__c, Question_Number__c, Risk_Reference__c, Control_Objective__c,';
        query += 'Group_Control_Description__c,Assertions__c,Controlled_Elsewhere__c,Controlled_Elsewhere_HFM_Code__c,';
        query += 'First_Approver__c,First_Approver__r.Name,Second_Approver__c,Second_Approver__r.Name,';
        query += 'Frequency_Selection__c,RCSAQ_Frequency__c,Preparer__r.Name,';
        query += 'Control_Clarification__c,Frequency__c,Control_Type__c,System_Report_SAP__c,System_Report_OTC__c,System_Name__c,';
        query += 'Excel_File_Name__c,Evidence_of_the_Control__c,Notes_Guidance__c,Preparer__c,Supported_By__c FROM ';
        query += 'FIN_RCSAQ__c WHERE Control_Number__c LIKE \'RR%\'';
        if(String.isNotBlank(parentId)) query += ' AND FIN_RCSA__c = \'' + parentId + '\'';
        List<FIN_RCSAQ__c> accList = Database.query(query);
        System.debug(accList);
        return accList;
    }
    
    @AuraEnabled
    public static List<FIN_RCSAQ__c> fetchAccount(String parentId, String sortField, boolean isAsc, String nameLike) {
        String query = 'SELECT Id, Name, Control_Number__c, Question_Number__c, Risk_Reference__c, Control_Objective__c,';
        query += 'Group_Control_Description__c,Assertions__c,Controlled_Elsewhere__c,Controlled_Elsewhere_HFM_Code__c,';
        query += 'Control_Clarification__c,Frequency__c,Control_Type__c,System_Report_SAP__c,System_Report_OTC__c,System_Name__c,';
        query += 'Preparer__r.Name,First_Approver__c,First_Approver__r.Name,Second_Approver__c,Second_Approver__r.Name,';
        query += 'Frequency_Selection__c,RCSAQ_Frequency__c,';
        query += 'Excel_File_Name__c,Evidence_of_the_Control__c,Notes_Guidance__c,Preparer__c,Supported_By__c FROM ';
        query += 'FIN_RCSAQ__c WHERE Control_Number__c LIKE \'' + nameLike + '%\'';
        if(String.isNotBlank(parentId)) query += ' AND FIN_RCSA__c = \'' + parentId + '\'';
        if (sortField != '') {
            query += ' order by ' + sortField;
            query += isAsc ? ' asc' : ' desc';
        }
        
        system.debug('The query is ' + query);
        return Database.query(query);
    }
    
    @AuraEnabled
    public static String getContactName(String conId) {
        String conName;
        List<Contact> conList = [Select Id,FirstName,LastName from Contact Where Id =: conId];
        if(conList.size() > 0)
            conName = String.isNotBlank(conList[0].FirstName) ? conList[0].FirstName + ' ' + conList[0].LastName : conList[0].LastName;
        System.debug(conName);
        return conName;
    }
    
    @AuraEnabled
    public static String getUserName(String conId) {
        String conName;
        List<User> conList = [Select Id,FirstName,LastName from User Where Id =: conId];
        if(conList.size() > 0)
            conName = String.isNotBlank(conList[0].FirstName) ? conList[0].FirstName + ' ' + conList[0].LastName : conList[0].LastName;
        System.debug(conName);
        return conName;
    }
    
    @AuraEnabled
    public static void updateAccount(List<FIN_RCSAQ__c> acc ){
        update acc;
    }
}

 
Hi All,

I am new to salesforce lightning experience, I would like to create a custom clone button with selected fields only on opportunity, does anyone know to do that? Thanks.