• SMARTIE
  • 1355 Points
  • Member since 

  • Chatter
    Feed
  • 47
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 188
    Replies
Hello, 

I am learning salesforce and quite new to it. can any one pls help me out in trigger design pattern  and frameworks. I am bit confused in this?
Create custom setting “ValidationSetting“. This custom setting should be used to activate/deactivate any Validation Rule from your org.
i have created validation rule but its not working.
User-added imageUser-added imagecan anyone help me thank you!!
Hi Is it possible to create a new object or new custom fields using apex trigger?
How to find out those accounts who's opportunity is more than 2? 
Im trying to create a related list lightning component that does inline editing .. everything so far works fine if I pass the Parent id .. I would like it to dynamically pull the parent id depending on the record im on .. 

Apex controller : Project__c should be dynamically pulled depending on the record im on ( project is parent Historical p&l is child)
public class DataTableApexClass {
    @AuraEnabled
  
  public static List<Historical_Projected_P_L__c> getHPPL(){
 
      //  String url =  ApexPages.currentPage().getUrl();
     //  string str = url.right(23).substring(0,15);
    List <Historical_Projected_P_L__c> returnList = new List<Historical_Projected_P_L__c>();
        returnList = [select id, Project__c,Closed_Deal_Data__c,Label2__c, FY0__c,FY1__c,FY_3__c,FY_1__c,LTM__c,FY_2__c,FY2__c,FY3__c from Historical_Projected_P_L__c  where Project__c='a0w0d000003yohCAAQ' ];
        //Project__c= :currentRecordId];   
        return returnList;  
    } 
    @AuraEnabled
    public static void updateHPPL(List<Historical_Projected_P_L__c> HPPL ){
        update HPPL;
    }}

Lightning component :
<aura:component controller="DataTableApexClass"  implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global">
    
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="errors" type="Object" default="[]"/>
    <aura:attribute name="draftValues" type="Object" default="[]"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <b>this is recordID {!v.recordID}</b><br/>
    <div class="slds-p-around_medium">
        <h1 class="slds-text-heading_large">Inline edit Data table</h1>
    </div>
    
    <!-- the container element determine the height of the datatable -->
    <div style="height: 300px">
        <lightning:datatable aura:id="dtTable"
                             columns="{! v.columns }"
                             data="{! v.data }"
                             strRecordId ="{! v.strRecordId}"
                             keyField="Id"
                             errors="{! v.errors }"
                             draftValues="{! v.draftValues }"
                             onsave="{! c.handleSaveEdition }"
                             />
    </div>
    
    
</aura:component>

Lightning controller : ({
    init: function (cmp, event, helper) {
        cmp.set('v.columns', [
            {label: 'Index', fieldName: 'Index__c', type: 'Number' , editable: true},        
            {label: 'Project', fieldName: 'Project__c', type: 'text' ,editable: false},
            {label: 'Financial Metrics', fieldName: 'Label2__c', type: 'text' ,editable: false},
            {label: 'FY-3', fieldName: 'FY_3__c', type: 'number' ,editable: true},
            {label: 'FY-2', fieldName: 'FY_2__c', type: 'number' ,editable: true},
            {label: 'FY-1', fieldName: 'FY_1__c', type: 'number' ,editable: true},
            {label: 'FY3', fieldName: 'FY3__c', type: 'number' ,editable: true},
            {label: 'FY2', fieldName: 'FY2__c', type: 'number' ,editable: true},
            {label: 'FY1', fieldName: 'FY1__c', type: 'number' ,editable: true}
        ]);
        helper.fetchData(cmp,event, helper);
    },
    handleSaveEdition: function (cmp, event, helper) {
        var draftValues = event.getParam('draftValues');
        console.log(draftValues);
        var action = cmp.get("c.updateHPPL");
        action.setParams({"HPPL" : draftValues});
        action.setCallback(this, function(response) {
            var state = response.getState();
            $A.get('e.force:refreshView').fire();        
        });
        $A.enqueueAction(action);     
    },
})


helper: 
({
    fetchData: function (cmp,event,helper) {
        var action = cmp.get("c.getHPPL");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var data = response.getReturnValue();
                cmp.set('v.data',data);
            }
            // error handling when state is "INCOMPLETE" or "ERROR"
        });
        $A.enqueueAction(action);
    }
})


ANy help will be appreciated 
 
