Yogesh Sharma
IndividualForum Replies Created
-
Yogesh
MemberDecember 12, 2019 at 7:49 am in reply to: Hoe to override new button to choose the record type automatically in Salesforce for below use case?Hi,
Click on Name | Setup | App Setup | Customize | Cases | Buttons, Links and Actions
Click on Edit link available near to New button
Navigate to Override Properties Section select Visualforce page and then select a value for Skip Record Type Selection Page checkbox
I hope this will help You.Thank you
-
Yogesh
MemberDecember 11, 2019 at 10:29 am in reply to: How to display dynamically added picklist value as a picklist value and as picklist field for that parent object in Salesforce?Hello,
I m assuming your controller property to get the options looks something like one of the following
If you are taking the values directly from a specific picklist field
public List<SelectOption> getMyOptions() {
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult field = yuopurObject.YourField.getDescribe();for (Schema.PicklistEntry f : field.getPicklistValues()){
options.add(new SelectOption(f.getLabel(), f.getLabel()));
}
return options;
}
Or if you are manually adding the options, then something like thispublic List<SelectOption> getMyOptions() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Option1','Option1'));
options.add(new SelectOption('Option2','Option2'));
options.add(new SelectOption('Option3','Option3'));
return options;
}
If you want to adjust the options according to profile then you could simply do something like thispublic List<SelectOption> getMyOptions() {
List<SelectOption> options = new List<SelectOption>();
//Might want to look into storing in a custom setting to avoid SOQL call
Profile p = [Select Id, Name From Profile Where Name = 'Your Profile Name'];
if(System.Userinfo.getProfileId() = p.Id){
//add your values here
}else{
//add alternate values here
}return options;
} -
Yogesh
MemberDecember 11, 2019 at 10:22 am in reply to: What is the user external id in the upsert operation? Which fields can be external id fields in Salesforce?Hello,
External ID is field in Salesforce to say that this field is primary key in external Database which can be used to identify that external record exists in Salesforce or not ? There are many benefits of external key like :
It can be used to identify if record exists or not and record automatically inserted or updated using upsert operation
Upsert operation is supported by Dataloader, Apex and API
Any field marked as external id is indexed and can be used in SOQL or report filter
You can create Parent child record in single statement in Apex
Using Upsert operation to create/update child record and relate to existing parent record with help of External IdLets assume that you have list of contacts and Account in external SQL Server database and you want to import those Account and contact weekly. It is possible that you have already imported contacts previously so don’t want to duplicate records if already created in Salesforce. To solve this problem we can use external Id on Contact and use upsert operation on dataloader. Let’s assume external Id field on Contact is “SQL_Server__Id__c” (I am assuming that Account records in Salesforce also have external Id and records are already imported. Same below steps can be used to import Account record as well).
Launch Dataloader installed from Salesforce and make sure settings like “Batch Size”, “Server host”, “Start at row” are correct.
Salesforce Dataloader Settings
click on “Upsert” button.
Login Window may appear, so enter your Username and Password+Security token.
Select “Contact” object in next window and choose CSV file of contact you want to import in Salesforce.
It will alert informing total number of records going to be processed, click OK.
In next screen , you will be prompted to select field from Contact which should be used by Salesforce to identify record and take decision that it needs to be updated or inserted. Id field and all fields which are marked as external Id will be listed here. Don’t expect this screen in any other operations except upsert.
External Id choice in Upsert operation of Dataloader
As shown in above image, select correct external Id field (in this case SQL_Server_Id__c) and click next.
Next screen will show list of all Parent Object and each object will provide choice to select either Id field or external id field of Parent Object. This is one of amazing feature of Salesforce where Parent child relationship can be established with help of external Id (No need to use excel sheet Vlookup functions to extract 15 digit Salesforce Id to establish relationship). In this case example, we only want to create relationship with Account so we will use only Account’s external Id and leave others unselected.
Create Parent child relationship using External Id in Dataloader
At end of this article, I have provided Youtube Video link following same steps.
In Next window we need to map CSV file field with Salesforce fields. One point to notice in below image, how we are mapping Parent Account’s External Id with contact record.
Field Mapping to create Parent Child relationship using ExternalId in Salesforce
Once all of above steps are followed, we can click on Next window and upsert operation will start. Salesforce will provide CSV file of success and failure results to perform post analysis of operation. -
Yogesh
MemberDecember 11, 2019 at 10:19 am in reply to: How to send an email notification to specific set of users when a Salesforce Visualforce Page gets updated?Hello,
ublic class CheckPageUpdates implements Schedulable {
public void execute(SchedulableContext context) {
LastTimeChecked__c check = LastTimeChecked__c.getOrgDefaults();
if(check != null) {
check = new LastTimeChecked__c(LastCheckedDateTime__c=DateTime.now());
}
ApexPage[] pagesModified = [SELECT Name FROM ApexPage WHERE LastModifiedDate <= :check.LastCheckedDateTime__c];
if(!pagesModified.isEmpty()) {
// Send an email or something here
}
check.LastCheckedDateTime__c = DateTime.now();
upsert check;
}
You can schedule this for whatever frequency you like, such as hourly:System.schedule('MonitorVFChanges', '0 0 * * * ?', new CheckPageUpdates());
-
Yogesh
MemberDecember 10, 2019 at 7:18 am in reply to: How to schedule batch class based on country in Salesforce?Hello,
global class Scheduler_class implements Schedulable{
public static String sched = '0 00 00 * * ?'; //Every Day at Midnight
global static String scheduleMe() {
Scheduler_class SC = new Scheduler_class();
return System.schedule('My batch Job', sched, SC);
}global void execute(SchedulableContext sc) {
batchAUpdate_based_on_stage b1 = new batchAUpdate_based_on_stage();
ID batchprocessid = Database.executeBatch(b1,50);
}
} -
Yogesh
MemberDecember 10, 2019 at 7:16 am in reply to: Do you know how to get the thumbs up/down icon for the Einstein bot response in Salesforce?Hello,
I think you're referring to emojis and emoticons. This is possible since this was mentioned from this trailhead:
https://trailhead.salesforce.com/en/content/learn/modules/service_bots_basics/plan-your-bot-content
Not sure how to do it.
-
Yogesh
MemberDecember 9, 2019 at 7:21 am in reply to: Can I edit a flow to add some feature after saving and activating it in Salesforce?Hello,
after you activated a Process, you need to Clone it in order to be able to edit it:
Once you have cloned it, you will be able to edit it. Just select 'Version of the current process' , when you do 'Save Clone as.
-
Yogesh
MemberDecember 9, 2019 at 7:16 am in reply to: How can I send an email while using PageReference getContent() method in Salesforce?Hello,
PageReference ref = Page.PDF_DEMO;
Blob b = ref.getContentAsPDF();Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
efa1.setFileName('attachment_WORK.pdf');
efa1.setBody(b);String addresses;
email.setSubject( Subject +String.valueOf(DateTime.now()));
email.setToAddresses( EmailIds );
email.setPlainTextBody(Body);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); -
Yogesh
MemberDecember 6, 2019 at 7:57 am in reply to: Is there any tool in Salesforce related to sustainable development goal?Hello,
Here are 17 ways you can learn, give back, and act in support of these goals at Dreamforce:
1. Quest: We’re calling on attendees to help unlock $1 million to accelerate progress on these goals by completing the Quest, a scavenger hunt in the Salesforce Events App. For every Quest completed, Salesforce will donate to an organization focused on advancing the SDGs.
2. Dreamforest: Visit the Dreamforest for a deep dive on the SDGs and ways you can support them. Take a quizto determine which goal most closely aligns your passions, and share your commitment by taking a photo and posting it on social media with #SDGforce.
3. Future Executive Summit: To promote workforce development and build on our commitment to SDG 8, we will host 400 young adults for two days of career exposure and network-building, Salesforce knowledge and skills, and civic and social engagement. Join in by signing up for Speed Networking.
4. Women’s Networking Reception: Kick off Dreamforce with an evening dedicated to SDG 5, women’s equality and empowerment. Hear from trailblazing women leaders and their allies and network with Salesforce customers, partners, employees, and other inspirational leaders.
5. Future Trailblazer Challenge Pitchfest: Hear Bay Area students pitch their ideas for using cutting-edge technologies like 3D printing and AI to create solutions to the world’s most pressing challenges. Stop by to vote for your favorite.
6. SDGs at Dreamforce Lodges: Play a digital game in any of the three industry lodges (Financial Services, Healthcare & Life Sciences, and Manufacturing) to learn more about the SDGs and to unlock a donation to an aligned nonprofit. In the Salesforce.org lodge, help the National Forest Foundation plant up to 5,000 trees, advancing SDGs 13 and 15.
7. Impact Labs Design Sprint: Join Salesforce.org Impact Labs to brainstorm solutions to challenges facing nonprofits and educators today – all aligned to the SDGs. Contribute ideas for solving these challenges, while leaving with best practices for innovating within your own organization.
8. Innovation Workshop: Future of AI in Education: Take part in a hands-on design sprint to use Artificial Intelligence (AI) to solve challenges in higher education. Explore how various AI technologies can promote quality education and advance SDG 4.
9. Equality Summit: Hear advocates for SDGs 5 and 10 share how they’re championing equality and prosperity for everyone. Megan Rapinoe, World Cup and Olympic Champion, will discuss using her platform to stand up for equal pay. CEOs will discuss the importance of advocating for equality and why representation matters.
10. Climate Summit: Join Climate Summit panelists for a conversation on how food systems can be more sustainable. Hear from youth activists who are on the front lines of the global climate strikes and demanding action from us all on SDG 13.
11. Meet & Greets: Stop by the Trailblazer Community Cove for Meet & Greets focused on building inclusive communities and reducing inequalities. Meet fellow Black/Latinx/Indigenous leaders and allies on Tuesday afternoon, or stop by to network with fellow women in tech leaders and allies on Wednesday.
12. Hear from leading voices for peace and equality: Curious about the role trust plays in achieving the SDGs? Cellist Yo-Yo Ma, South African TV & radio broadcaster Tumelo Mothotoane, UN Secretary-General's Advocate for the Sustainable Development Goals Eddie Ndopu, and World YMCA Secretary General Carlos Madjri Sanvee will dive into our collective pathway for restoring trust and building a better world.
13. Learn about doing well by doing good: Actress and Co-Owner of Pour Les Femmes Robin Wright, film writer and director Richard Curtis, UN Women Under-Secretary-General and Executive Director Phumzile Mlambo-Ngcuka, and Project Everyone Co-Founder Gail Gallie will dive into the $12 trillion opportunity behind the SDGs.
14. Sustainable consumption: To further our commitment to SDG 12 and to be mindful of sustainable consumption, lunches will be 100% beefless with 100% compostable packaging. Attendees will also receive a Dreamforce water bottle to reduce single-use plastic. Every time attendees fill their bottles, they’ll be supporting a clean water project in Tanzania, contributing to SDG 6.
15. Offsetting our carbon footprint: We’re offsetting 100% of Dreamforce’s onsite carbon emissions. Attendees can also contribute to SDG 13 by offsetting travel emissions to Dreamforce through Cool Effect.
16. Fifty Salesforce Military Trailblazers from around the world were awarded full scholarships to attend Dreamforce; they’ll share stories of how they’re applying their previous experiences to thrive in the future of work, promoting SDG 8.
17. Tune in for keynotes on the innovations driving progress on the SDGs: Learn more about the technology solutions driving social impact, and hear from Trailblazers making an impact in the nonprofit, education, and corporate social responsibility spaces.
-
Hello,
Its an app on appExchange.
-
Yogesh
MemberDecember 5, 2019 at 11:05 am in reply to: How to pass a string as a json which contains different objects in Salesforce?Hello,
use this method below:-
Map<String, Object> meta = (Map<String, Object>) JSON.deserializeUntyped(JsonString);
List<Map<String, String>> myMaps = (List<Map<String, String>>) meta.get('results'); -
Yogesh
MemberDecember 5, 2019 at 11:02 am in reply to: What feature would you use to track changes to settings in Salesforce?Hello,
The Audit Trail helps you track the recent Setup changes that you and other administrators havemade to your organization. This is especially useful in organizations with multiple administrators.
...
It lists:
The date and time (with timezone) of the change.
Who made it (by username).
What the change was. -
Yogesh
MemberDecember 4, 2019 at 8:23 am in reply to: What are the OwnerType of a case object in Salesforce ?Hello,
Possible values of Owner.Type are,
1. User
2. Queue -
Yogesh
MemberDecember 4, 2019 at 8:20 am in reply to: How to get know the OwnerType of a case is Queue in Salesforce apex?Hello,
you can check
if(string.valueOf(c.OwnerId).startsWith('005'))
{
//owner is User
}if(string.valueOf(c.OwnerId).startsWith('00G'))
{
//owner is Queue
}This can save you a SOQL 🙂 and is standard across all ORGS in salesforce
if our suggestion(s) worked, let us know by marking the answer as "Best Answer" right under the comment.This will help the rest of the community should they have a similar issue in the future.
Thank you!
-
Yogesh
MemberDecember 3, 2019 at 9:10 am in reply to: How to create a report to compare current year sales vs. previous year sales in salesforce?Hello,
You can do something like that using a Matrix report grouped by Division and CloseDate(Month) and CloseDate(Year).
However for the variance you'll need to create Custom Summary Formulas (CSF) and you might run into a problem displaying the monthly variance. -
Yogesh
MemberDecember 3, 2019 at 8:55 am in reply to: How can I add a lookup relationship using an external id on a before insert/update trigger in Salesforce?Hello,
trigger surveyTrigger on Survey__c (before insert) {
if(Trigger.isBefore){
if(Trigger.isInsert){
Map<String, String> extMap = new Map<String, String>();
Set<String> extIdSet = new Set<String>();
for(Survey__c survey : Trigger.new){
extIdSet.add(survey.Account_Key__c);
}
for(Account a : [select Id, Foreign_Key__c from Account where Foreign_Key__c IN :extIdSet]){
extMap.put(a.Foreign_Key__c, a.Id);
}
for(Survey__c survey : Trigger.new){
survey.Account__c = extMap.get(survey.Account_Key__c);
}
}
}
}Test class @isTest
private class TestSurveyTrigger {
static testMethod void myUnitTest() {
Account testAccount = new Account(Name='My test account', Foreign_Key__c='test123');
insert testAccount;
Test.startTest();
Survey__c testSurvey = new Survey__c(Account_Key__c='test123');
insert testSurvey;
Test.stopTest();
Survey__c result = [select Id, Account__c, Account__r.Name, Account__r.Foreign_Key__c from Survey__c where Account_Key__c = 'test123' limit 1];
system.assertEquals(testAccount.Id, result.Account__c);
}
}Hope this helps!!
-
Yogesh
MemberDecember 2, 2019 at 7:04 am in reply to: How to delete an apex class or apex trigger from a production org in Salesforce?Hello,
Here are the steps –
1.Download Force.com IDE.
2.Connect to the salesforce production org.
3.Download the apex class/trigger.
4.Open the XML file of the Apex class/trigger.
5.Change the status of the Apex class/trigger to Deleted.
6.Save and deploy to server. -
Yogesh
MemberDecember 2, 2019 at 7:01 am in reply to: How to delete a lookup record in vf page on clicking a custom button in Salesforce?Hello,
I have written code for deleting selected contacts.
Apex Controller:-
public class WrapperDeleteContactsAccounts
{
List<WrapContacts> conListWrap ;
List<Account> accounts ;
List<Contact> contacts ;
List<Contact> delContacts;
public WrapperDeleteContactsAccounts()
{
conListWrap = new List<WrapContacts>();
accounts = new List<Account>();
contacts = new List<Contact>();
delContacts = new List<Contact>();
}
public class WrapContacts
{
public Contact con {get;set;}
public Boolean check {get;set;}
public WrapContacts(Contact c)
{
con = c;
check = false;
}
}
public List<WrapContacts> getContacts()
{
contacts = [SELECT Id, LastName, AccountId, Gender__c FROM Contact LIMIT 100];
for(Contact c : contacts)
{
conListWrap.add(new WrapContacts(c));
}
return conListWrap;
}
public PageReference deleteContacts()
{
PageReference PageRefer = new PageReference(‘/apex/WrapperDelPage’);
PageRefer.setRedirect(true);
delContacts = new List<Contact>();
for(WrapContacts c : conListWrap)
{
if(c.check == true)
{
delContacts.add(c.con);
}
}
try
{
delete delContacts;
}
catch(Exception e)
{
System.debug(‘m=====’+e.getMessage());
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
return null;
}
return PageRefer;
}
}Apex Page:-
<apex:page controller=”WrapperDeleteContactsAccounts” sidebar=”false”>
<apex:form >
<apex:pageBlock id=”pb”>
<apex:pageBlockButtons >
<apex:commandButton value=”delete selected” action=”{!deleteContacts}” reRender=”pb” />
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockTable value=”{!Contacts}” var=”cont” columns=”5″ Id=”pb1″>
<apex:column headerValue=”select”>
<apex:inputCheckbox value=”{!cont.check}”/>
</apex:column>
<apex:column value=”{!cont.con.LastName}”/>
<apex:column value=”{!cont.con.Gender__c}”/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>Hope this helps.
-
Hello,
These are the classes containing methods and properties you can use with Apex REST.
Class Description
1.RestContext Class Contains the RestRequest and RestResponse objects.
2.request Represents an object used to pass data from an HTTP request to an Apex RESTful Web service method.
3.response Represents an object used to pass data from an Apex RESTful Web service method to an HTTP response. -
Hello,
OAuth 2.0 is an open protocol used to allow secure data sharing between applications. The user works in one app but sees the data from another. For example, you're logged in to your Salesforce mobile app and see your data from yourSalesforce org.
-
Yogesh
MemberNovember 28, 2019 at 9:04 am in reply to: How many roles can I create in Salesforce org?Hello,
By default, a Salesforce org can have up to 500 Roles or Territories. The current Maximum is 10000. A documented business case, including the specific amount ofroles or territories needed, is required when requesting a higher limit.
-
Yogesh
MemberNovember 28, 2019 at 8:53 am in reply to: How to render Lightning flow through Visualforce page in Salesforce?Hello,
If you want your flow to render in Lightning runtime in your Visualforce page, embed the flow Aura component to your Visualforce page.
1. Create a Lightning app that declares a dependency on the lightning:flow component.
2. Add the Lightning Components for Visualforce JavaScript library to your Visualforce page using the <apex:includeLightning/> component.
3. In the Visualforce page, reference the dependency app.
4. Write a JavaScript function that creates the component on the page using $Lightning.createComponent(). -
Yogesh
MemberNovember 27, 2019 at 7:09 am in reply to: What are possible Ways to Integrate with Salesforce Force.com?Hello,
If we need to have a straightforward data exchange between a client application and Salesforce, we should go with the Data Integration options like SOAP API, but in case we need to have some logic before or after the data is committed or sent out of Salesforce, we should opt for the Business Logic Integration options like Apex Web Services or Apex Callouts.
-
Yogesh
MemberNovember 27, 2019 at 7:02 am in reply to: How many types of API’s avaliable in salesforce?Hello,
Salesforce offers two primary types of APIs based on industry standards. The first is a SOAP based API, and the second is a REST based API. The REST API is very lightweight, has no WSDL definition file that is needed to install, and performs very well.
-
Yogesh
MemberNovember 26, 2019 at 9:51 am in reply to: How is access granted through the Role Hierarchy in salesforce?Hello,
Beyond setting the organization-wide sharing defaults for each object, you can specify whether users have access to the data owned by or shared with their subordinates in the hierarchy. For example, the role hierarchy automatically grants record access to users above the record owner in the hierarchy. By default, the Grant Access Using Hierarchiesoption is enabled for all objects, and it can only be changed for custom objects.
To control sharing access using hierarchies for any custom object, from Setup, enter Sharing Settings in the Quick Find box, then select Sharing Settings. Next, click Edit in the Organization Wide Defaults section. Deselect Grant Access Using Hierarchies if you want to prevent users from gaining automatic access to data owned by or shared with their subordinates in the hierarchies.