Forum Replies Created

Page 3 of 9
  • Abhinav

    Member
    August 1, 2016 at 4:34 pm in reply to: How can we use wrapper class in the Salesforce Visualforce page?

    Hi,

    You can use the wrapper class in <apex:repeat value="{!WrapperList}" var="wrap"> or you can use the wrapper class in <apex:pageBlockTable value="{!WrapperList}" var="wrap" id="table">

  • Abhinav

    Member
    August 1, 2016 at 1:52 pm in reply to: How can I apply trigger for lookup field update?

    Hi Pranav,

    Please associate the ID with that lookup field.

  • Abhinav

    Member
    August 1, 2016 at 1:48 pm in reply to: Is there any way to show the webpage in the flow ?

    Hi Pranav,

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

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

  • Hi Pranav,

    If you're doing this in a Field Update :-

    DATE(VALUE(LEFT(TextField__c, 4)), VALUE(RIGHT(TextField__c, 2)), 1)

    In apex code use the following -

    String dateString = '2014-09';
    Integer year = Integer.valueOf(dateString.subString(0, 4));
    Integer month = Integer.valueOf(dateString.subString(5));
    Date d = Date.newInstance(year, month, 1);

  • Abhinav

    Member
    August 1, 2016 at 1:41 pm in reply to: How do I programmatically get the instance address of a user?

    Hi Tanu,

    Please go through this link :- https://help.salesforce.com/apex/HTViewHelpDoc?id=remoteaccess_oauth_1_flows.htm&language=en#topic-title.

    I hope this helps.

  • Abhinav

    Member
    August 1, 2016 at 1:38 pm in reply to: How to define the records to be returned by SOSL search?

    Hi Pranav,

    Journal__c je = new Journal__c();
    je.Name = 'Test';
    je.UserID__c = UserInfo.getUserId();
    // Add all required Field here
    insert je;

    PageReference myVfPage = Page.MyJournal;
    Test.setCurrentPage(myVfPage);

    Id [] fixedSearchResults = new Id[]{je.Id};
    Test.setFixedSearchResults(fixedSearchResults);

    Please make sure that you have used Test.setFixedSearchResults(); before calling any method of the class.

    I hope this helps.

  • Abhinav

    Member
    August 1, 2016 at 1:31 pm in reply to: What is the formula to count the characters in a text field?

    Hi Tanu,

    LEN() - returns the number of characters in a text string.

    But LEN will count spaces as well.

    If you want just CHR counts, you will need to TRIM the string and then use LEN to return the number of CHR. If you do not want to count special ASCII CHR like ();: etc you will need to adjust some code for that as well.

  • Abhinav

    Member
    August 1, 2016 at 1:28 pm in reply to: How to Implement a component like “Recent Items” in Sidebar?

    Hi Tanu,

    You need to first create the Home Page component. After that you have to include that component on the home page layout.

    For Home Page component : -

    GoTo Setup -> Home page component.

    Home Page layout :-

    GoTo Setup -> Home page layout.

    I hope this helps.

  • Looks like we cannot show it. But still i am looking into this and will update you.

  • Abhinav

    Member
    July 29, 2016 at 1:22 pm in reply to: How to add music to a Salesforce Visualforce Page?

    Hi Tanu,

    To add video or music you can use the below sample :

    <apex:page showHeader="false" showChat="false" sidebar="false">
    <iframe width="560" height="315"
    src="http//myvideo.provider.com/embed/{!$CurrentPage.parameters.VideoID}"
    frameborder="0" allowfullscreen="true">
    </iframe>
    </apex:page>

  • Hi Tanu,

    In this case you have to create the inline visualforce which is the best approach.

  • Hi Mohit,

    If you have custom home page layouts that include components in the sidebar, this option makes the sidebar components available on all pages for all users in your organization. If you only want certain users to view sidebar components on all pages, grant those user the “Show Custom Sidebar On All Pages” permission.

  • Hi Pranav,

    Yes, you can call the below function :-

    ({
    limitCharacterTo : function(element, charLimit, evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if(element.value.length >= charLimit && charCode != 8) {
    return false;
    }
    }
    })

  • Hi Mohit,

    Yes, you can query the record type first on the basis of object.

    Please see the sample code below :-

    Id recordAccId = [select Id,name from RecordType where name='Accounts' and SObjectType='Account' limit 1].Id;

    And use the above recordAccId in the trigger. I hope this helps.

     

  • Abhinav

    Member
    July 26, 2016 at 10:19 am in reply to: How to Automatically Download attachments from opportunity?

    Hi Tanu,

    There is an app on appExchnage related to this. Here is the link :-

    https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003Iz0jEAC

  • Abhinav

    Member
    July 26, 2016 at 10:10 am in reply to: How to Create custom PDF Viewer with Save and Email buttons?

    Hi Tanu,

    Sure, it can be done. Below is the sample code :

    <apex:page standardController="Amount__c" extensions="AmountCreatePDFController" showHeader="true" tabStyle="Amount__c">
    <apex:sectionHeader title="Amount PDF" subtitle="Amount PDF"/>
    <apex:form >
    <apex:pageBlock >
    <apex:pageMessages id="Messages"></apex:pageMessages>
    <apex:iframe height="400px" width="800px" src="data:application/pdf;base64,{!pdf}></apex:iframe>
    <apex:pageBlockButtons location="bottom">
    <apex:commandButton action="{!save}" value="Save"/>
    <apex:commandButton action="{!cancel}" value="Cancel" />
    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
    </apex:page>

     

    public class AmountCreatePDFController
    {
    public String pdfurl{get;set;}
    private PageReference pdfPage;
    private Blob pdfBlob;

    public QuoteCreatePDFController(ApexPages.standardController sc)
    {
    initialize(sc.getId());
    }

    public override void initialize(blahId)
    {
    blah = [select whatever__c from Amount__c where id=:blahId];

    pdfPage = Page.Blah_Template;
    pdfPage.getParameters().put('id',blah.id);
    pdfBlob = pdfPage.getcontent();

    }
    public String pdf {
    get {
    return EncodingUtil.Base64Encode(pdfBlob);
    }
    }
    }

     

  • Abhinav

    Member
    July 25, 2016 at 5:27 pm in reply to: How can I export csv file of record through email in salesforce?

    Hi Pranav,

    Below is the sample code :-

    List<Account > acclist = [Select id,name , CreatedDate , lastModifiedDate from Account limit 10];
    string header = 'Record Id, Name , Created Date, Modified Date \n';
    string finalstr = header ;
    for(Account a: acclist)
    {
    string recordString = '"'+a.id+'","'+a.Name+'","'+a.CreatedDate+'","'+a.LastModifiedDate +'"\n';
    finalstr = finalstr +recordString;
    }
    Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
    blob csvBlob = Blob.valueOf(finalstr);
    string csvname= 'Account.csv';
    csvAttc.setFileName(csvname);
    csvAttc.setBody(csvBlob);
    Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
    String[] toAddresses = new list<string> {'[email protected]'};
    String subject ='Account CSV';
    email.setSubject(subject);
    email.setToAddresses( toAddresses );
    email.setPlainTextBody('Account CSV ');
    email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
    Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

  • Hi Mohit,

    Yes, we can get the last inserted record data. Please use the below query :-

    [Select id from Contact order by createdDate desc limit 1];

  • Abhinav

    Member
    July 25, 2016 at 5:09 pm in reply to: How to find the duplicate records in the external database?

    Hi Mohit,

    You can use one external key/primary key on the basis of that you can figure out duplicates in the external database.

  • Hi Pranav,

    Looks like currently this is not available.

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

    Member
    July 25, 2016 at 9:03 am in reply to: How to show Recently Used Tags?

    Hi Tanu,

    The Tags link and Recent Tags drop-down list, available in the sidebar, allow you to browse tags and access your most recently used tags.
    1. Click Tags to browse, search, and manage your entire tag collection.
    2. Select a tag in the Recent Tags drop-down list to view all records that have been marked with that tag. The tags that appear in this list are those you have most recently used to tag records.

  • Hi Pranav,

    Are you using Visualforce component or you need to cover the test class of Visualforce Page Controller?

  • Hi Pranav,

    Please refer to the link. I hope this helps and resolve your problem.

    http://www.salesforcetutorial.com/sending-email-to-all-contacts-of-an-account/

  • Hi Mohit,

    To cover the catch block you have to throw the exception in your test class. Sample for the callout exception.

    System.CalloutException in your mock:

    @TestVisible class UnauthorizedEndpointResponse implements HttpCalloutMock {
    public HttpResponse respond(HttpRequest request) {
    CalloutException e = (CalloutException)CalloutException.class.newInstance();
    e.setMessage('Unauthorized endpoint, please check Setup->Security->Remote site settings.');
    throw e;
    }
    }

    Then cause it to appear in your test with the normal HTTP mocks:

    Test.setMock(HttpCalloutMock.class, new UnauthorizedEndpointResponse());
    BatchClass.doTheCallout();

     

  • Abhinav

    Member
    July 21, 2016 at 8:56 am in reply to: How to extract the file extension into an custom field?

    Hi Tanu,

    Here is the sample code :-

    List<Attachment> attach = [SELECT Name FROM Attachment];
    for(Attachment a : attach){
    String nameField = a.Name;
    if(nameField.Contains('.'))
    system.debug(nameField.substringAfter('.'));
    }

    I hope this helps.

Page 3 of 9