When an opportunity is inserted check for it’s a delicacy on the basis of its name and the account to which it is related to i.e. If it has the same name and it’s linked to the same Account then append “Duplicate Opportunity” in the name.
In this Leave and the Resource are custom object. Leave has lookup relationship with Resource . Leave has the custom field Leaves__c. For the one Resource total Leaves__c will be calculated in Total_Used_Paid_Leaves__c (custom field) in Resource__c object.

my apex trigger

trigger LeaveTrigger on Leave__c (after insert,after update) {
    
    if(trigger.isInsert || trigger.isUpdate){
        HRLeaveController.getTotalLeaves(Trigger.New);
     
    }
}
Apex class code
public class HRLeaveController{
    
    public static void  getTotalLeaves(List<Leave__c> newLeaves){
        Set<ID> resId = new Set<ID>();
        List<Resource__c> listRes = new List<Resource__c>();
        List<Resource__c> updateRes = new List<Resource__c>();
        
        for(Leave__c lev : newLeaves){
            resId.add(lev.Resource__c);
        }
        
        if(resId.size() > 0){
            listRes = [select Id,Total_Used_Paid_Leaves__c ,(select Id,Leaves__c from Leaves__r) from Resource__c where Id IN : resId];
        }
        
        for(Resource__c resrc : listRes){
            Decimal val = 0;
            for(Leave__c levs : resrc.Leaves__r){
                
                val += levs.Leaves__c;
                System.debug('**val**'+val);
            }
            resrc.Total_Used_Paid_Leaves__c = val;
            updateRes.add(resrc);
        }
        
        if(!updateRes.isEmpty()){
            update updateRes;
        }
    }
}
 
Hi all,

I'm trying to create a validation rule for our phone numbers. Every number has 2 parts:

Country Code (numerical, 1 digit starts with '+') --> +1

Number (numerical, no digit limit, cannot start with 0)

Examples:

+12019841724

Thanks for help.
  • January 08, 2020
  • Like
  • 0
Hi, 
can anyone help me to write below TestClass with the help of @testSetup.
CompanyInformationTriggerHandlerTest:
@isTest
public class CompanyInformationTriggerHandlerTest {
    static testmethod void insertNewCompanyInformation(){
        Company_Information__c ci = new Company_Information__c();
        ci.Legal_Entity_Name__c ='Test123';
        ci.DBA_Name__c='Test DBA';
        ci.Business_Street_Address_Line_1__c='Address1';
        ci.Business_Street_Address_Line_2__c='Address2';
        ci.Business_Mailing_City__c='city';
        ci.Business_Mailing_Country__c='country';
        ci.Shipping_Street_Address_Line_1__c='Address3';
        ci.Business_Street_Address_Line_2__c='Address4';
        ci.Shipping_Mailing_City__c='Scity';
        ci.Shipping_Mailing_Country__c='Scountry';
        ci.Status__c='Active';
        insert ci;
    }

}
Handler Class:
public class CompanyInformationTriggerHandler {
    
    public void updatevalue(List<Company_Information__c> companyInfoList){
         List<Affirmation__c> af = new List <Affirmation__c>();
         for(Company_Information__c cf:companyInfoList)
         
        {
              Affirmation__c af1=new Affirmation__c(Name=cf.Name,
                                                    Legal_Entity_Name__c = cf.Legal_Entity_Name__c,
                                                    DBA_Name__c=cf.DBA_Name__c,
                                                    Business_Street_Address_Line_1__c=cf.Business_Street_Address_Line_1__c,
                                                      Business_Street_Address_Line_2__c=cf.Business_Street_Address_Line_2__c,
                                                    Business_Mailing_City__c=cf.Business_Mailing_City__c,
                                                    Business_Mailing_Country__c=cf.Business_Mailing_Country__c,
                                                    Shipping_Street_Address_Line_1__c=cf.Shipping_Street_Address_Line_1__c,
                                                      Shipping_Street_Address_Line_2__c=cf.Shipping_Street_Address_Line_2__c,
                                                    Shipping_Mailing_City__c=cf.Shipping_Mailing_City__c,
                                                    Shipping_Mailing_Country__c=cf.Shipping_Mailing_Country__c,
                                                       Company_Information__c=cf.Id
                                                    );
            if(cf.Status__c=='Active')
            {
                af1.Status__c='Draft';
            }
           af.add(af1);
    }
    insert af;
}
    }
Trigger:
trigger CompanyInformationTrigger on Company_Information__c (After insert, before update)
{
   CompanyInformationTriggerHandler handler = new CompanyInformationTriggerHandler();
        
    handler.updatevalue(Trigger.new);
}
Hi Team,
What is the step by step for the creation of the personal views/dashboards/charts?

