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
0answers
3 views

Create a Custom Object From an Inbound Email

I've got some code and I've gotten some help fixing some errors in it yesterday. it worked but only on the first email and would only create one Parent Opp per email address. I reworked it with some ...
0
votes
1answer
487 views

How can i pass two parameters in visualforce page url?

I would like to concatenate the "lang" parameter and I would also like to bring the "id" parameter behind whenever I switch the language. Below is my current code: //Language public PageReference ...
3
votes
3answers
2k views

How can we change the label of tab name in managed package

Is there any way that we can rename or change the tab name in the managed package. Or we can change the name in packaging org so that old customers can be upgraded and new customers should be able to ...
0
votes
0answers
12 views

Batch Generated CSV attachement is cut

I designed a Stateful batch to some data and send it as CSV via email. And I don't know why but the attachement received in the email doesn't contains all the expected data, the CSV file il cut in the ...
1
vote
2answers
672 views

Code Coverage for Custom Object HISTORY

I have method in controller class to get the history of the fields to show it in a detail page. But history details are not able to cover in test class. I have enabled Field history Tracking in object....
1
vote
0answers
27 views

Deserialize nested JSON to SObject and get keySet

I have two different requests as below that will hit same end point. I need to identify the request body based on the nested attributes. Now if the key attribute contacts must be same for both ...
9
votes
3answers
5k views

Console.log truncates my debug `…}`

I'm using developer console log to see all my debug logs but it cuts off my log after 1920 characters How do I fix that? and even I have tried download the log and open in a notepad++ but still I ...
0
votes
2answers
355 views

Convert string time to datetime with timezone

I have a requirement where I want to convert a String time "15:00" (pstTime String) in PST timezone to a string time "08:00"(gmtTime String) in GMT. The date is immaterial. The way I'm trying to ...
-2
votes
0answers
26 views

Can someone please post an example code to update assignment rules using Metadata API? [closed]

I want to update the Case's standard assignment rules using metadta API but can't find any success in it. Here is the steps I am following: 1. Using Read metadata API call on "assignmentRules", I am ...
0
votes
1answer
29 views

Parse HTML request in salesforce apex

I have a requirement to parse HTML form code in salesforce apex.At apex I need to fetch the fieldnames and respective values from the HTML form.Would be great if anyone could through an sample code on ...
0
votes
2answers
17 views

i need to use a visualforce component in an html body in my trigger which sends a mail

I have a trigger which sends a mail on update of the approval status . I am using a HTML part in that trigger to send the mail . In place of x I want to call my visualforce component which is ...
-1
votes
0answers
17 views

Hi…! need to generate the salesforce simple json…i had embeded a page in the other page.. and trying to generate the json

note: if the buton kept inside the page1 it was wrking , if iam using it in the other page it json was not getting update..can anyone find the solution for it.. Thanks Vfpage1 one: <apex:page ...
0
votes
1answer
18 views

reason: Apex CPU time limit exceeded (refine the codes)

