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
11
votes
3answers
9k views

How prevent page rerendered on <apex:actionFunction>?

I'm using <apex:actionFunction> and my page is reloaded. I don't use reRender attribute and I'm wondering if there is a way to prevent page reloading. Maybe there is a special value to set to ...
0
votes
0answers
19 views

How to write a test class for this Batch covering all scenarios [duplicate]

I am writing a test class for following batch, but code coverage is not increasing more than 28%. Can anyone please help with the test class for this batch. global class CaseOwnerManagerUpdate ...
1
vote
2answers
31 views

Count number of times an opp has been moved to different quarters

I want to be able to count the number of times an opportunity has been moved to different quarters. So, every time the Close Date is edited and moved to a different quarter, I want an existing number ...
0
votes
2answers
863 views

Validation Rule or Apex trigger To Allow Only One Checked Record based on the master record ID

We have two objects Assets and Employees with a Master-Detail Relationship (Where Asset is the Master and Employee is the Detail sObject). For Every asset that we have, at a given time only one ...
0
votes
1answer
60 views

Set Text Field as a URL link in a custom object using Apex Trigger

I am looking to add a URL into a text field in a similar fashion to the way you can add a HYPERLINK in a Formula (Text) field. I have already taken a look at the information in How to give a URL field ...
1
vote
1answer
211 views

CPQ: Generate Quote Documents for more than 25 Quotes

I'm trying to generate Quote Documents for several Quotes simultaneously. We're using a schedule but calling the API and running up against a limit: we can only call the API to create Quote Documents ...
0
votes
1answer
47 views

INVALID_CROSS_REFERENCE_KEY, You can only assign users to permission set groups that have the “Updated” status

I'm struggling to assign a mocked permission set group in a test class. The test class fails because of the following error: INVALID_CROSS_REFERENCE_KEY, You can only assign users to permission set ...
1
vote
1answer
19 views

How to write the Test class for a Schedulable class which uses a custom label ( converted to date in the apex class)

