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

Questions tagged [apex]

Questions relating to Apex, the native programming language for the Force.com platform. Use it for general questions on syntax, errors, constructs, and rules of use. Most questions should include a code *excerpt* to help answerers understand specifically what has gone wrong or why you need help.

Filter by
Sorted by
Tagged with
1 vote
0 answers
5 views

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

We have many composite apis for external party to enter data or modify data in our org in real time when the external system receives data. We also have an integration with CTI <-> SF, where ...
user avatar
0 votes
1 answer
16 views

Visualforce email template table row conditional with no controller

I'm not very salesforce savvy and I need some assistance. I need to separate the table below in two displays on the email one for when the Type__c is Online and other when the Type__c is Inperson I am ...
user avatar
  • 3
-1 votes
0 answers
35 views

How to prevent the symbol "&" from being replaced by "&amp;" in the URL?

string redirectURL= URL+'OppId='+oppId+'&Country='+country+'&Lang='+lanag+'&Status=Approved&QuoteId='+quoteId; As mentioned above is URL is used for a certain function. But when the ...
user avatar
-1 votes
1 answer
25 views

Can I check contact field conditions from the Map?

I would like to check the condition for npct_Last_Face_to_Face__c field on Contact(as shown in the comments) before performing contactsToUpdateList operation, how could I make use of F2FAgencyIds Map ...
user avatar
-2 votes
1 answer
18 views

Pass variable from LWC to apex controller

Not sure of the syntax to pass parameters from lwc javascript to my apex controller. js import createCustomer from '@salesforce/apex/HttpCallout.createStripeCustomer'; export default class ...
user avatar
  • 439
0 votes
2 answers
19 views

how to call a parameterized method from the developer console?

