Aman
IndividualForum Replies Created
-
Aman
MemberApril 25, 2018 at 7:54 am in reply to: How to enable schedule report options in Salesforce? -
Aman
MemberApril 24, 2018 at 5:57 am in reply to: Test is not going inside "trigger.new" while testing Salesforce TriggerHi,
Below is the code for test class. Below code providing 100% coverage.
@istest
public class SetPriceDemoTest {
@istest
public static void mytest()
{
Id pricebookId = Test.getStandardPricebookId();
pricebook2 pb = new pricebook2(id=pricebookId,isActive=true);
update pb;
Product2 po=new Product2();
po.Name='Raghav';
po.IsActive=true;
insert po;
}
} -
Aman
MemberApril 23, 2018 at 6:10 pm in reply to: Test is not going inside "trigger.new" while testing Salesforce TriggerHi,
Below is the code for your test class :
@istest(SeeAlldata=true)
public class SetPriceDemoTest {
@istest
public static void mytest()
{
Product2 po=new Product2();
po.Name='Raghav';
po.IsActive=true;
insert po;
}
} -
Aman
MemberApril 23, 2018 at 11:11 am in reply to: Can we call a future method from a Salesforce batch class using Apex?Hi ,
we can't call future method from batch class. If you try to invoke a future method from Batch/Future you will get the below error -
FATAL ERROR: Future method cant be called from future or Batch
-
Aman
MemberApril 23, 2018 at 6:44 am in reply to: Test is not going inside "trigger.new" while testing Salesforce TriggerHi Raghav,
You have not inserted the standard price book in your test class and you are querying the standard pricebook in your trigger. Insert a standard pricebook in your test class and run the test class again, it will work.
-
Aman
MemberApril 20, 2018 at 5:54 am in reply to: How can I get the list of Junction objects in Salesforce using Apex Code?Hi Deepika ,
you cannot query the list of junction objects using apex code but what you can do is query all the Sobjects using the schema class, below is the code to do :
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
system.debug('gd:::::'+gd); -
Aman
MemberApril 19, 2018 at 12:48 pm in reply to: How to hide "display:none" in html tag on a Visualforce Page Component?Hi,
I will look into it and will let you know.
-
Aman
MemberApril 19, 2018 at 11:11 am in reply to: How to hide "display:none" in html tag on a Visualforce Page Component?Hi,
Here the JavaScript is not executing. The reason is that when we add <apex:inputTextarea richText="true" ... it add hidden text area and its own iframe that shows as a text editor So when you add events to your text area its not get added to the text area which is displayed to user.
-
Aman
MemberApril 19, 2018 at 9:17 am in reply to: How to hide "display:none" in html tag on a Visualforce Page Component?can you please send the controller extension code ? so that i can try it at my end.
-
Aman
MemberApril 19, 2018 at 7:31 am in reply to: How to hide "display:none" in html tag on a Visualforce Page Component?Hi Harsh ,
You can replace the display :none by display : block. It will let you show your upload image Tab. One more thing if you want to render this tab after some action performed ,you can write a script but for that add an id to your html tag and add the below code to your script
document.getElementById("UploadImage").style.display = "block";
-
Aman
MemberSeptember 7, 2017 at 1:20 pm in reply to: How to open information about an account on click of an account through Lightning Component?Hello Shubham ,
you can try this :
server-side Controller :
public class SearchAcc {
@AuraEnabled
public static List<Account> getAccList(){
List<Account> acct=[select name,AccountNumber,phone,Description from account Limit 100];
return acct;
}@AuraEnabled
public static Account getAcc(String ID){
return[select name,Phone,Description from account where id= :ID];
}
}Component :
<aura:component controller="SearchAcc" >
<aura:registerEvent name="AccEvent" type="c:AccountDetailsEvent"/>
<aura:attribute name="Accounts" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.getList}"/>
<aura:iteration items="{!v.Accounts}" var="acc">
<h1><a id="{!acc.Id}" title="click me to do something" href="#" onclick="{!c.getID}" >
{!acc.Name}</a>
</h1>
</aura:iteration>
</aura:component>client-side controller :
({
getList : function(component, event, helper) {
var action = component.get("c.getAccList");
action.setCallback(this,function(response){
var state = response.getState();
if(state == "SUCCESS"){
alert('success')
component.set("v.Accounts",response.getReturnValue());}
});
$A.enqueueAction(action);},
getID: function(component, event, helper) {
var Ide = event.srcElement.id;
var action= component.get("c.getAcc");
action.setParams({ ID :Ide });
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// console.log(response.getReturnValue());
}
var Eve=component.getEvent("AccEvent");
Eve.setParams({ "Reqdata" :response.getReturnValue()});
console.log(Eve.getParam("Reqdata"))
Eve.fire();
});
$A.enqueueAction(action);
}
})- This reply was modified 7 years, 2 months ago by Aman.
-
Aman
MemberAugust 28, 2017 at 1:33 pm in reply to: How to find (trigger.meta.xml) file of any Trigger in Salesforce?Hello Shubham,
you can use Ant Migration to retrieve trigger.meta.xml use command Ant retrieveUnpackaged by specify the name of the trigger in your package.xml file.
your package.xml file look like this :
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>AddNameAcc</members>
<name>ApexTrigger</name>
</types>
<version>40.0</version>
</Package> -
Aman
MemberAugust 28, 2017 at 10:54 am in reply to: SOQL Query ( Accounts and Contacts ) in SalesforceHello Rahul ,
you can try this :
public class SearchCont {
public static List<Account> acct;
public static List<AggregateResult> aggRes;
public static void contSearch(){
List<String> ide=new List<String>();
aggRes =[select accountId,count(id) from contact where account.name !=null group by accountId having count(id) >1];
for (AggregateResult ar : aggRes) {
ide.add((String)ar.get('accountId'));
}
acct=[select name,(select LastName,FirstName from contacts) from account where id in :ide ];
for(account acc: acct){
system.debug('###'+acc);
for(contact con: acc.contacts){
system.debug('###'+con.LastName);
system.debug('###'+con.FirstName);}
}
}
} -
Hello Vijay,
All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, flows, Apex, and the SOAP API.
you can refer to the below given link :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_customsettings.htm
-
Hello Uday,
you can try this :
trigger Handler :
public class triggerHandler {
public static boolean fact=true;}
trigger :
trigger ContactUp on Contact (after insert,after update) {
if(triggerHandler.fact==true ){
triggerHandler.fact=false;
List<Contact> li123=[select id from contact where id in :trigger.new];
system.debug('####################');
for(contact con :li123){
con.description ='aaaaaaaaaaaaaaaa';
}
update li123;
}
} -
Aman
MemberAugust 10, 2017 at 2:05 pm in reply to: Messaging.EmailFileAttachment vs Messaging.singleEmailMessage in Salesforce?Hello shubham,
SingleEmailMessage Methods :
Contains methods for sending single email messages.
Namespace
Messaging
Usage
All base email (Email class) methods are also available to the SingleEmailMessage objects.Email properties are readable and writable. Each property has corresponding setter and getter methods. For example, the toAddresses() property is equivalent to the setToAddresses() and getToAddresses() methods. Only the setter methods are documented.
EmailFileAttachment Class :
EmailFileAttachment is used in SingleEmailMessage to specify attachments passed in as part of the request, as opposed to existing documents in Salesforce. -
Aman
MemberAugust 10, 2017 at 1:41 pm in reply to: How to get csv file in a web service post method in Salesforce?Hello Shariq,
you can try this :
@RestResource(urlMapping='/contactCsv/*')
global class RESTContactController {
@HttpPost
global static void newContacts(){
RestRequest req = RestContext.request;
System.debug('csv'+req);
}
} -
Hello Shubham,
The handy Log Inspector exists to make it easier to view large logs! The Log Inspector uses log panel views to provide different perspectives of your code. Check it out by selecting Debug | View Log Panels.
These panels are available in the Log Inspector.
Stack Tree—Displays log entries within the hierarchy of their objects and their execution using a top-down tree view. For instance, if one class calls a second class, the second class is shown as the child of the first.
Execution Stack—Displays a bottom-up view of the selected item. It displays the log entry, followed by the operation that called it.
Execution Log—Displays every action that occurred during the execution of your code.
Source—Displays the contents of the source file, indicating the line of code being run when the selected log entry was generated.
Source List—Displays the context of the code being executed when the event was logged. For example, if you select the log entry generated when the faulty email address value was entered, the Source List shows execute_anonymous_apex.
Variables—Displays the variables and their assigned values that were in scope when the code that generated the selected log entry was run.
Execution Overview—Displays statistics for the code being executed, including the execution time and heap size. -
Hello Shariq,
you can try this :
List<contact> conList =new List<contact>();
for(Id ide :mapAccIdVsCon.keySet())
{
for(Contact c : mapAccIdVsCon.get(ide))
{
conList.add(c);
}
}
insert conList; -
Aman
MemberAugust 8, 2017 at 12:38 pm in reply to: pageblockSection is not rendered on click of commandButtonHello Saloni,
You can try this :
VF page;-
<apex:page controller="SearchAccountCon" tabStyle="Account">
<apex:form ><apex:inputText value="{!searchString}" />
<apex:commandButton value="search" action="{!search}" rerender="pageblId"/><apex:pageBlock >
<apex:pageBlockTable value="{!acct}" var="acc" id ="pageblId">
<apex:column headerValue="Acccount Name" >
<apex:commandLink value="{!acc.name}" action="{!getCont}" reRender="LinkId" >
<apex:param value="{!acc.Id}" name="LinkCont" assignTo="{!SearchId}"/>
</apex:commandLink>
</apex:column>
<apex:column >
<apex:pageBlockTable value="{!cont}" var="con" id="LinkId">
<apex:column value="{!con.LastName}"/>
<apex:column value="{!con.id}"/>
</apex:pageBlockTable>
</apex:column></apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>Apex class :
public class SearchAccountCon {
public String SearchId{get;set;}
public String searchString {get; set; }
public List<Account> acct{get;set;}
public List<contact> cont{get;set;}
public void search(){acct= Database.query('Select Name, description From Account WHERE Name LIKE \'%'+searchString+'%\' Limit 100');
cont = new List<contact>();}
public void getCont(){
cont=[select id,LastName,accountId from contact where accountID =:SearchId];
}
} -
Aman
MemberAugust 8, 2017 at 12:32 pm in reply to: What is the difference between Render vs Rerender in Salesforce?Hello Shubham,
Rendered :
A visualforce component in a VF page can be displayed or hidden by using rendered attribute. Rendered is bound to a Boolean variable in controller which can be switched between true and false making the vf component display or hide depending on Boolean value.
ReRender :
Rerender is used to refresh a particular section of the visualforce page. We have to just mention the id of the page section (in the Rerender attribute) that needs to be refreshed.you can refer to this Link :
http://sfdcsrini.blogspot.com/2014/08/what-is-difference-between-rendered.html
-
Aman
MemberAugust 8, 2017 at 12:26 pm in reply to: By Map count all contact related to Account and,store contacts into a list.Do't use triggerHello Raghav,
you can try this :
public class CountContacts {
public static void getAllContact(){
Map<Id,Integer> AccountIdVsContact = new Map<Id,Integer>();
Set<Id> accid =new Set<Id>();
List<contact> cont =[select Lastname,accountId from contact Limit 100];
system.debug('@@@@'+cont.size());
for(contact con: cont){
accid.add(con.accountid);
}for(Id id :accid){
AccountIdVsContact.put(id, [select Lastname,accountId from contact where accountid= :id].size());
}
system.debug('#####'+AccountIdVsContact.values());
}
} -
Aman
MemberAugust 3, 2017 at 1:28 pm in reply to: How to query Custom settings in Salesforce Apex code?Hello shariq,
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. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary with profile or user, but is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. Because the data is cached, access is low-cost and efficient: you don't have to use SOQL queries that count against your governor limits.
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. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.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).Hierarchy Custom Setting Methods
The following are instance methods for hierarchy custom settings.
getInstance()
Returns a custom setting data set record for the current user. The fields returned in the custom setting record are merged based on the lowest level fields that are defined in the hierarchy.
getInstance(userId)
Returns the custom setting data set record for the specified user ID. The lowest level custom setting record and fields are returned. Use this when you want to explicitly retrieve data for the custom setting at the user level.
getInstance(profileId)
Returns the custom setting data set record for the specified profile ID. The lowest level custom setting record and fields are returned. Use this when you want to explicitly retrieve data for the custom setting at the profile level.
getOrgDefaults()
Returns the custom setting data set record for the organization.
getValues(userId)
Returns the custom setting data set record for the specified user ID.
getValues(profileId)
Returns the custom setting data set for the specified profile ID. -
Hello saloni,
Use Metadata API to retrieve, deploy, create, update or delete customization information, such as custom object definitions and page layouts, for your organization. This API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself. To create, retrieve, update or delete records, such as accounts or leads, use data SOAP API or REST API.
you should refer to this Link :
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_intro.htm
-
Hello shariq,
The result of an insert or update DML operation returned by a Database method.
Usage
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.A SaveResult object is generated when a new or existing Salesforce record is saved.
you can refer to this link: