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
1answer
15 views

How to pass set<id> dynamically to soql

I have a dynamic Soql in which I want to pass a set. I get an error: System.QueryException: expecting a colon, found '{' Anonymous window Set<Id> idSet = new Set<Id> (); idSet.add('...
0
votes
0answers
7 views

update phone number field on Account obj off of phone number from Lead obj

I'm writing a Queueable Apex, that will run and compare search the Lead last name to the Account name if Lead lastname == Account name && Account phone field is null || blank then update the ...
0
votes
0answers
10 views

Create Custom Tab Using MetaData Api in Salesforce

I am using the Apex Wrapper for the Salesforce Metadata API from github to create custom object and its tab. I am done with the object but not able to create tab in apex code. There is a class called ...
0
votes
2answers
14 views

Check some permission is enabled among assigned permission sets of User

I need to check if a permission is enabled among assigned permission sets of Logged in User. Lets say I have 3 permission sets named as PSet1, PSet2 and PSet3 assigned to a User. Need to find out if '...
0
votes
0answers
9 views

How can I send an email while using PageReference getContent() method?

I am trying to send an email while using PageReference and the getContent() method which is, only ocassionally, throwing an error (seems like every couple of emails regardless of the frequency). ...
0
votes
0answers
19 views

Using HttpResponse in a seperate class from future

I have written a trigger that calls a class which contains a future method and I need to use the response to update a field. Is there anyway to capture the HttpResponse in a separate class? public ...
0
votes
1answer
32 views

Pass Custom Type as a Method Parameter

Is it possible to pass a custom type into a static method? I have two custom types and I'd like to pass in a custom type as the method parameter and then identify which type was passed in and run the ...
0
votes
1answer
6 views

Doing division on a Decimal returns 0 when trying to return a percent [duplicate]

When I run the following code, it will return a 0. It should return 50.00. System.Debug((100/200)*100); I'm certain this is a simple solution. But haven't been able to find out the reason why. I ...
0
votes
1answer
20 views

Change name of standard object in managed package

I need to create a script to rename the salesforce standard object, or when i create the package include the new names. I create a Managed Package, this package will be need the new name of the ...
0
votes
0answers
28 views

Getting null pointer exception on populating map of map data

I am writing trigger to update an order line item of order related to an Account when an invoice line item is inserted corresponding to that order line item. Problem is whenever a loop is iterating ...
0
votes
1answer
18 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
24 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
1answer
33 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 ...
-1
votes
0answers
19 views

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

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
29 views

Parse HTML request in salesforce apex [closed]

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
1answer
22 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
2answers
20 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 ...
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
1answer
23 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 ...
6
votes
1answer
75 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 ...
2
votes
1answer
20 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: []. ...
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(...
4
votes
2answers
127 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 ...
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
33 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
25 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 ...
0
votes
2answers
47 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 ...
-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:...
-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....
0
votes
0answers
34 views

Apex Trigger Error

Here is my Apex Class: public class NavProductHelperClass { public void checkProductAvailability(list<OpportunityLineItem> opids) { for(OpportunityLineItem oli: opids) { ...
1
vote
1answer
37 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 ...
0
votes
0answers
20 views

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

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

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 ...
0
votes
0answers
24 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(...
-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
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 ...
-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
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
23 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 ...
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 ...
0
votes
1answer
13 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 ...
2
votes
1answer
43 views

VS Code Debugging Class

I am new to VS Code, I have read up on it. I can write APEX very well but only in the developer console. I am used to System.Debug Logs. I see that in VS Code you can put in Breakpoints versus debug ...
1
vote
1answer
26 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.
1
vote
1answer
16 views

Run report from Apex

My users want more control scheduling reports. The scheduler only offers a limited set of times and frequencies. I know how to schedule apex scripts using System.schedule and a cron string. Is ...
0
votes
0answers
12 views

How to retrive invalid phone format data from salesforce [closed]

Basically the phone format data are available in 0-9 but in my org there are lot of phone data for account object is in invalid format. I need to extract those data from org. Is there any apex code so ...
0
votes
1answer
25 views

Unable to identify REST API status code

I am testing a REST service in dev console and I'm getting a status of Found and a status code of 302. However, the body is empty and I know the parameter value returns a record from the system that I'...
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
1answer
21 views

Hot to get value of relationship dynamic Soql

I am using the following string in a dynamic soql: SELECT id, name, orderdate__c, status__c, sold_To_Customer__r.id, sold_To_Customer__r.name, sold_To_Customer__r.customerreference__c, ...