Abhinav Bhatia
IndividualForum Replies Created
-
Abhinav
MemberAugust 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
MemberAugust 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
MemberAugust 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> -
Abhinav
MemberAugust 1, 2016 at 1:44 pm in reply to: How to change the text field entered data into a particular format?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
MemberAugust 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
MemberAugust 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
MemberAugust 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
MemberAugust 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.
-
Abhinav
MemberJuly 29, 2016 at 1:25 pm in reply to: If we want to show the home page component on the particular sobject page?Looks like we cannot show it. But still i am looking into this and will update you.
-
Abhinav
MemberJuly 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> -
Abhinav
MemberJuly 29, 2016 at 1:20 pm in reply to: How can I filter an embedded report by a parent's record to show related records ?Hi Tanu,
In this case you have to create the inline visualforce which is the best approach.
-
Abhinav
MemberJuly 29, 2016 at 1:16 pm in reply to: If we want to show the home page component on the particular sobject page?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.
-
Abhinav
MemberJuly 29, 2016 at 1:13 pm in reply to: Is there any method to limit the maximum number of characters that can be typed into input field in Salesforce?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;
}
}
}) -
Abhinav
MemberJuly 28, 2016 at 2:58 pm in reply to: Can we apply the Record Type in sobject when trigger is fired.How?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
MemberJuly 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
MemberJuly 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
MemberJuly 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}); -
Abhinav
MemberJuly 25, 2016 at 5:22 pm in reply to: Is there any way to get the last inserted or updated recorded data. How?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
MemberJuly 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.
-
Abhinav
MemberJuly 25, 2016 at 5:06 pm in reply to: In Lightning Experience , Is the standard button Save & New not available or it can be enable from somewhere?Hi Pranav,
Looks like currently this is not available.
- This reply was modified 8 years, 4 months ago by Abhinav.
-
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. -
Abhinav
MemberJuly 22, 2016 at 3:42 pm in reply to: Is there any method to test a Visualforce page like an apex class?Hi Pranav,
Are you using Visualforce component or you need to cover the test class of Visualforce Page Controller?
-
Abhinav
MemberJuly 22, 2016 at 3:38 pm in reply to: How to email to all contacts associated with Account when the Account is updated ?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/
-
Abhinav
MemberJuly 22, 2016 at 3:34 pm in reply to: How can we manually cover the catch block(in try catch block) in apex test class?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
MemberJuly 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.