Parul
IndividualForum Replies Created
-
Parul
MemberSeptember 16, 2018 at 2:55 pm in reply to: Difference between global and static keyword in Salesforce?global: Defines a class, method, or variable that can be used by any Apex that has access to the class, not just the Apex in the same application.
you can declare static variable in global scope also it will be almost same as other global variable except it has initial value as zero, if you don’t assign any value to it.
Example:
global class myClass {
webService static void
makeContact(String lastName) {
// do some work
}static: This keyword defines a method/variable that is only initialized once, and is associated with an (outer) class, and initialization code. We can call static variables/methods by class name directly. No need of creating instance of a class.
Example:
public class OuterClass {
// Associated with instance
public static final Integer MY_INT;
// Initialization code
static {
MY_INT = 10;
}
}Thanks
-
Parul
MemberSeptember 16, 2018 at 2:53 pm in reply to: What is the difference between SOQL and SOSL?SOQL:
1) SOQL (Salesforce Object Query Language ) retrieves the records from the database by using “SELECT” keyword.
2) By Using SOQL we can know in Which objects or fields the data resides.
3) We can retrieve data from single object or from multiple objects that are related to each other.
4) We can Query on only one table.SOSL:
1) SOSL(Salesforce Object Search Language) retrieves the records from the database by using the “FIND” keyword.
2) By using SOSL, we don’t know in which object or field the data resides.
3) We can retrieve multiple objects and field values efficiently when the objects may or may not be related to each other.
4) We can query on multiple tables.Thanks
-
Parul
MemberSeptember 16, 2018 at 2:52 pm in reply to: Difference between Data Import Wizard and Data Loader in Salesforce?Import Wizard:
For simple imports of up to 50000 records.
It supports all custom objects and only few standard objects like Account, Contact, Leads, Solution.
It supports schedule export.
Delete operation is not available.
It doesn’t require installation.
While importing, duplicates can be ignored.
Data Loader:For complex imports of any size more than 50000 records.
It supports all standard and custom objects.
It doesn’t support schedule export.
Delete operation is available.
It requires installation.
While importing, duplicates cannot be ignored.Thanks
-
database.savepoint is a method which is used to define a point which can be roll back to. If any error occurs during a transaction, that contains many statements, the application will roll back to the most recent savepoint and the entire transaction will not be aborted.
for example,
Account acc = new Account();
acc.name ='ABC';
---- --------
----- some code ---------
Savepoint sp = Database.setSavepoint();
try{
insert acc;
}
catch( Exception e ){
Database.rollback( sp );
}
------ the code continues -----In this exapmle, if any error occurs while inserting the acc then the entire transaction will rollbak to savepoint sp ( as specified in the catch section by Database.rollback method).
It is advisable to use implicit savepoint is marked before executing an INSERT, UPDATE, or DELETEstatement. If the statement fails, a rollback to the implicit savepoint is done.
Thanks
-
Parul
MemberSeptember 16, 2018 at 2:45 pm in reply to: How is Trigger.New different from Trigger.newMap in Salesforce?Trigger.New is simply a list of the records being processed by the trigger. It returns a list which is ordered. Suppose you have a custom object Custom_obj__c then Trigger.New is a list represented as List<Custom_obj__c>.
Trigger.newMap just allows you to target specific records by Id should you not need to process everything. It returns a map which is unordered. Trigger.newMap is a map represented as map<Id, Custom_obj__c>.
Thanks
-
Parul
MemberSeptember 16, 2018 at 2:43 pm in reply to: How to query for custom object in salesforce?Hi
select name,(select name from Childs1__r) from Master__c .
for example:
Select Name from Position__c;
Thanks
-
Parul
MemberSeptember 16, 2018 at 2:39 pm in reply to: Can we deactivate a flow through workbench in Salesforce?Hi
Its possible to do by using metadata components and then download those components in a .zip file.
Read about Metadata for more information.Modify the flowDefinition file (contained in the .zip file you downloaded) by specifying a value of 0 in activeversionNumber.
For reference use the above link mentioned
Thanks
-
Parul
MemberSeptember 16, 2018 at 2:37 pm in reply to: Can a trigger call a batch class in Salesforce?Yes you can call the batch class but salesforce have some governor limits and if you call trigger using batch it hits the limit.
Thanks
-
Parul
MemberSeptember 16, 2018 at 2:35 pm in reply to: Can we change the system fields of the Salesforce sObject?No we can not edit the standard fields of the sobject but we can edit the fields of custom object.
Thanks
-
Hello,
We cannot deactivate person accounts. But we can take it out from all profiles' access. When activating person accounts, we confirm to the Salesforce support that "We understand that once enabled, we cannot turn it off".
Hope this helps.
-
hi
With the use purge function in the Data feature of workbench you can empty recycle bin using workbench.
Thanks
-
Parul
MemberSeptember 16, 2018 at 2:04 pm in reply to: What is Database.SaveResult() in salesforce?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.
List<Database.SaveResult> updateResults = Database.upsert(arudate, false);
for(Integer i=0;i<updateResults.size();i++){
if (updateResults.get(i).isSuccess()){
updateResults.get(i).getId();}else if (!updateResults.get(i).isSuccess()){
// DML operation failed
Database.Error error = updateResults.get(i).getErrors().get(0);
String failedDML = error.getMessage();
arudate.get(i);//failed record from the list
system.debug('Failed ID'+arudate.get(i).Id);
}}
Thanks
-
If we perform DML operation on standard/custom object and global objects(User, UserRole, Group, GroupMember, Permission Set, etc...) in same transaction this error will come.
To avoid this error, we should perform DML operation on standard/custom object records in a different transaction.
In general all the apex classes and apex triggers execute synchronously (execute immediately).
If we perform DML operation on standard/custom object records asynchronously (execute in future context), we can avoid MIXED-DML-OPERATION error.
To execute logic asynchronously keep the logic in an apex method (in a separate apex class, not in same apex trigger) which is decorated with @future annotation.
See the below example:
Note: To analyse the code copy it and paste it in notepad for the convenience.
public class TriggerUtility {
/*
1. Following future method execute asynchronously (whenever server is free it will execute in future context).
2. We should not declare @future method in Apex Trigger.
3. @future method should be always static.
4. @future method accepts only primitive data types (Integer, String, Boolean, Date, etc...) as parameters and it won't accept
non-primitive data types (sObject,Custom Objects and standard Objects etc.. ) as parameters.
5. @future method should not contain return type. Always it should be void.
6. From an apex trigger we can make only make asynchronous call outs. To make call out we should include "callout = true" beside the future @annotation.
7. We cannot perform synchronous call outs from Apex Trigger.
*/
//Below is the example for the future method -
@future(callout = true)
public static void processAsync(primitive parameters) {
//Logic to insert/update the standard/custom object.
}
}
Thanks
-
Parul
MemberSeptember 16, 2018 at 1:52 pm in reply to: What is the difference between deactivate a user and freeze a user in Salesforce?Deactivate User:
Deactivating a user in Salesforce means that user will not be deleted from the system but will no longer be able to log in to Salesforce and their records can be transferred to another user. They cannot be part of workflows or part of any automated processes.
Deactivating a user will be available user licenses available for use in your organization.
Deactivated users lose access to any records that were manually shared with them, or records that were shared with them as team members. Users higher in the role hierarchy relative to the deactivated users also lose access to those records. However, you can still transfer their data to other users and view their names on the Users page.Freeze User:
Freezing a user in Salesforce means that only stops the user from being able to login.
In some cases, you can’t immediately deactivate a user (such as when a user is selected in a custom hierarchy field or a user that’s assigned as the sole recipient of a workflow email alert). To prevent users from logging into your organization while you perform the steps to deactivate them, you can freeze user accounts.
Freezing user accounts doesn’t make their user licenses available for use in your organization.Thanks
-
Parul
MemberSeptember 16, 2018 at 1:51 pm in reply to: Can we use two fields in order by clause in Salesforce?Hi
You may use two field in Order By clause. But it sort according to first field
e.g.
Select id, name from Account Order By name, Phone
Here it Order according to name
Thanks
-
Parul
MemberSeptember 16, 2018 at 1:42 pm in reply to: How to query Custom settings in Salesforce Apex code?Custom settings are like custom objects, but have an organization wide access. Data can be added in them like any Object, through APEX code, or by creating new record. However the access is available organization wide.
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.
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.
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).Thanks
-
hi
you can try this code:
List<Position__c> newsumrecords = new List<Position__c>();
for (Contact con : fullcontacts)
{
map<Date, set<Decimal>> mrns = conid2datemapmap.get(con.Id);for (Date d : mrns.keyset())
{Position__c refent = new Position__c(
Referring_Physician_del__c = con.Id, FSC__c = 'None', Service_Date__c = d, Count_of_MRN__c = mrns.get(d).size());newsumrecords.add(refent);
debuglog += '<br/>' + (newsumrecords);}
}Thanks
-
Parul
MemberSeptember 16, 2018 at 1:19 pm in reply to: How to get csv file in a web service post method in Salesforce?Hi
@RestResource(urlMapping='/accountCsv/')
global class REST ContactController{
@HttpPost
global static void newAccounts(){
RestRequest req = RestContext.request;
System.debug(‘csv’+req);}}
Thanks
-
Parul
MemberSeptember 16, 2018 at 1:13 pm in reply to: How to turn my input field empty on the button click?Hi
<!DOCTYPE html>
<html>
<head>
<title>Jquery</title>
<meta charset="utf-8">
<script src='http://code.jquery.com/jquery-1.7.1.min.js'></script>
</head><body>
<input type="text" id="message" value="" />
<input type="button" id="sendButton" value="Send"><script>
$(document).ready(function(){var checkField;
//checking the length of the value of message and assigning to a variable(checkField) on load
checkField = $("input#message").val().length;var enableDisableButton = function(){
if(checkField > 0){
$('#sendButton').removeAttr("disabled");
}
else {
$('#sendButton').attr("disabled","disabled");
}
}//calling enableDisableButton() function on load
enableDisableButton();$('input#message').keyup(function(){
//checking the length of the value of message and assigning to the variable(checkField) on keyup
checkField = $("input#message").val().length;
//calling enableDisableButton() function on keyup
enableDisableButton();
});
});
</script>
</body>
</html>Thanks
-
Parul
MemberSeptember 16, 2018 at 12:54 pm in reply to: What is the difference between feed item and attachment in Salesforce?FeedAttachment
Represents an attachment to a feed item, such as a file attachment or a link. Use FeedAttachment to add various attachments to one feed item. This object is available in API version 36.0 and later.
Supported Calls
create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()Feeditem : FeedItem represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts.
Thanks
-
Parul
MemberSeptember 16, 2018 at 12:52 pm in reply to: How to show all records instead of recent records in user type lookup search in Salesforce?Hi
This is possible I have done this in my project by enabling some settings in that particular object.
Thanks
-
Parul
MemberSeptember 16, 2018 at 12:47 pm in reply to: What is Remote Action in Salesforce/What is the use of this action?The RemoteAction annotation provides support for Apex methods used in Visualforce to be called via JavaScript. This process is often referred to as JavaScript remoting. This action function in salesforce allows user to access any method from any class through javasrcipt methods.
JavaScript remoting in Visualforce provides support for some methods in Apex controllers to be called via JavaScript. Remote method invocation you add to the Visualforce page, written in JavaScript.
Thanks
-
Parul
MemberSeptember 16, 2018 at 12:43 pm in reply to: Can we make nested page block table in Salesforce?Yes, we can make nested page block table in Salesforce
Ex:
<apex:page controller="dbPracticeChangesController">
<apex:form >
<apex:pageblock >
<apex:pageblocktable value="{!ChangeList}" var="cs">
<apex:column headervalue="Competency">
<apex:outputtext value="{!cs.Name}"/>
</apex:column>
<apex:column headervalue="Rollup Data">
<apex:facet name="Facet Name">
</apex:facet>
<apex:pageblocktable value="{!cs.dbPracticeChanges__r}" var="db">
<apex:column headervalue="Name">
<apex:outputtext value="{!db.Name}"/>
</apex:column>
<apex:column headervalue="Late Start">
<apex:outputtext value="{!db.Late__c}"/>
</apex:column>
</apex:pageblocktable>
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>Thanks
-
The ContentDocument object represents a document that has been uploaded to a library in Salesforce CRM Content or Salesforce Files.
ContentDocument object is to retrieve, query, update, and delete the latest version of a document, but not a content pack, in a library or a file in Chatter.
Use the ContentVersion object to create, query, retrieve, search, edit, and update a specific version of a Salesforce CRM Content document or Chatter file.
Thanks
-
Parul
MemberSeptember 16, 2018 at 12:28 pm in reply to: Can we create custom object through Salesforce apex code?You can create a custom object using Metadata API
THanks