Parul
IndividualForum Replies Created
-
Parul
MemberSeptember 21, 2018 at 10:45 am in reply to: What is the difference between HTTP Post and HTTP GET in Salesforce apex?hi
HTTP POST:
POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource. The POST method is not idempotent, however POST responses are cacheable so long as the server sets the appropriate Cache-Control and Expires headers.
GET requests can easily be forged (see Cross-Site Request Forgery) by just placing an image on a page while forging POST requests is not that easy (this is also a reason why you should only allow authorized POST requests).
-
Parul
MemberSeptember 21, 2018 at 10:23 am in reply to: What are the drawbacks of JSON in Salesforce?hi
If JSON not inserted, nothing happens. It just fails silently. For example, you are not able to catch a 404 error from the server, Nor can you cancel or restart the request. You can, however, timeout after waiting a reasonable amount of time.
Disadvantages of JSON is it has no error handling for JSON calls. If the dynamic script insertion works, you get called and will get the response perfectly. If not inserted, nothing happens. It just fails silently.
Thanks
-
Parul
MemberSeptember 21, 2018 at 10:22 am in reply to: Which Objects can we access without using seeAllData=true?hi
User, profile, organization, AsyncApexjob, Corntrigger, RecordType, ApexClass, ApexComponent, ApexPage and custom metadata types. when we use seeAllData = true to get real-time data in the test class, but without using this also you can get the data from the following objects.
Thanks
-
Parul
MemberSeptember 21, 2018 at 10:21 am in reply to: What is the difference between bound and unbound expressions in Salesforce?Hi
Unbound Expression: Unbound Expression is represented as {#v.messageText}. Whenever the value of the string is changed, this expression will not reflect the change, we can say the value remains static through this expression.
Bound Expression: Bound Expression is represented as {!v.messageText}. Whenever the value of the string is changed, this expression will reflect the change and also affect the components where it is used, we can say the value change dynamically through this expression.
Example :
<aura:component implements=”force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction” access=”global” >
<aura:attribute name=”str” type=”string” default=”Hello World!”/>
<ui:outputText value=”Enter a string value : “/><ui:inputText value=”{!v.str}”/>
<br/><br/>
<ui:outputText value=”{#v.str}”/>
<br/><br/>
<ui:outputText value=”{!v.str}”/>
</aura:component>Thanks.
-
Parul
MemberSeptember 21, 2018 at 10:20 am in reply to: What is the use of Salesforce chatter REST API?Salesforce Chatter provides businesses with the collaboration tools consumers have become accustomed to through popular social networking sites such as Facebook. However, Chatter is designed for the enterprise, allowing private, secure, and trusted collaboration around your business data.
The Chatter REST API lets you access Chatter information via an optimized REST-based API accessible from any platform. Developers can now build social applications for mobile devices, or highly interactive websites, quickly and efficiently.
Use Chatter REST API examples to perform tasks.
While using the Chatter REST API, keep this in mind:Request parameters may be included as part of the Chatter REST API resource URL, for example, /chatter/users?q=searchtext. A request body is a rich input which may be included as part of the request. When accessing a resource, you can use either a request body or request parameters. You cannot use both.
With a request body, use Content-Type: application/json or Content-Type: application/xml.
With request parameters, use Content-Type: application/x-www-form-urlencoded.Thanks
-
Parul
MemberSeptember 21, 2018 at 8:34 am in reply to: What Is Aura? Why Do We Use The Aura: Namespace In The Code ?The Aura framework. Note that the open source Aura framework has features and components that are not currently available in the Lightning Component framework. We are working to surface more of these features and components for Salesforce developers.
Thanks
-
Parul
MemberSeptember 21, 2018 at 8:32 am in reply to: Is There Any Limit On How Many Component To Have In One Application ?There is no limit to use number of components in an appplication its upto you.
Thanks
-
Parul
MemberSeptember 21, 2018 at 8:31 am in reply to: Can We Make A Lightning Component That Shows Up In Both The Mobile And The Desktop User Interfaces ?Yes, with Salesforce1 Mobile app We can Make A Lightning Component That Shows Up In Both The Mobile And The Desktop User Interfaces.
Lightning component is lightning experience ready by default and is also compatible in Salesforce1 App, it has a responsive layout therefore it adjusts its resolution according the screen size and therefore can be used on desktop as well without writing any separate code.
Thanks
-
Hi,
The benefits include an out-of-the-box set of components, event-driven architecture, and a framework optimized for performance.
Performance – :Uses a stateful client and stateless server architecture that relies on JavaScript on the client side to manage UI, It intelligently utilizes your server, browser, devices, and network so you can focus on the logic and interactions of your apps.
Event-driven architecture -: event-driven architecture for better decoupling between components
Faster development – : Empowers teams to work faster with out-of-the-box components that function seamlessly with desktop and mobile devices.
Device-aware and cross browser compatibility – : responsive design,supports the latest in browser technology such as HTML5, CSS3, and touch events.
Out-of-the-Box Component Set -: Comes with an out-of-the-box set of components to kick start building apps. You don’t have to spend your time optimizing your apps for different devices as the components take care of that for you.
Rich component ecosystem-: Create business-ready components and make them available in Salesforce1, Lightning Experience, and Communities.
Thanks
-
Parul
MemberSeptember 21, 2018 at 7:35 am in reply to: How to invoke batch apex job (or) how to execute the batch apex job programmatically?Adding code snippet
Execute the following code.
Id <variable name>= Database.executeBatch(new <Class name>(), batch size);Thanks
-
Adding some points:
It is not possible to add a Visualforce page within a flow, e.g. there is no way to see it as an option in the Flow Builder. The only method to switch to visualforce is using a page as a wrapper for the flow and passing control to it by setting a variable value within the flow, which there is an example of
Add the following to the controller
public Attachment attachment {
get {
if (attachment == null)
attachment = new Attachment();
return attachment;
}
set;
}// Specific flow name for flow type
public Flow.Interview.my_flow myflow { get; set; }public String varCaseId;
public String varUpload;
public Boolean upload;
public Boolean uploaded = false;
public String fName{ get; set;}
public String displayName{get; set;}// The Case Id value from the flow
public String getvarCaseId()
{
If(myFlow == null)
Return null;
Else
return myflow.varCaseId;
}// The varUpload variable value from the flow
public String getvarUpload()
{
If(myFlow == null)
Return String.valueOf('0');
Else
Return myflow.varUpload;
}Public Boolean getupload()
{
If(myFlow != null && myflow.varUpload != null && myflow.varUpload == '1' && uploaded!= null && uploaded == false)
Return true;
else
Return false;
}// Save method, leading to next step in flow
public PageReference Save()
{
return upload(System.Boolean.valueOf(true));
}// Save More method, leading to the attachment upload functionality again
public PageReference SaveMore()
{
return upload(System.Boolean.valueOf(false));
}// Cancel method, leading to next step in flow
public PageReference Cancel()
{
This.uploaded = true;
attachment = null;
return null;
}// Upload method for actual attachment upload, setting the upload variable appropriately to allow/ not allow another attachment upload
public PageReference upload(Boolean varUploaded)
{
attachment.OwnerId = UserInfo.getUserId();
attachment.ParentId = getvarCaseId(); // the record the file is attached to
attachment.IsPrivate = false;if( (!(attachment.name != null && attachment.name != '')) && (fName != null && fName != ''))
{
String afterExt = fName.substringAfter('.');
System.debug('afterExt :: ' + afterExt );
if(displayName != null && displayName != '')
{
attachment.name = displayName + '.' + afterExt;
}
else
attachment.name = fName;
}
try
{
if(!(attachment.body != null))
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Please specify a file to be uploaded'));
}
else if (!(attachment.name != null && attachment.name != ''))
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Please specify a file name'));
}insert attachment;
displayName = '';
fName = '';}
catch (DMLException e)
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
return null;
}
finally
{
attachment = new Attachment();
}This.uploaded = varUploaded;
// true for save and false for Save more
return null;// End of upload
}
Visualforce page<apex:outputPanel id="theAttachmentPanel" rendered="{!upload}">
<apex:sectionHeader title="Attachment Upload (Upto 10 MB)"/><apex:pageMessages />
<apex:pageBlock title="Upload an Attachment"><apex:pageBlockButtons >
<apex:commandButton action="{!SaveMore}" value="Upload More"/>
<apex:commandButton action="{!Save}" value="Finish Uploading"/>
<apex:commandButton action="{!Cancel}" value="Submit with no Attachment"/>
</apex:pageBlockButtons><apex:pageBlockSection showHeader="false" columns="2" id="block1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="File Name" for=" filesName "/>
<apex:inputText value="{!displayName}" id="filesName"/>
</apex:pageBlockSectionItem><apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{!attachment.body}" filename="{!fName}" id="file"/>
</apex:pageBlockSectionItem><apex:pageBlockSectionItem >
<apex:outputLabel value="Description" for="description"/>
<apex:inputTextarea value="{!attachment.description}" id="description"/>
</apex:pageBlockSectionItem></apex:pageBlockSection>
</apex:pageBlock>Hope this will help you.
Thanks
- This reply was modified 6 years, 2 months ago by Parul.
-
Parul
MemberSeptember 21, 2018 at 7:32 am in reply to: What is the main difference between using data table vs .page block table tags ?Hi
Apex:dataTable –
An HTML table that is defined by iterating over a set of data, displaying information about one item of data per row. The body of the < apex:dataTable > contains one or more column components that specify what information should be displayed for each item of data. The data set can include up to 1,000 items.->no need to write inside <apex:pageblock> or <apex:pageblocksection>
-> there is no required value
-> the data can be displayed using custom styles
-> we need to specify column headers explicitlyApex:pageBlockTable – A list of data displayed as a table within either an < apex:pageBlock > or < apex:pageBlockSection > component, similar to a related list or list view in a standard Salesforce page. Like an < apex:dataTable >, an < apex:pageBlockTable > is defined by iterating over a set of data, displaying information about one item of data per row. The set of data can contain up to 1,000 items.The body of the < apex:pageBlockTable > contains one or more column components that specify what information should be displayed for each item of data, similar to a table. Unlike the < apex:dataTable > component, the default styling for < apex:pageBlockTable > matches standard Salesforce styles. Any additional styles specified with < apex:pageBlockTable > attributes are appended to the standard Salesforce styles. ->pageblocktable should be inside of <apex:pageblock> or <apex:pageblocksection>
-><apex:pageblocktable> has a required attribute called “value”
->it uses the standard salesforce page styles
->column headers will be displayed automaticallyThanks.
-
Execute the following code.
Id <variable name>= Database.executeBatch(new <Class name>(), batch size);Thanks
-
Parul
MemberSeptember 21, 2018 at 4:46 am in reply to: What is the use of writing sharing rules? Can you use sharing rules to restrict data access?Adding more points:
Sharing rules to extend sharingaccess to users in public groups or roles. As with role hierarchies, sharing rules can never be stricter than your org-wide default settings. They just allow greater access for particular users. You can share records owned by certain users or meeting certain criteria.
Thanks
-
Parul
MemberSeptember 21, 2018 at 4:43 am in reply to: What are the advantages of Trigger Handler in comparison to the normal trigger operation in Salesforce?Adding more:
Benefits of the Trigger Handler Pattern
Related reading: Trigger Frameworks and Apex Trigger Best PracticesWhile my preferred pattern differs slightly, the above article lays out many of the advantages. I personally find a handler implementation must-have because it:
facilitates logic-less triggers and One Trigger Per Object, which itself has many benefits(including fine grained control over order of execution)
improves readability and Separation of Concerns(this improved readability makes version control more fruitful as well)
optionally facilitates selective disablementThanks
-
Parul
MemberSeptember 21, 2018 at 4:41 am in reply to: What is the use of oldMap and newMap context variables in Salesforce Triggers?Hi , Difference in oldMap and newMap
//Trigger.new: Contains all new Data
//Trigger.Old: Contains all old Data (before change)
//Trigger.newMap: Map contains new Data (Key: Id)
//Trigger.oldMap: Map contains old Data (Key: Id)
for(Opportunity opp:Trigger.New){
if(opp.Stage != Trigger.oldMap.get(opp.Id).Stage){
//Your logic
}
}
//Same way you can use Trigger.newMapI hope this will helpfull to you.
Thanks
-
Parul
MemberSeptember 21, 2018 at 4:38 am in reply to: Difference between Trigger.New and Trigger.NewMap in Salesforce?Hi Shariq, Difference in Trigger.New and Trigger.NewMap:
trigger.new is simply a list of the records being processed by the trigger, so if all you need to do is loop through them then you can use that.
trigger.newMap just allows you to target specific records by Id should you not need to process everything, or if you need to map other records back to these.
set<Id> accIds = new set<Id>();
for(Account acc : Trigger.new)
{
accIds.add(acc.id);
}
//query the contact records now from currently processed Account Ids
List<Contact> lstContact = [select id from contact where Accountid in : accIds];Get All the Account ids from Trigger.Newmap
List<Contact> lstContact = [select id from contact where
Accountid in : Trigger.newmap.Keyset()];Thanks
-
Parul
MemberSeptember 21, 2018 at 4:34 am in reply to: Is the method trigger:old only used for the event "before delete"?Hi, Thanks a lot to clear my doubt.
In Before Insert Trigger.old collection is not able, it's null.
Trigger.old trigger is available in after update trigger and will hold old copy of current modifying record.
Trigger.old is available in Delete trigger .Trigger.new is not available on before delete, and after delete triggers.
For future refrence:
trigger ParentTrigger on Parent__c (before delete) {
List<Id> parentIds = new List<Id>();
for(Parent__c p : Trigger.Old)
parentIds.add(p.Id);Map<Id, List<Child__c>> childMap = new Map<Id, List<Child__c>>();
for (Child__c child : [SELECT id, Parent__c FROM Child__c WHERE Parent__c IN :parentIds]) {
if(!childMap.containsKey(child.Parent__c))
childMap.put(child.Parent__c, new List<Child__c>());
childMap.get(child.Parent__c).add(child);
}for (Parent__c par : Trigger.Old) {
if (childMap.containsKey(child.Parent__c)) {
par.adderror('Cannot be deleted');
}
}
}Thanks Shariq.
-
I have use this to find the reason
The RemoteSiteSetting is not directly exposed in Apex. It is neither possible to query it, nor to instantiate it.
RemoteSiteSetting s = new RemoteSiteSetting();
results in Invalid TypeSELECT Id FROM RemoteSiteSetting
results in sObject type 'RemoteSiteSetting' is not supported.This error throw.
Thanks
-
Parul
MemberSeptember 21, 2018 at 4:27 am in reply to: How to include stylesheet in visualforce page rendered as pdf ?Here is the example:
A Visualforce page rendered as a PDF file displays either in the browser or is downloaded, depending on the browser’s settings. Specific behavior depends on the browser, version, and user settings, and is outside the control of Visualforce.
The following page includes some account details and renders as a PDF file.<apex:page standardController="Account" renderAs="pdf">
<apex:stylesheet value="{!URLFOR($Resource.Styles,'pdf.css')}"/>
<h1>Welcome to Universal Samples!</h1>
<p>Thank you, <b><apex:outputText value=" {!Account.Name}"/></b>, for
becoming a new account with Universal Samples.</p><p>Your account details are:</p>
<table>
<tr><th>Account Name</th>
<td><apex:outputText value="{!Account.Name}"/></td>
</tr>
<tr><th>Account Rep</th>
<td><apex:outputText value="{!Account.Owner.Name}"/></td>
</tr>
<tr><th>Customer Since</th>
<td><apex:outputText value="{0,date,long}">
<apex:param value="{!Account.CreatedDate}"/>
</apex:outputText></td>
</tr>
</table></apex:page>
Thanks
-
Parul
MemberSeptember 21, 2018 at 4:22 am in reply to: How to differentiate LIST apart from HIERARCHY setting in Apex?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.
Example
For example we are going to focus on hierarchy type settings. Once created these settings can be used even in formula fields or normally in APEX code to store information which can be only changed by administrators. -
Parul
MemberSeptember 21, 2018 at 4:17 am in reply to: How to handle mixed DML Exception in salesforce?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 21, 2018 at 4:13 am in reply to: In Salesforce, when to use Process Builder , work Flows and Flows and What are the limitation of each? -
Parul
MemberSeptember 21, 2018 at 4:10 am in reply to: What is the difference between Process Builder and Workflow?Workflow enables you to set up workflow rules. A workflow rule identifies what kinds of record changes or additions trigger specified workflow actions, such as sending email alerts and updating record fields.
Workflow rules and actions are associated with a specific object (and can cross objects only to update fields on a related master record).
Visual Workflow:
Visual Workflow enables you to create flows, which are triggered by users rather than events. Unlike Workflow, which always executes rules and actions behind the scenes, Visual Workflow offers screens for displaying and collecting information from the user running the flow.
Flows aren’t tied to any one object. They can look up, create, update, and delete records for multiple objects.
Process Builder:
The Process Builder’s simple and powerful design allows you to:Create your processes using a convenient layout with point-and-click efficiency.
Create your whole process in one place rather than using multiple workflow rules.
Create processes by collaborating with different teams in your business.
Stop using Apex code to automate simple tasks.Hope this helps you
Thanks
-
Parul
MemberSeptember 21, 2018 at 4:08 am in reply to: How can we insert a dynamic value in the Email Body of an Email Template in Salesforce?Here is example;
<messaging:emailTemplate subject="List of opportunity" recipientType="User" relatedToType="Account">
<messaging:htmlEmailBody >
Hi,<br/>
Below is the list of opportunities for your account {!relatedTo.Name}.<br/><br/>
<c:OpptyList AcctId="{!relatedTo.Id}" /><br/><br/>
<b>Regards,</b><br/>
{!recipient.FirstName}
</messaging:htmlEmailBody>
</messaging:emailTemplate>Thanks