Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

New answers tagged

0 votes

When the triggers run in context of a composite standard Rest api, which governor limit it comes under?

Sorry for the long post. But an interesting finding with data points. I did some testing around this. Here are my findings. FIRST services/data/v52.0/composite { "allOrNone":true, "...
user avatar
0 votes

How to generate and download file(text) in visualforce page

I resolved this problem,I am using the javaScript download function in two ways Visualforce page: <apex:page controller="VFPageDownloaderController" action="{!downloadAutomatic}"...
user avatar
0 votes

Text file download in Visualforce page

I resolved this problem ,I am using the javaScript download function with two ways Visualforce page: <apex:page controller="VFPageDownloaderController" action="{!downloadAutomatic}&...
user avatar
0 votes

When the triggers run in context of a composite standard Rest api, which governor limit it comes under?

All the standard apex governor limits apply here for every individual REST API inbound call or sub requests within composite inbound call. As mentioned here, the entire composite inbound counts ...
user avatar
  • 4,452
0 votes

Chatter feed auto refresh

You cannot auto refresh chatter feed in salesforce, Kindly review and vote for this feature. Thanks
user avatar
  • 1,484
0 votes

Visualforce email template table row conditional with no controller

You have: <apex:outputField value="{!IF(rx.Type__c == 'Online', rx.Training_Start_Time__c, '')}" You can't do this -- apex:outputFields can't be dynamically specified in an IF block ...
user avatar
  • 61.5k
0 votes

Apex Class - Day Light Savings - If statement to adjust for daylight savings based on dates

I'd like to take @sfdcfox's response and extend it. When you consider Daylight Savings Time, this has two transitions in the year (unless DST is being made permanent, as The Fox says). You can ...
user avatar
  • 26.7k
0 votes

How to give profile label permission for files upload and delete

To prevent file upload capability, you will have to enable or disable the Select Files from Salesforce permission as mentioned here To prevent deletion of files, refer this Only the file owner can ...
user avatar
  • 4,452
0 votes

store pair of 2 fields on a map

your syntax looks correct, but I'd run it in Anonymous Apex to double check (screenshot added for reference). You other questions can be answered from the Apex Documentation linked below. Let me know ...
user avatar
  • 11
1 vote

Can I check contact field conditions from the Map?

If I understand correctly, the code above is iterating through a list of Campaign Members, then if the Campaign Member is linked to a Contact, calculate a date value called LatestDate, then put the ...
user avatar
  • 11
0 votes

Pass variable from LWC to apex controller

Well that was more simple than I thought. . . two lines: js createCustomer({name: 'Skip', email: 'skip@gmail.com'}) controller public static String createStripeCustomer(String name, String email) {
user avatar
  • 439
2 votes

Triggers on contact to update decsiption field of its parent account

You have queries and DML operations in a loop, both of which are bad. Also, you're querying the records only in the trigger, which would cause the overwriting you've observed. Instead, you'll want to ...
user avatar
  • 430k
0 votes

how to call a parameterized method from the developer console?

You declared your add() method as static, which means that you call it using the name of the class instead of an instance of the class. Other than that, you just need to pass the correct number and ...
user avatar
  • 47k
0 votes

how to call a parameterized method from the developer console?

'add' method in above class expects two parameters to be passed when being called. If you call 'first.add()' without passing any parameter code will try to find a function with name as 'add' which ...
user avatar
  • 460
0 votes

Unable to fetch the Parent Account information into the Child Account Record

in the line no. 4 Replace this line if((ac.Account_Level__c == 'Parent' || ac.Account_Level__c == 'Account') && !ac.Exclude_Account__c && ( ac.ParentId != oldAccountMap.get(ac.Id)....
user avatar
2 votes
Accepted

How to fetch name field for a record of given record id but known object?

Salesforce says, sometimes it is not accurate, what it says :) There is a possibility to get "main" name field for every object: custom and standard. Use isNameField method. String ...
user avatar
0 votes

How to get translation of field label based on language and locale?

Here are 2 possible coding options to retrieve translated field label based on current user language In APEX Using Schema describe methods, the field label is translated based on user language Map<...
user avatar
  • 3,230
1 vote

How to download all Apex classes from Prod using VS code

We can also use these commands from the terminal: Retrieve All Apex classes sfdx force:source:retrieve -m ApexClass Deploy All Apex classes (Never do, a very bad habit) sfdx force:source:deploy -m ...
user avatar
  • 11
1 vote

Best practice for async apex classes (Queueable, Batchable) in relation to service classes

My practice which is not bullet-proof and subject to better alternatives. If it is a Schedulable class with no call to a batchable (or calls a configurable batchable) xxxSchedulable If it is a ...
user avatar
  • 61.5k
1 vote

Best practice for async apex classes (Queueable, Batchable) in relation to service classes

This is more an opinion questions so what I share here is an opinion, which may or may not work for you/others. We came to realize that in Salesforce due to nature of platform, smaller classes are ...
user avatar
  • 1,550
0 votes

SOQL: Convert set to list

If someone like me enjoys using the array notation for the lists like: Id[] ids = new Id[]{}; instead of, List<Id> ids = new List<Id>(); to create a list from a set would be as the ...
user avatar
  • 596
1 vote
Accepted

Named Credential - using a merge field

Named Credential acts as a runtime proxy. The proxy receives your HTTP request then searches its body or headers for the merge field as a literal string. If NC doesn't find the field, it won't ...
user avatar
  • 6,150
0 votes
Accepted

Database.query() question

No need to use variables if they are not required to be referred in another place. However, careful use of them can enhance the readability of the code to reduce the noise or complexity. I assume you ...
user avatar
  • 1,550
2 votes
Accepted

Does Date.addDays() method skip the weekends based on the Org's Business Hours settings?

It does not interact with your Business Hours at all. It just adds days. From the documentation on the Date class: addDays(additionalDays) Adds the specified number of additional days to a Date.
user avatar
  • 142k
0 votes

Need help with test class for code coverage on AccountContactRelation Object

This code works for me with no errors: @isTest static void test_CreateAcctContactRelation() { Account accRecord = new account(); accRecord.Name = 'Test Acc1114'; insert accRecord; ...
user avatar
  • 113
2 votes
Accepted

Salesforce - Edit field on before delete

You can update the record via DML in a before delete trigger. Here's a copy-paste example: trigger markAccountAsDeleted on Account (before delete) { Account[] accounts = new Account[0]; for(...
user avatar
  • 430k
1 vote

My LWC comes up as Object object in communities but works in lightning apps page

You should debug what you have in rent.error when it is opened in the community. It seems like, there is some exception thrown by rentController.getRent method, which is an object in error. [object ...
user avatar
3 votes
Accepted

Conflict between Run Time and CPU time in Apex

The five second concurrent transaction limit is primarily there to prevent us from consuming too many resources. You can view the 10/60 second limit as a "burst" limit, while the 5 second ...
user avatar
  • 430k
3 votes

why my JSON deserializeUntyped giving me Exception

The decoded parameter is JSON, so you have to deserialize again: Map<String, Object> params = (Map<String, Object>)System.JSON.deserializeUntyped( RestContext.request.requestBody....
user avatar
  • 430k
3 votes
Accepted

Batch apex not executed from test class

The key thing that you're missing is Test.startTest() and Test.stopTest(). Async apex (@future, queueable, batch, schedulable) runs in a separate transaction from the one that it's called from. In the ...
user avatar
  • 47k
1 vote

Named Credential - using a merge field

I don't think you can use a merge field like this, because it's replaced when the call is made. Effectively you're ending up with the encoded value of the literal text {!$Credential.Username}:*...
user avatar
  • 211
0 votes

How to find account with inactive opportunity and send email alert?

You could create a scheduled flow that runs daily, and checks all your accounts iteratively and their opportunities. You should have a new date field on your accounts for 'email sent'. For those that ...
user avatar
  • 618
3 votes

why my JSON deserializeUntyped giving me Exception

That is because event_value is escaped inside of a string. Meaning it starts with quotes, and all quotes inside are escaped with a backslash: { "event_source": "", "...
user avatar
0 votes

Apex Class - Day Light Savings - If statement to adjust for daylight savings based on dates

Don't hard-code the timezone offset; parse the time as a GMT, then use the TimeZone class to calculate the correct offset. // If using this in a loop, compile once for performance Pattern p = Pattern....
user avatar
  • 430k
0 votes

How to properly test and assert an @restresource that do multiple API calls?

So try something like this (note, this is me coding in the browser so you might need to adjust it). public class MockHttpResponse { public Integer code { get; set; } public String status { get; ...
user avatar
  • 1,576
0 votes

Salesforce - Best way to pass namespace__ (e.g:Apttus__, svmax__ etc) to get('obj').getDescribe().fields.getMap(); method

The namespace prefix is part of the object API name. You should be storing the complete ("fully-qualified") object API name. So if you have an object called apttus__Template__c, you must ...
user avatar
  • 86.3k
0 votes
Accepted

Validate lineitems and throw error if the lineitem values dont match

Maps and Sets are your friend whenever you want to perform pretty much any comparison. The general approach here is: Determine what you want your map key to be, and what you want the value to be Make ...
user avatar
  • 47k
0 votes
Accepted

Multiplication of two fields in salesforce using trigger

Even if your code ended up working, you'd run into a recursive loop. You should use before insert/before update, and set the value directly. You'll need to query the parent record(s), then perform the ...
user avatar
  • 430k
1 vote

System.LimitException: Too many callouts: 101 Error

The error message is clear that you cannot make more than 100 calls in Transaction (Tx) context. Each time your future job runs, it starts a new Tx context and that execution can make max 100 calls. ...
user avatar
  • 1,550
0 votes

How to remove time from date?

A more elegant way I found was: System.debug('Current date: ' + String.valueOf(Date.today().toStartOfMonth()).split(' ')[0]);
user avatar
1 vote

How to convert JSON String of RESTRequest to Map

Naming your string "json" is shadowing the JSON class, causing you to be unable to use the JSON class in the same scope where this variable is present. Rename your string variable, or use ...
user avatar
  • 47k
0 votes
Accepted

What do we mean when we write the below code?

There was some aggregate query on which is returning the Accountid, Amount .. etc. You are iterating the result through the for Loop and adding the Id and Amount to the Map called amountMap. The same ...
user avatar
0 votes

Lightning Dual Listbox style

I removed selected-label="Selected" and the box was aligned correctly .
user avatar
1 vote

Platform event Fired from two objects

Platform Events can be absolutely used in this case. Just to recall, Platform Event is similar to a Custom Object, has its own set of fields and is not tied to any other Object hence it can be used to ...
user avatar
  • 1,550
0 votes

How to In trigger, when an account is Inserted it should create multiple contacts without nested loop?

we can add one more step to this code, if you create 'Total Contacts' field in Account, the trigger will create as many contacts as you indicate in this field; trigger testAccountTrigger on ...
user avatar
3 votes
Accepted

Is there anyway to check what the triggering class is?

I think the most correct term to use here is the "calling class", and No, there is not an out-of-the-box way to determine that. The closest thing you'd get to this is to have the class where ...
user avatar
  • 47k
0 votes

How to define a constructor and pass parameters to schedulable controller

Here's my way of passing parameters to a schedulable apex class. This following class has a constructor that takes two parameters and sets the class attributes to hold the values passed into as the ...
user avatar
  • 596
0 votes

Passing Parameter Into Schedulable Class

Here's my way of passing parameters to a schedulable apex class. This following class has a constructor that takes two parameters and sets the class attributes to hold the values passed into as the ...
user avatar
  • 596
2 votes
Accepted

setBody on HTTPCallout not working apex to stripe

When you're having trouble with a third party API, your first stop should be to look at that third party's documentation. Here's Stripe's API documentation for the customer object. Combine that with ...
user avatar
  • 47k
2 votes
Accepted

How to add ALL ROWS in fflib selector class

Seems like there is no fflib solution for it. Append the ALL ROWS string at the end of a built query string. public List<AccountTeamMember> selectByDeletedId( Set<Id> ids) { ...
user avatar

Top 50 recent answers are included