+ Start a Discussion
jkcjkc 
Hi,
I'm in a terrible dilemma with the trigger. I was wondering why there is no id assigned on the record anymore
trigger trigger_Account on Account(before insert, before update){
  for( Account acc : Trigger.new){
    system.debug('Account id: ' + acc.id);
  }
}
this change affected some of my previous triggers
Best Answer chosen by jkc
ManojSankaranManojSankaran
Hi,

Your trigger will fire in two condition before insert and before update.

In before insert - id value wont be there....since the record is not inserted into database.
in before update - id value will be there and you will be albe to use that id for calcualtion.

Only in After Insert you will get the id of that record.


Let me know if you need more clarification. If it answers your question please mark it as answer.

Thanks
Manoj S
Laura KempenaarLaura Kempenaar 
Hi all,

Another question from me: I am still working on the admin module within Trailheads and I cant finish it, because in the Create object specific quick actions-part I can't seem to find Properties under Tabs. I did create Property/Properties as an object, but then I have to do this:

Enter Tab in the Quick Find box, then select Tabs.
In the Custom Object Tabs list, click New.
In the Object dropdown list, select Property.

And in that object dropdown list, there is no Property. Can someone tell me what to do here, please? Thanks! :)
Best Answer chosen by Laura Kempenaar
Andras Arva(HU)Andras Arva(HU)
hey @Laura Kempenaar
I was in the same situation, reviewed tab access, even FLS but did NOT helped.
After a while i noticed that if i scroll UP in my mobile it refresh my tabs list ! (where you generally see tabs/recent/connections etc.)
And this was necessary as probably tab names were cached (if i use another mobile to connect that could work w/o it)
Muhammad Jawwad 16Muhammad Jawwad 16 
global class LoanOfficerBatch implements Database.Batchable<sObject> {
    public String query = 'SELECT Loan_Officer_1a__c,Loan_Officer_1a__r.Email, ConvertedOpportunityId, Name, Phone,' 
                          +  'Status, Est_Re_Pull_Date__c, Realtor_Name__c ' 
                          +   ' FROM Lead'; 
    public EmailTemplate templateId = [Select Id,HtmlValue,Subject from EmailTemplate where name = 'LoanOfficerRecord' LIMIT 1];

    global Database.QueryLocator start(Database.BatchableContext bc) {

        query += ' WHERE CreatedDate = LAST_MONTH  AND Loan_Officer_1a__c != null';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, list<Lead> allLeads) {
        
        
         
        List<String> convertedOppId = new List<String>();
         for(Lead l: allLeads){
	         convertedOppId.add(l.ConvertedOpportunityId); 
             }

         Map<Id, Opportunity> opptyMap = new Map<Id, Opportunity>();  
         for(Opportunity o : [SELECT Id,Name,Contact__r.Name,Contact__r.Phone,Starting_Credit_Score__c,Enrolled_On__c,Est_Re_Pull_Date__c,StageName FROM Opportunity WHERE Id IN: convertedOppId]){
	      opptyMap.put(o.Id, o);
          }
        
        
        
        Map<Id,List<Lead>> leadMap = new Map<Id,List<Lead>>();
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMEssage>();
        if(allLeads != null && allLeads.size() > 0){
            for(Lead l: allLeads){
                if(!leadMap.containsKey(l.Loan_Officer_1a__c)){
                    leadMap.put(l.Loan_Officer_1a__c, new List<lead>());
                }
                leadMap.get(l.Loan_Officer_1a__c).add(l);
            }
        }
        if(leadMap.keySet().size() > 0){
            Map<Id,Contact> officers = new Map<Id,Contact>([SELECT Id,Email,Name FROM Contact WHERE Id IN: leadMap.keySet()]);
            for(Id i: leadMap.keySet()){
                Contact con = officers.get(i);
                System.debug(con);
                if(String.isnOtBlank(con.Email)){
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    mail.setToAddresses(new String[]{con.EMail});
                    mail.setSubject(templateId.Subject);
                    String html = templateId.HtmlValue;
                    html = html.replace('||OfficerName||',con.Name);
                    String leadsTable = '<table cellpadding="3" cellspacing="3" width="100%" align="center" border="1" style="border-collapse:collapse;">'+
                        '<tr style="font-weight:bold;"><td>Name</td><td>Phone</td><td>Status</td><td>Est. Re Pull Date</td><td>Realtor Name</td></tr>';
                    
                    for(Lead l: leadMap.get(i))  
                    if(l.ConvertedOpportunityId==null)
                    {                    {
                        
                        
                        leadsTable += '<tr><td>'+l.Name+'</td>'+
                            '<td>'+l.Phone+'</td><td>'+l.Status+'</td>'+
                            '<td>'+l.Est_Re_Pull_Date__c+'</td><td>'+l.Realtor_Name__c+'</td></tr>';
                    }
                                               }
                    leadsTable += '</table>';
                    
                     String opptyTable = '<table cellpadding="3" cellspacing="3" width="100%" align="center" border="1" style="border-collapse:collapse;">'+
                        '<tr style="font-weight:bold;"><td>Name</td><td>Phone</td><td>Starting Credit Score</td><td>Enrolled On</td><td>Estimated Pull Date</td><td>StageName</td></tr>';
                    
                    for(Id idKey: opptyMap.keySet()){
                        Opportunity o = opptyMap.get(idKey);
                        
                        
                        opptyTable += '<tr><td>'+o.Contact__r.Name+'</td><td>'+o.Contact__r.Phone+'</td><td>'+o.Starting_Credit_Score__c+'</td><td>'+o.Enrolled_On__c+'</td>'
                            +'<td>'+o.Est_Re_Pull_Date__c+'</td><td>'+o.StageName+'</td></tr>';
                    }
                    opptyTable += '</table>';
                    html = html.replace('||Leads||',leadsTable);
                    html = html.replace('||Opportunity||',opptyTable);
                    html = html.replace('null',' ');
                    mail.setHTMLBody(html);
                    mails.add(mail);
                }
            }
        }
        if(mails.size() > 0){
            Messaging.sendEmail(mails);
        }
    }

    global void finish(Database.BatchableContext BC) {

    }
   
}
please help
 