Regards,
Thangamani

Hello All,

Taking a shot at my first Lighting Component App and cannot resolve my #^&!# error. The purpose of my app is to display CaseComments related to a Case. When I attempt to Preview my app get the following error:

User-added image

*** Can Someone please help me find my error? ***

Thanks in advance.

Robert

Here's my code:

CaseCommentListController.cls

// Apex Controller for CaseComment List Lightning Component
public class CaseCommentListController {
  
    @AuraEnabled
    public static List<CaseComment> getCaseCommentsList(List<Id> parentIds) {
      // Getting the list of casecomments from where Id is in parentIds
    List<CaseComment> casecommentList = [SELECT Id, CommentBody, ParentId FROM CaseComment WHERE ParentId in :parentIds];
    // Returning the casecomment list
        return casecommentList;
    }

    @AuraEnabled
    public static Map<String,String> saveCaseCommentList(List<CaseComment> casecommentList) {
      // Forming a  string map to return response
        Map<String,String> resultMap = new Map<String,String>();
        // Adding try catch for exception handling
        try {
          // Updating the CaseComment List
            update casecommentList;
            // Setting the success status and message in resultMap
            resultMap.put('status', 'success');
          resultMap.put('message', 'CaseComments Updated Successfully');        
      }
      catch(Exception e) {
            // Setting the error status and message in resultMap
            resultMap.put('status', 'error');
      resultMap.put('message',e.getMessage());
      }
      // Returning the result string map
        return resultMap;
    }
    
    @AuraEnabled
    public static Map<String,String> deleteCaseCommentList(List<Id> casecommentIds) {
        //Fetching CaseComments
        List<CaseComment> casecommentsToDelete = [SELECT Id FROM CaseComment WHERE Id in :casecommentIds];
        // Forming a  string map to return response
        Map<String,String> resultMap = new Map<String,String>();
        // Adding try catch for exception handling
        try {
          // Deleting the CaseComments
            delete casecommentsToDelete;
            // Setting the success status and message in resultMap
            resultMap.put('status', 'success');
          resultMap.put('message', 'CaseComments Deleted Successfully');        
      }
      catch(Exception e) {
            // Setting the error status and message in resultMap
            resultMap.put('status', 'error');
      resultMap.put('message',e.getMessage());
      }
      // Returning the result string map
        return resultMap;                
    }

    @AuraEnabled
    public static Map<String, String> createCaseCommentRecord(CaseComment newCaseComment) {
        // Forming a  string map to return response
        Map<String,String> resultMap = new Map<String,String>();
        // Adding try catch for exception handling
        try {
            // Inserting the CaseComment
            insert newCaseComment;
            // Setting the success status and message in resultMap
            resultMap.put('status', 'success');
            resultMap.put('message', 'CaseComment Inserted Successfully');        
        }
        catch(Exception e) {
            // Setting the error status and message in resultMap
            resultMap.put('status', 'error');
            resultMap.put('message',e.getMessage());
        }
        // Returning the result string map
        return resultMap;        
    }
}

CaseCommentListApp.app

<!-- Application to call CaseCommentList component -->
<aura:application extends="force:slds" >
	<!-- force:slds extended to apply lightning design system styling and passed in the record Id -->
    <c:CaseCommentList recordId="5000y00001dWMmQAAW" />
</aura:application>

CaseCommentListAppController.js

({
    // Function called on initial page loading to get casecomment list from server
    getCaseCommentsList : function(component, event, helper) { 
        // Helper function - fetchCaseComments called for interaction with server
		helper.fetchCaseComments(component, event, helper);
	},

    // Function used to create a new CaseComment
    newCaseComment: function(component, event, helper) {
        // Global event force:createRecord is used
        var createCaseComment = $A.get("e.force:createRecord");
        // Parameters like apiName and defaultValues are set
        createCaseComment.setParams({
            "entityApiName": "CaseComment",
            "defaultFieldValues": {
                "ParentId": component.get("v.recordId")
            }
        });
        // Event fired and new casecomment dialog open
        createCaseComment.fire();
    },

    // Function used to update the casecomments
    editCaseComments: function(component, event, helper) {
        // Getting the button element
        var btn = event.getSource();
        // Getting the value in the name attribute
        var name = btn.get('v.name');
        // Getting the record view form and the record edit form elements
        var recordViewForm = component.find('recordViewForm');
        var recordEditForm = component.find('recordEditForm'); 
        // If button is edit
        if(name=='edit') {
            // Hiding the recordView Form and making the recordEdit form visible
            $A.util.addClass(recordViewForm,'formHide');
            $A.util.removeClass(recordEditForm,'formHide');
            // Changing the button name and label
            btn.set('v.name','save');
            btn.set('v.label','Save');
        }
        else if(name=='save') {
            // Calling saveCaseCommentList if the button is save
            helper.saveCaseCommentList(component, event, helper);
        }
    }
})

