Parul
IndividualForum Replies Created
-
Parul
MemberSeptember 18, 2018 at 8:32 pm in reply to: How to remove single and multi-line comments from a string in Salesforce apex?May be use this to remove:
.replace(///.*?/?*.+?(?=n|r|$)|/*[sS]*?//[sS]*?*//g, ”)
Thanks
-
RESTful web services are built to work best on the Web. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs), typically links on the Web. The resources are acted upon by using a set of simple, well-defined operations. The REST architectural style constrains an architecture to a client/server architecture and is designed to use a stateless communication protocol, typically HTTP. In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.
Features of RESTful Services:
Representations
Messages
URIs
Uniform interface
Stateless
Links between resources
Caching -
@TestVisible Annotation.
This annotation enables a more permissive access level for running tests only. TestVisible annotation allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes.
@testSetup: For most unit tests in Salesforce, we need to generate some test data. And for different test methods within one single test class, the required test data set is usually very close. In order to serve for this purpose, Salesforce has introduced TestSetup annotation. The data generated in TestSetup will be persisted for every test method within the test class to use. And the data will only be rolled back after the execution of the whole test class completes.Methods defined with the @testSetup annotation are used for creating common test records that are available for all test methods in the class.
Thanks
-
Hi
@testSetup: For most unit tests in Salesforce, we need to generate some test data. And for different test methods within one single test class, the required test data set is usually very close. In order to serve for this purpose, Salesforce has introduced TestSetup annotation. The data generated in TestSetup will be persisted for every test method within the test class to use. And the data will only be rolled back after the execution of the whole test class completes.Methods defined with the @testSetup annotation are used for creating common test records that are available for all test methods in the class.
Thanks. -
Parul
MemberSeptember 18, 2018 at 8:16 pm in reply to: How can you create partial page refreshes in Visualforce?Adding some more point:
One of the most widely used Ajax behaviours is a partial page refresh, in which only a specific portion of a page is updated/refreshed following some user action, rather than a reload of the entire page.
The simplest way to implement a partial page update is to use the reRender attribute on an <apex:commandLink> or <apex:commandButton> tag to identify a component that should be refreshed. When a user clicks the button or link, only the identified component and all of its child components are refreshed.
For example, consider the contact list example shown in Getting and Setting Query String Parameters on a Single Page. In that example, when a user clicks the name of a contact in the list to view the details for that contact, the entire page is refreshed as a result of this action. With just two modifications to that markup, we can change the behaviour of the page so that only the area below the list refreshes:
1. First, create or identify the portion of the page that should be rerendered. To do this, wrap the <apex:detail> tag in an <apex:outputPanel> tag, and give the output panel an id parameter. The value of id is the name that we can use elsewhere in the page to refer to this area. It must be unique in the page.
2. Next, indicate the point of invocation (the command link) that we want to use to perform a partial page update of the area that we just defined. To do this, add a reRender attribute to the <apex:commandLink> tag, and give it the same value that was assigned to the output panel's id.
Thanks
-
Parul
MemberSeptember 18, 2018 at 8:13 pm in reply to: How to Invoke Rest Service from Visualforce page?Hi
Salesforce has introduced a concept called AJAX ToolKit, which help us to make REST API call from the JavaScript in Visualforce Page. Here is an example to invoke REST API from Visualforce Page. In below example I’m using http://fixer.io/ web service HTTP callout and send a GET request to get the foreign exchange rates. The foreign exchange rates service sends the response in JSON format.
Here is the code snippet:
<apex:page>
<apex:includeScript value="//code.jquery.com/jquery-1.11.1.min.js" />
<script>
function apiCall() {
//Get a reference to jQuery that we can work with
$j = jQuery.noConflict();
//endpoint URL
var weblink = "https://api.fixer.io/latest?base=USD";$j.ajax({
url: weblink,
type: 'GET', //Type POST or GET
dataType: 'json',
beforeSend: function(request) {
//Add all API Headers here if any
//request.setRequestHeader('Type','Value');
},crossDomain: true,
//If Successfully executed
success: function(result) {
//Response will be stored in result variable in the form of Object.
console.log('Response Result' + result);//Convert JSResponse Object to JSON response
var jsonResp = JSON.stringify(result);
document.getElementById("apiData").innerHTML = jsonResp;
},//If any Error occured
error: function(jqXHR, textStatus, errorThrown) {
//alert('ErrorThrown: ' + errorThrown);
}
});
}
</script>
<apex:form>
<!--call javaScript-->
<input type="button" value="Call API" onclick="apiCall()" />
<div id="apiData">
</div>
</apex:form>
</apex:page> -
Apex code coverage requires that you generate a test record in your test class and test how it behaves under the custom logic in your trigger or apex code.
This test class should atleast touch 75% of your custom code. In other words the more scenarios or records you create for a test class the greater your coverage would be.
You can check your code coverage in developer console. The red part depicts code that has not been covered, blue for covered and white lines for code that does not require coverage.Thanks
-
Parul
MemberSeptember 18, 2018 at 8:03 pm in reply to: How to get values stored in custom metadata type object in Salesforce Apex?Hi
You can do query like this
SELECT Entity_Relationship__c, Field_Relationship__c, Default__c FROM Source_Default_Value__mdt WHERE Entity_Relationship__c = ‘Account’.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:58 pm in reply to: What is the actual use of Serialization and Deserialization of a JSON?Hi
JSON is a format that encodes objects in a string. Serialization means to convert an object into that string, and deserialization is its inverse operation.
When transmitting data or storing them in a file, the data are required to be byte strings, but complex objects are seldom in this format. Serialization can convert these complex objects into byte strings for such use. After the byte strings are transmitted, the receiver will have to recover the original object from the byte string. This is known as deserialization.
Example you have an object
{foo: [1, 4, 7, 10], bar: "baz"}
serializing into JSON will convert it into a string:'{"foo":[1,4,7,10],"bar":"baz"}'
which can be stored or sent through wire to anywhere. The receiver can then deserialize this string to get back the original object. {foo: [1, 4, 7, 10], bar: "baz"}Thanks
-
Parul
MemberSeptember 18, 2018 at 7:56 pm in reply to: How to use Salesforce Custom Metadata Loader to load bulk records in one go?Hi,
You can use custom metadata loader you load or update up to 200 records with a single call. You can search “Load or Update Records with the Custom Metadata Loader” in the Salesforce Help Articles.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:53 pm in reply to: Is there any way to select all fields of object via soql query in Salesforce?Hi
you can use following code to get fields.
SObjectType objectType = Schema.getGlobalDescribe().get(‘objectAPIName’);
Map<String,Schema.SObjectField> mfields = objectType.getDescribe().fields.getMap();mfields map have field names for that particular object which you will mention in objectAPIName.
I hope this help you.
-
Parul
MemberSeptember 18, 2018 at 7:52 pm in reply to: Is there any way to get all the fields of the sObject without using their API names?I want to add some points:
public Void GetAllField()
{
String query =”;
String SobjectApiName = ‘Account’;
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();String strFields = ”;
for(String fieldName : fieldMap.keyset() )
{
if(strFields == null || strFields == ”)
{
strFields = fieldName;
}else{
strFields = strFields + ‘ , ‘ + fieldName;
}
}query = ‘select ‘ + strFields + ‘ from ‘ + SobjectApiName + ‘ Limit 10 ‘;
List <Account> accList = Database.query(query);
}
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:50 pm in reply to: How to restrict a user from switching to classic from lightning and vice-versa in Salesforce?I want to add some points:
If you want to restrict the behavior for a user, then disable at profile and do not assign any permission set that provides access to the lightning experience while assign permission set to users needing the functionality.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:46 pm in reply to: How to make a div block rendered on a particular event in Salesforce Lightning?Hi
You can render the content inside the div by setting the attribute inside Javasript and you can put your div tag inside the <aura:if> and set the boolean value from JavaScript. It will rerender automatically.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:43 pm in reply to: When creating a test callout for POST method, Is it necessary to set values of setHeader, setBody?Yes, we have to get the fake responsive via setBody with all the related files and setHeader() act as key-value pair that sets the contents of the request header so that 75% of code must have test coverage.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:40 pm in reply to: Is it possible to insert a Salesforce Parent-Child record in one DML operation?Here I am adding code snippet:
public class ParentChildSample {
public static void InsertParentChild() {
Date dt = Date.today();
dt = dt.addDays(7);
List<Opportunity> opp = new List<Opportunity>();
List<Account> acc = new List<Account>();for(Integer i = 0; i < 3; i++){
Opportunity newOpportunity = new Opportunity(Name='OpportunityWithAccountInsert ' +i,StageName='Prospecting',CloseDate=dt);
Account accountReference = new Account(MyExtID__c='SAP111111'+i);
newOpportunity.Account = accountReference;
Account parentAccount = new Account(Name='Hallie '+i);
system.debug('DDDDDDDDDDDDDDDDDD'+newOpportunity.Account);
opp.add(newOpportunity);
acc.add(parentAccount);}
Database.SaveResult[] results = Database.insert(acc,opp);
for (Integer i = 0; i < results.size(); i++) {
if (results[i].isSuccess()) {
System.debug('Successfully created ID: '+ results[i].getId());
} else {
System.debug('Error: could not create sobject '+ 'for array element ' + i + '.');
System.debug(' The error reported was: '+ results[i].getErrors()[0].getMessage() + '\n');
}
}
}
}Thanks
-
Parul
MemberSeptember 18, 2018 at 7:36 pm in reply to: Which one to use and why - JavaScript Remoting and Remote Objects?Visualforce Remote Objects:
Makes basic “CRUD” object access easy
Doesn’t provide automatic relationship traversals; you must look up related objects yourself.JavaScript Remoting:
Requires both JavaScript and Apex code
Uses network connections (even) more efficientlyThanks
-
Parul
MemberSeptember 18, 2018 at 7:34 pm in reply to: How to get global picklist value set in a Salesforce Visualforce page?I am adding some points:
The only way to reference global picklist values in Visualforce would be to create a custom field that uses your global picklist, and then reference that field in your Visualforce page.
Thanks
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:32 pm in reply to: What is the difference between a Role and Profile in Salesforce?Role = controls records a user can SEE in the hierarchy
Roles controle which records/objects a user can SEE based on their role in the hierarchy.
Profile = what a user can DO
Profile settings determine what users can see (control the visibility of objects, tabs, CRUD, fields) and do with objects. Profiles are typically defined by a job function. Each profile is associated with a license type.
What do profile controls?
1. User interface: Tabs, page layouts, record types, applications
2. Access to data: Field level security
3. Login hours and login IP ranges
4. Permissions: App, System, Standard/Custom object CRUDThanks
-
Parul
MemberSeptember 18, 2018 at 7:31 pm in reply to: How to insert Quick Text in Salesforce Lightning?Quick text is predefined messages, like greetings, answers to common questions, and short notes. One can insert quick text in the case feed publisher, emails, chats, and more. Available in Salesforce Classic in Enterprise, Performance, Unlimited, and Developer Editions.
1. Go to setup, enter Quick Text Settings in the Quick Find box, then select Quick Text Settings.
Click Enable Quick text.Remember once quick text is enabled it can’t be turn off.
Click save.
2. Create a Quick Text Message. Following are the steps to create quick text message :
3. Inserting Quick text .Let’s insert quick text in an email reply. Following are the steps to insert Quick text :In the Service Console, open a case. Click the Feed tab to see the Case Feed.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:25 pm in reply to: How to disable Quick Text in Salesforce Classic after enabling it?Introduction Quick Text:
Quick text is predefined messages, like greetings, answers to common questions, and short notes. One can insert quick text in the case feed publisher, emails, chats, and more. Available in Salesforce Classic in Enterprise, Performance, Unlimited, and Developer Editions.
-
Parul
MemberSeptember 18, 2018 at 7:23 pm in reply to: How to disable Quick Text in Salesforce Classic after enabling it?In addition to the above response, you can find this by following the bellow steps:
Once Quick text is enabled ,it can’t be turned off.
Click on “Setup” button.
Search “Quick Text Settings” under Quick Text option in “Quick Search/Find” box.
Now you can disable it by unchecking the checkbox.
Then click on “Save” button. -
Parul
MemberSeptember 18, 2018 at 7:20 pm in reply to: How many records can we display on page for a report in Salesforce?Hi
We can display up to 2000 records on a page. If more records are there to display we cannot see those through user interface. If you export the records to a excel sheet then you can export all records.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:18 pm in reply to: What is Grant Account Login Access? How to enable Grant Account Login Access in Salesforce?rant Account login access in salesforce is a powerful feature provide by salesforce. Sometimes you may have queries or issues with salesforce itself or the applications you have installed in your salesforce org. In order to assist you with the issue, you can grant account login access to the salesforce.com support or other Provider support whose applications you have installed in your org for a definite time.
Salesforce support to enable the "Enables Org Admins to log in as any user without having access granted by the users" permission on your Org.
You can then turn the feature on by going to Your Name > Setup > Security Controls > Login Access Policies > Administrators Can Log in as Any User. Once that is done you should have the Login action link available for all users.
Otherwise you can ask the individual users to grant you login access by going to Your Name > My Personal Information > Grant Login Access.
Thanks
-
Parul
MemberSeptember 18, 2018 at 7:11 pm in reply to: How to create custom objects/setting using Apache Ant in Salesforce?here is code snippet
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>CustomMetadata</name>
</types>
<version>40.0</version>
</Package>Custom Object:
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>ABC__mdt</members>
<name>CustomObject</name>
</types>
<version>40.0</version>
</Package>Thanks