Best Answer chosen by Muhammad Jawwad 16
Maharajan CMaharajan C
Hi Mohammad,

First create scheduler class to your batch class. Then only you can run your batch class monthly.

Scheduler Class:

global class LoanOfficerBatchSheduler implements Schedulable {
   global void execute(SchedulableContext sc) {
      LoanOfficerBatch b = new LoanOfficerBatch(); 
      database.executebatch(b);
   }
}

Then there is two way to run this batch class via the Scheduler:

1. Salesforce Standard Out of Box Scheduler : (Cons : you can only scehdule up to next five years)

Setup > Apex Classes > Shedule Apex Button > Then you can lookup the above Sheduler Class. Please refer the below screenshot for further:

User-added image



2. Using CRON and Developer Console:

Developer Console > Debug > Open Execute Anonymous Window > paste the below code > Execute


LoanOfficerBatchSheduler m = new LoanOfficerBatchSheduler();
String sch = '0 0 0 1 * ? *';
String jobID = system.schedule('Merge Job', sch, m);

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
http://amitsalesforce.blogspot.com/2017/07/how-to-write-test-class-for-scheduler.html
https://webkul.com/blog/cron-expression-for-scheduling-jobs-in-salesforce/

Thanks,
Maharajan.C
Goran K.Goran K. 

Keep getting following error when I try to call static library for reading QR codes.
TypeError: a.default is not a function
    at v._tick (eval at t (aura_prod.js:1:1), <anonymous>:3:1996)
    at eval (eval at t (aura_prod.js:1:1), <anonymous>:3:2384)
The code is based on following article. 

https://eltoroit.medium.com/etqr-code-scanner-47ef5ea67d90

Has anyone experince similiar errors? Wonder if its the way of calling the library or something with the settings. 

Best Answer chosen by Goran K.
Goran K.Goran K.

If anybody have the same problem. You need to load the scripts before using them. Since every example I saw was not using scripts loading I totally missed that step.
 

To illustrate:

import { loadScript } from 'lightning/platformResourceLoader';
import jsQrScript from '@salesforce/resourceUrl/jsQR';

export default class JSqrcodeScan extends LightningElement {

	jsQR = jsQrScript;

		
	renderedCallback() {		
		loadScript(this, this.jsQR);
	}
}
User SethUser Seth 
Please provide any video that will fit into this requirement
Best Answer chosen by User Seth
SwethaSwetha (Salesforce Developers) 
HI Seth,
Check this blog https://www.learnexperiencecloud.com/s/article/How-To-Personalize-The-Shared-Regions-of-Your-Experience-Builder-Site

I've found this related video: https://www.youtube.com/watch?v=37xrVqSJ7p4

If this information helps, please mark the answer as best. Thank you
fernandotakaifernandotakai 

Hi!

 

I have a package with a publisher name as MyCorp, but I would love to change to something more meaningful (as my real company name), but I can't find a way of doing it.

 

Is there a way, or do I need to create a new package (or is there any other way)?

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
A_SmithA_Smith

Change the your dev organizations name under Company Profile > Company Information in setup.  It will take up to 30 minutes, but this will change the publisher shown for packages in subscriber orgs.  


Thanks,

Andrew

YiQin HeYiQin He 
Hi, 

I created a lightning component as a quick action button. In the component, I have a cancel button that I want it closed when user clicks.
User-added image