CaseCommentListAppHelper.js

({
	helperMethod : function() {
		
	}
})

CaseCommentListApp.css

.THIS {
}
.THIS .formHide {
	display: none;
}

CaseCommentListCmp.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" controller="CaseCommentListController" access="global">
    <!-- Handler to call function when page is loaded initially -->
    <aura:handler name="init" action="{!c.getCaseComments}" value="{!this}" />
    <!-- List of casecomments stored in attribute -->
    <aura:attribute name="casecommentList" type="List" />
    <!-- New CaseComment Object -->
    <aura:attribute name="casecomment" type="CaseComment"
    default="{
        'SObjectType': 'CaseComment', 'CommentBody': ''
    }">            
    </aura:attribute>
    <!-- Method to validate new casecomment -->
    <aura:method name="validateCaseComment" action="{!c.validateCaseComment}" />
    <!-- Lightning card to show casecomments -->
    <lightning:card title="CaseComments">
        <!-- Body of lightning card starts here -->
        <p class="slds-p-horizontal_small">
            <!-- Aura iteration to iterate list, similar to apex:repeat -->
            <div aura:id="recordViewForm">
                <aura:iteration items="{!v.casecommentList}" var="casecomment">
                    <!-- recordViewForm to view the record -->
                    <lightning:recordViewForm recordId="{!casecomment.Id}" objectApiName="CaseComment">
                        <div class="slds-box slds-theme_default">
                            <!-- inputfield checkbox used to check wether to delete the casecomment or not -->
                            <lightning:input type="checkbox" value="{!casecomment.Id}" label="Mark for Deletion" aura:id="deleteCaseComment" />
                            <br />
                            <!-- outputfield used to output the record field data inside recordViewForm -->
                            <lightning:outputField fieldName="CommentBody" />
                        </div>
                    </lightning:recordViewForm>
                    <!-- Line break between two records -->
                    <br />
                </aura:iteration>
            </div>
            <div aura:id="recordEditForm" class="formHide">
                <aura:iteration items="{!v.casecommentList}" var="casecomment">
                    <div class="slds-box slds-theme_default">
                        <!-- inputfield used to update the record field data -->
                        <!-- Validation added -->
                        <lightning:input aura:id="fieldToValidate" value="{!casecomment.CommentBody}" messageWhenValueMissing="Comment is Mandatory" required="true"/>
                    </div>
                    <br />
                    <!-- Line break between two records -->
                </aura:iteration>
            </div>
        </p>
        <!-- Lightning card actions -->
        <aura:set attribute="actions">
            <!-- New casecomment modal button added -->
            <lightning:button name="casecommentModal" label="New CaseComment" onclick="{!c.openModal}" />
            <!-- Delete button added -->
            <lightning:button variant="destructive" label="Delete" onclick="{!c.deleteCaseComments}" />
            <!-- New button added -->
            <lightning:button label="New" onclick="{!c.newCaseComment}" />
            <!-- Edit/Save button added -->
            <lightning:button variant="brand" label="Edit" name="edit" onclick="{!c.editCaseComments}" />
        </aura:set>
    </lightning:card>
    <!-- CaseComments Modal Section -->
    <div>
        <section aura:id="casecommentModal" role="dialog" tabindex="-1" aria-labelledby="casecommentModalHeading" aria-modal="true" aria-describedby="casecommentModalBody" class="slds-modal">
            <!-- Modal Container -->
            <div class="slds-modal__container">
                <!-- Modal Header ( consists of close button and heading of modal ) -->
                <header class="slds-modal__header">
                    <lightning:buttonIcon class="slds-modal__close" alternativeText="Close" iconName="utility:close" onclick="{!c.closeModal}" variant="bare-inverse" size="large"></lightning:buttonIcon>
                    <h2 id="casecommentModalHeading" class="slds-text-heading_medium slds-hyphenate">New CaseComment</h2>
                </header>
                <!-- Modal Body ( consists of form ) -->
                <div class="slds-modal__content slds-p-around_medium" id="casecommentModalBody">
                    <!-- Validation added -->
                    <lightning:input aura:id="formFieldToValidate" label="Comment" messageWhenValueMissing="Comment is Mandatory" required="true" value="{!v.casecomment.CommentBody}" />
                </div>
                <!-- Modal Footer ( consists of cancel and save buttons ) -->
                <footer class="slds-modal__footer">
                    <lightning:button onclick="{!c.closeModal}" variant="neutral">Cancel</lightning:button>
                    <lightning:button onclick="{!c.createCaseComment}" variant="brand" >Save</lightning:button>
                </footer>
            </div>
        </section>
        <!-- Modal Backdrop -->
        <div aura:id="casecommentModalBackdrop" class="slds-backdrop"></div>
    </div>
