Avnish Yadav
IndividualForum Replies Created
-
Avnish Yadav
MemberAugust 9, 2018 at 7:50 am in reply to: How do we send the notification through Salesforce WebHook?Hi Anurag,
A webhook (also called a web callback or HTTP push API) is a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately.
The first step in consuming a webhook is giving the webhook provider a URL to deliver requests to. This is most often done through a backend panel or an API. This means that you also need to set up a URL in your app that’s accessible from the public web.
The majority of webhooks will POST data to you in one of two ways: as JSON or XML to be interpreted, or as a form data (application/x-www-form-urlencoded or multipart/form-data). Your provider will tell you how they deliver it (or even give you a choice in the matter). Both of these are fairly easy to interpret, and most web frameworks will do the work for you. If they don’t, you may need to call on a function or two.
for more info go through https://www.jamesward.com/2014/06/30/create-webhooks-on-salesforce-com
Source: Vikas Kumar
Thanks.
-
Avnish Yadav
MemberAugust 9, 2018 at 7:25 am in reply to: What is the Flow of code in Salesforce lightning event?Hello Anurag,
Let's say you have Component A and Component B and an event E. You want to move from A to B then,
The flow of Code in Lightning Event are:-
Component Event:-
1. Firstly you have to register an event in component A.
<aura:registerEvent name="EventE" type="c:EventE"/>
2. Fire the event by clicking any button, like onclick="{!c.fireComponentEvent}". Controller Code is here:-
{
fireComponentEvent : function(cmp, event) {
// Get the component event by using the
// name value from aura:registerEvent
var cmpEvent = cmp.getEvent("EventE");
cmpEvent.setParams({
"message" : "A component event fired me. " +
"It all happened so fast. Now, I'm here!" });
cmpEvent.fire();
}
}3. In Event E we have to pass data message so it look like this
<aura:event type="COMPONENT">
<aura:attribute name="message" type="String"/>
</aura:event>4. Handle the event in Component B.
<aura:handler name="EventE" event="EventE" action="{!c.handleComponentEvent}"/>5. Code for Component B controller:-
{
handleComponentEvent : function(cmp, event) {
var message = event.getParam("message");// set the handler attributes based on event data
cmp.set("v.messageFromEvent", message);
}
}That's all for Component Event. Let's talk about Application Event.
Application Event:-
1. Firstly you have to register an event in component A. Well, in Application event, it is not mandatory to register event but here we are registering the event.
<aura:registerEvent name="EventE" type="c:EventE"/>
2. Fire the event by clicking any button, like onclick="{!c.fireComponentEvent}". Controller Code is here:-
{
fireApplicationEvent : function(cmp, event) {
// Get the application event by using the
// e.<namespace>.<event> syntax
var appEvent = $A.get("e.c:EventE");
appEvent.setParams({
"message" : "An application event fired me. " +
"It all happened so fast. Now, I'm everywhere!" });
appEvent.fire();
}
}3. In Event E we have to pass data message so it look like this
<aura:event type="APPLICATION">
<aura:attribute name="message" type="String"/>
</aura:event>4. Handle the event in Component B.
<aura:handler name="EventE" event="EventE" action="{!c.handleApplicationEvent}"/>5. Code for Component B controller:-
{
handleApplicationEvent : function(cmp, event) {
var message = event.getParam("message");// set the handler attributes based on event data
cmp.set("v.messageFromEvent", message);
}
}Thanks.
-
Avnish Yadav
MemberAugust 9, 2018 at 6:09 am in reply to: How to delete Time based workflow if there is already an action scheduled in Salesforce?Hello Sanjana,
First, you need to remove all schedule action from Time-Based Workflow (Monitor) queue. Then you can deactivate or delete the workflow
Setup->Monitor-->Time-Based Workflow--> Then search record and deleteThanks.
-
Avnish Yadav
MemberAugust 9, 2018 at 6:00 am in reply to: Can Salesforce Lightning Bolt Solution support various licenses like partner, employee etc?Hello Abhay,
Yes, Salesforce Lightning Bolt Solution support licenses like a partner, employee, franchisors, and franchisees etc.
Check out this video for more information:- https://www.salesforce.com/video/1756759/
Thanks.
-
Avnish Yadav
MemberAugust 8, 2018 at 12:36 pm in reply to: What are the advantages of statelessness in RESTful Webservices in Salesforce?Hi Suniti,
An advantage of statelessness in RESTful Webservices:-
- For this specialty, the web services can deal each method request independently.
- Web services do not maintain the record of the client’s previous interactions which simplifies designing the application.
- As RESTful web services constantly deal with HTTP protocols which are also a statelessness protocol that matches the basic criteria.
Thanks.
-
Avnish Yadav
MemberAugust 8, 2018 at 12:28 pm in reply to: Why SOAP services are not cacheable in Salesforce?Hi Madhulika,
SOAP services are not cacheable in Salesforce because SOAP when using HTTP as the transfer mechanism is sent via HTTP POST requests. As HTTP POST is non-idempotent, it is not cached at the HTTP level.
Thanks.
-
Avnish Yadav
MemberAugust 8, 2018 at 12:19 pm in reply to: How to implement callout integration in Salesforce?Hi Suniti,
In Salesforce a 'callout' is any https call that accesses an external URL -- some other web services or website. A 'calling' would be the opposite -- some external web service or application using the Salesforce API to access Salesforce data.For more information:- https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts
Thanks
-
Avnish Yadav
MemberAugust 8, 2018 at 6:31 am in reply to: What are the best practices for Salesforce triggers?Hi Madhulika,
Trigger Best Practices:-
- There should only be one trigger for each object.
- Avoid complex logic in triggers. To simplify testing and reuse, triggers should delegate to Apex classes which contain the actual execution logic.
- Bulkify any "helper" classes and/or method
- Triggers should be "bulkified" and be able to process up to 200 records for each call.
- Execute DML statements using collections instead of individual records per DML statement.
- Use Collections in SOQL "WHERE" clauses to retrieve all records back in the single query
- Use a consistent naming convention including the object name (e.g., AccountTrigger)
Thanks.
-
Avnish Yadav
MemberAugust 8, 2018 at 6:23 am in reply to: Explain how to transform JSON text to a JavaScript object in Salesforce?Hi Prachi,
JSON is to collect as JSON data from a web server as a file or HTTP request and convert the JSON data to a JavaScript, and then it avails the data in a web page.
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
Thanks.
-
Avnish Yadav
MemberAugust 8, 2018 at 6:18 am in reply to: Mention what is the rule for JSON syntax rules? Give an example of JSON object in Salesforce?Hi Prachi,
JSON is a simple data exchange format. JSON means JavaScript Object Notation; it is language and platform independent.
Syntax Rules for JSON:-
JSON syntax is a set of the JavaScript object notation syntax.
- Data is in name/value pairs
- Data is separated by a comma
- Curly brackets hold objects
- Square bracket holds arrays
JSON Object:- An object can be defined as an unordered set of name/value pairs. An object in JSON starts with {left brace} and finish or ends with {right brace}. Every name is followed by: (colon) and the name/value pairs are parted by, (comma).
Example:-
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986"
"GlossSee": "markup"
}
}
}
}
}Thanks.
-
Avnish Yadav
MemberAugust 7, 2018 at 6:40 am in reply to: How to get picklist value in Salesforce formula?Hi Anjali,
A picklist value often determines which other fields on a record are required. ISPICKVAL() and CASE() are used for creating validation rules that check whether a certain picklist value is selected. For example, say you want users to enter a reason when they change a case’s Status picklist value to Escalated.
First, create a custom text field Reason for Escalating on the Case object.
- Setup, use the quick find box to find the Object Manager.
- Click Case | Fields & Relationships and click New.
- Select the Text Area and click Next.
- In Field Label, enter Reason for Escalating. Field Name populates automatically.
- Click Next.
- Click Next again and then click Save.
Now use the Status picklist field to set up a validation rule on Reason for Escalating.
a. Click the newly created Reason for Escalating field.
b. Under Validation Rules, click New.
c. In Rule Name, enter Reason_Required.
d. In Error Condition Formula, enter the following validation rule:AND(
ISPICKVAL(Status, "Escalated"),
ISBLANK(Reason_for_Escalating__c)
)e. In Error Message, enter Please enter a reason for changing the case status to Escalated.
Click Save.Thanks.
-
Avnish Yadav
MemberAugust 7, 2018 at 6:13 am in reply to: Why can we not query fields of type long text in Salesforce?Hi Shradha,
In SOQL you simply cannot filter on long text areas, well the reason maybe Salesforce is doing some optimizations to prevent it from reaching the heap size.
Hope this will help you.
Thanks.
-
Avnish Yadav
MemberAugust 7, 2018 at 6:04 am in reply to: What are the advantages of contract and renewal automation in Salesforce?Hi Anjali,
Advantages of Contract Automation renewal:-
- Automated contract management improves business cycle times.\
- Automated contract management strengthens supplier, partner and customer relationships.
- Automated contract management mitigates risk.
Thanks.
-
Avnish Yadav
MemberAugust 7, 2018 at 6:00 am in reply to: Describe how contracts and Salesforce CPQ quotes are related.Hi Anjali,
Are asking about CPQ Contract Fields, then Contracts store information on the subscriptions that sales reps have quoted or ordered. They also contain fields that help customize your renewals and amendments.
More information:- https://help.salesforce.com/articleView?id=cpq_contract_fields.htm&type=5
Thanks.
-
Avnish Yadav
MemberAugust 7, 2018 at 5:56 am in reply to: What are the best practices while writing test classes in Salesforce?Hi Anjali,
The Apex Test Class Best Practices:-
- Use @isTest at the Top for all the test classes
- Always put assert statements for negative and positive tests
- Use the @testSetup method to insert the test data into Test class that will flow all over the test class.
- Always use Test.startTest() and Test.stopTest() doing this it will increase the governor limit of salesforce. We also use this to increase the governor limit.
- Use System.runAs() method to test the functionality in user Context.
- Do not put (seeAllData = true) in test class otherwise, use it for exceptional cases.
- Avoid Using Hard Coding Ids anywhere in test Class or any apex class.
- Please make sure that each class has a minimum of 75% coverage and also the main functionality has been covered. If possible increase code coverage up to 95%.
- All class method must be tested for at least 200 records and keep the real scenarios in mind.
- Only one Test.startTest() and Test.stopTest() statement can be in a method, and no of Test.startTest() and Test.stopTest() statement in any test class depend upon the test methods.
Thanks.
-
Avnish Yadav
MemberAugust 7, 2018 at 5:49 am in reply to: What is the use of THIS CSS class in Salesforce?Hello Prachi,
All top-level elements in a component have a special THIS CSS class added to them. This, effectively, adds namespacing to CSS and helps prevent one component's CSS from overriding another component's styling. The framework throws an error if a CSS file doesn't follow this convention.
Thanks.
-
Hello Anurag,
When you have a very large number of child records associated with the same account in Salesforce, we call that “data skew”.
Thanks.
-
Avnish Yadav
MemberAugust 6, 2018 at 5:04 am in reply to: How to use If condition with picklist in formula field?Hello Anjali,
You can use ISPICKVAL() with IF condition.
Example-
IF(ISPICKVAL(API__c1, "Option1"), Sobject.field_name,
IF(ISPICKVAL(API__c2, "Option2"), Sobject.field_name
IF(ISPICKVAL(API__c3, "Option3"), NULL))).Thanks.
-
Avnish Yadav
MemberAugust 6, 2018 at 4:50 am in reply to: How to display image of picklist by formula field by using direct URL in Salesforce?Hello Anjali,
You will need to use a nested if formula.
Something like this
IMAGE(
IF(ISPICKVAL(API__c, "Confirm"), "img/msg_icons/confirm32.png",
IF(ISPICKVAL(API__c, "Error"), "img/msg_icons/error32.png",
IF(ISPICKVAL(API__c, "Warning"), "img/msg_icons/warning32.png"),
IF(etc....))
)
)
Or you can also try out the case formula that will be much easier.IMAGE(
CASE(API__c,
"Confirm", "img/msg_icons/confirm32.png",
"Error", "img/msg_icons/error32.png",
"Warning", "img/msg_icons/warning32.png",
"Info", "img/msg_icons/info32.png",
"/s.gif"),
"Status")API__c is the API Name of the picklist field that you want to base upon.
Thanks.
-
Avnish Yadav
MemberAugust 6, 2018 at 4:34 am in reply to: How to include external javascript file in Salesforce Lightning Component?Hello,
To reference a JavaScript library that you’ve uploaded as a static resource, use a <ltng:require> tag in your .cmp or .app markup.
<ltng:require scripts="{!$Resource.***resourceName***}"
afterScriptsLoaded="{!c.afterScriptsLoaded}" />Thanks.
-
Avnish Yadav
MemberAugust 3, 2018 at 6:30 am in reply to: What are the effects of using the transient keyword in Visualforce Page?Hello Chanchal,
Use the transient keyword to declare instance variables that can't be saved, and shouldn't be transmitted as part of the view state for a Visualforce page.
For example- Transient Integer currentTotal;
You can also use the transient keyword in Apex classes that are serializable, namely in controllers, controller extensions, or classes that implement the Batchable or Schedulable interface. In addition, you can use transient in classes that define the types of fields declared in the serializable classes. - SalesforceThanks.
-
Avnish Yadav
MemberAugust 3, 2018 at 6:27 am in reply to: What is @IsTest(isParallel=true) in Salesforce?Hi Prachi,
Use the @isTest(isParallel=true) annotation to indicate test classes that can run in parallel and aren't restricted by the default limits on the number of concurrent tests. This makes the execution of test classes more efficient because more tests can be run in parallel.
Thanks.
-
Avnish Yadav
MemberAugust 3, 2018 at 6:24 am in reply to: What is @testVisible used for while testing an Apex class in Salesforce?Hi Prachi,
For example, If you have an Apex class or controller, It has a Private or Protected variable or methods or inner classes. so you can't access them in other classes. But using this @testVisible annotation in a Private or Protected variable or methods or inner classes safely expose them only for test classes.
Ex: In Apex class not in Test class:// Private variable
@TestVisible private static String accountName= 'acme';
// Private method
@TestVisible private static void showRecord(String name) {
// add something
}
access them in test class accustomed.Thanks.
-
Avnish Yadav
MemberAugust 3, 2018 at 6:21 am in reply to: What is @testSetup annotation? When you will use it?Hello Prachi,
For example, we have a test class, It has two test methods and each test method required 5 account records. So without creating 5 records for each test method, we will create a new method with annotation @testSetup then create only 5 account records. These records can access all test methods using SOQL query in that test class.
Ex: @testSetup method
@testSetup static void setup() {
// Create common test accounts
List<Account> accountsLst = new List<Account>();
for(Integer i=0;i<5;i++) {
testAccts.add(new Account(Name = 'TestAc '+i));
}
Insert accountsLst;
}
Thinks to remember when you use @testSetup method:- We can use only one test setup method per class.
- Test setup method will execute first in the test class.
- If any DML error occurs in this test setup method, the rest of the method not executed.
- If a test setup method calls a non-test method of another class, no code coverage is calculated for the non-test method.
Thanks.
-
Avnish Yadav
MemberAugust 3, 2018 at 6:18 am in reply to: Which Objects can we access without using seeAllData=true?Hi Prachi,
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.
User, profile, organization, AsyncApexjob, Corntrigger, RecordType, ApexClass, ApexComponent, ApexPage and custom metadata types.Thanks.