Himanshu Jasuja
IndividualForum Replies Created
-
Himanshu
MemberAugust 2, 2016 at 1:26 pm in reply to: When should I use Lists and Maps and Sets in Apex?Hi Pranav,
List : A list is an ordered collection
so use list when you want to identify list element based on Index Number.(List can contain Duplicates)
EX: ListSet: A set is an unordered collection of primitives or sObjects that do not contain any duplicate elements.
So, use set if you want to make sure that your collection should not contain Duplicates.
EX: SetMap: A map is a collection of key-value pairs where each unique key maps to a single value. Keys can be any primitive data type, while values can be a primitive, sObject, collection type or an Apex object. For example, the following table represents a map of countries and currencies
Hope this helps you.
-
Himanshu
MemberAugust 2, 2016 at 1:23 pm in reply to: When to use Test.isRunningTest() in Salesforce Apex Class?Hi Pranav,
isRunningTest()
Returns true if the currently executing code was called by code contained in a test method, false otherwise. Use this method if you need to run different code depending on whether it was being called from a test.
Other scenarios:
1) To ensure the trigger doesn't execute the batch if Test.IsRunningTest() is true, and then test the batch class with it's own test method.
2) Testing callouts - in your callout code you check to see if you're executing within a unit test context by checking Test.isRunningTest() and instead of getting your callout response from an HttpResponse.send() request, you return a pre-built test string instead. -
Himanshu
MemberAugust 2, 2016 at 1:15 pm in reply to: What is the difference between WhoId and WhatId?Hi Hazel,
WhoID - refers to people things.Ex- Lead ID or a Contact ID
WhatID- refers to object type things.Ex- Account ID or an Opportunity ID -
Himanshu
MemberAugust 1, 2016 at 12:53 pm in reply to: Is there any way that we can find that particular sobject query can we applied or not in apex code?Hi Mohit,Can you elaborate your question and give us more detail of your requirement?
-
Himanshu
MemberAugust 1, 2016 at 12:50 pm in reply to: What is difference between the Test environment for the class and the Production environment for the class?Hi Mohit,
Hi
Production Enviroment of Apex Class:- its a piece of code which do some task in your application.
in simple if you have written a piece of code to add two fields and display that in another field.Ex:-
Public Class add{
your code..........
}Test Enviroment of Apex test Class :-its also a piece of code which test the functionality of the apex class.
Ex:-to check the above apex program is performing correctly or not in runtime ,you will write test method by insert in some dummy data and checking the out put in the same class by using system assert function.apex test class syntax:-
@isTest
private class add {
static testMethod void add() {
Your test code...............
}
} -
Hi Mohit,
Below is the code of fetching data via dynamic query and shows on the visualforce page.
public class selectAllSOQLExampleController {
public List accList{get;set;}
public String query{get;set;}
public selectAllSOQLExampleController(){
}
public PageReference fetch(){
String SobjectApiName = 'Account';
Map schemaMap = Schema.getGlobalDescribe();
Map fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();String commaSepratedFields = '';
for(String fieldName : fieldMap.keyset()){
if(commaSepratedFields == null || commaSepratedFields == ''){
commaSepratedFields = fieldName;
}else{
commaSepratedFields = commaSepratedFields + ', ' + fieldName;
}
}query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Limit 5';
accList = Database.query(query);
return null;
}
}Hope this helps you.
-
Himanshu
MemberAugust 1, 2016 at 10:59 am in reply to: How to send an automatic email to owner that a particular user opens the record based on role hierarchy?Hi Pranav,
You can use the workflow(Email Alert) to send the email to owner.
-
Himanshu
MemberAugust 1, 2016 at 8:16 am in reply to: How can I overwrite the standard lookup field?Hi Pranav,
You can follow Jeff's tutorial to override standard lookup.
http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window
Hope this helps you.
-
Himanshu
MemberAugust 1, 2016 at 8:07 am in reply to: How can I disable any(either custom or standard) button after performing its action?Hi Pranav,Try the below code that helps you to disable and enable the button.
My Button
Disable "My Button"
Undisable "My Button"function disableBtn() {
document.getElementById("myBtn").disabled = true;
}function undisableBtn() {
document.getElementById("myBtn").disabled = false;
} -
Himanshu
MemberAugust 1, 2016 at 7:31 am in reply to: How to store/enter more than 255 characters in a custom setting field?Hi Pranav,
No, you can't currently store more than 255 characters in any field in a Custom Setting. If you absolutely need this, you'd have to use multiple fields or use a full-blown Custom Object.
-
Himanshu
MemberJuly 29, 2016 at 1:28 pm in reply to: How can I use soql query on sobject in community user in apex?Hi Pranav,
If you have the sobject name in a string, e,g, 'sobjname', you can then query back the record via something like:
String queryStr='select id from ' + sobjname;
List<sobject> = Database.query(queryStr);
Hope this helps you.
-
Himanshu
MemberJuly 29, 2016 at 1:05 pm in reply to: Can we direct Access a server side controller method from lightning component?Hi Tanu,
You can't access directly the server side controller method.Use the @AuraEnabled annotation to enable client- and server-side access to the controller method in lightning.
-
Himanshu
MemberJuly 29, 2016 at 11:57 am in reply to: Is there any way to duplicate the visualforce page in Salesforce community?Hi Mohit,
You cannot duplicate the Visual force page in Salesforce community but you can clone the page.
-
Himanshu
MemberJuly 29, 2016 at 11:53 am in reply to: How to use console component in salesforce classic? Is there any way to use it in standard app?Hi Pranav,
Go to Setup, enter Apps in the Quick Find box, then select Apps.
Select a console app.
Click Edit.
In Choose Custom Console Components, add available components to your app.
In Align Console Components, choose whether to align components to the left or right of the console’s footer.
Click Save.We can't use console component in standard app.Its only use in “Customize Application” and “Service Cloud User” OR “Sales Console”.
Hope its helps you.
-
Himanshu
MemberJuly 28, 2016 at 12:38 pm in reply to: If we declare lightning style in a Salesforce lightning component does it affect lightning application?Hi Pranav,
if you use this tag that's that helps you to provide the standard css in your lightning pages.
<ltng:require styles=”{!$Resource.REPLACE_WITH_NAME_OF_SLDS_STATIC_RESOURCE +’/assets/styles/salesforce-lightning-design-system-ltng.css’}”/>
-
Himanshu
MemberJuly 28, 2016 at 12:28 pm in reply to: How can we export the result of a query editor in to the file?Hi Mohit,
You can use the Developer Workbench to export the results in csv:
-
Himanshu
MemberJuly 28, 2016 at 11:13 am in reply to: How to make output link work for both drill down and open a new tab?Hi Tanu,
<apex:outputLink value="{!redirectUrl}" onClick="window.top.location.href = '{!redirectUrl}'; return false;">{!fa[field]}
</apex:outputLink> -
Hi Tanu,
<apex:page controller="testcontroller">
<apex:form >
<apex:pageBlock >
<apex:commandButton value="Process"/>
<apex:inputCheckbox value="{!output1}">Export</apex:inputCheckbox>
<apex:inputCheckbox value="{!output2}">Import</apex:inputCheckbox>
<apex:outputPanel id="out1" rendered="{!output1}">
<p>hello this is sfdc</p>
</apex:outputPanel>
<apex:outputPanel id="out2" rendered="{!output2}">
<p>HEllo this is nitesh</p>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>controller:-
//##controller code
public with sharing class testcontroller{
public boolean output2 { get; set; }
public boolean output1 { get; set; }
public testactionsupportcontroller(){
output1=false;
output2=false;}
}
Hope this helps you.
-
Hi Pranav,
In this code we have used some approval methods that helps for execution the process by code.
public class TestApproval {
void submitAndProcessApprovalRequest() {
// Insert an account
Account a = new Account(Name='Test',annualRevenue=100.0);
insert a;User user1 = [SELECT Id FROM User WHERE Alias='SomeStandardUser'];
// Create an approval request for the account
Approval.ProcessSubmitRequest req1 =
new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval.');
req1.setObjectId(a.id);// Submit on behalf of a specific submitter
req1.setSubmitterId(user1.Id);// Submit the record to specific process and skip the criteria evaluation
req1.setProcessDefinitionNameOrId('PTO_Request_Process');
req1.setSkipEntryCriteria(true);// Submit the approval request for the account
Approval.ProcessResult result = Approval.process(req1);// Verify the result
System.assert(result.isSuccess());System.assertEquals(
'Pending', result.getInstanceStatus(),
'Instance Status'+result.getInstanceStatus());// Approve the submitted request
// First, get the ID of the newly created item
List<Id> newWorkItemIds = result.getNewWorkitemIds();// Instantiate the new ProcessWorkitemRequest object and populate it
Approval.ProcessWorkitemRequest req2 =
new Approval.ProcessWorkitemRequest();
req2.setComments('Approving request.');
req2.setAction('Approve');
req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});// Use the ID from the newly created item to specify the item to be worked
req2.setWorkitemId(newWorkItemIds.get(0));// Submit the request for approval
Approval.ProcessResult result2 = Approval.process(req2);// Verify the results
System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());System.assertEquals(
'Approved', result2.getInstanceStatus(),
'Instance Status'+result2.getInstanceStatus());
}
}Hope this helps you.
-
Himanshu
MemberJuly 28, 2016 at 10:27 am in reply to: How to create reusable methods in Lightning JS client side controller for reuse within the client side controller itself?Hi Tanu,
All the reusable code in the helper section in lightning - "helper.functionname(component,event)". In case, if the helper method themselves need to call other methods, then you can call the same by using the "this" keyword.
-
Himanshu
MemberJuly 28, 2016 at 10:12 am in reply to: How we can add inline visualforce page edit view in sobject?Hi Mohit,
In New and Edit page overriden by VF page you can still enable inline editing by adding a new page for detail override.
<apex:page standardController="Opportunity">
<apex:detail inlineEdit="true"/>
</apex:page>You just need to create a VF page with the standard controller as the sObject for which we want detail page to be overriden for inline editing.
Hope this helps you.
-
Himanshu
MemberJuly 28, 2016 at 8:15 am in reply to: Difference between 'with sharing' and 'without sharing'?Hi Mohit,
Without Sharing: the code runs in system context; all records and fields are available for use.Sharing rules are not applied for the current user.
With Sharing: the code runs in user context; DML operations may fail because of sharing settings, and queries will only return values available to the user.sharing rules for the current user are enforced
System Context: the code has full access to all records and fields in the system.
User Context: the code can only access records (and possibly fields, such as executeAnonymous calls) available to the user.
-
Hi Pranav,Use the below code to assign portal user in test class.
ID ProfileID = [ Select id from Profile where name = 'Customer Portal Manager Custom'].id;
Account acc = new Account(Name = 'Test Account');
insert acc ;
List<Contact> ContactList = new List<Contact>();
Contact Con = new Contact( AccountID = acc .id, FirstName = 'User', LastName = 'test',
email = '[email protected]' );
insert Con;
User u = new User( email='[email protected]', contactid = Con.id, profileid = profileid, UserName='[email protected]', alias='tuser', CommunityNickName='tuser',
TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1',
LanguageLocaleKey='en_US', FirstName = 'User', LastName = 'Test' );
insert u;
Hope this helps you.
-
Himanshu
MemberMay 31, 2016 at 11:41 am in reply to: How do I prepopulate fields on a Standard layout?Hi Ravi,
You can achieve this by passing the values to the standard field id's in the url. In this instance, you'd retrieve the standard id of the "Amount" field, and then use this Id in the url to assign a static value to the Amount field. Override the standard "New Opportunity" button to redirect to this url, and you are set to go.
-
Himanshu
MemberMay 31, 2016 at 10:45 am in reply to: What are the recommended ways to refactor in Apex?Hi Ravi,
you can do it with File search in eclipse, but instead of a new class. I mostly create a new method with required changes in the same class, after all the dependencies are updated I just delete the old method header and reuse the same old code with new one. Same applies to variables as well.