</aura:component>

CaseCommentListCmpController.js

({
    // Function called on initial page loading to get casecomment list from server
	getCaseCommentsList : function(component, event, helper) {
        // Helper function - fetchCaseComments called for interaction with server
		helper.fetchCaseComments(component, event, helper);
	},

    // Function used to create a new casecomment
    newcasecomment: function(component, event, helper) {
        // Global event force:createRecord is used
        var createcasecomment = $A.get("e.force:createRecord");
        // Parameters like apiName and defaultValues are set
        createcasecomment.setParams({
            "entityApiName": "casecomment",
            "defaultFieldValues": {
                "ParentId": component.get("v.recordId")
            }
        });
        // Event fired and new casecomment dialog open
        createcasecomment.fire();
    },

    // Function used to update the casecomments
    editCaseComments: function(component, event, helper) {
        // Getting the button element
        var btn = event.getSource();
        // Getting the value in the name attribute
        var name = btn.get('v.name');
        // Getting the record view form and the record edit form elements
        var recordViewForm = component.find('recordViewForm');
        var recordEditForm = component.find('recordEditForm'); 
        // If button is edit
        if(name=='edit') {
            // Hiding the recordView Form and making the recordEdit form visible
            $A.util.addClass(recordViewForm,'formHide');
            $A.util.removeClass(recordEditForm,'formHide');
            // Changing the button name and label
            btn.set('v.name','save');
            btn.set('v.label','Save');
        }
        else if(name=='save') {
            // Getting the edit form fields to validate
            var casecommentFields = component.find("fieldToValidate");
            // Initialize the counter to zero - used to check validity of fields
            var blank=0;
            // If there are more than 1 fields
            if(casecommentFields.length!=undefined) {
                // Iterating all the fields
                var allValid = casecommentFields.reduce(function (validSoFar, inputCmp) {
                // Show help message if single field is invalid
                inputCmp.showHelpMessageIfInvalid();
                // return whether all fields are valid or not
                return validSoFar && inputCmp.get('v.validity').valid;
                }, true);
                // If all fields are not valid increment the counter
                if (!allValid) {
                    blank++;
                }
            } else {
                // If there is only one field, get that field and check for validity (true/false)
                var allValid = casecommentFields;
                // If field is not valid, increment the counter
                if (!allValid.get('v.validity').valid) {
                    blank++;
                }
            }
            // Call the helper method only when counter is 0
            if(blank==0) {
                // Calling saveCaseComments if the button is save
                helper.saveCaseComments(component, event, helper);                
            }
        }
    },
    
    // Function used to delete the casecomments
    deleteCaseComments: function(component, event, helper) {
        // Calling removeCaseComments Helper Function
        helper.removeCaseComments(component, event, helper);
    },

    // Function used to open the casecomment modal
    openModal: function(component, event, helper) {
        var modal = component.find("casecommentModal");
        var modalBackdrop = component.find("casecommentModalBackdrop");
        $A.util.addClass(modal,"slds-fade-in-open");
        $A.util.addClass(modalBackdrop,"slds-backdrop_open");
    },

    // Function used to close the casecomment modal
    closeModal: function(component, event, helper) {
        var modal = component.find("casecommentModal");
        var modalBackdrop = component.find("casecommentModalBackdrop");
        $A.util.removeClass(modal,"slds-fade-in-open");
        $A.util.removeClass(modalBackdrop,"slds-backdrop_open");
    },

    // Function used to create new casecomment
    createcasecomment: function(component, event, helper) {
        var iscasecommentValid = component.validatecasecomment(component, event, helper);
        if(iscasecommentValid) {
           helper.insertcasecomment(component, event, helper);
        }
    },

    // Function to validate new casecomment - Aura method used for the same
    validatecasecomment: function(component, event, helper) {
        // Getting all fields and iterate them to check for validity
        var allValid = component.find('formFieldToValidate').reduce(function (validSoFar, inputCmp) {
            // Show help message if single field is invalid
            inputCmp.showHelpMessageIfInvalid();
            // Get the name of each field
            var name = inputCmp.get('v.name');
            // Check if name is emailField
            if(name=='emailField') {
                // Getting the value of that field
                var value = inputCmp.get('v.value');
                // If value is not equal to robert.wambold@almacgroup.com, add custom validation
                if(value != 'robert.wambold@almacgroup.com') {
                    // Focus on that field to make custom validation work
                    inputCmp.focus();
                    // Setting the custom validation
                    inputCmp.set('v.validity', {valid:false, badInput :true});
                }                
            }
            // Returning the final result of validations
            return validSoFar && inputCmp.get('v.validity').valid;
        }, true);
        // Returning Validate casecomment result in boolen
        return allValid;
    }

})

