Forum Replies Created

Page 8 of 10
  • Piyush

    Member
    September 13, 2019 at 2:42 am in reply to: Can we write test class for a shedulable batch class in Salesforce?

    Hi Deepak,

    Yes, We can write test class for a shedulable batch class in Salesforce:-

    For Example:-

    @isTest
    public class testScheduleBatch{  
    
        public static testmethod void first1(){
            Test.startTest();
            Datetime dt = Datetime.now().addMinutes(1);
            String CRON_EXP = '0 '+ dt.minute() + ' * ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
            testScheduleBatch.SchedulerMethod('Sample_Heading', CRON_EXP, new ScheduleBatch () );   
            Test.stopTest();
        }  
    
    }

     

  • Hi Deepak,

    To create the Knowledge article:-

    1. Click the App Launcher  and select Knowledge.
    2. Click New.
    3. For Title, enter "ABC"
    4. Click in the URL Name field to generate the URL Name from the title.
    5. For Text, enter "Hopefully this summer!"
    6. Under Properties, select Visible to Customer.
    7. Click Save & New.

    To Publish the knowledge article:-

    1. Click the *Knowledge tab [1] at the top and change the list view to Draft Articles [2].
    2. Check the box next to all three article titles and then click Publish.
    3. Ensure Publish Now is selected.
    4. Click Publish.
  • Hi Saddam,

    Custom Setting:

    Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, flows, Apex, and the SOAP API.

    Custom Metadata:

    Custom metadata is customizable, deployable, packageable, and upgradeable application metadata. First, you create a custom metadata type, which defines the form of the application metadata. Then you build reusable functionality that determines the behavior based on metadata of that type. Similar to a custom object or custom setting, a custom metadata type has a list of custom fields that represent aspects of the metadata.

  • Piyush

    Member
    September 12, 2019 at 3:36 am in reply to: What are the setup and non-setup object?

    Hi Saddam,

    • Setup Object is:
      1. Profiles
      2. Users
      3. Record Type
    • Non-Setup Object :
      1. Lead
      2. Account
      2. Contact
      4. Any Custom Object
  • Hi Deepak,

    First you need to add the object to the tab.

    Go to setup -> Enter Tabs in the quick find box  and select tabs -> In custom object tabs  click new -> select your object and click next, save.

    Now you will be able to see your object on the tab and you can check the required field of the object.

  • Hi Nikita,

    you can use this to get only Date from the field which is of DateTime type in apex:-

    System.debug('date=' + Date.valueOf(System.now()));

     

  • Piyush

    Member
    September 11, 2019 at 5:24 am in reply to: how to write test class for a scheduler class in salesforce?

    Hi Deepak,

    You can write test class for a scheduler class in salesforce like this:-

    @isTest
    public class testScheduleBatch{  
    
        public static testmethod void first1(){
            Test.startTest();
            Datetime dt = Datetime.now().addMinutes(1);
            String CRON_EXP = '0 '+ dt.minute() + ' * ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
            testScheduleBatch.SchedulerMethod('Sample_Heading', CRON_EXP, new ScheduleBatch () );   
            Test.stopTest();
        }  
    
    }

     

  • Piyush

    Member
    September 10, 2019 at 4:45 am in reply to: How to refresh a lightning component after a record is saved ?

    Hi Hariom,

    You can use this code to refresh a lightning component after a record is saved:-

    <aura:component controller="editRecordSimulationController"
                    implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName">
        
        <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
        
        <aura:dependency resource="markup://force:editRecord" type="EVENT" />
        
        <aura:handler event="force:refreshView" action="{!c.doInit}" />
    
    
        
        <aura:attribute name="recordId" type="string" />
        <aura:attribute name="accType" type="String" />
        <aura:attribute name="accObj" type="account" default="{ sObjectType: 'Account'}"/>
        
        
        <ui:inputText label="Record Id" value="{!v.recordId}" required="true"/>
    	<ui:button class="btn" label="Submit" press="{!c.setOutput}"/>
        
        <br />
        <br />
        <br />
        Account Type: <ui:outputText value="{!v.accObj.Type}" />
    </aura:component>
    ({
        doInit : function(component, event, helper) {
            var recordId = component.get("v.recordId");
            var action = component.get("c.getTypeFromAccount");
            action.setParams({
                	recordId: recordId
            });
            action.setCallback(this, function(response){
                var state = response.getState();
                if (state === "SUCCESS") {
                    var acc = response.getReturnValue();
                    component.set("v.accType", acc.Type);
                    component.set("v.accObj", acc)
                }
            });
            
            $A.enqueueAction(action);
        },
    	setOutput : function(component, event, helper) {
            var editRecordEvent = $A.get("e.force:editRecord");
            editRecordEvent.setParams({
                 "recordId": component.get("v.recordId")
            });
            editRecordEvent.fire();
    	}
    })

     

  • Piyush

    Member
    September 10, 2019 at 4:39 am in reply to: What is System runAs in Salesforce?

    Hi Deepak,

    The system method runAs enables you to write test methods that change the user context to an existing user or a new user so that the user's record sharing is enforced.

  • Piyush

    Member
    September 10, 2019 at 4:37 am in reply to: How to use IF Statements in Salesforce Lightning Component?

    Hi Deepak,

    You can use IF Statements in Salesforce Lightning Component like this:-

    aura:if  isTrue="{!and(
                            and(v.wrp.ObjectApiNAme!='Pay_Element_Master__c', v.wrp.ObjectApiNAme!='CTC_Master__c'), 
                            v.wrp.ObjectApiNAme!='Section_Master__c')
                        )}">
            <lightning:select name="select" label=" " aura:id="o" >
                <option value="">None</option>
            </lightning:select>
        </aura:if>

     

  • Hi Prachi,

    Yes. You can have a roll-up summary in case of a master-detail relationship. But not in case of a lookup relationship.

  • Piyush

    Member
    September 9, 2019 at 5:10 am in reply to: How can we implement pagination in Visualforce page in salesforce?

    Hi Prachi,

    You can check this code to implement pagination in Visualforce page in salesforce:-

    <apex:page standardController="Opportunity" extensions="oppoNe" recordSetVar="opportunities">
    <apex:pageBlock title="Viewing Opportunities">
    <apex:form id="theForm">
    <apex:pageBlockSection >
    <apex:dataList var="opp" value="{!opportunities}">
    {!opp.Name}
    </apex:dataList>
    </apex:pageBlockSection>
    <apex:panelGrid columns="4">
    <apex:commandLink action="{!first}">FIRST</apex:commandLink>
    <apex:commandLink action="{!next}">NEXT</apex:commandLink>
    <apex:commandLink action="{!previous}">PREVIOUS</apex:commandLink>
    <apex:commandLink action="{!last}">LAST</apex:commandLink>
    </apex:panelGrid>
     
    </apex:form>
    </apex:pageBlock>
    </apex:page>
    public class oppoNe {
     
        public oppoNe(ApexPages.StandardSetController controller) {
            controller.setPageSize(10);
        }
     
    }

     

  • Piyush

    Member
    September 9, 2019 at 5:04 am in reply to: How can you embed a Visualflow in a Visualforce page in Salesforce?

    Hi Prachi,

    1. From Setup, enter Flows in the Quick Find box, then select Flows.
    2. Click the name of the flow that you want to embed.
    3. Define a new Visualforce page or open one that you want to edit.
    4. Add the <flow:interview> component, somewhere between the <apex:page> tags.
    5. Set the name attribute to the unique name of the flow. For example:

    <apex:page>
    <flow:interview name="flowAPIName"/>
    </apex:page>

  • Piyush

    Member
    September 6, 2019 at 7:55 am in reply to: How to generate Salesforce lightning readiness report?

    Hi Laveena,

    1. From Setup in Salesforce Classic, click Get Started in the Lightning Experience Transition Assistant tile at the top of the menu . From Setup in Lightning Experience, enter Lightning in the Quick Find box, then select Lightning Experience Transition Assistant.
    2. Select the Discover phase.
    3. Click Evaluate Lightning Experience Benefits and Readiness to expand the stage.
    4. Click Check Readiness next to Check your Lightning Experience readiness.
  • Piyush

    Member
    September 6, 2019 at 7:10 am in reply to: How to delete or freeze users in the Salesforce?

    Hi Achintya,

    Steps to Unfreez or freeze users in the salesforce:-

    1. From Setup, enter Users in the Quick Find box, then select Users.
    2. Click the username of the account you want to freeze.
    3. Click Freeze to block access to the account or Unfreeze to allow access to the account again.
  • Piyush

    Member
    September 6, 2019 at 7:06 am in reply to: What are the limitations of Time-dependent workflow in Salesforce?

    Hi Achintya,

    The limitations of Time-dependent workflow in Salesforce:

    1. Time triggers don’t support minutes or seconds.
    2. Time triggers can’t reference the following:
    3. DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
    4. Formula fields that include related-object merge fields.
    5. You can’t add or remove time triggers if:
    6. The workflow rule is active.
    7. The workflow rule is deactivated but has pending actions in the queue.
    8. The workflow rule evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
    9. The workflow rule is included in a package.
  • Piyush

    Member
    September 5, 2019 at 3:33 am in reply to: What is an object store in mule 4.

    Hi Gursimran,

    An ObjectStore is a Mule component which allows for simple key-value storage. Although it can serve a wide variety of use cases, it’s mainly designed for:

    1. Storing synchronization information like watermarks
    2. Storing temporal information like access tokens
    3. Storing user information
  • Piyush

    Member
    September 5, 2019 at 3:28 am in reply to: How to create OnClick button on visualforce page in Salesforce?

    Hi Deepak,

    You can take help from this below example of vf page to create an onclick event on vf page:-

    <apex:page standardController="Lead" extensions="D_B_LeadCntrlr">
    <apex:includeScript value="/soap/ajax/29.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/29.0/apex.js"/>
    <script >
    
        var success = 'false';
        function myFunction(){
            var Retrieve_DB_Detail = '{!Retrieve_DB_Details}';
            if(Retrieve_DB_Detail == false || Retrieve_DB_Detail == 'false'){
                alert('You cannot perform DB Check with retrieve DB details as false');
            }else{
                var result = sforce.apex.execute("RetriveDBDetailsController","getDBDetails",{leadId:"{!leadId}"});
                alert(result);
                 window.location.reload();
            }
        }
    
        function showSuccess(){
            if(showSuccess == 'true'){
                alert(success);
               window.location.reload();
            }
        }
        </script>
    <apex:form >
    
        <apex:actionFunction name="callMethod" action="{!callMethod}" onComplete="showSuccess()"/>
    
            <apex:PageBlock >
                <div align="center" draggable="false" >
                    <apex:CommandButton value="D&B Check" onclick="myFunction()" />
                </div>
            </apex:PageBlock>
        </apex:form>    
    </apex:page>

     

  • Piyush

    Member
    September 4, 2019 at 12:03 pm in reply to: What are the effects of using the transient keyword in Salesforce?

    Hi Hariom,

    Use the transient keyword to declare instance variables that can’t be saved, and shouldn’t be transmitted as part of the view state for a Visualforce page.

    For example- Transient Integer currentTotal;
    You can also use the transient keyword in Apex classes that are serializable, namely in controllers, controller extensions, or classes that implement the Batchable or Schedulable interface. In addition, you can use transient in classes that define the types of fields declared in the serializable classes. – Salesforce

  • Piyush

    Member
    September 4, 2019 at 11:58 am in reply to: What is a Salesforce Upsert Connector in mule 4 ?

    Hi Gursimran,

    Upsert Connector is used to create an object only if it doesn't exist, or delete an existing object on the ExactTarget web server. This operation is achieved by using "Create" method of the ExactTarget SOAP API.

  • Piyush

    Member
    September 4, 2019 at 11:45 am in reply to: Can I schedule a active dashboard in salesforce?

    Hi Achintya,

    Yes, In Enterprise Edition and Unlimited Edition, you can schedule an active dashboard in salesforce.

  • Piyush

    Member
    September 3, 2019 at 7:55 am in reply to: How to send Reports via email to a group of users on an hourly basis

    Hi Yogesh,

    You can take help from this example:-

    global with sharing class ScheduleandEmailReport implements schedulable {
        global void execute(SchedulableContext SC){
            // Get the report ID
               scheduleJob();
        }
        
        @future(callout=true)
        private static void scheduleJob(){
                    List <Report> reportList = [SELECT Id,DeveloperName FROM Report where 
                       DeveloperName = 'Account_Report_for_Email' ];
            System.debug(reportList);
            List<Messaging.SingleEmailMessage> lstEmail = new List<Messaging.SingleEmailMessage>();
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            List< Messaging.EmailFileAttachment> lstAttachment = new List< Messaging.EmailFileAttachment>();
            String[] reportId = new String[reportList.size()];
            String[] reportname = new String[reportList.size()];
            for(Integer i=0;i < reportList.size();i++)
            {
               
                //Getting record on the basis of Report Id and puttinf it into Excel as attachment.
                reportId[i] = (String)reportList.get(i).get('Id');
                reportname[i] = (String)reportList.get(i).get('DeveloperName');
                ApexPages.PageReference report = new ApexPages.PageReference( '/' + reportId[i] + '?excel=1'); // or csv=1
                Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
                System.debug('---report--'+ report);
                attachment.setFileName(reportname[i] + '.xls');
                Blob content = !Test.isRunningTest() ? report.getContent() : Blob.valueOf('Test');
                attachment.setBody(content);
                attachment.setContentType('application/vnd.ms-excel'); //  or text/csv
                lstAttachment.add(attachment);
    
            
              
                message.setFileAttachments(lstAttachment);
                message.setSubject('Report: ' + 'All Extracted Reports');
                message.setHtmlBody(content.toString());
                message.setToAddresses( new String[] {'[email protected]'} );
                System.debug('Send --'+ message);   
                lstEmail.add(message); 
            }         
            if(!lstEmail.isEmpty()){
                Messaging.sendEmail(lstEmail ); 
            }
        }
    }

     

  • Piyush

    Member
    September 3, 2019 at 7:49 am in reply to: Why can't we use DML and SOQL inside the for loop in Salesforce?

    Hi Achintya,

    By moving queries outside of for loops, your code will run faster, and is less likely to exceed governor limits. A common mistake is that queries are placed inside a for loop. There is a governor limit that enforces a maximum number of SOQL queries. When queries are placed inside a for loop, a query is executed on each iteration and governor limit is easily reached. Instead, move the SOQL query outside of the for loop and retrieve all the necessary data in a single query.

  • Piyush

    Member
    August 30, 2019 at 8:03 am in reply to: How can we get picklist values dynamically in Apex in Salesforce?

    Hi Achintya,

    First get describefieldresult by using this code: Schema.DescribeFieldResult dfr = Schema.sObjectType.Account.fields.status;

    Then, get picklist values by suing this code: getPicklistValues() methods available in Schema.DescribeFieldResult object.

  • Hi Yogesh,

    You should really keep this type of logic out of a Visualforce page. A Visualforce page should be used simply for View logic.

    Apex:-

    public Boolean getRenderPageBlockTable(){
        return mapToCheck.containsKey('keyToCheck');
    }

    Visualforce:-

    <apex:pageBlockSection rendered="{!renderPageBlockTable}">
        ...
    </apex:pageBlockSection>

     

     

Page 8 of 10