Forum Replies Created

Page 6 of 8
  • Aman

    Member
    April 25, 2018 at 7:54 am in reply to: How to enable schedule report options in Salesforce?

    Hi Rahul,

    you can follow the following steps :

    1. Enter profiles in the quick find box and select profiles.
    2. open a profile.
    3. search for schedule report.

    profile

  • Hi,

    Below is the code for test class. Below code providing 100% coverage.

    @istest
    public class SetPriceDemoTest {
    @istest
    public static void mytest()
    {
    Id pricebookId = Test.getStandardPricebookId();
    pricebook2 pb = new pricebook2(id=pricebookId,isActive=true);
    update pb;
    Product2 po=new Product2();
    po.Name='Raghav';
    po.IsActive=true;
    insert po;
    }
    }

  • Hi,

    Below is the code for your test class :

    @istest(SeeAlldata=true)
    public class SetPriceDemoTest {
    @istest
    public static void mytest()
    {
    Product2 po=new Product2();
    po.Name='Raghav';
    po.IsActive=true;
    insert po;
    }
    }

  • Aman

    Member
    April 23, 2018 at 11:11 am in reply to: Can we call a future method from a Salesforce batch class using Apex?

    Hi ,

    we can't call future method from batch class. If you try to invoke a future method from Batch/Future you will get the below error -

    FATAL ERROR: Future method cant be called from future or Batch

  • Hi Raghav,

    You have not inserted the standard price book in your test class and you are querying the standard pricebook in your trigger. Insert a standard pricebook in your test class and run the test class again, it will work.

     

  • Hi Deepika ,

    you cannot query the list of junction objects using apex code but what you can do is query all the Sobjects  using the schema class, below is the code to do :

    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    system.debug('gd:::::'+gd);

  • Aman

    Member
    April 19, 2018 at 12:48 pm in reply to: How to hide "display:none" in html tag on a Visualforce Page Component?

    Hi,

    I will look into it and will let you know.

  • Aman

    Member
    April 19, 2018 at 11:11 am in reply to: How to hide "display:none" in html tag on a Visualforce Page Component?

    Hi,

    Here the JavaScript is not executing. The reason is that when we add <apex:inputTextarea richText="true" ... it add hidden text area and its own iframe that shows as a text editor So when you add events to your text area its not get added to the text area which is displayed to user.

     

  • can you please send the controller extension code ? so that i can try it at my end.

  • Hi Harsh ,

    You can replace the display :none by display : block. It will let you show your upload image Tab. One more thing if you want to render this tab after some action performed ,you can write a script but for that add an id to your html tag and add the below code to your script

    document.getElementById("UploadImage").style.display = "block";

  • Hello Shubham ,

    you can try this :

    server-side Controller :

    public class SearchAcc {
    @AuraEnabled
    public static List<Account> getAccList(){
    List<Account> acct=[select name,AccountNumber,phone,Description from account Limit 100];
    return acct;
    }

    @AuraEnabled
    public static Account getAcc(String ID){
    return[select name,Phone,Description from account where id= :ID];
    }
    }

    Component :

    <aura:component controller="SearchAcc" >
    <aura:registerEvent name="AccEvent" type="c:AccountDetailsEvent"/>
    <aura:attribute name="Accounts" type="Account[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.getList}"/>
    <aura:iteration items="{!v.Accounts}" var="acc">
    <h1><a id="{!acc.Id}" title="click me to do something" href="#" onclick="{!c.getID}" >
    {!acc.Name}</a>
    </h1>
    </aura:iteration>
    </aura:component>

    client-side controller :

    ({
    getList : function(component, event, helper) {
    var action = component.get("c.getAccList");
    action.setCallback(this,function(response){
    var state = response.getState();
    if(state == "SUCCESS"){
    alert('success')
    component.set("v.Accounts",response.getReturnValue());

    }
    });
    $A.enqueueAction(action);

    },
    getID: function(component, event, helper) {
    var Ide = event.srcElement.id;
    var action= component.get("c.getAcc");
    action.setParams({ ID :Ide });
    action.setCallback(this, function(response) {
    var state = response.getState();
    if (state === "SUCCESS") {
    // console.log(response.getReturnValue());
    }
    var Eve=component.getEvent("AccEvent");
    Eve.setParams({ "Reqdata" :response.getReturnValue()});
    console.log(Eve.getParam("Reqdata"))
    Eve.fire();
    });
    $A.enqueueAction(action);
    }
    })

     

    • This reply was modified 7 years, 2 months ago by  Aman.
  • Aman

    Member
    August 28, 2017 at 1:33 pm in reply to: How to find (trigger.meta.xml) file of any Trigger in Salesforce?

    Hello Shubham,

    you can use Ant Migration to retrieve trigger.meta.xml  use command Ant retrieveUnpackaged by specify the name of the trigger in your package.xml file.

    your package.xml file look like this :

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
    <members>AddNameAcc</members>
    <name>ApexTrigger</name>
    </types>
    <version>40.0</version>
    </Package>

  • Aman

    Member
    August 28, 2017 at 10:54 am in reply to: SOQL Query ( Accounts and Contacts ) in Salesforce

    Hello Rahul ,

    you can try this :

    public class SearchCont {
    public static List<Account> acct;
    public static List<AggregateResult> aggRes;
    public static void contSearch(){
    List<String> ide=new List<String>();
    aggRes =[select accountId,count(id) from contact where account.name !=null group by accountId having count(id) >1];
    for (AggregateResult ar : aggRes) {
    ide.add((String)ar.get('accountId'));
    }
    acct=[select name,(select LastName,FirstName from contacts) from account where id in :ide ];
    for(account acc: acct){
    system.debug('###'+acc);
    for(contact con: acc.contacts){
    system.debug('###'+con.LastName);
    system.debug('###'+con.FirstName);

    }
    }
    }
    }

  • Aman

    Member
    August 22, 2017 at 6:28 am in reply to: Custom Setting

    Hello Vijay,

    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.

    you can refer to the below given link :

    https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_customsettings.htm

  • Aman

    Member
    August 11, 2017 at 7:25 am in reply to: Salesforce Trigger order of execution

    Hello Uday,

    you can try this :

    trigger Handler :

    public class triggerHandler {
    public static boolean fact=true;

    }

    trigger :

    trigger ContactUp on Contact (after insert,after update) {
    if(triggerHandler.fact==true ){
    triggerHandler.fact=false;
    List<Contact> li123=[select id from contact where id in :trigger.new];
    system.debug('####################');
    for(contact con :li123){
    con.description ='aaaaaaaaaaaaaaaa';
    }
    update li123;
    }
    }

  • Hello shubham,

    SingleEmailMessage Methods :
    Contains methods for sending single email messages.
    Namespace
    Messaging
    Usage
    All base email (Email class) methods are also available to the SingleEmailMessage objects.

    Email properties are readable and writable. Each property has corresponding setter and getter methods. For example, the toAddresses() property is equivalent to the setToAddresses() and getToAddresses() methods. Only the setter methods are documented.

    EmailFileAttachment Class :
    EmailFileAttachment is used in SingleEmailMessage to specify attachments passed in as part of the request, as opposed to existing documents in Salesforce.

  • Aman

    Member
    August 10, 2017 at 1:41 pm in reply to: How to get csv file in a web service post method in Salesforce?

    Hello Shariq,

    you can try this :

    @RestResource(urlMapping='/contactCsv/*')
    global class RESTContactController {
    @HttpPost
    global static void newContacts(){
    RestRequest req = RestContext.request;
    System.debug('csv'+req);
    }
    }

  • Aman

    Member
    August 10, 2017 at 7:16 am in reply to: What is Log inspector in Salesforce?

    Hello Shubham,

    The handy Log Inspector exists to make it easier to view large logs! The Log Inspector uses log panel views to provide different perspectives of your code. Check it out by selecting Debug | View Log Panels.

    These panels are available in the Log Inspector.
    Stack Tree—Displays log entries within the hierarchy of their objects and their execution using a top-down tree view. For instance, if one class calls a second class, the second class is shown as the child of the first.
    Execution Stack—Displays a bottom-up view of the selected item. It displays the log entry, followed by the operation that called it.
    Execution Log—Displays every action that occurred during the execution of your code.
    Source—Displays the contents of the source file, indicating the line of code being run when the selected log entry was generated.
    Source List—Displays the context of the code being executed when the event was logged. For example, if you select the log entry generated when the faulty email address value was entered, the Source List shows execute_anonymous_apex.
    Variables—Displays the variables and their assigned values that were in scope when the code that generated the selected log entry was run.
    Execution Overview—Displays statistics for the code being executed, including the execution time and heap size.

  • Aman

    Member
    August 9, 2017 at 6:10 am in reply to: How to insert all contact list using map?

    Hello Shariq,

    you can try this  :

    List<contact> conList =new List<contact>();

    for(Id ide :mapAccIdVsCon.keySet())
    {
    for(Contact c : mapAccIdVsCon.get(ide))
    {
    conList.add(c);
    }
    }
    insert conList;

  • Aman

    Member
    August 8, 2017 at 12:38 pm in reply to: pageblockSection is not rendered on click of commandButton

    Hello Saloni,

    You can try  this :

    VF page;-

    <apex:page controller="SearchAccountCon" tabStyle="Account">
    <apex:form >

    <apex:inputText value="{!searchString}" />
    <apex:commandButton value="search" action="{!search}" rerender="pageblId"/>

    <apex:pageBlock >
    <apex:pageBlockTable value="{!acct}" var="acc" id ="pageblId">
    <apex:column headerValue="Acccount Name" >
    <apex:commandLink value="{!acc.name}" action="{!getCont}" reRender="LinkId" >
    <apex:param value="{!acc.Id}" name="LinkCont" assignTo="{!SearchId}"/>
    </apex:commandLink>
    </apex:column>
    <apex:column >
    <apex:pageBlockTable value="{!cont}" var="con" id="LinkId">
    <apex:column value="{!con.LastName}"/>
    <apex:column value="{!con.id}"/>
    </apex:pageBlockTable>
    </apex:column>

    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
    </apex:page>

    Apex class :

    public class SearchAccountCon {
    public String SearchId{get;set;}
    public String searchString {get; set; }
    public List<Account> acct{get;set;}
    public List<contact> cont{get;set;}
    public void search(){

    acct= Database.query('Select Name, description From Account WHERE Name LIKE \'%'+searchString+'%\' Limit 100');
    cont = new List<contact>();

    }
    public void getCont(){
    cont=[select id,LastName,accountId from contact where accountID =:SearchId];
    }
    }

  • Aman

    Member
    August 8, 2017 at 12:32 pm in reply to: What is the difference between Render vs Rerender in Salesforce?

    Hello Shubham,

    Rendered :

    A visualforce component in a VF page can be displayed or hidden by using rendered attribute. Rendered is bound to a Boolean variable in controller which can be switched between true and false making the vf component display or hide depending on Boolean value.

    ReRender :
    Rerender is used to refresh a particular section of the visualforce page. We have to just mention the id of the page section (in the Rerender attribute) that needs to be refreshed.

    you can refer to this Link :

    http://sfdcsrini.blogspot.com/2014/08/what-is-difference-between-rendered.html

  • Hello Raghav,

    you can try this :

    public class CountContacts {

    public static void getAllContact(){
    Map<Id,Integer> AccountIdVsContact = new Map<Id,Integer>();
    Set<Id> accid =new Set<Id>();
    List<contact> cont =[select Lastname,accountId from contact Limit 100];
    system.debug('@@@@'+cont.size());
    for(contact con: cont){
    accid.add(con.accountid);
    }

    for(Id id :accid){
    AccountIdVsContact.put(id, [select Lastname,accountId from contact where accountid= :id].size());
    }
    system.debug('#####'+AccountIdVsContact.values());
    }
    }

  • Aman

    Member
    August 3, 2017 at 1:28 pm in reply to: How to query Custom settings in Salesforce Apex code?

    Hello shariq,

    There are two types of custom settings:
    List Custom Settings
    A type of custom setting that provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary with profile or user, but is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. Because the data is cached, access is low-cost and efficient: you don't have to use SOQL queries that count against your governor limits.
    Hierarchy Custom Settings
    A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

    You can query Custom Settings using following Methods :

    List Custom Setting Methods
    The following are instance methods for list custom settings.
    getAll()
    Returns a map of the data sets defined for the custom setting.
    getInstance(dataSetName)
    Returns the custom setting data set record for the specified data set name. This method returns the exact same object as getValues(dataSetName).
    getValues(dataSetName)
    Returns the custom setting data set record for the specified data set name. This method returns the exact same object as getInstance(dataSetName).

    Hierarchy Custom Setting Methods
    The following are instance methods for hierarchy custom settings.
    getInstance()
    Returns a custom setting data set record for the current user. The fields returned in the custom setting record are merged based on the lowest level fields that are defined in the hierarchy.
    getInstance(userId)
    Returns the custom setting data set record for the specified user ID. The lowest level custom setting record and fields are returned. Use this when you want to explicitly retrieve data for the custom setting at the user level.
    getInstance(profileId)
    Returns the custom setting data set record for the specified profile ID. The lowest level custom setting record and fields are returned. Use this when you want to explicitly retrieve data for the custom setting at the profile level.
    getOrgDefaults()
    Returns the custom setting data set record for the organization.
    getValues(userId)
    Returns the custom setting data set record for the specified user ID.
    getValues(profileId)
    Returns the custom setting data set for the specified profile ID.

  • Aman

    Member
    August 2, 2017 at 1:52 pm in reply to: What is the use of Metadata API in Salesforce?

    Hello saloni,

    Use Metadata API to retrieve, deploy, create, update or delete customization information, such as custom object definitions and page layouts, for your organization. This API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself. To create, retrieve, update or delete records, such as accounts or leads, use data SOAP API or REST API.

    you should refer to this Link :

    https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_intro.htm

  • Aman

    Member
    July 31, 2017 at 10:40 am in reply to: What is Database.SaveResult() in salesforce?

    Hello shariq,

    The result of an insert or update DML operation returned by a Database method.

    Usage
    An array of SaveResult objects is returned with the insert and update database methods. Each element in the SaveResult array corresponds to the sObject array passed as the sObject[] parameter in the Database method, that is, the first element in the SaveResult array matches the first element passed in the sObject array, the second element corresponds with the second element, and so on. If only one sObject is passed in, the SaveResult array contains a single element.

    A SaveResult object is generated when a new or existing Salesforce record is saved.

    you can refer to this link:

    https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database_saveresult.htm

     

Page 6 of 8