CaseCommentListCmpHelper.js

({
    // Function to fetch data from server called in initial loading of page
	fetchCaseComments : function(component, event, helper) {
        // Assign server method to action variable
        var action = component.get("c.getCaseCommentList");
        // Getting the parent id from page
        var parentId = component.get("v.recordId");
        // Setting parameters for server method
        action.setParams({
            parentIds: parentId
        });
        // Callback function to get the response
        action.setCallback(this, function(response) {
            // Getting the response state
            var state = response.getState();
            // Check if response state is success
            if(state === 'SUCCESS') {
                // Getting the list of casecomments from response and storing in js variable
                var casecommentList = response.getReturnValue();
                // Set the list attribute in component with the value returned by function
                component.set("v.casecommentList",casecommentList);
            }
            else {
                // Show an alert if the state is incomplete or error
                alert('Error in getting data');
            }
        });
        // Adding the action variable to the global action queue
        $A.enqueueAction(action);
	},

    // Function to update the casecomments on server
    saveCaseComments: function(component, event, helper) {
        // Getting the casecomment list from lightning component
        var casecommentList = component.get("v.casecommentList");
        // Getting the recordViewForm and recordEditForm component
        var recordViewForm = component.find('recordViewForm');
        var recordEditForm = component.find('recordEditForm'); 
        // Initializing the toast event to show toast
        var toastEvent = $A.get('e.force:showToast');
        // Defining the action to save casecomment List ( will call the saveCaseCommentList apex controller )
        var saveAction = component.get("c.saveCaseCommentList");
        // setting the params to be passed to apex controller
        saveAction.setParams({ casecommentList: casecommentList });
        // callback action on getting the response from server
        saveAction.setCallback(this, function(response) {
            // Getting the state from response
            var state = response.getState();
            if(state === 'SUCCESS') {
                // Getting the response from server
                var dataMap = response.getReturnValue();
                // Checking if the status is success
                if(dataMap.status=='success') {
                    // Remove the formHide class
                    $A.util.removeClass(recordViewForm,'formHide');
                    // Add the formHide class
                    $A.util.addClass(recordEditForm,'formHide');
                    // Getting the button element
                    var btn = event.getSource();
                    // Setting the label and name of button back to edit
                    btn.set('v.name','edit');
                    btn.set('v.label','Edit');
                    // Setting the success toast which is dismissable ( vanish on timeout or on clicking X button )
                    toastEvent.setParams({
                        'title': 'Success!',
                        'type': 'success',
                        'mode': 'dismissable',
                        'message': dataMap.message
                    });
                    // Fire success toast event ( Show toast )
                    toastEvent.fire();            
                }
                // Checking if the status is error 
                else if(dataMap.status=='error') {
                    // Setting the error toast which is dismissable ( vanish on timeout or on clicking X button )
                    toastEvent.setParams({
                        'title': 'Error!',
                        'type': 'error',
                        'mode': 'dismissable',
                        'message': dataMap.message
                    });
                    // Fire error toast event ( Show toast )
                    toastEvent.fire();                
                }
            }
            else {
                // Show an alert if the state is incomplete or error
                alert('Error in getting data');
            }
        });
        $A.enqueueAction(saveAction);
    }    
})

CaseCommentListCmp.css

.THIS {
}
.THIS .formHide {
	display: none;
}
 

*** Thanks again for helping !!! ***

 

 

