• {tushar-sharma}
  • 578 Points
  • Member since 2015
  • Sr. Developer

  • Chatter
  • 18
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 152
How to write below peice of code in lightning, please assist.


My requirement is, will be on contact detaled page, i have data table which displays list of orders of that contact.

When i click on any row's checkbox in that datatable, it has to get  that particular order details and refrsh the current page and open page ,for this new page, will have to contruct url in lightning same as above.
I have tried all possible ways to mock the apex callout but still couldn't get over this error - "Methods defined as TestMethod do not support Web service callouts" .. Please Help.

My Main Class - 
public class UpdateOFACResponse {
    public static void makeCallout(List<Lead> leads)
        if(!System.isFuture() && !System.isBatch())
    public static void saveResponse(Id leadId)
        String Result;
        Integer Score;
        List<Lead> cName= [Select Company FROM Lead WHERE ID=:leadId limit 1];
        String companyName= String.valueOf(cName[0].Company);  
        String compName = EncodingUtil.urlEncode(companyName,'UTF-8').replace('+','%20') ;
        System.debug('Encoded compName>>>>'+ compName);
        String loginurl='https://search.ofac-api.com/v2?';
        String apikey='52c4b1bd-8bd8-450e-90e6-3ca9bf5bffaf';
        String format='json';
        String Alias ='false';
        String Name= compName;
        String MinScore='95';
        String Source='SDN,DPL';
        String type='Entity';
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        HttpResponse response = http.send(request);
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) 
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
            List<object> apiResponse = (List<Object>)results.get('matches');
             Result = (String)((Map<String,Object>)(((List<Object>)results.get('matches')).get(0))).get('name');
             Score = (Integer)((Map<String,Object>)(((List<Object>)results.get('matches')).get(0))).get('score'); 
            //System.debug('Result-Name'+ Result);
            Id devRecordTypeId = Schema.SObjectType.Lead.getRecordTypeInfosByName().get('Partner Onboarding').getRecordTypeId();
                List<Lead> updateList = new  List<Lead>();
                    List<Lead> lstLead =[SELECT Id,OFAC_Response__c,OFAC_Score__c FROM Lead where RecordtypeId=:devRecordTypeId AND ID=:leadId];
                    lstLead[0].OFAC_Response__c= Result;
                    lstLead[0].OFAC_Score__c = Score;
                        update updateList;
                catch(exception e)
                    System.debug('Error occured'+ e.getMessage());

