Radhakrishna Makkena
IndividualForum Replies Created
-
Radhakrishna
MemberJune 20, 2017 at 9:05 am in reply to: How to Upload excel sheet from Salesforce Visualforce pages?Hello Vishant,
You can use CSV parser for this..please refer the below example code where I have created one Visualforce page from where I am uplaoding the excel file .csv and extracting the records data and mapping with object columns
please check and let me know if it helps you
page:
<apex:page sidebar="false" controller="UploadOpportunityScheduleLineItem">
<apex:form >
<apex:sectionHeader title="Upload data from CSV file"/>
<apex:pagemessages />
<apex:pageBlock >
<center>
<apex:inputFile value="{!contentFile}" filename="{!nameFile}" />
<apex:commandButton action="{!ReadFile}" value="Upload File" id="theButton" style="width:70px;"/>
<br/> <br/>
</center><apex:pageBlocktable value="{!mapUnmatchedSchedules}" var="mapID" title="Unmathed Lines of CSV file">
<apex:column headervalue="Opportunity Id">
{!mapUnmatchedSchedules[mapID][0]}
</apex:column>
<apex:column headervalue="Oportunnity Name">
{!mapUnmatchedSchedules[mapID][1]}
</apex:column>
<apex:column headervalue="Month">
{!mapUnmatchedSchedules[mapID][2]}
</apex:column>
<apex:column headervalue="Year">
{!mapUnmatchedSchedules[mapID][3]}
</apex:column>
<apex:column headervalue="Actualized Amount">
{!mapUnmatchedSchedules[mapID][4]}
</apex:column>
</apex:pageBlocktable>
</apex:pageBlock>
</apex:form>
</apex:page>
classpublic with sharing class UploadOpportunityScheduleLineItem
{// Global variables
public string nameFile{get;set;}
public Blob contentFile{get;set;}
List<Schedule__c> lstScheduleToUpdate = new List<Schedule__c>();
public Schedule__C objSchedule{get;set;}
//String array for taking csv data by line.
String[] filelines = new String[]{};
//string array for taking csv columns.
String[] fileColumns = new String[]{};//set for storing all id's from csv.
set<String> opptoupload{get;set;}
//map for storing data from csv.
public map<String,String> mapOppIDMonthYearToAccAmount{get;set;}
public map<String, List<String>> mapUnmatchedSchedules{get;set;}//Main constructor
public UploadOpportunityScheduleLineItem()
{
//Initalizing required objects.
objSchedule = new Schedule__c();
opptoupload = new set<String>();
mapOppIDMonthYearToAccAmount = new map<String,String>();
mapUnmatchedSchedules = new map<String, List<String>>();
}
//Method to read file content and check extension and file format.
public Pagereference ReadFile()
{
//If without selecting csv file you clicked on upload it will give error message.
if(nameFile == null)
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'You should select csv file to upload');
ApexPages.addMessage(errormsg);
return null;
}
//Taking file extension.
String extension = nameFile.substring(nameFile.lastIndexOf('.')+1);
//Checking if file extension is .csv.
if(extension == 'csv' ||extension == 'CSV')
{
nameFile=contentFile.toString();
//Spliting by new line
filelines = nameFile.split('\n');
//Spliting values by (,) for checking coloumn size
fileColumns = filelines[0].split(',');
//If column size is 5 then only it will proceed.
if(fileColumns.size() ==5)
{
for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');
opptoupload.add(inputvalues[0]);mapOppIDMonthYearToAccAmount.put(inputvalues[0]+inputvalues[2]+inputvalues[3],inputvalues[4]);
mapUnmatchedSchedules.put(inputvalues[0]+inputvalues[2]+inputvalues[3],inputvalues);
lstScheduleToUpdate = new List<Schedule__c>();
}
for(Schedule__c objSchedule : [select Opportunity__r.Id ,Month__c,Year__c,
Actualized_Amount__c from Schedule__c where
Opportunity__c IN :opptoupload])
{
String str = objSchedule.Opportunity__r.Id;
String str1;
str1 = str.substring(0, 15);
if(mapOppIDMonthYearToAccAmount.containsKey(str1 + objSchedule.Month__c +objSchedule.Year__c))
{objSchedule.Actualized_Amount__c = decimal.valueOf(mapOppIDMonthYearToAccAmount.get(str1 + objSchedule.Month__c +objSchedule.Year__c).trim());
mapUnmatchedSchedules.remove(str1 + objSchedule.Month__c +objSchedule.Year__c);
lstScheduleToUpdate.add(objSchedule);
}
}
//Checking if list is not empty then updating.
if(lstScheduleToUpdate.Size()>0)
{
update lstScheduleToUpdate;
}
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.info,'File uploaded successfully');
ApexPages.addMessage(errormsg);return null;
}
else
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'There should be 5 columns in csv file');
ApexPages.addMessage(errormsg);
return null;
}
return null;
}
//If file is not csv type then it will give error message.
else
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'File type should be csv type');
ApexPages.addMessage(errormsg);
return null;
}
}
}Also, please mark this as best answer if it solves your issue...let me know if anything else needed.
-
Radhakrishna
MemberJune 14, 2017 at 10:25 am in reply to: How can I delete Streaming API Push Topics in salesforce?Hi Suraj,
Go to workbench ,login with your salesforce credentials.
Select queries -> Streaming Push Topics -> select your push topic and click on delete button
-
Radhakrishna
MemberJune 14, 2017 at 5:54 am in reply to: How to Generate a conga report with salesforce custom object.Hello Upendra,
Conga Composer doesn't support joined reports, it supports the use of up to 50 unique Salesforce Reports or SOQL Queries as data sets in a single merge process. It sounds like you can't include both of your target objects in a non-joined report, so I'd recommend using 2 separate reports that span the respective Account->Acts and SP->Trgt relationships and then including both reports in your Conga Composer button URL. The parameter syntax will look a little something like:
&ReportID=[Your1stAliasGoesHere]00Oxxxxxxxxxxxx,[Your2ndAliasGoesHere]00Oxxxxxxxxxxxx
This article in our KnowledgeBase explains how to add reports to a button URL: Click here
I hope this helps, but please feel free to contact our support team at any time to get hands-on assistance with your solution: https://support.getconga.com/
-
Radhakrishna
MemberJune 13, 2017 at 4:20 am in reply to: Email Template in salesforce Marketing CloudHello Vikas,
This may help you
https://help.salesforce.com/articleView?id=admin_emailtemplates.htm&type=0
-
Radhakrishna
MemberJune 13, 2017 at 4:10 am in reply to: How to do Salesforce to Salesforce integration using Rest API?Hello Rajesh,
One of the ways to Integrate two Salesforce Instances will be using oauth for session management and using REST API
Lets Assume you have SalesforceA as Source ORG and SalesforceB as Destination ORG .Now lets assume flow of data is from SalesforceA to SalesforceB Instance
1) For oauth 2.0 in Destination org(SalesforceB) create a Connected App .To help you configure the Connected App in Destination below screenshot should assist.Callback Url may not be of any significant as we are using User-Name Password flow model.You will obtain client secret, consumer key in this process and one should store in Source org custom object or custom setting
2) In your source org create a Remote site settings with url as the URL of the Destination Instance
3) Create a Integration User in the Destination org whose credentials you will use to call API from Salesforce Source ORG
4) Use the username, password and security token(Also i would prefer setting password never expires here for integration User) and also client secret and consumer key in a custom object or custom setting (Protected) in Source org.
-
Radhakrishna
MemberJune 1, 2017 at 10:15 am in reply to: Confirm box on submit for Salesforce Lightning Button does not appearuse below code add new attribute type="submit" in Salesforce lightning button
<lightning:button label="Delete"
iconName="utility:delete"
iconPosition="left"
variant="destructive"
type="submit"
/> -
Radhakrishna
MemberMay 31, 2017 at 9:06 am in reply to: How to make Formula Field indexed in Salesforce?Hi Manpreet,
The list below details some important criteria to see if your request is a good fit for a custom index.
1. Record count for the indexed object must be greater than 1,000 rows (greater than 10,000 rows is recommended to be of significant benefit).
2. Queries should take 5 seconds or more to process. Note that sometimes queries are slow the first run, then fast due to caching of the query results.
3. Query must contain a WHERE clause with a value that somewhat unique (i.e., the custom index should be able to filter out ~ 90% of the records). For example if the query is [SELECT AccountId FROM Contact WHERE LastName = 'Smith'], less than 10% of the Contact records can be 'Smith' for the custome index to be effective. For queries without WHERE clauses, custom indexes will not help performance.
4. Some commonly used fields, external id fields, and reference (lookup/master-detail) fields are already standard indexed. Formula fields and certain other fields cannot be custom indexed.
5. Customers can request that a particular field be indexed; however, they need to understand that it is not always beneficial to index all or some the field(s) they have requested.
6. For SOQL queries executed in Apex, it is common for developers to embed data binding variables to make the query dynamic; however, for analyzing the query for custom indexing, we need to know the typical values that will actually be used at runtime. For example, in the customer's Apex classes or triggers, they might have a query that looks like this:
Opportunity[] opp = [SELECT Name FROM Opportunity WHERE Amount > :minValue AND Amount < :maxValue];
Before anlyzing the query, we need to know what the typical values for :minValue and :maxValue will actually be. Please provide a few sample values and incidate if any of them will be null.
Thank you
-
Radhakrishna
MemberMay 26, 2017 at 8:31 am in reply to: Can we use a timer for other integrated API in Lightning Component?http://enreeco.blogspot.it/2014/10/salesforce-lightning-loading-scripts.html
Use RequireJS to load whatever script you want.
Hope this helps -
Radhakrishna
MemberMay 5, 2017 at 7:03 am in reply to: Difference between JavaScript Remoting and ActionFunction in Salesforce?Hello Manpreet,
ACTION FUNCTION:
ActionFunction is used to execute a method in your Apex Class from within your Visualforce Page asynchronously via AJAX requests. What does asynchronous AJAX requests mean ? This means that Visualforce Pages(otherwise HTML pages when rendered at the Client Side via the Browser) can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. So when we execute an Apex Method via the ActionFunction, the page is not disturbed and the request to the servers(Apex Code compiles and runs on the Salesforce servers while the Visualforce pages which are nothing but HTML pages are rendered by browser at the Client Side) are sent and received in the background. The other way of doing such AJAX requesst to Apex Methods include the Visualforce Remoting. The only difference between the same is that when using the Visualforce Remoting you will have to write some extra lines of JavaScript which is not needed in case of the ActionFunction.
Now, a very simple and a common example of ActionFunction is mimicking the Field Dependency feature on Visualforce Pages. Say for example you had two Picklists – Select the Object and Select the Field. When a user selects an Object, the next Picklist automatically gets populated with the Fields that belong to the object.
REMOTE ACTION:
@RemoteAction in Visual force page
JavaScript remoting in Visualforce provides support for some methods in Apex controllers to be called via JavaScript.JavaScript remoting has three parts:
The remote method invocation you add to the Visualforce page, written in JavaScript.
The remote method definition in your Apex controller class. This method definition is written in Apex, but there are few differences from normal action methods.
The response handler callback function you add to or include in your Visualforce page, written in JavaScript.To use JavaScript remoting in a Visualforce page, add the request as a JavaScript invocation with the following form:
[namespace.]controller.method(
[parameters...,]
callbackFunction,
[configuration]);namespace is the namespace of the controller class. This is required if your organization has a namespace defined, or if the class comes from an installed package.
controller is the name of your Apex controller.
method is the name of the Apex method you’re calling.
parameters is the comma-separated list of parameters that your method takes.
callbackFunction is the name of the JavaScript function that will handle the response from the controller. You can also declare an anonymous function inline. callbackFunction receives the status of the method call and the result as parameters. -
Hello Manpreet,
JavaScript remoting is a tool that front-end developers can use to make an AJAX request from a Visualforce page directly to an Apex controller. JavaScript remoting allows you to run asynchronous actions by decoupling the page from the controller and to perform tasks on the page without having to reload the entire page.
-
Radhakrishna
MemberApril 26, 2017 at 6:25 am in reply to: Difference between Enterprise WSDL and Partner WSDL in salesforce?Hi Saurabh,
Salesforce provides a WSDL (Web Service Description Language) files. They are called "Enterprise WSDL" and "Partner WSDL". A WSDL is an XML-document which contains a standardized description on how to communicate using a web service (the Salesforce API is exposed as a web service). The WSDL is used by developers to aid in the creation of Salesforce integration pieces. A typical process involves using the Development Environment (eg, Eclipse for Java, or Visual Studio for .Net) to consume the WSDL, and generate classes which are then referenced in the integration.
The primary differences between the two WSDL that we provide are:
Enterprise WSDL:
a) The Enterprise WSDL is strongly typed.
b) The Enterprise WSDL is tied (bound) to a specific configuration of Salesforce (ie. a specific organization's Salesforce configuration).
c) The Enterprise WSDL changes if modifications (e.g custom fields or custom objects) are made to an organization's Salesforce configuration.For the reasons outlined above, the Enterprise WSDL is intended primarily for Customers.
Partner WSDL:
a) The Partner WSDL is loosely typed.
b) The Partner WSDL can be used to reflect against/interrogate any configuration of Salesforce (ie. any organization's Salesforce configuration).
c) The Partner WSDL is static, and hence does not change if modifications are made to an organization's Salesforce configuration. -
Radhakrishna
MemberApril 26, 2017 at 6:22 am in reply to: What are different Salesforce annotations?Hello Saurabh,
An apex annotation modifies the way a method or class is used similar to annotations in Java
Annotations are defined with an initial @ symbol, followed by the appropriate keyword.
To add an annotation to a method, specify it immediately before the method or class definition.
Types of Salesforce annotations@ Deprecated
@ Future
@ Is test
@ Read-only
@ Remote action -
Radhakrishna
MemberApril 25, 2017 at 11:20 am in reply to: Sequence of Execution of Triggers on "before insert"Hello Suraj,
Triggers get a list of objects (up to 200), but process each object individually. The before trigger as a whole will complete its batch before the after trigger fires. However, if you have more than 200 objects, there will be multiple before triggers (1 trigger context for each batch of up to 200 objects). When each trigger context finishes, the records in that trigger become eligible for after triggers. In your after triggers, you can't be certain that it is the same set of 200 objects that were in your original before trigger since a user may have created/updated a record which would get included in the trigger batch.
As an alternative to triggers, have you thought about using Workflow Rules and Field Updates/Email Alerts? Those are both non-programming approaches.
-
Radhakrishna
MemberApril 25, 2017 at 11:17 am in reply to: Inline Editing in Related list of a Record?Hello Manpreet,
Check out this free Chrome extension:
You can inline eidt all the fileds right from the report page. All you need is to create a report type with the related objects.
Hopes this helps... -
Radhakrishna
MemberApril 25, 2017 at 10:48 am in reply to: How to get the reserved words used in Json Body in Salesforce?You can use JSON class.
If you have a model you can use JSON.deserialized Ex
String myJson = '{name="Test",phone="1234567890"}';
Account ac = (Account) JSON.deserialize(myJson, Account.class);If you dont want use a model then you can use JSON.deserializeUntyped Ex:
String myJson = '{name="Test",phone="1234567890"}';
Map<String,Object> ac = JSON.deserializeUntyped(myJson);
System.debug(ac.get('name'));
System.debug(ac.get('phone')); -
Radhakrishna
MemberApril 24, 2017 at 9:10 am in reply to: What is the Difference between Related List and Enhanced List in salesforce?Hiii Saurabh,
Related List -
Related list contains all child records that your record have. Related list is always in Page Layout.
Enhanced List -
This is a list view where you can view list of records, List view is always on Tab
If offers addtional funcationlity like Mass Edit, Navigation, Print view etc. -
Radhakrishna
MemberApril 24, 2017 at 8:57 am in reply to: What is the default timeout period while calling webservice from Apex in salesforce?Hello Saurabh,
The following limits and limitations apply when Apex code makes a callout to an HTTP request or a web services call. The web services call can be a SOAP API call or any external web services call.
A single Apex transaction can make a maximum of 100 callouts to an HTTP request or an API call.
The default timeout is 10 seconds. A custom timeout can be defined for each callout. The minimum is 1 millisecond and the maximum is 120,000 milliseconds. See the examples in the next section for how to set custom timeouts for Web services or HTTP callouts.
The maximum cumulative timeout for callouts by a single Apex transaction is 120 seconds. This time is additive across all callouts invoked by the Apex transaction.
You can’t make a callout when there are pending operations in the same transaction. Things that result in pending operations are DML statements, asynchronous Apex (such as future methods and batch Apex jobs), scheduled Apex, or sending email. You can make callouts before performing these types of operations.
Pending operations can occur before mock callouts in the same transaction. See Performing DML Operations and Mock Callouts for WSDL-based callouts or Performing DML Operations and Mock Callouts for HTTP callouts.
When the header Expect: 100-Continue is added to a callout request, a timeout occurs if a HTTP/1.1 100 Continue response isn’t returned by the external server. -
Radhakrishna
MemberApril 21, 2017 at 9:54 am in reply to: Non-deterministic Force.com formula fields in Salesforce?Hi Manpreet,
Here are examples of common non-deterministic formulas. Force.com cannot index fields that:
· Reference other entities (i.e., fields accessible through lookup fields)
· Include other formula fields that span over other entities
· Use dynamic date and time functions (e.g., TODAY, NOW)
A formula is also considered non-deterministic when it includes:
· Owner, autonumber, divisions, or audit fields (except for CreatedDate and CreatedByID fields)
· References to fields that Force.com cannot index
o Multi-select picklists
o Currency fields in a multicurrency organization
o Long text area fields
o Binary fields (blob, file, or encrypted text)
· Standard fields with special functionalities
o Opportunity: Amount, TotalOpportunityQuantity, ExpectedRevenue, IsClosed, IsWon
o Case: ClosedDate, IsClosed
o Product: Product Family, IsActive, IsArchived
o Solution: Status
o Lead: Status
o Activity: Subject, TaskStatus, TaskPriority
-
Radhakrishna
MemberApril 21, 2017 at 9:43 am in reply to: How many controller extensions we can use in salesforce?Hello Saurabh,
You can have a standard object controller and multiple controller extensions. I don't think there is any upper limit on the same
-
Radhakrishna
MemberApril 21, 2017 at 9:06 am in reply to: Can we change values in after trigger in salesforce?Hello,
An AFTER trigger is typically used to update something other than the row being updated. For example, if you wanted to log the fact that an update had been made, an AFTER trigger is ideal.
To change the value of a column as it is being inserted, you need to use a before trigger. For example
CREATE TRIGGER modify_column BEFORE INSERT ON mytable
SET @column = value;Where value is a query, pre defined value or NEW.column
-
Radhakrishna
MemberApril 19, 2017 at 5:36 am in reply to: How to add css file to static Resources ?You can use relative paths in files in static resource archives to refer to other content within the archive. For example, in your CSS file, named styles.css, you have the following style:
table { background-image: url('img/testimage.gif') }When you use that CSS in a Visualforce page, you need to make sure the CSS file can find the image. To do that, create an archive (such as a zip file) that includes styles.css and img/testimage.gif. Make sure that the path structure is preserved in the archive. Then upload the archive file as a static resource named “style_resources”. Then, in your page, add the following component:
<apex:stylesheet value="{!URLFOR($Resource.style_resources, 'styles.css')}"/>Since the static resource contains both the style sheet and the image, the relative path in the style sheet resolves and the image is displayed.
-
Radhakrishna
MemberApril 19, 2017 at 5:27 am in reply to: Can we update records using data loader in salesforce?Hello Saurabh,
Yes we can update records using data loader in salesforce. The Data Loader is a client application for the bulk import or export of data. Use it to insert, update, delete, or extract salesforce records. The Apex Data Loader can move data into or out of any type of salesforce record, including opportunities and custom objects.
-
Radhakrishna
MemberApril 18, 2017 at 8:50 am in reply to: Difference Between Queueable and Future Method?Hello Suraj,
The difference between Queueable, and Future methods is how they're designed to behave. Batchable calls were designed to allow for heavy asynchronous processing. But, it was the only asynchronous code at one point, and it was too "heavy" in terms of resource usage, and had a lot of baggage associated with it. It required a long time to process and was often used only to handle callouts or things that were slightly longer than a normal transaction could handle.
So, next came future methods. Unlike Batchable methods, they were lighter on resources and perfect for doing that job that Batchable was doing before, but much more efficiently. Unfortunately, it was too efficient. You didn't know when the job was done (no Job ID), and it only had a limited amount of space to store data (the reason why it only accepted primitives and collections thereof).
In response to feedback, a third version of asynchronous code was designed: Queueable. It was lighter than Batchable, but it gave you a Job ID and let you store complex data patterns. The lesser resources it used compared to batchable also meant higher limits. Queueable was meant to be a hybrid between the limited future methods and the resource-hungry Batchable interface.
So, to get back to your question: you should always avoid passing in entire SObjects, especially if they may change between serialization and execution. If you need heavy processing, you probably want Batchable, while if you want normal-sized transactions with increased limits, you probably want Queueable. Of course, you can still use future methods if you don't need to monitor the results of the execution, and they'll continue to work for the foreseeable future.
-
Radhakrishna
MemberApril 18, 2017 at 8:13 am in reply to: Can we create 2 opportunities while the Lead conversion in salesforce?Hello Saurabh,
If there is a requirement to create multiple Opportunities upon Lead conversion, process builder must be used.
Please check the below link it may help you..
https://help.salesforce.com/articleView?id=000220210&type=1
-
Radhakrishna
MemberApril 18, 2017 at 8:10 am in reply to: Can I create Standard PriceBook From TestClass?Hello Suraj,
You can create price book entries for standard and custom price books in Apex tests.
Previously, you couldn’t create price book entries in an Apex test by default unless the test had access to organization data via the @isTest(SeeAllData=true) annotation. With this new support, you can isolate your price book test data from your organization data. Note that custom price books can be created but standard price books cannot.
Support for test price book entries is added for all tests, including tests that use the default data isolation mode (tests that can’t access organization data). With this support, you can do the following.Query for the ID of the standard price book in your organization with the Test.getStandardPricebookId() method.
Create test price book entries with standard prices by using the standard price book ID that’s returned by Test.getStandardPricebookId().
Create test custom price books, which enables you to add price book entries with custom prices.