But the problem is that I cannot find any document explain how to close the modal dialog. This is the ui code:
<aura:component controller="ContactController" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" >
    <style>
        .changeRecordTypeRow {
        margin-top: 1.5rem;
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 0;
        }
        
        .changeRecordTypeLeftColumn {
        float: left;
        text-align: right;
        padding-right: 1.5rem;
        width: 35%;
        font-size: .8125rem;
        color: rgb(84, 105, 141);
        }
        
        .changeRecordTypeRightColumn {
        float: right;
        text-align: left;
        width: 65%;
        }
        
        .modal-body
        {
        	height:auto !important;
        	padding:0;
        }
        
        .forceChatterLightningComponent .bodyWrapper{height:100%;width:100%;padding:0;box-sizing:border-box}
    </style>
    <div class="modal-header slds-modal__header">
        <h2 class="title slds-text-heading--medium" >Change Contact Type</h2>
    </div>
    <div class="scrollable slds-modal__content slds-p-around--medium">
        <div class="changeRecordTypeRow">
            <fieldset class="slds-form-element">
                <div class="changeRecordTypeLeftColumn">
                    <legend class="form-element__legend slds-form-element__label">Select a record type</legend>
                </div>
                <div class="changeRecordTypeRightColumn slds-form-element__control">

                    <span class="slds-radio">
                        <input type="radio" id="radio_PrimaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_PrimaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Primary Contact</span>
                        </label>
                    </span>
                    <span class="slds-radio">
                        <input type="radio" id="radio_SecondaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_SecondaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Secondary Contact</span>
                        </label>
                    </span>
                </div>
            </fieldset>
        </div>
	</div>
    <div class="modal-footer slds-modal__footer">
    	<div class="forceChangeRecordTypeFooter">
        	<button type="button" class="slds-button slds-button--neutral .slds-modal__close" aura:id="btnCancel" >
            	Cancel
            </button>
            <button type="button" class="slds-button slds-button--brand" aura:id="btnSave">
            	Save
            </button>
        </div>
    </div>
</aura:component>
Does anyone have similar experience? Thanks in advance.
Best Answer chosen by YiQin He
YiQin HeYiQin He
Hi Karthik,

Thanks for the reply. I've already found the solution.
Call this method $A.get("e.force:closeQuickAction").fire() will close the modal dialog.

Yiqin
IanDoneganIanDonegan 
I have an external app that I would like to use to create records of a custom object through the rest API. I can create Accounts just fine, but have not been able to replicate that functionality for any custom object.

I took a look at workbench.developerforce.com, and found that the rest explorer is not returning information about any custom objects.

I am logged in as a system administrator, so I should have access to everything. What am I doing wrong?
Best Answer chosen by IanDonegan
Khan AnasKhan Anas (Salesforce Developers) 
Hi Ian,

Greetings to you!

You should try to grab the URL by GET method first. Then apply post on that URL.

URL: /services/data/v45.0/sobjects/Test__c

Method: POST
Body: Here assign the field values for all the required fields on that object. 

{
"Name":"Test Record 1"
}


Also, please make sure you are logged into workbench using the correct instance. For example, my Trailhead instance has different data from my Dev instance.

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
PRASENJIT BANERJEE 24PRASENJIT BANERJEE 24 
public with sharing class  AccountTeamMemberController 
{
    @AuraEnabled
    public static list<Account_Team_Member__c> getRelatedList(Id recordId)
        {
            Apttus__APTS_Agreement__c objAgreement = [Select id , Apttus__Account__c from Apttus__APTS_Agreement__c where id =: recordId ];
            List<Account_Team_Member__c> atmlist = [Select Name, Role__c, Active__c,Email__c from Account_Team_Member__c 
                                                    where Account__c =: objAgreement.Apttus__Account__c AND Role__c ='Relationship Manager'];
             return atmlist;
           
        }
}
Best Answer chosen by PRASENJIT BANERJEE 24
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prasenjit,

The test class can be something as below. You should give all the mandotaty fields in all the respective objects while creating them.
 
@istest
public class AccountTeamMemberControllerTest {
static testmethod void methTest(){
    Account Acc= new Account();
    Acc.Name='Sample';
    insert acc;
   Apttus__APTS_Agreement__c  agg= new Apttus__APTS_Agreement__c ();
    agg.name='sample agreement';
    agg.Apttus__Account__c = acc.id;
    insert agg;
    Account_Team_Member__c  acm= new Account_Team_Member__c ();
    acm.Name='samplemember';
    acm.Role__c='Relationship Manager';
    acm.Active=true;
    acm.Email__c='sample@gmail.com';
    acm.Account__c= acc.id;
    insert acm;
    AccountTeamMemberController.getRelatedList(agg.id);
}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Sudeep SinghSudeep Singh 
Done an integration with saleforce and SAP using Platform event.
Created a button so that when that button is clicked then the flow is triggered and Bi-directional integration happens. 
But problem is that in a single quote several quote line can be created and user can click that button in every addition of quote line group. that button will be activated if the quote status is "accepted". 
I want to prevent the user for clicking many times that button. 

how it is possible  ??

thnx
Best Answer chosen by Sudeep Singh
Sai PraveenSai Praveen (Salesforce Developers) 
HI Sudeep,

Can you edit your lightning page related to the object on which this button is present and enable dynamic form if it is not enabled and put the filter on the button such that checkbox field which you created should be false and then save it.

Now this button will be visible only when checkbox is false.

Please find the below article (https://help.salesforce.com/s/articleView?id=sf.dynamic_forms_overview.htm&language=en_US&r=https%3A%2F%2Fwww.google.com%2F&type=5#:~:text=With%20Dynamic%20Forms%2C%20you%20can,and%20sections%20that%20they%20want.) for the same.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,