Test Class- 
global class UpdateOFACResponse_Test {
    static void makeData(){
        RecordType rt = [select id,Name from RecordType where SobjectType='Lead' and Name='Partner Onboarding' Limit 1];
        Lead lead = new lead(
            FirstName = 'Test First Name',
            LastName = 'Sample Last Name',
            Phone = '555-555-5555',
            Company = 'ananimforceTest',
        insert lead;     
    static void testCallout() {
        List<Lead> lstLead = [SELECT Id, FirstName, LastName,Phone,MobilePhone FROM lead LIMIT 1];
        //Set mock callout class.
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        // UpdateOFACResponse.makeCallout(lstLead);
    global class MockHttpResponseGenerator implements HttpCalloutMock {
        // Implement this interface method
        global HTTPResponse respond(HTTPRequest req) {
            String fullJson = ('{error=false, matches=({additionalSanctions=(), addresses=({address1=Calle 50 Y 53 Marbella, address2=Edificio Plaza 2000, address3=Piso 7, city=Panama City, country=Panama, uid=0}), akas=(), citizenship=(), name=GLOBAL TECHNOLOGY IMPORT & EXPORT, S.A. (GTI), passports=(), programs=(SDNTK), score=96, sdnType=Entity, source=SDN, ...}), searchTerm=GLOBAL IMPORT LTD, sourcesUsed=({source=SDN}, {source=DPL})}');
            // Create a fake response
            HttpResponse res = new HttpResponse();
            res.setHeader('Content-Type', 'application/json');
            return res;
I have a requirement to display username format in the username field.
ex: Username: <abc@abc.com>
Username field should have a default value which shows the format the user should enter. I'm not able to do that...can someone help out here.
<apex:pageMessages id="error"/> <label>Username</label> <apex:inputText value="{! username }" onkeypress="return noenter(event)" styleClass="input r4 wide mb16 mt8 username"/>
I have created data table, as below. I am getting selectedRows is [object Object] in console when i select any row.

i supposed to get array of selected row.I guess i have done some  mistake in declaration of attributes (columns, data).Please clarify asap.


<aura:component controller="ContactTopTen" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="columns" type="List" />
    <aura:attribute name="data" type="Object"  />
     <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <lightning:datatable aura:id="contactTable"
                         onrowselection="{!c.doSelect}" />

    init : function(component, event, helper) {
            {label: 'Account Name', fieldName: 'Name', type: 'text', sortable: true},
              {label: 'Rating', fieldName: 'Rating', type: 'text', sortable: true},
             var action=component.get('c.getCon');
             action.setCallback(this, function(response){
             var state=response.getState();
             if(state==='SUCCESS' || state==='DRAFT')
             var responseValue=response.getReturnValue();
             component.set('v.data', responseValue);
             doSelect:function(component, event, helper) {
             var selectedRows=event.getParam('selectedRows');
             console.log('selectedRows is : ' +selectedRows);

Apex class:
public class ContactTopTen {

    public static List<Account> getCon(){
        List<Account> con=[select Name,Id, Rating from Account Limit 5];
        return con;

<apex:page standardController="RFQ__c" recordSetVar="RFQ"
           applyHtmlTag="false" applyBodyTag="false"
    <apex:form >
        <apex:pageBlock title="Create Quotes" mode="maindetail">
                <apex:outputLabel rendered="{!ifSuccess}" style="color:Green"><H3>

                          <!-- Calling success toast-->

                <apex:outputLabel rendered="{!ifError}" style="color:red"><H3>

                           <!-- Calling error toast -->

    <apex:slds />
    function toastSuccess()
            "title": "Success!",
            "key": 'info_alt',
            "type": "success",
            "message": "Sucess message !!!"
        function toastError()
            "title": "Success!",
            "key": 'info_alt',
            "type": "error",
            "message": "Error message !!!"
calling toast functions dynamically 
this visualforce page is added to listview button controller performing mass action, I have to display toast depending on success or failure
 all things are done just need call this script functions.
I am a brand new developer starting from scratch. I've been working on the following issue for over a month and would greatly appreciate some help.

Data Model: I have a parent object called Financial_Month__c with chid records of Workout__c. This is a master-detail relationship on the Workout__c object.

Desired Endstate: Override New standard button on Workout__c object tab with a custom Visualforce page. On that page, prepopulate the parent (Financial_Month__c) lookup value.

  1. Created custom controller (see below)
  2. Created Visualforce page that references custom controller.
  • Before I enter the workoutMonth variable in the Visualforce page, I receive the following error: "Unknown property 'custom_Controller_New_Workout_VF_Page.Workout__c"
  • After I enter the workoutMonth variable in the pageBlockSection, I receive the following error: "Invalid field Workout__c for SObject Financial_Month__c"
Custom Controller
public class custom_Controller_New_Workout_VF_Page 

    //Create a list to store Workout Month records.
    public Financial_Month__c workoutMonth {get; set;}
    public custom_Controller_New_Workout_VF_Page()
    	//Get current Financial Month record.
    	workoutMonth = [SELECT Id,
                          FROM Financial_Month__c
                         WHERE RecordType.DeveloperName = 'Workout_Month' AND Current_Month__c = True
                      ORDER By CreatedDate DESC
                         LIMIT 1];
     public Financial_Month__c getworkoutMonth() {
        return workoutMonth;

    public PageReference save() {
        update workoutMonth;
        return null;

Visualforce Page
<apex:page controller="custom_Controller_New_Workout_VF_Page" lightningStylesheets="true">           
        <apex:pageBlock mode="edit">            
        <apex:pageMessages />
             <apex:pageBlockSection columns="1"  title="🏋️‍♂️ New Workout" collapsible="false" showHeader="true"> 
                  <apex:outputField value="{!workoutMonth.Workout__c.Workout_Month__c}"/> 
                  <apex:inputField value="{!Workout__c.Date__c}" required="true"/>
                  <apex:inputField value="{!Workout__c.Workout__c}" required="true"/>
                  <apex:inputField value="{!Workout__c.Rest_Reason__c}"/>
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!save}" value="Save"/>   

I'm getting ready to quit on this project but wanted to see if someone could help me first.

Any thoughts you have would be greatly appreciated. Thank you in advance!
Hello Everyone,

I have a situation where i'm using the email-to-case. The scenerio is : 
1. If i use email-to -case then i'm not able to fetch the attachments from Case object
query --> SELECT CaseNumber, (Select Name from Attachments) from Case
This doesn't return any attachment.
2. If i use custom apex class :- inboundemailhandler class, I'm receiving the attachments from email and also able to fetch the attachments using the same query mentioned above..

Code --> global class GetEmailToSalesForce implements Messaging.InboundEmailHandler {   
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.Inboundenvelope envelope) {    
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        Case newCase = new Case();
        newCase.SuppliedName = email.plainTextBody;
        newCase.SuppliedEmail = envelope.fromAddress;
        newCase.Subject = email.subject;
        newCase.Status = 'New';
        newCase.Origin = 'Email';
        insert newCase;
            System.debug('New Case is  created:'+newCase.Id);
        }catch(Exception e){
            system.debug('Got an exception:'+e);
        if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
            for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
                Attachment attachment = new Attachment();
                //attachment.ParentId = contact.Id;
                attachment.ParentId = newCase.Id;
                attachment.Name = email.binaryAttachments[i].filename;
                attachment.Body = email.binaryAttachments[i].body;
                insert attachment;
        return result;

Can someone please let me know the reason.

Hi I got to migrate call center app to lightning.So   there are two vf pages.

1) In Home page, Click on "Request " button --> enter request ID --> click on Search
It connects to web service and get the result back in list view.
Click on any record in that list.
New workspace tab will get opened  which is  Customized Case detailed page (VF page) and it contains customized details at end of the page and detailed pages at Top panel.

Now as part of migration, I have migrated customized Home page(VF1) to lightning, created new Lightning Application and placed  this VF1 as Home page in lightning App.
 Then I am able to get the records from webservice and display in list view.So far so good.

While migrating second page ,I got to recreate VF2 as lightning Component as it has  java script which is not supporting in lightning.

I have done the same , able to view as expected in lightning component.

Now all i have to do is, connect these two i.e   Lightning migrated VF1
and Lightning component..

Please anyoneof suggest as early as possible.

I'm attempting to reference the PersonEmail field (on Person Account) from a formulae field on the Contact record. When attempting to reference the field, if I use the Insert field button to find the field I can navigate as follows:
Contact > Account > Person Account > 
But then cannot find the PersonEmail field.  
hi guys, 

i have created a data factory class. i am struggeling to pass the stagename of the opportunity as parameter. This is my code:
public static Opportunity createOpportunity(String stageName, Id accountId){
        Opportunity opp = new Opportunity();
        opp.Name = 'Test';
        opp.StageName = stageName;
        opp.Type = 'Neukundengeschäft';
        opp.AccountId = accountId;
        opp.CloseDate = System.today();
        opp.z_Vertragsbeginn__c = Date.newInstance(2019, 1, 1);
        opp.z_Enddatum__c = Date.newInstance(2019, 12, 31);

        return opp;
// here i pass the parameter stage1 
Opportunity opp = DataFactory.createOpportunity('stage1', acc.id);
// but this condition fails, it is null
System.assertEquals(opp.StageName, 'stage1')

I appreciate your help guys ! 

Greetings marry

Hello, I would be grateful for any assistance with the following question. Where can we find an audit record for cases to see when changes have been made and who has made them?
The download button for Windows 64 has a .amd and my system labels that as potentially harmful. at https://developer.salesforce.com/tools/sfdxcli  

Any advice?

My system specs:
OS Name        Microsoft Windows 10 Pro
Version        10.0.18362 Build 18362
Other OS Description         Not Available
OS Manufacturer        Microsoft Corporation
System Name        HP-xxxxxxx
System Manufacturer        Hewlett-Packard
System Model        HP EliteBook 850 G2
System Type        x64-based PC
Processor        Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2601 Mhz, 2 Core(s), 4 Logical Processor(s)
Hello Guys,

Since I am new to Lightning and practicing myself by creating some simple components. 

I need some help to get some requirements simmilat to real time project requirements so that I try from my end.

Please share some sample requirments based on your project experience or if you know.
     <aura:handler event="c:AccountsLoaded" action="{!c.onAccountsLoaded}"/>
    <aura:attribute name="map" type="Object"/>
     <aura:attribute name="accounts" type="Account" />
    <ltng:require styles="/resource/leaflet/leaflet.css" scripts="/resource/leaflet/leaflet.js" afterScriptsLoaded="{!c.jsLoaded}" />
    <div id="map"/>


    jsLoaded: function(component, event, helper) {
       var accounts = event.getParam('accounts');
        for (var i=0; i<accounts.length; i++) {          
            var account = accounts[i];
            var map = L.map('map', {zoomControl: false}).setView([account.BillingLatitude, account.BillingLongitude],11);
            'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
        component.set("v.map", map);
        var circle = L.circle([account.BillingLatitude, account.BillingLongitude], {
            color: 'red',
            fillColor: '#f03',
            fillOpacity: 0.5,
        L.marker([account.BillingLatitude, account.BillingLongitude]).addTo(map).bindPopup(account.Name).openPopup(); 
        //L.marker([account.BillingLatitude, account.BillingLongitude]).addTo(map).bindPopup('Hyatt').openPopup(); 
        //L.marker([account.BillingLatitude, account.BillingLongitude]).addTo(map).bindPopup('Marriott Marquis').openPopup();



This page has an error. You might just need to refresh it. Action failed: c:leafflet$controller$jsLoaded [Unable to get property 'length' of undefined or null reference] Failing descriptor: {c:leafflet}
Hi All,

Please find below my apex and visualforce code:
public class Learn1 {
    public string aname{get;set;}
    public string arating{get;set;}
    public string aphone{set;get;}
    Account acc=new Account();
    public void getName(){
        insert acc;
<apex:page controller="Learn1">
                <apex:outputLabel value="Name of Account" style="width:100px;"/>
            <apex:inputText value="{!aname}"/>
            <apex:outputLabel value="Phone" />
        	<apex:inputText value="{!aphone}"/>
            	<apex:commandButton value="Submit" action="{!getName}"/>

On the Visualforce page, when I input the values for Name and Phone,  the value gets inserted and I can see the new record in Accounts. Also the values in the form become null.

However once I enter a different set of values, I get the following error:

System.DmlException: Insert failed. First exception on row 0 with id 001f400001MIzTMAA1; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Error is in expression '{!getName}' in component <apex:commandButton> in page learnvf1: Class.Learn1.getName: line 13, column 1
Class.Learn1.getName: line 13, column 1

Please advise. Thanks!!

I am facing an issue for writing a test class for a invocable method which is getting called by Process Builder.
Actual class--
public class vOppDuplicate {
//public virtual class BaseException extends Exception {}
//public class OtherException extends BaseException {}
@InvocableMethod (label='Records for duplicate' description='Duplicate Check')
public static void updateOppDup(List<Id> OpportunityIds) {
        List<Opportunity> oppList = [SELECT Opp_Acc_Concatenate__c,Opportunity_Unique_Name__c FROM Opportunity WHERE Id in :OpportunityIds];
        for(Opportunity opp: oppList)
           opp.Opportunity_Unique_Name__c = opp.Opp_Acc_Concatenate__c;               
          update oppList;
        //return oppList;
    catch(DMLException e)
        //throw new OtherException('Duplicate value is present');
        throw new DMLException('Duplicate value with same opportunity and account name already present.'+'<br/>');
        //System.debug('The following exception has occurred: ' + e.getMessage());
        //if(e.getMessage().contains('Update failed')){
        //e.setMessage('Duplicate value is already present.');
        //ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, e.getMessage()));


Test Class---
private class vOppDuplicateTest {
@isTest static void testdup() {
    Account acc = new Account(name='TestClient');
    insert acc;
    Opportunity oppList = new Opportunity(Opportunity_Unique_Name__c= 'DupAccOppTest', Name = 'OppDup',AccountId=acc.Id);
    insert oppList;
    //oppList = [SELECT Id from Opportunity where Id = : oppList.Id];
    vOppDuplicate oppdup = new vOppDuplicate();

How do i call the method and pass the value ?


Hi, I'm absolute beginner and I'm trying to get familiar with salesforce triggers. I got main idea - what it's all about but I'm stuck with part of code:

CC_Variables__c variables = CC_Variables__c.getInstance('EloquaMarketingId');


I keep getting error: Error: Compile Error: Invalid type: CC_Variables__c at line 9 column 5

I have already checked many forums and tried to solve it as follows: "You need to use the API name of the object and not the label. Hence the error. To find the API name of the object go to:

Setup > create> objects> myObject > API name." 


But there is not such an object is this the problem? Thank you very much.


I have created a class for Slack Notification and I would link to create a link to view the Question Post created on community.
I know it can be done via a custom label but that's exactly what I try to avoid.
The link should take me the the question post as seen below:

User-added image
The ideal would be to use Network class; that gets me close to what I need. For example "Network.getSelfRegUrl(myNetwork.id)" takes me correctly to support/s/register/...

User-added image
Network myNetwork = [SELECT Id FROM Network WHERE Name ='Smart Client Portal'];
		System.debug('MyDebug: ' +Network.getSelfRegUrl(myNetwork.id));
		//String fullRecordURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + myNetwork.Id;

        for(slackRequest r:requests){
            if(r.id != null && r.name != null && r.title != null) {
                System.debug('### SlackNotificationCommunityPosts new post');
                channelName = '#' +Label.Slack_Community_Channel;
                msg = 'A new community post has been created : *'+r.title+'* - By User : (*'+r.name+'*)';
                msg += '\nLink to Community post : '+Network.getSelfRegUrl(myNetwork.id)+'/'+r.id;
But I cannot find any a way to get to 

User-added image

Is there a way to use Network class and get to support/s/question/...
Thank you

here is the whole code:
public class SlackNotificationCommunityPost {
    -- - Description   : Class to send Slack notification based on QuestionPost created on Community
    -- -----------  ----  -------  ------------------------------------------------------------------
    public class slackRequest {
        public String title; 
        public String id; 
        public String name;    
    @InvocableMethod(label='Publish New Community posts to Slack')
    public static void publishNewCommunityPostsToSlack(List<slackRequest> requests) {

        //String webhookURL='https://hooks.slack.com/services/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';
        String webhookURL = system.label.Param_Slack_Token;
        String msg;
        String channelName;
        Network myNetwork = [SELECT Id FROM Network WHERE Name ='Smart Client Portal'];
		System.debug('MyDebug: ' +Network.getSelfRegUrl(myNetwork.id));
		//String fullRecordURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + myNetwork.Id;

        for(slackRequest r:requests){
            if(r.id != null && r.name != null && r.title != null) {
                System.debug('### SlackNotificationCommunityPosts new post');
                channelName = '#' +Label.Slack_Community_Channel;
                msg = 'A new community post has been created : *'+r.title+'* - By User : (*'+r.name+'*)';
                msg += '\nLink to Community post : '+Network.getSelfRegUrl(myNetwork.id)+'/'+r.id;
            //Generate JSON for request
            try {
                if (r.id != null && r.title !=null && r.name != null) {
                   System.debug('### SlackNotificationCommunityPosts sending message');
                   JSONGenerator gen = JSON.createGenerator(true);
                    gen.writeStartObject(); //Inserts {
                    gen.writeStringField('text', msg);
                    gen.writeStringField('channel', '#salesforce_test');
                    gen.writeStringField('username', 'bot-support');
                    gen.writeStringField('icon_emoji', ':smartplus:');
                    gen.writeEndObject(); //Inserts }
                    String body = gen.getAsString(); //Translates JSONGenerator to string to be passed to callout
                    System.debug('### SlackNotificationCommunityPosts body: '+ body);
                    System.enqueueJob(new qCallOut(webhookURL, 'POST', body)); // Send request
               	 } else {
                    System.debug('### SlackNotificationCommunityPosts Id = '+ r.id);
            catch (exception e) {
                System.debug('### SlackNotificationCommunityPosts error:' +e);
     public class qCallOut implements System.Queueable, Database.AllowsCallouts {
        private final String url;
        private final String method;
        private final String body;
        public qCallOut(String url, String method, String body) {
            this.url = url;
            this.method = method;
            this.body = body;
        public void execute(System.QueueableContext ctx) {
            HttpRequest req = new HttpRequest();
            Http http = new Http();
            // to pass when process builder is invoked by another test class
              HttpResponse res = http.send(req);


Hi Team,
I am trying to see if we can get old values of an object in Flows as we get in trigger using trigger.oldMap. or PriorValue in Workflows.

Thanks for your help in advance
public class DynamicCopy {
public String selectedSObject {get;set;}

    public List<SelectOption> objects = new List<SelectOption>();

    public List<String> recordList {get;set;}//this list will hold record from selected sObject

    public String selectedRecord {get;set;}
    public string FilterRecords{get;set;}
       public Contact con{get;set;}    

    public Id selectedRecordId {get;set;}
        List<string> conditions = new List<string>();    

     public  DynamicCopy(){
                Con = new Contact();         


    This method will add all sObjectName in sObjectNames list

       public List<SelectOption> getSObjectNames(){
       objects.add(new SelectOption('','Select'));
       objects.add(new SelectOption('Account','Account'));
       objects.add(new SelectOption('Lead','Lead'));
       objects.add(new SelectOption('Opportunity','Opportunity'));
       objects.add(new SelectOption('Contact','Contact'));
       return objects;
    public PageReference generateRecordList(){
            if(selectedSObject != null && selectedSObject != ''){          

                String recordQuery = 'SELECT Id, Name, Email FROM '+selectedSObject+' LIMIT 100';

                List<sObject> records = Database.query(recordQuery);

                recordProcessing(Database.query(recordQuery), true);


        } catch(Exception e){

            ApexPages.Message myMsg;
        return null;
    public Void FilterRecords(){
        if(selectedSObject != null && selectedSObject != ''){  
        String strQuery ='SELECT Name,LeadSource,Phone From Contact WHERE Id!=null '; 
         if(Con.Name !=null && Con.Name !=''){            
            conditions.add('Name Like \'%' +Con.Name +'%\' ');            
        if(Con.LeadSource !=null && Con.LeadSource !=''){            
            conditions.add('LeadSource Like\'%' +Con.LeadSource +'%\' ');            


     public void recordProcessing(List<sObject> records, boolean nameIncluded){

        if(recordList == null){

            recordList = new List<String>();

        } else{



        for(sObject sObj : records){

            String recordName;


            recordName = String.valueOf(sObj.get('Name'))+' - '+String.valueOf(sObj.get('Id'));

            } else{

                recordName = String.valueOf(sObj.get('Id'));





        if(recordList.size() == 0){

            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'No record found for this sObject!!');





<apex:page controller="DynamicCopy" sidebar="false">
    <apex:form id="pageForm">
        <apex:pageMessages />
        <apex:selectList label="Select Object Name" title="Select Object Name" multiselect="false" value="{!selectedSObject}" size="1">
            <apex:actionSupport event="onchange" action="{!generateRecordList}" reRender="pageForm"/> 
            <apex:selectOptions value="{!SObjectNames}" /> 
         <table border="2px">

         <apex:dataList id="output" value="{!recordList}" var="r">



Can Someone help me how to add a filter condition to page depend on each object.
Hello together,

guest users cannot upload files anymore with the new Summer '20 release.

Step to reproduce:
1. You will need a sandbox with the Summer '20 release. 
2. Create a flow (any context even the new system mode with no permission restrictions) with the standard File Input component provided by Salesforce.
3. Make this flow available to a Guest User profile.
4. Notice that the Guest users can't upload any files.

Does anyone else noticed this behaviour and has a workaround.

Best regards,
If it is different then how can we get ClientID for the authorized client?

I am following the lighting web component trailhead (https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/create-a-hello-world-lightning-web-component ).
I created the web component, but when i try to add it to the home component, the custom web component is not showing and cannot add it to the home page. The helloworld.js-meta.xml file is same as what metioned in the trailhead account.
I am doing this in my trailhead playground. Any help on this will be highly appreciated
  • March 11, 2019
  • Like
  • 0
Hi folks,

trying to finish the trailmix Get Started with Lightning Web Components by 28/02/2019 and complete the quest to help Per Scholas.

Unfortunately I am not able to create a Scratch Org in two moments that are requested in the trailmix:

-Lightning Web Components Basics - Unit 3
-Set Up Your Lightning Web Components Developer Tools - Unit 2

Facing following error:
User-added image
Dev Hub was properly configured
User-added image
and Dev Hub TP access properly allowed.
User-added image

Has anyone experienced this and can you help me?

Best regards,

Hi All,
I have a custom object Interests (with only 2 Record types Primary and Secondary) which is a child to Account (lookup relationship) and Account has a Related List to create child records.

1) Standard Process : The standard "New" button lets the users to redirect and select the record type of their choice to create Child records(Interests).
what i am looking for is a customized solution (Probably URL hacking) with a custom list button which should redirect the users straight away to the edit mode and Prepopulate the Account (Parent ID) and the Primary (record type) on the  child record that is going to be created,in other words when the users are redirected from the Parent Record(Account) the child record that is going to be created should have the Parent Id in the lookup field and be with its record type as Primary.
I am thinking of 2 ideas:
1) Having a custom button, upon click the users would be on edit mode by auto populating Record type (in the standad field) and the parent ID.
2) Having a custom button which lets the users to a custom VF Page where there would be only a button, upon click of the button the record type will be populated as Primary and auto populating the Parent id when creating the child record.

Now all i need is a URL to make the things work, Please let me know if anyone has a better idea or with the possible apex work around for the URl part.

  • September 16, 2018
  • Like
  • 0

i am strungeling with a custom "create"-Button. I want to select a recordtype and submit a parameter to prefill a field. Selecting a recordtype works, but submitting a value does not.

Can anyone give me an advice? I was looking around the web and tried some suggestions but nothing helps. 

Important: i am on Lightning!

My code:
var newTestpoint = $('<a href="/a0B/e?&ent=Warengruppen_Struktur__c&CF00N0O00000AfEAi='+node.title+'&CF00N0O00000AfEAi_lkid='+node.key+'"> neuer Endpunkt | </a>');


HI All, I do not have much experience in Salesforce but i am learning and i came acroos this statement "You can use an object to change its own field values using trigger.new, but only in before triggers. In all after triggers, trigger.new is not saved, so a runtime exception is thrown"

I have two issue now 
a)  As it is mentioned we can not update Object in After Trigger but we can update it like below 
trigger AccountNumberUpdate on Account (before insert,after insert) {
list<Account> up = new list<Account>();

for (Account c : Trigger.new)
if (Trigger.isBefore)
if (String.isBlank(c.AccountNumber))
 c.AccountNumber.addError('Account Number Can not be bLanks');

if (Trigger.isAfter)

 Account a = [Select Id,AccountNumber from Account where id = :c.id];
 a.AccountNumber = NULL;

update up;

b) (Refre Above Code)Second issue with order of execution lets say i have custom validation on field here AccountNumber and in all after trigger again i am making AccountNumber blank in that  case error will not throw because custom validation does not takes place after trigger . Is it limitation of salesforce ?

We want to use an account object custom field for an email trigger alert based on the old value of the field.  We ran a report and see the old and new value using the account history report but we are unable to produce the old value for our custom field named 'lifecycle prior value.'  SF support directed us to the forum for help from SF developers.  We appreciate any help!
  • January 05, 2017
  • Like
  • 0
Hi All
can you please share interview questions and different senarios which ask for experienced sfdc developers
his organization has implemented URL hacks through its Salesforce.com instance. There are several ways that these hacks are executed.  Pre-populating fields on form opening is one of the multiple reasons for the hacks.

For the most part Visualforce pages were avoided.  This allowed the administrators to manage configuration on their own.  After attending Dreamforce '15, the users are now demanding Lightning offering them the same functionality as Classic Salesforce.com.

Please explain the steps it would take to replace these development practices.  It would be hard to believe a huge organization like Salesforce.com would recklessly eliminate a core part of their functionality without a work around.  Cannot find an answer.   

This example scraps the opportunity and pre-populates a custom object with values from the opportunity.  The record is placed in edit mode. The user has the ability to chose wether or not to save it or not.  Please explain the new process that has to take place in steps.  This is an existing javascript button.
var TheMockUpName = "Mock Up: " + "{!Opportunity.Name}";
var TheValues = "{!Opportunity.KCO_Competition_Current_Suppliers__c}";
var TheValueArray = TheValues.split(";");
var TheTarget = "&00N50000002pCh2";
var TheParameters = "";

for (var i=0;i<TheValueArray.length;i++){
TheParameters = TheParameters + TheTarget + "=" + TheValueArray[i] ;

var TheAmount = "{!Opportunity.Amount}";
TheAmount = TheAmount.substring(3);
var TheURL = "/a0G/e?CF00N500000026uRE={!Opportunity.Name}&CF00N500000026uR5={!Opportunity.Account}&00N50000002pCi0={!Opportunity.Opportunity_Number__c}&00N50000002pCuV={!Opportunity.KI_Quote__c}&00N500000026uRM={!Opportunity.Sales_Representative__c}&00N50000002pCmW={!Opportunity.District_Name__c}&00N50000002pCmb={!Opportunity.Region__c}" + TheParameters + "&00N500000026uRK=" + TheAmount + "&00N500000026uRK={!Opportunity.Project_Coordinator__c}" + "&Name=" + TheMockUpName + "&retURL=/{!Opportunity.Id}";
window.open( TheURL,"_blank","menubar=yes, location=yes, titlebar=yes, status=yes, toolbar=yes, scrollbars=yes, resizable=yes, top=1, left=1, fullscreen=no" );

Thank you.

On the Accounts object i have a custom lookup field called 'Account Manager' of type user.
I also have another custom field 'Previous Manager' of type Text. What I am trying to do is, when the Account Manager is changed,copy the old value of 'Account Manager' to 'Previous Manager. To achieve this, I have created a workflow with the following properties,

Rule Criteria: ISCHANGED(Account_Manager__C)

Field to Update: Previous Manager    
Formula Value: PRIORVALUE(Account_Manager__c)

Of course this gives me the record id of the user, to get the Manger's Name (FirstName Last Name) I did,


PRIORVALUE(   Account_Manager__r.FirstName & ' '&  Account_Manager__r.LastName ),


However it gives me the error 'Incorrect argument type for function 'PRIORVALUE()'

How can I get the Manager's First Name and Last Name?




I have a custom object named 'Process_Unit__c' :

1) The user clicks on the Process unit tab.

2) Then clicks on the 'New' button and goes to record type selection and selects the record type.

3)  then he goes and creates a new record, when the new record shows up i want to populate a default value named "Please do not type here" in a mandatory field called 'process unit name' and make it read only is this possible?


I did try it but i am not able to override the new button of the object it self any idea of how this  can be done or should i use a apex class and trigger to populate this default value in the field in the edit mode:


I did this URL over ride, but i am able to put this button in the page layout and this is visible in saved mode only, i am not able to override the 'New' button with button i created:




Help ias higly appreciated.


We have several RecordTypes for our Contacts.  For our "Study Contact" page layout, all the appropriate detail fields are there, and we have a related list that shows Contacts that the current Contact has referred to us.  I want to hide the default New button on this related list and replace it with a "New Referral" button.  Clicking the "New Referral" button should invoke the New action, but set the RecordType to "Study Contact" behind the scenes and bypass the "Select Contact Record Type" page.
I have looked everywhere for examples, and managed to put together the following... but it still shows the "Select Contact Record Type" page.   I am putting the RecordType parameter in the parameter array and also including it directly on the URL just in case....  Help?
//First construct the new URL
var newUrl = "{!URLFOR( $Action.Contact.NewContact, null,
retURL=$Request.retURL], true)}&RecordType={!Contact.RecordType}";
//Then redirect the user to it

This is run in an Execute Javascript button.
I have tried putting the RecordTypeId value in there directly too (rather than use Contact.RecordType), but to no avail.
I'm also trying to automatically link the new Contact with the referrer Contact, and trying to pre-populate the Account ID.
Thank you for your help,

I want to carry fields from a parent object to the child object when the user clicks the new button.
I have created a URL to update the code.  I put it on a seperate button called update and it works after the record has been created but now I want it to work when a new one is created.
What code do I use to override the next step of selecting the proper record type? 
I want the user to still select the record type then when they get to the edit screen have the fields populated.
  • February 05, 2008
  • Like
  • 0

I'm sure this question has been asked from time to time, but I could not find the answer with my search strings:
Is there a specified execution order of apex triggers, workflow rules and validation rules?
I have some problems that depend on this execution order and need to know in wich squence these were executed.

Thanks for your help!