+ Start a Discussion
Best Answer chosen by hasya hasya
Iqbal Hossain 1Iqbal Hossain 1
First check whether you are able to see different record types using SOQL.
As a workaround send the 'recordTypeId' prior to setting default values like follows:

/lightning/o/<Object Name>/new?recordtypeId= recordTypeId=<15 digit Id>&
Field1=value 1,
Field2=value 2

Abby StockerAbby Stocker 
Please help with the following error. Thank you! 
User-added imageUser-added image
Best Answer chosen by Abby Stocker
Hi Abby,

If you initially setup the trigger on diffferent sobject and change the code of the trigger to act on different sobject this error will occur.

Please follow below steps
Copy (backup) the trigger code to a text file and delete the original trigger first

Recreate the trigger again on EmailMessage object
Hope this helps! Please mark as best answer if it does.

I have two clases:
1. a controller class to a vf page and another as
2. a helper class accessed by multple classes. 

I have a simple query running in the helper class that is failing to return any records:
public static void refreshOrder(Id orderId, Id accountId){

        // Retrieve the Order
        Order ord = [Select Id, Name, Status From Order Where Id = :orderId];

The controller class that calls the above method has the following extract:

Order order = new Order(
    Pricebook2Id = OrderHelper.getStandardPriceBookId(),
    AccountId = acc.Id
    EffectiveDate = System.today(),
 insert order;

OrderHelper.refreshOrder(order.Id, acc.Id);
Any idea why a system.debug in the helper class does show a valid Order Id being apssed but then the simple order query does not return anything, and instead throws an error:
"List has no rows for assignment to SObject" ?
Best Answer chosen by aam1r
Ok, i figured thsi out.  i thought i'd post in case anyone else faces the same issue.  Here's what i checked:
1. User permissions.  This was part of a process involving a Site Guest User.  And although i had set up sharing rules i guess this user worjks a bit differently from a standard, rather a normal user in salesforce
2. I moved the select query from the helper class to teh controller class and then passed the field values to the helper class - and it did work.  So user has access, but only in one class - not the other.
3. I then checked the class definition and yes, it was set to public with sharing. So,
4. i changed this to public without sharing

And it all worked.  Of course, this means that sharing settings will not apply in this class, and that it will run on a system level.  But that's fine.  I'll control access to sensative info via the profile when needed.
Thanks for looking!
Nathan NipperNathan Nipper 
I have a picklist field 'Status' with three options. Requested, Approved, and Denied. I have a currency field 'Total Price' with a requested total. Lastly, I have a currency formula field 'Accepted Total' that I only want to populate with the same amount from the 'Total Price' field if a picklist selection is Approved. Otherwise the Accepted Total is just blank. What's the best way to do this?
Best Answer chosen by Nathan Nipper
Maharajan CMaharajan C
Hi Nathan,

Please use the below formula in Accepted Total currency formula field :   
IF( ISPICKVAL(Status, 'Approved'), Total_Price__c, Null)

And  chose the Treat blank fields as blanks in Blank Field Handling section . Refer the below screenshot for this.

Dear All,
My If condition is always false even the 2 values compared match each other ?? see picture the result
        <aura:iteration items="{!v.reclamationList}" var="reclamation">

            <aura:renderIf isTrue="{!reclamation.Type__c == !v.category}">
                {!reclamation.Type__c}/{!v.category}--True <aura:set attribute="else"> {!reclamation.Type__c}/{!v.category}--False </aura:set>

  updateSelect: function(component, event, helper) {
    //return the selected value

    var cat = component.find("selectItem").get("v.value");
    component.set("v.category", cat);

Best Answer chosen by KARIM EL ALAOUI
Maharajan CMaharajan C
Hi Karim,

Try the below change in  your aura:renderIf 

<aura:renderIf isTrue="{!v.category == reclamation.Type__c}">

Ryan Avent 10Ryan Avent 10 

Hello i have toast messages that display to users based on diffrent rules, i need this test to be translatable / as well as allow overridable by system admins when the managed package is deployed.

I beleave Custom Metadata fields in conjunction with translation workbench will allow this but i have not idea how to retrieve the data in SOQL, could somone give me an example?

when i try the below all i get is an empty entry.

SELECT Label, ExampleNamespace__Ex_example_field__c FROM ExampleNamespace__Ex_example__mdt


Best Answer chosen by Ryan Avent 10
paul diracpaul dirac
Hi Ryan,
Consider custom settings as an alternative to your use case.
Check if your metadata is actually non-empty, go to your metadata, press Manage *your metadata name* and see if there is at least one row
Arpitha GowdaArpitha Gowda 
Hello All

How do i write test class for below Batch apex class, 
global class Emailalertbatchclass implements Database.Batchable<sObject>, Schedulable, Database.Stateful {
    //Variable Section
    global FINAL String strQuery;
    global FINAL String leadid;
    global List<String> errorMessages = new List<String>();
    global Emailalertbatchclass() { 
        this.strQuery = getBatchQuery();
    //Returns the Query String to Batch constructor to fetch right records.
    private String getBatchQuery() {
        String strQuery = 'SELECT Id,Name,Status,Email,owner.email,owner.name,ownerid,No_Enquiry_Email_Sent__c,Manager_Email__c FROM Lead where No_Enquiry_Email_Sent__c=false AND Status=\'Enquiry\' And (CreatedDate = YESTERDAY OR LastModifiedDate = YESTERDAY) limit 1';
        return strQuery;
    //Batch Start method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(strQuery);
    //Batch Execute method calls findCostForWoD method
    global void execute(Database.BatchableContext BC, List<sObject> scopeList) {
        System.debug(LoggingLevel.INFO, '== scopeList size ==' + scopeList.size());
        List<Lead> ld = (List<Lead>) scopeList;
        List<Lead> updatedld = new List<Lead>();
        if(!ld.isEmpty()) { 
            List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
            for (Lead prod : ld)
                // Step 1: Create a new Email
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                // Step 2: Set list of people who should get the email
                String[] toAddresses = new String[] {prod.owner.Email,prod.Manager_Email__c,'chandra.s@proseraa.com'};
                // Step 3: Set who the email is sent from
                mail.setSenderDisplayName('No Activity on Leads for 24hrs');
                // (Optional) Set list of people who should be CC'ed
                List<String> ccTo = new List<String>();
                // Step 4. Set email contents - you can use variables!
                mail.setSubject('No Activity on Lead for 24hrs');
                String body = 'Dear ' + prod.owner.name + ', <br><br>';
                body += 'This is to notify you that there is no activity done on the respective <b> Lead Name: ';
                body +=prod.Name+'</b>  please find the link below..<br><br>';
                body += 'link to file: https://moengage--proseraa.lightning.force.com/lightning/r/Lead/'+prod.id+'/view'+'<br><br><br> Thanks,<br>Moengage Team</body></html>';
                // Step 5. Add your email to the master list
                prod.No_Enquiry_Email_Sent__c = true;
            if(!mailList.isEmpty()) {
                    update updatedld;
                catch (Exception ex) {
                    errorMessages.add('Unable to send email to Tech: '+ ex.getStackTraceString());
    //Batch Finish method for after execution of batch work
    global void finish(Database.BatchableContext BC) { 
    //Method which schedules the ProductDownloadBatch
    global void execute(SchedulableContext sc) {        
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);

Best Answer chosen by Arpitha Gowda
Dushyant srivastava 8Dushyant srivastava 8
remove the "Test.startTest()" from the 3rd line of the method and add that after "Test.setCreatedDate(ld.Id, yesterday);"

It will work fine then.
public class EmailalertbatchclassTestclass
    static testMethod void testmethod1()
        lead ld = new lead();
        ld.FirstName= 'test';
        ld.Company = 'fgfh';
        ld.Email = 'manjunath.s@proseraa.com';
        ld.Manager_Email__c = 'chandra.s@proseraa.com'  ;  
        Insert ld;  
        Datetime yesterday = Datetime.now().addDays(-1);
        Test.setCreatedDate(ld.Id, yesterday);
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);

See the above Class and try to modify your code accordinly.
Akis AthanasiadisAkis Athanasiadis 
I have created a flow and a lightning component which run on new.
The flow creates a record and I want at the end of the flow to be redicted inside the record which was  just created.
In the flow I store the new record's id as {!recordId}

The controller is:
    init : function (component) {
        // Find the component whose aura:id is "flowId"
        var flow = component.find("flowId");
        // In that component, start your flow. Reference the flow's Unique Name.
handleStatusChange : function (component, event) {
    if(event.getParam("status") === "FINISHED") {
       var navEvt = $A.get("e.force:navigateToSObject");
                "recordId": "??????????",
                "slideDevName": "related"

What do i set at the record Id though to be redicted in the new record?

All the threads I have found, provide specific Id which of course does not apply to our needs.

Best Answer chosen by Akis Athanasiadis
Nayana KNayana K

I am sorry. Looks like you are overriding 'New' button. So, definitely recordId will be not be present.

I am assuming you are talking about flow output variable whose name is 'recordId'.
handleStatusChange : function (component, event) {
    if(event.getParam("status") === "FINISHED") {
       var outputVariables = event.getParam("outputVariables"); 
       var outputVar; 
       for(var i = 0; i < outputVariables.length; i++) { 
             outputVar = outputVariables[i]; // Pass the values to the component's attributes 
             if(outputVar.name === "recordId") { 
                  var navEvt = $A.get("e.force:navigateToSObject"); 
                  navEvt.setParams({ "recordId": outputVar.value, "slideDevName": "related" }); 

My code is at present hard coded
vf page
<apex:page controller="EmployeeDataClass">
 <apex:form >
 <apex:pageBlock title="Department:" >
 <apex:outputText value="{!selectedEmp}" label="you have selected:"/>
  <apex:pageBlockSection title="Custom Picklist Using selectList and selectOptions departments" collapsible="false">
  <apex:selectList value="{!selectedEmp}" multiselect="false" size="1">
                <apex:selectOptions value="{!countriesOptions}"/>
     <apex:pageBlock title="Employee Data">
         <apex:pageBlockTable value="{!lstEmp}" var="e">
             <apex:column headerValue="Employee Name" >
                 <apex:outputtext value="{!e.Name}"></apex:outputtext>
             <apex:column headerValue="Employee City" >
                 <apex:outputtext value="{!e.Email__c}"></apex:outputtext>
             <apex:column headerValue="Employee Contact" >
                 <apex:outputtext value="{!e.Phone__c}"></apex:outputtext>
              <apex:column headerValue="Employee department" >
                 <apex:outputtext value="{!e.Dept__c}"></apex:outputtext>

public class EmployeeDataClass{

       constructor is a method which executes automatically when the class is loaded.
   public List<Employee__c> lstEmp{get;set;} // Property Declaration.
   public String selectedEmp{get;set;}

   public EmployeeDataClass(){
       lstEmp = new List<Employee__c>(); // Initialization.
       lstEmp = [select id,name,email__c,phone__c,dept__c from Employee__c  limit 50000];
    public List<SelectOption> getCountriesOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        countryOptions.add(new SelectOption('','-None-'));
        countryOptions.add(new SelectOption('Learning','Learning'));
        countryOptions.add(new SelectOption('HR','HR'));
        countryOptions.add(new SelectOption('Accounts and Finance','Accounts and Finance'));
        countryOptions.add(new SelectOption('Infrastructures','Infrastructures'));
        countryOptions.add(new SelectOption('Research and development','Research and development'));
        countryOptions.add(new SelectOption('Product development','Product development'));
        countryOptions.add(new SelectOption('IT services','IT services'));
        return countryOptions;
    public PageReference save(){
        return null;

Now I want code in controller to be dynamic.Please suggest any ideas.
Best Answer chosen by T L TEJASWINI
Khan AnasKhan Anas (Salesforce Developers) 

Greetings to you!

Below is the sample code. Kindly modify the code as per your requirement.

<apex:selectList value="{!selectedEmp}" multiselect="false" size="1">                                 
           <apex:selectOptions value="{!countriesOptions}"/>

public String selectedEmp {get;set;}

public List<SelectOption> getCountriesOptions() {
        List<SelectOption> empOptions= new List<SelectOption>();
        empOptions.add( new SelectOption('','--Select--'));
        for( Employee__c emp : [SELECT Id, Country__c FROM Employee__c ] ) { // Country__c is API name of a field which you want to display in a picklist
            empOptions.add( new SelectOption(emp.Id, emp.Country__c));
        return empOptions;

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Chris Summers 5Chris Summers 5 
Hello, I hope someone might be able to provide me some guidance!

I work in an area where we provide training to school districts, and we have recently started building out a tracking system to monitor our technical assistance to the districts. We currently have it where we have an object built which stores districts as record pages, and an object to create technical assistant events as a record. It currently uses a lookup field to link a technical assistant event to the school district. We are hoping to learn how we can make it possibile to link the technical assistant event to more than one school district.  I would like to be able to still have the function of the lookup field to search the school district, but the added ability of attaching a single technical assistant event to a district.

This was if I am out training at District 1 and District 2 I can record that in the same event, not have to create two different events.

I have attached a screenshot of the current new event creation form.

Any help is appriciated, thanks!

User-added image
Best Answer chosen by Chris Summers 5
Andrew GAndrew G
Short answer is yes.  You would need to create the additional junction records manually.  You could make the object simple and use just the two joining fields.  There is the "Save and New" button OR you could leverage the "Clone" button to make creation easier.  ( I do like the Clone button).

To make it so the creation is a one stop shop, you may need to go to a VF page with controller to create the junction objects all at once behind the scenes.

I would maybe do some checking to see the volumnes involved.  For example, if multiple districts for an event is less than 10%, then maybe the manual process would be sufficient. Once it's over 20%, then going to a VF page or similar solution to allow "one stop" creation is a given.