Hi, I am new to VS code and LWC. I have used root tag as template but still this error is coming-
[Line: 1, Col: 1] LWC1079: Expected root tag to be template, found lightning-cardUser-added image
Hello,
I have a button that needs to be disabled.  Ideally after it has successfully created a record:
<button label="My Button" class="slds-button slds-button--brand" onclick="{!c.submit}">Submit Button</button>

Enable/show this div so that the child component is available
<div style="text-align:right;">
            <c:child parentId="{!v.id}"/>
        </div>

Thanks,
P
Hi,
I am learning lightning, can some1 pls help me.

I have created 2 components 1 is parent and the other is child and i am using child component in application so that it wud call parent indirectly.And if i call my parentcomponent in application its throwing me an error saying "It cant be instantiated". 

<--c:parentinherit-->
<aura:component extensible="true">
    <h3>Hi i am parent comp</h3>
</aura:component>

<--c:childinherit-->
<aura:component  extends="c:parentinherit">
    <h1> I am from child</h1>
</aura:component>


In my application i am using child component.I am not getting child component header tag output. Can any1 help?

<aura:application >
    
    Hi i am from application
    <c:childinherit/>
</aura:application>







 
  • December 04, 2019
  • Like
  • 0
@isTest
public class TestVerifyDate {
    @isTest static void testOldDate(){
        Date dateTest = VerifyDate.CheckDates(date.today(), date.today().addDays(-1));
        System.assertEquals(date.newInstance(2016, 4, 30), dateTest);
    }
    
    @isTest static void testLessThan30Days(){
        Date dateTest = VerifyDate.CheckDates(date.today(), date.today().addDays(20));
        System.assertEquals(date.today().addDays(20), dateTest);
    }
    
    @isTest static void testMoreThan30Days(){
        Date dateTest = VerifyDate.CheckDates(date.today(), date.today().addDays(31));
        System.assertEquals(date.newInstance(2016, 4, 30), dateTest);
    }

}

 
i want to get only Updated and newly created records from custom object... How to get only Updated and newly created records using SOQL query?
I had a field (Allotment) Long TextArea Field in Bren Updates(Custom Object).
I need to display the data which was in Allotment in te Visualforce Page.
I have tried it using <apex:outputField>
But still i was not getting thhe data to display on Visualforce page.

My issue on my Visualforce page:

    <apex:pageBlockSectionItem >
                              

                        <apex:outputLabel value="Allotment Summary" for="AllSum" style="font-family:Ancillary Bold; font-size:15px" />
                      <!--  <apex:outputField value="{!brenup.Allotment__c}" id="a0Wp0000003JTYb" />  -->
                        <apex:outputText value="{!HTMLENCODE(brenup.Allotment__c)}" style="white-space:pre;" escape="false"/>
                      <!--  <apex:inputfield value="{!brenup.Allotment_Summary__c}" id="AllSum" html-disabled="true" /> -->
                      <!--  <apex:inputTextarea richtext="false" value="{!brenup.Allotment__c}"  id="AllSum" readonly="true" cols="150" rows="25"/> -->
                        
                    </apex:pageBlockSectionItem>   

Bold code data is using now and it was not even displaying my data on Visualforce page.

ere below is my issue.
User-added image 
Please help me that i need to display my data in Visualforce page of that field(Allotment(Long Textarea Field)).

Please provide a solution for thisss.

Thanks and Regards,
Azhar Khasim.
public class Acc_Dynamic 
{
   Public List<AccAll> acl{set;get;}
   Public Acc_Dynamic()
    {
      acl=new List<AccAll>();
        for(Integer i=0;i<10;i++)
        {
          Account acc=new Account();
          acl.add(new AccAll(acc,false));
        }        
    }
    public class AccAll
    {
        Public Account accs{set;get;}
        Public Boolean flag{set;get;}
        public AccAll(Account acs,Boolean flg)
        {
          accs=acs;
          flag=flg;
        }   
    }
}
I've a picklist with the values like the below, I want the number part to show, so for example, BA, I want my field to just show 10001:-

10001: BA
10002: Virgin

Any thoughts? My List is 3000, so cannnot use dependent/workflow rule!
Hi Everyone.

I'm new to lightning and trying to open a datatable in a modal(popup). I have a requirement where when i check a checkbox, then a modal should open where data will be displayed from a certain object. I cannot figure out how to achieve this. I'm only able the display the datatable on the same page as of checkbox, and not in the modal.

Kindly siggest a solution. Thank you in advance.
Dear Team ,

Greetings for the day !!!