Im struggling to fix this CPU time problem, I have tried to refine my code as good as possible by implementing maps and as can be seen below; public class dailyUpdates2{ /// used for converting ...
0
votes
0answers
19 views

AWS Signature version 4 using Named Credentials callouts - how to add request parameters

Name- aws_WScallout url - https://servicename.amazonaws.com Identity Type - Named Principal Authentication Protocol - AWS Signature Version 4 AWS Access Key ID - ****** AWS Secret Access Key - ********...
0
votes
0answers
11 views

Search Criteria is getting Lost [closed]

In our project we have a criteria based search.When I click on an object name and then use the back arrow to return to Home Search button, it clears out my search results and makes me enter my ...
0
votes
0answers
22 views

email template to be used in apex . Email template used approval.id

I am trying to send emails through email template in my apex class . This is the code I am trying Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(...
0
votes
1answer
499 views

How to add Field/button in Salesforce in Create/Edit view to add a set of fields many times?

I have a module named as Portfolio Allocation, in this module, I want to have a (field and a button) pair by using which I can add a particular set of fields again and again. Sample template for the ...
6
votes
1answer
66 views

Does the same caching algorithm apply to storable actions and @AuraEnabled(caching=true)

In Aura components we used to call action.setStorable() on the client side. For LWC (and optionally Aura) we now cache query results by setting @AuraEnabled(cacheable=true) on the server side. Is the ...
0
votes
1answer
17 views

Trigger on ContentDocument/ContentVersion Firing before “After Insert”

So I've seen related questions to this about triggers not firing on ContentDocument, however my trigger is firing - just before the record is saved. I am trying to make an After Insert Trigger on ...
0
votes
2answers
396 views

How to update custom(another) field value if field default value is changed

The requirement is On the std layout of opportunity,there is a field probability which has some default value based on the stage that you use. When I modify the default value of probability,I have to ...
2
votes
1answer
18 views

First exception on row 3; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded

Am getting following error message 06:15:51:437 FATAL_ERROR System.EmailException: SendEmail failed. First exception on row 3; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: []. ...
4
votes
2answers
117 views

Disjoint Collection Method in Apex?

Does the disjoint method (mentioned in the Java documentation here exist in Apex? To summarize the method takes two Lists/Sets and compares them to see if either contains an element in the other and ...
3
votes
1answer
65 views

Package BatchApexErrorEvent trigger

I'm writing a managed package which uses a batch and i would like to provide errors tracking on this batch. I use a trigger on BatchApexErrorEvent but it doesn't appears in the package creator. ...
3
votes
3answers
4k views

How to retrieve ALL metadata in vscode

I'd rather not have to type out all the metadata types in the package.xml but i'm not seeing any other way to do it?
0
votes
1answer
37 views

Pulling values from inner curly brackets

I am trying to pull the values from a JSON response and have managed to get most of the values except the one I need which is nested in an inner set of curly brackets public class web_ser { @future(...
0
votes
0answers
15 views

SLDS Modal in Repeat Tag

Im trying to get this Modal working in Apex:Repeat tag. When I add Modal in Apex:Repeat, it doesnt work. When I keep it outside the tag, it works fine but then I cannot access s3list. Im not sure ...
1
vote
3answers
30 views

What is causing the “Invalid Character in Identifier” error when compiling my Apex code

I've got the Following code: Global class EmailToLeadTST implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, ...
0
votes
1answer
24 views

Find Report Type Id using Metadata API

I’ve been trying to find out if it is possible to get the id of a report type and everything I’ve found so far points to this doc: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/...
0
votes
2answers
46 views

Before Insert Trigger SOQL Limits

I am building a before insert trigger on hed__Program_Enrollment__c. What I am trying to do is delete everything in the hed__Program_Enrollment__c table based on a certain condition and this seems to ...
0
votes
2answers
24 views

Methods defined as TestMethod do not support Web service callouts on working test class [closed]

I'm experiencing a wierd thing, I'm made a deployment on a refactoring of code on cases this monday (2019.12.02) and my test classes use the Test.setMock method. It worked so I started doing the same ...
-2
votes
1answer
31 views

Serialize string to json format in apex [closed]

I am trying to serialize a string into JSON content Below is the string used: String Address_List ='[{addressLine1:Firstaddr1,addressLine2:Firstaddr2,addressline3:Firstaddr3},{addressLine1:...
0
votes
3answers
79 views

Clean code way to process a list of objects

Let’s say you have a list of Accounts and you want to populate their birthday with the same date. However, you also want this method to be reusable. What is the best way to do this in APEX? So far ...
0
votes
0answers
33 views

Apex Trigger Error

Here is my Apex Class: public class NavProductHelperClass { public void checkProductAvailability(list<OpportunityLineItem> opids) { for(OpportunityLineItem oli: opids) { ...
-2
votes
0answers
23 views

Parse JSON response using deserialize object [duplicate]

I'm attempting to parse a JSON response using the deserialize method. Here is a sample of the JSON response: {"result":[{"u_mp_other":"","parent":"","u_cf_user":{"link":"https://mydomain.service-now....
2
votes
0answers
14 views

Surprising compilation error: “A non foreign key field cannot be referenced in a path expression: ChangeEventHeader”

Why is it that this will not compile: trigger AccountChangeTrigger on AccountChangeEvent (after insert) { String dmlType = Trigger.new[0].ChangeEventHeader.changetype; ... A non foreign ...
-5
votes
0answers
34 views

Salesforce admin and developer [closed]

This is not interview or exam question. We have an issues where while creation of account, if no gender is speicified , it defaults to U. So just want to know if there is anything wrong in the below ...
1
vote
1answer
34 views

Debugging Apex Triggers

I am attempting the Apex Superbadge trigger and have bugs in my code. In the past, I have only written Apex controllers attached to a LWC. So, when I open a page/use the LWC, I can then see my debug ...
1
vote
1answer
25 views

Default account team in apex code

I was wondering how one would create a default account team in apex code. I'm trying to create a test class where it is being used but I cannot figure out how to add a default team.
0
votes
1answer
620 views

Showing Infinite scrolling in DataTable

I want to show the lightning datatable in modal and when user will scroll it will show more records after the spinner. I don't want to call server side controller every time so i tried to implement ...
0
votes
2answers
2k views

How do I send report results to non Salesforce users by email?

I am trying to automate a report by scheduling the report to run at a date/time and emailing the results to mail group. How do I send report results to mail group? Apparently via the standard ...
0
votes
0answers
10 views

FullCalendar.io timezone issues while rendering events

We're trying to render salesforce events in fullcalendar using jquery. We're facing some issues with timezone when rendering events in dayview/monthview/weekview. I'm rendering full calendar using ...
-1
votes
1answer
13 views

Display Profile Photo of Partner Users in a VF page [closed]

I have a requirement to display FullphotoURL of Partner Users in a VF page which are of 700 (Pagination can be applied to display in multiple pages). It should be displayed with the name of the User ...
3
votes
2answers
3k views

How to use locale settings for decimal separator

How can i use Locale setting to know decimal separator? I read on net that - The Salesforce locale settings determine the following display formats: * Date and time * Users’ names * Addresses * ...
0
votes
1answer
371 views

Mass transfer approval process

In our case, usually the users request us the approvals pending of a particular user. We go to Setup -> Administration Setup -> Data Management -> Mass Transfer Approval Processes and we manage ...
2
votes
2answers
54 views

Datetime.parse() start to fail in Apex Controller

An apex controller invoked by vf page in Salesforce orgs (both sandbox and prod) start to fail recently. No code update was made for years on this apex file. The failing line is like Datetime.parse('...
0
votes
0answers
23 views

Batch Apex - Try to create order while loading data

I have a batch apex that runs thru some attachments of a custom "Job" object that I made. There are 5 CSV files attached to this Job object, which I parse & create Salesforce records from. Now ...
0
votes
1answer
20 views

only root queries support aggregate expressions

I was working on one trigger and using sum in query but I am getting the following error when I tried to save record. only root queries support aggregate expressions Can anyone helps me out in this ...
1
vote
0answers
11 views

Barcode scanning through Salesforce mobile - 2019

I looked at previous questions and it seems that this blog post from Bob Buzzard from 2014 shows that it's possible to scan barcodes through a VF page. I want to know if this is possible with recent ...
0
votes
1answer
12 views

Passing List<sObject/Wrapper> vs JSON.serialize(List<sObject/Wrapper>) when using action:Function

To avoid view state, I know the best practices would be to mark variables transient where ever possible or to use javascript remoting, which does not transfer view state info with it. But lets say I ...
1
vote
3answers
391 views

Opportunity Trigger After Update doesn't work

So here is the scenario, I want to have an error message when user click Save after he changes Opportunity Stage from 10% Probability to 20% probability. I am using Related list Object Contact Role so ...