This is my code ( apex class) below global class deleteclass implements Schedulable{ global void execute(SchedulableContext SC) { Datetime dt = DateTime.valueOf(System.Label.OldRecords); ...
0
votes
2answers
780 views

Providing date in custom label and use it in my apex class

I have a requirement where I have written batch class to delete old records(Have to house keep old records for many objects as we don't use them). Just to test it I have created it in my Dev org for ...
1
vote
0answers
16 views

Retrieve source in manifest from Org

I'm trying to retrieve classes from my test org using package.xml. Recently the operation fails immediately with the following error; 10:35:14.995 Starting SFDX: Retrieve Source from Org Socket is ...
0
votes
2answers
10k views

How to fetch Custom Metadata Type record in apex and compare it with a string

I have a string which is holding email ids of users from my org. Now I have few custom metadata type records which are holding email IDs of users who are inactive. Now I need to compare the string ...
0
votes
0answers
14 views

ContentPublication Limit exceeded in Test Class?

Is the content publication limit applicable to test class as well? All i am doing on my test class is to create a contentversion record. It still says that ContentPublication Limit exceeded. Does ...
0
votes
0answers
18 views

Is it possible to change color of this highlite?

Hi guys I need to change color of this highlight https://i.stack.imgur.com/eqhDs.png is it possible to do this. I read about overriding apex page but I hope that i can do this easier. Best regards
0
votes
1answer
28 views

Lightning Tabset and Tab is same as lightning__tab

Asking if why the tabset and tab are not the same with the default tab component on the lightning app builder. When I tried to create an aura component, and viewed in Salesforce Mobile App, then the ...
2
votes
1answer
656 views

“Access to entity 'MatchingInformation' denied” on batch

I have a batch that's been running for years that started failing because of First error: Access to entity 'MatchingInformation' denied. I've searched around and can't find anything about this and I ...
0
votes
1answer
19 views

Experience Builder: Custom Self Register Component

When a guest user tries to register for the community with an existing email address, he gets following error. Your request cannot be processed at this time. The site administrator has been alerted. ...
0
votes
0answers
57 views

rest api integration error - invalid signature

I need some help here with REST API Signature Generation. Signature generation doc is at: https://developers.woohoo.in/docs/get-started-title/oauth-2-0-protocol-recommended/oauth2-0-signature-...
3
votes
2answers
554 views

Why the Service layer is usually implemented with Static methods?

After reading some books about the Service Layer I realized all the methods implemented in this layer are static. What's the reason to do that? https://trailhead.salesforce.com/content/learn/modules/...
0
votes
1answer
31 views

Implement pagination on APEX REST Endpoint without using OFFSET or LastRecordID

I want to be able to get a set of records independent of previous calls. So without a LastRecordID. OFFSET also doesn't do the trick as it has a limit of 2000. For example: Query contains 10000 ...
6
votes
1answer
2k views

Implement pagination on APEX REST Endpoints

I am working on a Apex REST framework that acts as an abstraction layer to make it easier for all our other systems to consume data from salesforce (i.e. consistent naming scheme for field names, ...
0
votes
2answers
903 views

UNKNOWN_EXCEPTION, List has no rows

I have the following error when trying to send an email. System.EmailException: SendEmail failed. First exception on row 0; first >error: UNKNOWN_EXCEPTION, List has no rows for assignment to ...
-1
votes
0answers
25 views

Increase the coverage rate for the test class AttachmentBO 73% of cover

I managed to get up to 73% but the lines that are in red below can't cover the code at all. I would like ideas or modifications to make this code acceptable to production. Can you help me? public ...
2
votes
2answers
729 views

Named Credential with JWT Token Exchange for authorizing calls to Google Cloud

I can make requests with Bearer from Auth.JWT: Auth.JWT jwt = new Auth.JWT(); jwt.setSub('service-portal-rlj@appspot.gserviceaccount.com'); jwt.setAud('https://accounts.google.com/o/oauth2/token'); ...
-2
votes
1answer
13k views

How to convert List to a Map?

I have a List<custom_object__c>. I want to convert to a Map, where the ID is the String and the value to be an custom_object__c object. Map<String, WrapperEmployee> mapEmp = new Map<...
1
vote
1answer
6k views

How do I pass a record to an Invocable Method from process builder?

I understand from this article that it is possible, my question is what do I choose in the process builder in order to pass a case and not some case's parameter? I don't want to pass the casenumber or ...
0
votes
1answer
18 views

Salesforce Process Builder Apex Error: Too Many Future Calls

I've created an SalesForce Process that automates the creation of Asana projects for my org. This works well in small-scale, however when many data updates happen at once, we receive an error; Error ...
1
vote
2answers
69 views

Where to place database activities on a SoC architecture

Considering a SoC architecture where the following classes exist: InvoicesService - Service Layer- Invoices -Domain Layer- Let's say, in a new InvoicesService method I need to insert Contact records....
0
votes
0answers
20 views

error: Illegal assignment from Object to Map<String,String> [duplicate]

String input = '{"orgId":{"isRequired":"true", "valiateDataType": "Id"},"numOfVehicles":{"isRequired": "true"}}'; Map<...
2
votes
1answer
598 views

Zoom / Scale down the entire visualforce page when rendered as pdf

I'm trying to scale down the entire pdf generated from VF page using rederAs="pdf". Using transform: scale(0.9) works only when page is not rendered as PDF, when rendered as PDF this attribute seems ...
0
votes
0answers
14 views

How to provide admin access on Report folders in Salesforce?

Hope all are doing good! How to provide admin access to one user for one report folder in salesforce. Thanks In Advance, Chan Basha
-1
votes
1answer
30 views

Help with invocable apex method for process builder

Create apex class that can be lunched from Process Builder (for Account). Apex class should make next logic: When new Account is created, create new Task object with Subject “Negotiations with {...
-2
votes
0answers
19 views

How to parse/Iterate json [duplicate]

I have a string that has to be converted to JSON. And i need to iterate through every key (for ex: "orgId" and access values of isRequired/validateDataType inside OrgId). How do i iterate ...
0
votes
1answer
2k views

Is there any way to rollback the insert/update DML operations while processing a number of records with bulk upload in salesforce apex

I have a list of contacts which get inserted/Updated in salesforce database. After this those contacts assosiated with new case/existing case. If case fails to update or insert then rollback the ...
1
vote
2answers
100 views

Unable to escape the governor limits (Too Many SOQL Queries: 201)

My governor limits are getting exceeded because i need to use count() for each individual fieldName and check fieldName != null, and return it's individual value But there are over 300 fields, how to ...
0
votes
1answer
80 views

Join multiple JSON strings in Apex

I have a requirement to display Accounts-->child Accounts-->Tasks-->Child Tasks in the JSON. Here is my Apex code: List<Account> accountRecordsList = new list<Account>(); List<...
0
votes
0answers
37 views

LWC Button with parameterized Apex method

I want an LWC Button component where the user putting it on a Flexipage can define which Apex method to call? By putting the name of a Callable class into a parameter field? Is that possible in LWC?
3
votes
2answers
402 views

SOQL query for all Users who have read access to Task object

I am trying to write a SOQL query to find a list of Users who have read access to the standard Task object but my query keeps coming back empty. Is there a better way to do this? I have a dropdown ...
-1
votes
0answers
17 views

Identify initiator for trigger [closed]

Scenario: We have a button to update the stage for a custom record. When it is updated, there is a trigger on after update. Requirement: We need to identify if the trigger has been instantiated due to ...
-1
votes
1answer
15 views

When we click on edit address, It is showing subfields under that address field. How to achieve this?

When we click on edit address, It is showing subfields under that address field. How to achieve this?
2
votes
2answers
635 views

Assign JSON Values to Fields in Test

Markup <apex:page controller="skillproficiencycontroller" id="p"> <apex:form id="f"> <script> var state = {}; function passState() { document.getElementById("...
0
votes
1answer
1k views

How do I use a standard controller and custom controller together?

What I want is to use Opportunity in standard controller so i can use its detail page and then use a custom controller to insert a button on top of the page to export the details to excel. I was ...
0
votes
0answers
19 views

Does sharing recalculation happens for whole org when inserting doing Apex Dynamic Sharing?

We have apex managed sharing in our project. No manual sharing, or sharing rules are there. Consider the below scenario. User Creates a group and shares Contact A to that group. User filters users to ...
0
votes
1answer
659 views

Sandbox Login not working

We can't login to our eloqua sandbox. I get this error... We can't log you in because you're only allowed to use single sign-on. For help, contact your Salesforce administrator. SSO setting not ...
-4
votes
0answers
25 views

Unit testing for value that need to return image value in a custom object [duplicate]

i want to test that if checkbox is checks, Attachment__c needs to contain image if else will get an error. Attachment__c is a rich text area. My test class: @isTest public class TestPraTrigger { ...
2
votes
1answer
779 views

no preview for ContentVersion when inserting from Apex

I'm using the following code to generate ContentVersion. String title = 'sample file.txt'; ContentVersion contentVersion = new ContentVersion( VersionData = Blob.valueOf(...
1
vote
2answers
48 views

New LWC Actions in Salesforce

Looks like in the current release Salesforce has made LWC Quick action "Generally available" but the tag that we use in LWC quick actions which is lightning-quick-action-panel is still in ...
1
vote
1answer
748 views

Lighting datatable Custom Inline Edit

I have a custom LWC Page which is used as Public site. In my Page I have form which will populate the data in Contact object and display the value in Data table. I have integrated inline edit in my ...
0
votes
1answer
838 views

Send Bulk SMS by calling Twilio API using http callout

I'm using Twilio to send SMS through salesforce. I'm able to send the sms by calling http callout to Twilio API. but, Now I've send bulk sms, when I inserting bulk record in salesforce. I'm ...
0
votes
1answer
835 views

SSL certificate

One of our partners (to whom we plan to send our SF data) has asked whether we have a SSL certificate. I have looked at our configuration and all I can see is "Self Signed Certificate" which already ...
0
votes
1answer
935 views

Update existing AccountContactRelation in before insert trigger

I have a custom field on my AccountContactRelation object, called SurrogateId__c, that has to be unique across all AccountContactRelation. I have the following code that is called upon before insert ...

1
2 3 4 5
650