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
0 votes
1 answer
6 views

How do field types convert from json and SF object

I am working on a lwc. I am passing a array of json objects into a apex method. The parameter for the apex method is a List<Work_Items> where work items is a SF object. At run time apex converts ...
  • 1
0 votes
0 answers
9 views

Concurrent API Warnings

I wanted to ask a question about the Concurrent API limit. Our middleware team is getting warnings a couple of times a week that w are using 60 to 70 percent of the limit. Duplicate requests seem to ...
0 votes
0 answers
7 views

Field with @InvocableVariable(required=false) does not is ignored by einstein bot

I have an apex class like this: 01 public class Example { 02 03 public class HandleInput { 04 @InvocableVariable(required=true) 05 public String id; 06 } ...
1 vote
1 answer
25 views

How to query Contact details to display on visualforce page

Hello I am fairly new to Apex and still learning a lot. I have got stuck with an issue that I cannot figure out how to resolve, I have looked at several articles and answers to similar questions but I ...
1 vote
1 answer
22 views

How to use Test.setCreatedDate method with a list

I'm getting this error: Method does not exist or incorrect signature: void setCreatedDate(List<Object__c>, Datetime) With this (excerpt of) test class below List<Object__c> testRecords = ...
  • 13
-1 votes
0 answers
28 views

Loop variable must be a generic SObject or List or a concrete SObject or List of: Lead

for(lead le: [select id,name from lead ]){ System.debug('Lead Name: '+le); // nameSet.add(le.Name); // phoneSet.add(le.Phone); // emailSet.add(le.Email);...
0 votes
2 answers
33 views

Test Class for SOQL(CollaborationGroupFeed Object)

I'm new Apex coding, Could anybody help me fill out the test class? I guess it is a simple soql query statement, and I wrote a test class, but I keep getting errors and I don't know why. I got two ...
0 votes
1 answer
27 views

APEX Multiple From in Database.getQueryLocator

I have a class (inherited) that sets the StandardSetController through a Database.getQueryLocator as follows: ApexPages.StandardSetController setCon = new ApexPages.StandardSetController(Database....
0 votes
0 answers
23 views

Test Class Showing in Code Coverage Window as Available for Coverage

a strange situation I can't find an example of elsewhere. I have a test class for a batchable apex that is showing in the developer console window as available for code coverage. Haven't seen a test ...
  • 9
0 votes
0 answers
19 views

How to get the list of fields that are available to ADD into the Field set?

I have a requirement where I want to show the list of Fields that are available to be added into the Fieldset. But I am not getting on how to retrieve the Fields that can be added into fieldset. I am ...
1 vote
1 answer
114 views

Special Characters breaking Apex Loop

I have code that is being uploaded as a CSV that is breaking if special characters are present i.e: comma , Apostrophe ' à I have built docs that has them remove these but the one I am not sure how ...
0 votes
0 answers
27 views

I locked the quote in apex, but I can still do an update on it

The update here completes without issue. That's not what I was expecting after locking the record. Please advise. public static Map<String, String> undoNotAwarded(String[] quoteIdsArray){ ...
0 votes
0 answers
14 views

Permission set with 'edit' access on custom object used in a CongaGrid not granting assigned users 'edit' access... odd bug?

I have come across extremely odd behavior: if a user was assigned a permission set directly, then that user could read/edit fields of a custom object. However, if the user was assigned the permission ...
0 votes
1 answer
35 views

Apex Trigger and Test to Not Insert Duplicate Records

I have a requirement where we will be using dataloader to upsert a number of records, and do not want to import records with matching Case_Id__c. I will be handling the update through flows since I am ...
0 votes
0 answers
24 views

PlatformAction ActionTarget does not return URL for Lightning Experience

I am creating a related list type Lightning Web Component that should dynamically pull the related list quick actions for the record the component is on. I've been attempting to use the PlatformAction ...
2 votes
1 answer
44 views

Is it possible to call a LWC from Apex?

I need to create a PDF document completely customizable and I decided to use an external JS PDF generation lib (PDF-lib) to create the documents from a LWC instead of using the Visualforce PDF method. ...
-2 votes
2 answers
48 views

return count of record collection

I am fairly new to apex and SOQL. I am trying to get a record count of a new collection list to display in VF. any hints? Public with sharing class TestDisplayQueryList2 { public List<...
-1 votes
0 answers
27 views

How to create Mock Callout Class if I am getting response as a single string and not as a JSON

HttpResponse response = new HttpResponse(); response.setStatus('OK'); response.setStatusCode(200); response.setBody('"Sample Response"'); return response; When I am using ...
-2 votes
0 answers
24 views

How to read and insert csv file data of Contact object based on AccountId from an excel sheet using lwc

I have an excel sheet which has columns FirstName, LastName, Email, Phone and Account Id records. I need to insert those records from excel sheet but based on AccountId
-1 votes
0 answers
31 views

Inserting and Deleting Large Numbers of Records get Error: No more than one executeBatch can be called from within a test method

I have a class in which I need to test if a large number of records is deleted. But first I have to insert the large number of records. I wrote batch Apex to insert and delete. However when I try the ...
0 votes
0 answers
30 views

Is there a way to know application name based on "Application Id" which is available in url in salesforce

I implemented application rating screen using "Login flows" option. Now I have a requirement, based on the application name, need to display the rating question in the rating screen. Once ...
  • 1
0 votes
1 answer
19 views

Apex to get the name of the org edition?

Would like to detect which Salesforce Edition my Apex classes are running. I've been pouring over the documentation but so far haven't found the right class and method to retrieve this as a string. ...
0 votes
1 answer
13 views

Help with Testing Database.Batchable

I have a class with the following: global with sharing class MS_Batch_Delete implements Database.Batchable<sObject>{ global final List<MS__c> mss; global MS_Batch_Delete( ...
0 votes
1 answer
24 views

How to Force an Apex Sharing Recalculation DML Exception?

I have implemented the following Sharing Recalculation class from the Documentation try { // Delete the existing sharing records. // This allows new sharing records to be ...
  • 5
0 votes
0 answers
12 views

Code inside apex method not running intermittently on button click Aura component

I'm having a parent and child Aura component. There is a button on the parent component that invokes a js action and it further calls a aura enabled apex method. The issue is it is calling the apex ...
0 votes
0 answers
12 views

actionFunction - controller method doesn't run even though oncomplete does

I am trying to get a controller method to run using an onclick actionFunction, but the method does not appear to execute, even though the oncomplete does. Here is the code: Controller: public with ...
  • 143
0 votes
0 answers
25 views

convert soap.Address to APEX-Address

Que-1) At Java Layer, we have common.api.soap.wsdl.Address Data type. Which DataType should we use in APEX Layer that maps from common.api.soap.wsdl.Address A) Schema.Address B) System.Address C) ...
1 vote
1 answer
37 views

What does this do? Throw new MS_Exception

I have (inherited) a class MS_exception that is this: public with sharing class MS_Exception extends Exception { } It has zero code coverage. Does it actually do anything? Do I need to cover it? The ...
1 vote
1 answer
36 views

creating a close case button that updates status using lwc instead of visualforce

I am trying to add a button to a portal page in Salesforce. Everything on the portal is straight out of the box containing information for a specific users case. I just want to add a button on the ...
  • 141
2 votes
2 answers
19 views

Ramifications of deleting (not uninstalling) a first-generation Managed Package

Got a first-generation managed package distributed to a small number of Orgs (<10). In the early design, several classes were setup with the global instead of public attribute thinking we might ...
0 votes
1 answer
21 views

Unable to pass checkmarx security review

When I use 'Without Sharing' Keyword with class in a managed package and install it in a destination org or sandbox, the code works fine but get error in the checkmarx report. If I replace 'without' ...
  • 3
0 votes
0 answers
16 views

Invalid id: An unexpected error occurred. Your solution provider has been notified. (vlocity_cmt) \ OmniStudio \ Integration Procedure \ Dataraptor

Yesterday I was creating quotes using omniscripts, but today, it suddenly it's not working anymore. and nothing was changed. The message error is: "Invalid id: An unexpected error occurred. Your ...
-1 votes
0 answers
21 views

How to assign cases to caseteam?

I want to assign cases to CaseTeam .I know how to assign cases to caseTeamMember ,but is there anyway to assign to it directly CaseTeam using Apex?
1 vote
1 answer
42 views

Apex Trigger that whenever account owner gets changed, send an email to previous account owner

Hello Everyone I wanted to write trigger that whenever account owner gets changed, send an email to previous account owner. and I wrote this trigger but working. trigger SendEmail on Account (after ...
0 votes
0 answers
23 views

Custom code not implementing functionality

I am writing a trigger on Account when Account Active field is updated from ‘Yes’ to ‘No’ then check all opportunities associated with the account. Update all Opportunities Stage to close lost if ...
1 vote
1 answer
43 views

Use Invocable Apex Class with LWC

I have an Invocable Apex Method which I am using in a Flow and I want to call from my LWC. I have created a separate AuraEnabled Method to call the Invocable method. public with sharing class ...
0 votes
1 answer
33 views

Apex Test insert is not setting a field on the record

In my Test class, a custom field is not set when inserted: The field Product_Family__c on OpportunityLineItem, while inserted, is missing when queried. @isTest public class tempTest { @isTest ...
-1 votes
0 answers
30 views

Callout error when running new API from salesforce APEX

I am facing an issue when trying to make a POST API call using an URL. This is a new API call that is being made from Salesforce to other system. The API works good in POSTMAN wherein we give content-...
1 vote
1 answer
37 views

Get Endpoint/URL of new named credentials

We have developed an app and we are using named credentials (now legacy) to access an external API. Based on the those we also get the URL and build slightly changed iframe srces within the APP. At ...
0 votes
0 answers
28 views

Issue with PDF file using getContentAsPDF

I am creating attachment with paypal invoice using getContent method in apex and attaching file under record but there issue with pdf file. it's not creating properly Here is my code : String ...
1 vote
1 answer
48 views

Too many DML statements 151 inside while loop

I am receiving this error on Update DML inside while loop I have marked the error line in code Code public class LeadFuture_TradingAccUpdate { @future(callout=true) public static void ...
1 vote
1 answer
24 views

How to assign field name dynamically to list of sobject to check and assign value?

I have a metadata stored in a map as Map<String, Contract_Aggregate_Fields__mdt> mapCMD = Contract_Aggregate_Fields__mdt.getAll(); map<string,string> mapofFields = new map<string,...
1 vote
2 answers
97 views

Why can't we use non-primitive data types in future methods?

Why can we use non-primitive data types in Queueable and not in Future methods when both are async processes? The reason that salesforce has documented is - 'The reason why sObjects can’t be passed as ...
1 vote
1 answer
64 views

error status:400,body:{message:The related lists UI API currently does not support this related list while using uiRelatedListApi

i am trying to display a related list in an LWC that was deployed in an AppPage This is the code : editMaterielAlivrer.js import { LightningElement, wire } from 'lwc'; import { getRelatedListRecords } ...
1 vote
0 answers
34 views

Using Apex to determine Connected App

I want to share an Apex class with two Connected Apps that will be housed in different Managed Packages: ProdApp and TestApp. Is there a way to programmatically determine which of the two Connected ...
0 votes
1 answer
28 views

Why Test.setMock() is not working in case of static resource?

Test.setMock() is not working Error: Method does not exist or incorrect signature: void setMock(System.Type, System.StaticResourceCalloutMock) from the type test Source Code: @isTest private class ...
0 votes
1 answer
55 views

Is List.isEmpty() necessary before a DML? [duplicate]

After working on many different code bases in Salesforce, I noticed that almost all developers check if a list is empty before doing a DML in order to avoid the unnecessary DML statement. Here's an ...
1 vote
1 answer
38 views

Change the apex:commandButton value from 'Return to Uploader' to 'Done' from Javascript (Jquery)

I have a requirement to change the value of apex:commandButton from 'return to uploader' to 'Done' using Javascript(Jquery). Below is my VF Page code: <apex:commandButton style="float: right;&...
0 votes
0 answers
28 views

Error on activating a Journey on MarketCloud - Salesforce Data Entry

We're trying to activate a journey on marketingcloud with an entry event from salesforce, however, we get the following error: FLOW_EXCEPTION;...
0 votes
1 answer
24 views

APEX Testing ErrorLoggingSystem__c.getInstance()

I have code that I need to cover: private static void log(String developerMessage, String exceptionMessage, String stackTrace, String exceptionType) { ErrorLoggingSettings__c els = ...

1
2 3 4 5
710