I am going to integrate Salesforce with Google Drive . I configured files connect , Permission sets , Auth Providers moreover callback URL also generated . Parallely i am using https://console.developers.google.com/projectselector but when m feeding callback url it is showing error please have a look on snapshot and suggest me some steps in order m able to solve the error .

Thanks & Regards
Sachin BhaleraoUser-added image
Hi Master developers,

i am getting one callout error kindly suggest me , how can overcome  this error .

timeout: error is 120,000 milliseconds can be exceeded then how we can handle this issue in callouts ?

Thanks,
Chinna
Hello, 

I am learning salesforce and quite new to it. can any one pls help me out in trigger design pattern  and frameworks. I am bit confused in this?
Hello,

I want to track the changes in Opportunity Amount(standard field) and create a report for the changes.

How can i implement the usecase.

thank you for suggestion
Create custom setting “ValidationSetting“. This custom setting should be used to activate/deactivate any Validation Rule from your org.
i have created validation rule but its not working.
User-added imageUser-added imagecan anyone help me thank you!!
Hey, this one is for the Salesforce pros:

I have an app installed for mass editing records. When I was installing the app, I chose the accessibility settings 'for all users'. It is accesible via a list view of an object, let's say via object Account. I open Account, change list view to "Show all", then on the right side of the page I see my custom button that comes with the intalled app! Awesome!

I would like to hide it for some users now. Is that possible?

I know that profiles have set access to Visualforce Pages (that's how the button is made). If I disable the access to that Visualforce Page containing the code for the button, I still have the button visible, it just won't let the user access it.
Hi Is it possible to create a new object or new custom fields using apex trigger?
Hi Guys,

I am getting this error while inserting user in the test class.
System.DmlException: Insert failed. role type must match user type.

Please find the below code.

 Set<String> customerUserTypes = new Set<String> {'CSPLiteUser', 'PowerPartner', 'PowerCustomerSuccess',   'CustomerSuccess'};
        Profile portalProfile = [SELECT Id FROM Profile WHERE UserType in :customerUserTypes Limit 1];
        UserRole role = [Select Id From UserRole Where PortalType = :'CustomerPortal' Limit 1];
        User user1 = new User(
            Username = System.now().millisecond() + 'test12345@test.com',
            ContactId = contact1.Id,
            ProfileId = portalProfile.Id,
            UserRoleId = role.Id,
            Alias = 'test56',
            Email = 'test12345@test.com',
            EmailEncodingKey = 'UTF-8',
            LastName = 'McTesty',
            CommunityNickname = 'test12345',
            TimeZoneSidKey = 'America/Los_Angeles',
            LocaleSidKey = 'en_US',
            LanguageLocaleKey = 'en_US'
        );
    Database.insert(user1);


 
I need to Send Email to All users on Every Friday @ 10Am . So can anyone suggest how to write a Workflow with time based.
Thanks in advance...
Say I have a class that creates a new account. 
To check for FLS for an insert operation I can call the isCreateable method on the DescribeSObjectResult:

if(Schema.sObjectType.Account.isCreateable()){
    insert account;
}

So what's the point of for example Schema.sObjectType.Account.fields.Name.isCreateable() ?

I understand isUpdateable() on a field (some fields can be created but not updated). But isn't isCreateable the same thing on a field as it is on an object? if you can create an object, you should have the ability to create the required fields? 

I'm asking this as I'm trying to fix some FLS errors that I got back on a preliminary security scan of my package. 
I want to change the community name, so that what shows up in emails etc isn't the wrong name.  We have a capital letter in the name that shouldn't be there and need to update it.  We do not need to make any changes to the url or anything.  Is this possible?
How to find out those accounts who's opportunity is more than 2? 
_self is opening new subtab in lightning console. I dont want to open link in new subtab. It should override primary subtab. The formula field is-

(" [" &
HYPERLINK("/apex/Sc_UpdateCustomerEnvironment_Update?action=Select&CaseNumid="&Id,"Select", "_self") & "]" &
" [" & HYPERLINK("/apex/Sc_UpdateCustomerEnvironment_Update?action=View&CaseNumid="&Id&"&EnvId="&CustomerEnvironment__c,"View Selected", "_self") & "]" &
" [" & HYPERLINK("/apex/Sc_UpdateCustomerEnvironment_Update?action=Edit&CaseNumid="&Id&"&EnvId="&CustomerEnvironment__c, "Edit Selected", "_self") & "]" &" [" &
HYPERLINK("/apex/Sc_UpdateCustomerEnvironment_Update?action=New&CaseNumid="&Id,"New Environment", "_self") & "]")

It is working perfect in classic console.