I wrote this code on apex class public class greeting{ String Hi = 'Good Morning Mike'; Integer num1 = 34; Integer num2 = 43; public void printHi() { System.debug(Hi); } ...
user avatar
-1 votes
1 answer
12 views

How to give profile label permission for files upload and delete

I want to give permission for some profiles users where the users should not able to upload files and delete files. They can only download file. What is the suitable way to achieve that.
user avatar
-1 votes
0 answers
11 views

Deletion of Related Items (emails, activities, tasks, chats) on case but not the case itself through Apex

Could someone please help with the below requirement. I have a list of cases with related items (chatTranscripts, Emailmessages, tasks etc), need to delete all the related items on these cases but the ...
user avatar
-1 votes
1 answer
20 views

store pair of 2 fields on a map

I need to store and access values of 2 fields on a Map and be able to iterate over them. List<Quote> quots = [select Id,ContractId,CalculationMatrixVersion__c from quote where ContractId != ...
user avatar
0 votes
1 answer
21 views

Triggers on contact to update decsiption field of its parent account

i am new to sales-force triggers i need help for writing this trigger i tried to wrote but whenever i am inserting new contact for the same parent the account descriptions is getting over written with ...
user avatar
0 votes
1 answer
15 views

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

I have one section in Account named as Credit Information having five fields init. While creating Child Account Record, I wanted to fetch the Credit Information from Parent Account. Below is the ...
user avatar
  • 1
-1 votes
0 answers
12 views

How call and get values from rest api in salesforce

hey I am new to salesforce, i need to call a rest api and simply get values to populate a list using apex. i have no idea where to make the actual rest api call and how to pass the returned value to ...
user avatar
0 votes
0 answers
18 views

Throwing Error Message Using Trigger for aggregate query

My scenerio is like we have a case object. That case object has relation with "sample" object. "sample" has master detail relation with case object. Now in "sample" we ...
user avatar
  • 1
-1 votes
0 answers
22 views

How to eliminate the duplicate from same list and to use the map of values

Iam using the map here for remove the duplicates correct me on this Map<id,PartnersProfs> lstprofilemap = new Map<id,PartnersProfs>(); for(PartnersProfs p : lstMembersWithquery){ ...
user avatar
  • 1
-1 votes
0 answers
16 views

Can you able to suggest me any solution for the errors what I have in my trigger?

I just want to do that. When I attach any document to an opportunity, that related account should also be updated with that same document in Notes & Attachments. [! [enter image description here] ...
user avatar
0 votes
0 answers
7 views

LogoutEventStream not getting handled

I have written trigger to handle the logoutevent using LogoutEventStream platform event. But its not getting executed. I have enabled the streaming for LogoutEventStream from EventManger, then written ...
user avatar
1 vote
1 answer
25 views

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

I am trying to obtain all related child (look up) records of a record whose record id is passed. Salesforce docs say that for every object, regardless of type, name is a standard field, just like Id. ...
user avatar
0 votes
2 answers
19 views

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

When creating async apex classes (e.g. Batcheable, Queueable), especially classes associated with specific SObjects, what might be the best practice for where these async classes should be housed. ...
user avatar
  • 600
0 votes
0 answers
10 views

Opportunity Parent and Child Self Relationship & reporting

We have a use case where we have parent deal & child deals & when chid deal(S) close, we update its parent deal with aggregate data from its children. The way I plan to do it is to have a ...
user avatar
  • 25
0 votes
1 answer
17 views

Database.query() question

Is it ok to use String.escapeSingleQuotes() inside of a database.query() or do you need to create a new variable using the String.escapeSingleQuotes() first and then use the new variable in the ...
user avatar
2 votes
1 answer
26 views

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

For example when I use Date.addDays(1) for a task's due date. I realized if the next day falls into a weekend both Sat and Sun are skipped and it adds 1 workday (which is three days count). Now, this ...
user avatar
  • 596
0 votes
1 answer
19 views

Salesforce - Edit field on before delete

I need modify a custom field (datetime) when the record is deleted If I modify in before delete I get an error "There's a problem saving this record. You might not have permission to edit it, or ...
user avatar
  • 150
0 votes
1 answer
16 views

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

I have created this custom LWC to bring back some data from a custom object but for some reason when I return the data in a Community page I get: When its a lightning component on a home page it ...
user avatar
-3 votes
0 answers
16 views

Error Occurred: An Apex error occurred: System.NullPointerException: Attempt to de-reference a null object

I have Apex code that fired from Flow. The conditions for this Flow is when the user choose a specific record type. I create a new record type for this object and add this record type to the condition ...
user avatar
0 votes
1 answer
32 views

Conflict between Run Time and CPU time in Apex

According to documentation. RUN_TIME : The amount of time that the request took in milliseconds. Requests with a value over five seconds are considered long-running requests for the purposes of the ...
user avatar
2 votes
1 answer
43 views

Batch apex not executed from test class

I made batch class, and It's working very well. But when I try to execute it in test class, Batch apex not getting executed from test class, and it does not see test data. I've made two versions of ...
user avatar
-1 votes
1 answer
25 views

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

I have a scenario where I have to find Account which is not having active opportunity over 1 year period and send email alert in the first week after 1 year period of inactivity. How can I achieve ...
user avatar
0 votes
2 answers
31 views

Named Credential - using a merge field

Im facing issues trying to generate the auth header in Apex when using Named Credentials. Unfortunately I cannot use the standard Named Credential approach (auto header generation) as I have to embed ...
user avatar
  • 3
0 votes
2 answers
38 views

why my JSON deserializeUntyped giving me Exception

I'm creating a new REST API in salesforce and receiving the below JSON in Restrequest string {"event_source":"","event_time":"2022-05-25 08:12:40.151","...
user avatar
0 votes
2 answers
22 views

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

We have Apex classes that trigger and process a CSV file with rows of data. One of the columns is a time column and it is set up below. We implemented this Apex class in September/October and it ...
user avatar
0 votes
1 answer
17 views

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

I am struggling to do a test class, mainly building a proper assert method based on the following @RestResource (at the end). This class have 3 different API calls (First API response an XML the other ...
user avatar
  • 1,899
0 votes
1 answer
17 views

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

We have a requirement to prefix namespace__ value object at below code. For e.g : For template, need to prefix Apttus__, so the object value will be Apttus_template . We have multiple managed packages ...
user avatar
-1 votes
0 answers
20 views

Need to populate a field in a new claim form based on the logged in user

We have all custom objects in our org that our customers use. What I need to accomplish, is, that I need to auto-populate a field based on the logged-in user. Under the user profile, they have to set ...
user avatar
-2 votes
1 answer
38 views

System.LimitException: Too many callouts: 101 Error

I have this below code which is pushed to prod. Where in I am trying to make callout in future method to update lat/long values on Standard location Trigger, and each time the records are processed i ...
user avatar
  • 1
0 votes
1 answer
24 views

Validate lineitems and throw error if the lineitem values dont match

On the OpportunityLineItem, I have 2 custom lookup fields and 2 text fields. So if I have like 5 line items added, and if the 2 lookup fields match on any 2 lineitems, I need to make sure the other 2 ...
user avatar
-1 votes
1 answer
31 views

Multiplication of two fields in salesforce using trigger

I am new to salesforce. I tried multiplying two fields from two different objects but was failed to do so. I have two objects object 1 and object 2 as given below: object 1 is child of object 2. ...
user avatar
0 votes
0 answers
29 views

"Do not support Web service callouts" Error while manipulating with string, Without any callouts

I have Test Class where I don't do any callouts, or requests or something else. I think The problem in Email field Which has record like "{id}@plaseholder.com". When I try to manipulate with ...
user avatar
0 votes
1 answer
18 views

How to convert JSON String of RESTRequest to Map

I'm new to Integration in salesforce. I'm using RestRequest and getting requestBody something like below: {"event_source":"","media_source":"restricted"} I ...
user avatar
-2 votes
0 answers
26 views

Create a action-button based automation to auto convert leads to Account, Contact, Opportunity - For New Leads [closed]

Create a action-button based automation to auto convert leads to Account, Contact, Opportunity - For New Leads If Account, Contact is new - then create Account, Contact, Opportunity If Account is ...
user avatar
-4 votes
1 answer
23 views

What do we mean when we write the below code? [closed]

for(AggregateResult a: results){ //getting the AccountId and sum(Amount) in separate variables and putting it to map Id accountId = (Id)a.get('AccountId'); double TotalAmount = (double)a.get('...
user avatar
-3 votes
0 answers
11 views

Comparing records in excel with database ,if new record is found in excel it should be inserted or if record matches it should return record's id [closed]

The code should be to scan an excel with First Name and Last Name. The name matching should give a scoring %. If scoring matches above 75%, then provide Case Safe ID on excel If it scores below, then ...
user avatar
0 votes
0 answers
18 views

how to get the appExchange package namespace and version details from listing url

I am working on package automation, to install/upgrade and uninstall the package through APIs. I am achieving this with a combination of metadata API classes and Tooling SOQL queries. i have a couple ...
user avatar
0 votes
1 answer
22 views

Platform event Fired from two objects

We are planning to build a platform event, which should publish changes from two objects. Consider there is an insert/update of records in Account object or Customer__c object. We need to insert/...
user avatar
-1 votes
1 answer
37 views

Is there anyway to check what the triggering class is?

Is there a way to grab say sometrigger.class or sometest.test as the triggering class within apex? From what I can understand the request is that our helper class would tailor its response based on ...
user avatar
0 votes
0 answers
15 views

Displaying record type value of selected Lookup record as a message on VF Page

I am trying to display the record type value of the selected lookup account as a message under the lookup field on a pageBlocksection in VF page. I tried using outputField and actionSupport to ...
user avatar
  • 101
0 votes
1 answer
32 views

setBody on HTTPCallout not working apex to stripe

I used some similar code I had done successfully in a trailhead here public class HttpCallout { @AuraEnabled public static String makePostCallout() { System.debug('----apex ...
user avatar
  • 439
0 votes
1 answer
19 views

How to add ALL ROWS in fflib selector class

I need to get delete records in SOQL query so i have used ALL ROWS in the end of the SOQL in SOQL its working fine but I need to add in fflib selector class Im getting error public List<...
user avatar
-1 votes
0 answers
28 views

Count items in JSON Object Map

I'm struggling with trying to count items within an Object Map. How could I count the number of "objectEntries" of the following JSON using Apex? This is the result of an IQL query from JIRA ...
user avatar
  • 21
-2 votes
0 answers
25 views

Is there a way to monitor clicks on a lwc from Event Logs except ApexExecution event type?

Can we track clicks made on a lightning web component from the Event Logs? I don't want to do an apex call to monitor the click.
user avatar
-2 votes
1 answer
22 views

can we close a case in before trigger? Case status still show Open

trigger caseClose on Case (before insert) { list<case> cases= new list<case>(); Id caseRecordtypeId = SObjectType.Case.getRecordTypeInfosByDeveloperName().get('abc')....
user avatar
  • 39

1
2 3 4 5
682