Forum Replies Created

Page 2 of 9
  • Abhinav

    Member
    August 16, 2016 at 10:26 am in reply to: How to ignore duplicate management rules and save update address?

    Hi Bhavesh,

    There must be Matching Rules on Account which are active in your org. This rules validate the address. There must be accounts exist in your org with the same address with which you are trying to create the new account.

    These are the standard salesforce rules which are by default active. When you will deactivate these it will allow you to save the records.

    These rules are to save the creation of duplicate records with either same address or email. If you dont require these rules please deactivate these and it will allow you to create the records.

    Thanks,

    • This reply was modified 8 years, 4 months ago by  Abhinav.
  • Abhinav

    Member
    August 11, 2016 at 4:39 pm in reply to: How can we dynamically create a chart using javascript?

    Hi Mohit,

    Below is the sample code :-

    <apex:page>
    <script>
    function getRemoteData(callback) {
    PieChartController.getRemotePieData(function(result, event) {
    if(event.status && result && result.constructor === Array) {
    callback(result);
    }
    });
    }
    </script>

    <apex:chart data="getRemoteData" ...></apex:chart>
    </apex:page>

    @RemoteAction
    public static List<PieWedgeData> getRemotePieData() {
    List<PieWedgeData> data = new List<PieWedgeData>();
    data.add(new PieWedgeData('Jan', 30));
    data.add(new PieWedgeData('Feb', 15));
    data.add(new PieWedgeData('Mar', 10));
    data.add(new PieWedgeData('Apr', 20));
    data.add(new PieWedgeData('May', 20));
    data.add(new PieWedgeData('Jun', 5));
    return data;
    }

  • Abhinav

    Member
    August 11, 2016 at 4:37 pm in reply to: How can we export selected record by checkbox in a table view?

    Hi Mohit,

    Here is the sample code :-

    <apex:page controller="ExportToExcelMultipleSheets" contentType="txt/xml#myTest.xls" cache="true">
    <apex:outputText value="{!xlsHeader}"/>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:html="http://www.w3.org/TR/REC-html40">
    <Styles>
    <Style ss:ID="s1">
    <Alignment/>
    <Borders/>
    <Font ss:Bold="1"/>
    <Interior/>
    <NumberFormat/>
    <Protection/>
    </Style>
    </Styles>
    <Worksheet ss:Name="Accounts">
    <Table x:FullColumns="1" x:FullRows="1">
    <Column ss:Width="170"/>
    <Row>
    <Cell ss:StyleID="s1"><Data ss:Type="String" >Account Name</Data></Cell>
    </Row>
    <apex:repeat value="{!accountList}" var="account">
    <Row>
    <Cell><Data ss:Type="String">{!account.name}</Data></Cell>
    </Row>
    </apex:repeat>
    </Table>
    </Worksheet>
    <Worksheet ss:Name="Contacts">
    <Table x:FullColumns="1" x:FullRows="1">
    <Column ss:Width="170"/>
    <Column ss:Width="280"/>
    <Column ss:Width="330"/>
    <Row>
    <Cell ss:StyleID="s1"><Data ss:Type="String" >Contact Name</Data></Cell>
    <Cell ss:StyleID="s1"><Data ss:Type="String" >Email</Data></Cell>
    <Cell ss:StyleID="s1"><Data ss:Type="String" >Account Name</Data></Cell>
    </Row>
    <apex:repeat value="{!contactList}" var="contact">
    <Row>
    <Cell><Data ss:Type="String">{!contact.name}</Data></Cell>
    <Cell><Data ss:Type="String">{!contact.email}</Data></Cell>
    <Cell><Data ss:Type="String">{!contact.account.name}</Data></Cell>
    </Row>
    </apex:repeat>
    </Table>
    </Worksheet>
    </Workbook>
    </apex:page>

    public with sharing class ExportToExcelMultipleSheets {

    public List<account> accountList{get;set;}
    public List<contact> contactList{get;set;}
    public String xlsHeader{
    get{
    String strHeader = '';
    strHeader += '<?xml version="1.0"?>';
    strHeader += '<?mso-application progid="Excel.Sheet"?>';
    return strHeader;
    }
    }
    public ExportToExcelMultipleSheets(){
    accountList = [select Name,Id from Account LIMIT 10];
    contactList = [SELECT id,Name, LastName, Account.Name, Email FROM Contact WHERE Email != '' AND Account.Name != '' LIMIT 5];
    }
    public Pagereference exportAll(){
    return new Pagereference('/apex/exportAll');
    }
    }

    I hope this helps.

  • Hi Mohit,
    Apex:inputField does not have the attribute "disabled". You may have to do this through rendering or jQuery.

    Below is the sample code for rendering :-
    Sample Code:

    Visualforce page:

    <apex:page controller="sample">

    <script type="text/javascript">

    </script>

    <apex:form >

    <apex:pageMessages />

    <apex:pageBlock >
    <apex:pageBlockSection columns="2">
    <apex:pageblockSectionItem >
    <apex:outputLabel value="Metro"/>
    </apex:pageblockSectionItem>
    <apex:pageblockSectionItem >
    <apex:inputCheckbox value="{!metro}">
    <apex:actionSupport event="onchange" reRender="a" action="{!demo}"/>
    </apex:inputCheckbox>
    </apex:pageblockSectionItem>
    <apex:pageblockSectionItem >
    <apex:outputLabel value="City"/>
    </apex:pageblockSectionItem>
    <apex:pageblockSectionItem >
    <apex:inputField value="{!city}" id="a" disabled="{!bool}"/>
    </apex:pageblockSectionItem>
    </apex:pageBlockSection>
    </apex:pageBlock>

    </apex:form>

    </apex:page>

    Apex Code:

    public class sample
    {
    public Boolean metro {get;set;}
    public Boolean city {get;set;}
    public Boolean bool {get;set;}

    public sample()
    {

    }

    public void demo()
    {
    if(metro)
    {
    bool = true;
    }
    else
    {
    bool = false;
    }
    }

    }

  • Abhinav

    Member
    August 11, 2016 at 4:11 pm in reply to: How to get code coverage programmatically through Apex?

    Hi Tanu,

    For synchronous testing: The RunTestsResult returned by calling ApexService.runTests() contains a codeCoverage property, which is a CodeCoverageResult array.

    The CodeCoverageResult locationsNotCovered property gives you the line number and column of code that wasn't tested in the run.

    My experience with this is that it will return code coverage results for any class that gets touched by the test case(s) and you don't get any control over it. Also, it isn't a cumulative view of the code coverage, only what is covered by that specific test run. So you can get lots of results indicating very low code coverage for classes that weren't being targeted by the test cases in the run but might otherwise have really good coverage.

  • Abhinav

    Member
    August 11, 2016 at 4:09 pm in reply to: Why we can't perform DML operations in Constructor?

    Hi Tanu,

    Using insert/update/delete in constructor is a bad practice in any language.

    Establishing connection to DB - OK.
    Constructor is used to create an object and initialize it's parameters; nothing more.
    1. Using DML in constructor will slow down initialization of your object.

    2. It may fail and object just doesn't create at all.

  • Abhinav

    Member
    August 11, 2016 at 4:05 pm in reply to: How to convert a Set to Set in Apex Salesforce?

    Hi Tanu,

    Yes, here is the sample code :-

    Set<Id> ids = new Set<Id>{'001C000001DgWqW','001C000001DgWsE'};
    Set<String> idStrs = (Set<String>)JSON.deserialize(JSON.serialize(ids), Set<String>.class);

    System.debug('idStrings=' + idStrs);

  • Abhinav

    Member
    August 11, 2016 at 3:59 pm in reply to: How can I access javascript function in lightning component?
  • Hi Pranav,

    Please refer to the code below :-

    <apex:page controller="AccountRec_Barchart" docType="html-5.0" title="Bar chart" >
    <apex:form >

    <apex:outputText value="from Date">
    </apex:outputText>
    <apex:input type="date" value="{!fromdate}"/>
    <apex:outputText value="ToDate"></apex:outputText>
    <apex:input type="date" value="{!todate}" />
    <apex:commandButton value="submit" action="{!submit}" reRender="chartid" />

    </apex:form>

    <apex:chart id="chartid" height="300" width="650" data="{!data}" colorSet="2A98DC" resizable="true" >

    <apex:axis type="Numeric" position="left" fields="count" title="Recordcount" minimum="0" grid="false" />
    <apex:axis type="Category" position="bottom" fields="billingcityname" title="billingcity" />
    <apex:barSeries orientation="vertical" axis="left" xField="billingcityname" yField="count">

    </apex:barSeries>

    </apex:chart>

    <apex:chart height="300" width="650" data="{!data}" resizable="true">
    <apex:pieSeries tips="true" dataField="count" labelField="billingcityname"></apex:pieSeries>
    <apex:legend position="right"/>
    </apex:chart>

    </apex:page>

     

    public class AccountRec_Barchart
    {
    public date fromDate{set;get;}
    public date todate{set;get;}
    public list<aggregateresult> listaggregate= new list<aggregateresult>();
    public list<barchartdata> lb = new list<barchartdata>();

    public void submit()
    {
    listaggregate = [select billingcity, COUNT(Id) n
    from Account
    where createddate > : fromDate and createddate <:todate
    group by billingcity
    HAVING billingcity like '%'];
    }

    public barchartdata[] getdata()
    {
    system.debug('getdata');
    barchartdata[] datachart = new barchartdata[]{};

    for(aggregateresult a :listaggregate)
    {
    datachart.add(new barchartdata(a));
    }
    return datachart;
    }

    // wrapper class
    public class barchartdata
    {
    public string city {set;get;}
    public integer count{set;get;}
    public string billingcityname{set;get;}
    barchartdata(aggregateresult result)
    {
    this.count = (Integer) result.get('n');
    this.city = (string) result.get('billingcity');
    this.billingcityname = city+'';
    }
    }
    }

    I hope this helps.

     

  • Abhinav

    Member
    August 11, 2016 at 3:54 pm in reply to: Why there is some debug is missing while checking in debug log?

    Hi Pranav,
    Your log will need to be significantly smaller as the skipped section is over 7MB.

    One way to reduced the log size is to adjust the logging levels. See Setting Debug Log Filters.

    You could keep the Apex Code Log Level set to DEBUG and then reduce the other categories to be off.

  • Abhinav

    Member
    August 11, 2016 at 3:34 pm in reply to: Sobjet detail page in lightining

    Hi Ajit,

    Here is the link which will help you to build the lightning component. Please refer to this link  :-

    https://trailhead.salesforce.com/en/projects/slds-lightning-components-workshop

    I hope this helps.

  • Abhinav

    Member
    August 9, 2016 at 8:41 am in reply to: Restricting characters and removing space at the end of a field?

    Hi Tanu,

    You can use this formula example to validate against usage of those special characters and checking if there are spaces at the end.

    OR(
    CONTAINS( Text_Field__c , "'"),
    CONTAINS( Text_Field__c , '"'),
    CONTAINS( Text_Field__c , ","),
    CONTAINS( Text_Field__c , "*"),
    CONTAINS( Text_Field__c , "%"),
    CONTAINS( Text_Field__c , "@"),
    CONTAINS(RIGHT(Text_Field__c, 1), " ")
    )

    I hope this helps.

     

  • Abhinav

    Member
    August 9, 2016 at 8:38 am in reply to: How to use captcha image in visualforce page?

    Hi Pranav,

    Please refer to the link below. I hope this will help.

    https://developer.salesforce.com/page/Adding_CAPTCHA_to_Force.com_Sites

  • Abhinav

    Member
    August 8, 2016 at 3:36 pm in reply to: How can we find the unused method in apex class?

    Hi Mohit,

    The Tooling API can be used to retrieve the SymbolTable for each apex class. This Symbol Table will tell you the methods that are defined in the apex class, and the references to methods that are consumed in the externalReferences.

    By scanning the methods and corresponding references in each apex classes symbol table you can find methods that aren't called by other apex classes.

    Happily, Andrew Fawcett has already made such a tool as a canvas app. See Spring Cleaning Apex Code with the Tooling API.

    Note, as this is only scanning the apex classes it won't detect declarative references from Visualforce markup.

  • Abhinav

    Member
    August 8, 2016 at 1:55 pm in reply to: How to add error message in a Salesforce Apex Trigger?

    Hi Pranav,

    Test__c trigObj = trigger.newMap.get(Test.id);
    if(trigObj != null){
    trigObj.addError('Cloned record should not have the same period as that of Parent record');
    }

  • Hi Pranav,

    You can use the following query :- SELECT Id, Name FROM RecentlyViewed WHERE Type IN ('Account', 'Contact')ORDER BY LastViewedDate DESC

  • Hi Tanu,

    Please go through this link :- http://salesforce.stackexchange.com/questions/4102/creating-a-custom-list-view-button-that-handles-multi-record-selection.

    I hope this helps.

  • Abhinav

    Member
    August 8, 2016 at 1:44 pm in reply to: Why the reRender function in visualforce page is not working?

    Hi Mohit,

    Please use the output panel above it and provide the Id to the panel. Instead of rerender on the page block =, rerender the output panel.

  • Abhinav

    Member
    August 6, 2016 at 9:16 am in reply to: Account records do not match

    Hi Bruce,

    We can filter the salesforce report such that it should not display the deleted records. Then we can get the same number of records as that with the Excel using Excel Connector.

    Thanks,

  • Hi Mohit,

    You can use the attachment object to store or for reference of the attachment and using the object you can download the files. I hope this helps.

  • Abhinav

    Member
    August 5, 2016 at 11:29 am in reply to: WhoID is null when send email in sandbox on Contacts

    Hi Jitesh,

    This is the wiered case. You may have to contact to the salesforce support. Or through log a case.

     

    • This reply was modified 8 years, 4 months ago by  Abhinav.
  • Abhinav

    Member
    August 5, 2016 at 11:28 am in reply to: Sharepoint Salesforce Integration - How to get download link?

    Hi Sourabh,

    You can use the attachment object to store or for reference of the attachment and using the object you can download the files. I hope this helps.

  • Hi Pranav,

    If no size is specified with the optional scope parameter of Database.executeBatch, Salesforce chunks the records returned by the start method into batches of 200. The system then passes each batch to the execute method. Apex governor limits are reset for each execution of execute.

  • Abhinav

    Member
    August 2, 2016 at 5:42 pm in reply to: How can we track the status of an email sent to the customer?

    Hi Mohit,

    Enable Email Tracking (Setup > Customize > Activities > Activity Settings) must be enabled, and the template or email must be sent in HTML mode only. Tracking status is not available in text-only templates, text-only email mode, or Visualforce template that uses only plain text.

  • Hi Mohit,

    Yes you can send the value. Call the <apex:actionFunction> from the javascript. Then using <apex:param> send the value to the controller.

Page 2 of 9