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

Serialize list of objects to json array not working as expected

It seems like in some instances apex is serializing Lists differently. I need it to serialize a list to a json array, however I'm getting a comma separated list of objects. Why does this give me a ...
0
votes
0answers
23 views

Best book or website to learn Apex programming with tons of examples and practice? [duplicate]

I'm looking to expand my knowledge and am fairly new to the apex programming language. I would like to become familiar with the beginners material and eventually become an intermediate apex dev. Are ...
0
votes
0answers
15 views

Trigger Report Snapshot Via Execute Anonymous

Has anybody tried executing reporting snapshots via execute anonymous. I only ask, because the "Preferred Start Times" that I have left via the Salesforce UI is now mid day. I would not want to take a ...
0
votes
1answer
24 views

List all child, parent objects and its relation attribute key [closed]

I have a requirement where i want to display all salesforce objects in visual force page. After salesforce object selection, list its parent objects and relational key attribute name of current ...
0
votes
0answers
39 views

how do i design a test class for visualforce controller [duplicate]

I am new to the Salesforce Apex development, i know the basic knowledge of test classes, but i am not able to write the Test class for the below code please help, i somehow designed the test class ...
2
votes
0answers
49 views

Accessing Custom Permission from Managed Package

I'm trying to check the User assigned Custom Permission from a Managed Package. The Custom Permission and the Permission Set are not part of the package, but in the subscribers Org. Currently I'm ...
1
vote
1answer
19 views

How does a detail page button which is invoking a flow works?

I have a flow where I am passing a Custom Object's recordId to the flow by invoking it from a detail page button like this /flow/Activate_Record/myRecordId?={!Inactive_Farms__c.Id} This flow is ...
0
votes
0answers
17 views

Lightning component data visibility

I created a lightning component that displays all account related cases. I want to make this component available to users, but I would like it to display all issues regardless of whether the user has ...
0
votes
0answers
9 views

How to set margins for all elements inside panelGroup?

Let's say we have markup <apex:panelGroup> <apex:selectList value="{!orderField}" size="1"> <apex:selectOptions value="{!...
1
vote
1answer
26 views

How to delete the shared object record

I have written a trigger which will insert, update and delete the project when a new project team is created and removes access when the it is deleted . I have successfully written the code for insert ...
1
vote
2answers
27 views

Method overload runs with least specific type with inline if statement

I had the impression that when we overload, it will run with the most specific type(Date for example). In the following example, it always runs with least specific type (Object): String.valueOf((true)...
0
votes
1answer
26 views

Invalid type: Schema.SObject

My requirement is, whenever the checkbox is checked on Contact Object then records in the related junction object(Custom Object) should gets deleted automatically. For that here is the code: public ...
0
votes
1answer
26 views

Using Python as backend to Salesforce App

Python has some amazing libraries that I want to take advantage of. The only issue that I am concerned about here are the governor limits for long running operations. I am creating a deduping app and ...
0
votes
0answers
15 views

Problem sending email with attachment

I have a method to send email with attachment but some weird stuff keeps occuring where some emails + attachment arrived to the accounts that are returned by the query but some didnt receive anything ...
0
votes
2answers
32 views

Access from Test class to Inner class

I tried to test my method which is using inner class. Wrote like this, and got error Invalid type: innerclass. Apex public class myclass { public class innerclass { @AuraEnabled ...
0
votes
2answers
33 views

Why is associated User information null when queried through a lookup in a test?

I have an apex class that I am testing that queries for the record Owner information on leads. When I try to access the Owner information the values are null. However, when I query the user object ...
0
votes
0answers
20 views

Default value on <apex: input> that is based on another variable

I have a custom formula field called "Open Quantity". I want whatever is in that field to be the default of the input box under the "Receiving Quantity" column on my visualforce page. Then be able to ...
0
votes
1answer
20 views

Non static method cannot be referenced from a static context: Id AutocreatedConfigSelfReg

I'm currently working on a Salesforce Community and used the 'Create a configurable self-reg handler' so I could map an existing contact to my user instead of creating a generic user. The default Apex ...
0
votes
1answer
26 views

Building Salesforce Applications using the Salesforce API

I am creating a salesforce deduping application using python. The issue I am running into is that deduping applications literally take hours to run through large databases. How do others execute ...
0
votes
2answers
23 views

Running a query on a lookup table and returning the value in the private key

I have a trigger that is being tripped every time a Order is changed from draft to active and vise versa. I have a conditional inside my trigger that runs a query and saves the output into a Map. When ...
0
votes
1answer
32 views

Messaging.sendEmail not compiling for some reason

I have the following method that has been working fine until today, I have not changed anything with the code. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); if(cc !=...
0
votes
1answer
11 views

BusinessHours methods not compiling

For some reason when I attempt to use the BusinessHours.isWithin method within Salesforce I get the following error: Compile failure on line 4, column 34: Method does not exist or incorrect signature:...
0
votes
1answer
27 views

rendered attribute does not work for me

Let's say I want to conditional rendering of outputPanel markup <apex:page controller="SOQLBC"> <apex:outputPanel id="sobj" rendered="{!LEN(sObj)>0}"> <span> --- {!sObj} -...
0
votes
1answer
15 views

how to capture column values from a lightning:datatable to compare two of its column values

I am working on a datatable : That Displays; Description , Due Date, Reminder Date History November 26, 19 November 25, 19 How to compare Due date with Reminder Date to display an alert ...
2
votes
0answers
35 views

Site Guest Users Cannot Insert or Query ContentDocument or ContentDocumentLink objects

As a Guest User on a Salesforce Site, executing Apex code to insert ContentDocument or ContentDocumentLink objects "silently fails". I have configured a Site which has a simple landing page with the ...
1
vote
1answer
55 views

Apex Specialist Superbadge Step 4: The 'MaintenanceRequest' trigger does not appear to be handling bulk operations correctly

I have been working towards getting the Salesforce Developer 1 certification and am currently stuck on step 4 of the Apex Specialist Superbadge test. It keeps reporting the following each time I check:...
0
votes
1answer
22 views

Return of Datetime value

I am new to Apex. I have instantiated the Datetime field with (2019, 12, 31, 12, 12, 12) where hour/minute/sec all are '12'. but in the output it is returning '20:12:12'. Please help me to ...
1
vote
2answers
72 views

Can we purchase addon to increase limits on SingleEmail Apex limits?

The number of emails(using Messaging.SingleEmailMessage) we can send using Apex per day per org is 5000. There is a workaround to send emails using workflow but it won't solve our need as it won't ...
0
votes
1answer
32 views

First exception on row 0; first error: INVALID_ID_FIELD, Invalid entity type for whatId

Getting Following error in the below code 23:27:13:030 FATAL_ERROR System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, Invalid entity type for whatId.: [...
1
vote
1answer
23 views

Re-parenting primary CPQ quote Line Items not rolling up to Opportunity

Within CPQ, Opportunity Line Items should automatically sync with the Primary Quote's Line Items. However, when re-parenting a primary quote from a Source Opp to a Destination Opp (Destination Opp ...
1
vote
0answers
29 views

How to add an HTML link on a Lightning Communities Page

Have a seemingly easy request that I can't find a workable answer to. Trying to add an internal link to an error message thrown on a Lightning Communities page, but so far no luck. FWIW, the code: ...
1
vote
1answer
38 views

Math/Subtraction is different between Formula field and Apex

I have a Formula field which does simple subtraction between two other fields. Field X - Formula (return type Number, 2 decimal places). Field Y - Currency(16, 2) The formula field simply does : X ...
0
votes
0answers
32 views

Test Class Coverage: unable to associate Territory data with Group and AccountShare Objects

While writing test class, I am unable create the data that connects AccountShare, Group and Territory. Group and Territory are related by the field relatedID on Group which is read only. Has anybody ...
3
votes
0answers
24 views

What causes leftover XML to exist in files when a component is deleted via the UI?

I've had interesting situation come up today when doing a metadata validation on a very large package. An error was occurring on a Page Layout where it was expecting that a QuickAction should also be ...
1
vote
1answer
24 views

RelatedToId field on EmailMessage Not Writeable

I am getting this response 'Field is not writeable: EmailMessage.RelatedToId' Email trigger helper method is the following: public static void parseEmailSubjectForLeadRelation(List<EmailMessage&...
0
votes
3answers
81 views

Trigger, after first soql seems to stop executing without error. *Edit*

*EDIT-I have updated my code with more explanation and debugs showing what is printed and where execution unexpectedly exits without error. I am also only working with 1 test method for now. I am ...
1
vote
0answers
21 views

Correctly Write Test and Callout test on trigger [duplicate]

I have a trigger on Account after insert and after update. In both cases I need to call my BUS to update in the compagny database. Since I will have to deploy my dev into QA I need to write a test ...
1
vote
2answers
60 views

SOQL subquery access variables

Attempting to access the variables MIlestone1_Project__c has a Lookup relationship to Account with relationship name: `Projects__r'. List<Account> accList = [ SELECT Id, Name, EHR_Status__c,...
0
votes
2answers
19 views

not populating merge field (detail link) through apex

Is there any way to populate {!Opportunity.link} while sending email through apex? or Is there any way to replace {!Opportunity.id} with 15 or 18 character id like: https://xx.salesforce.com/{...
0
votes
1answer
33 views

Expected '[' at the beginning of List/Set

I’m trying to make a webcallout to pull data from the webservice and insert data from the JSON response into my custom object. After making the callout I’m getting an error of System.JSONException: ...
1
vote
1answer
31 views

To achieve same functionality as that of account teams in custom object

I want to achieve the same functionality as that of account team in project(Custom object)  using trigger . For this I have made a new custom object as projectteam and added lookup of user as well as ...
2
votes
0answers
24 views

A way to stop hard deleted records to come in query results

I'm querying deleted records in a query like below Select Id, Name from Lead where isdeleted = true ALL ROWS Records hard deleted from recycle bin using emptyrecyclebin() call still coming in the ...
0
votes
1answer
14 views

Does execution log show all validation rules occur in each iteration or not?

In the image above every iteration has its validation rule occurred, I wonder if there were more validation rules, does the execution log show all of them in every iteration or show only one ...
1
vote
1answer
38 views

Convert Streaming PDF from String to viewable PDF

I am trying to open a PDF that I am receiving as a streaming PDF from a microservice and open a visualforce page that contains the viewable PDF file. I can convert the streaming PDF to base64 using ...
0
votes
1answer
15 views

Problem on Line 0

I'm new to salesforce dev and am trying to create a simple visual force page. I'm getting the below problem and my page is coming up blank on preview. How do I fix this? Name: GeneralDefense Line: ...
0
votes
0answers
25 views

Deployment Failed Developer Edition

I can't save a class in a developer org. I receive this error: "Can't alter metadata in an active org". How can I resolve this problem?
0
votes
1answer
29 views

Soql query field value starts with

How to retrieve account records where the name starts with "comp"? Select Id,Name From Account Where Name Like 'comp%' Does the above query guarantee at least 4 characters in length?
2
votes
1answer
20 views

Bypassing Header Based Authentication

I am configuring a REST Hook between Salesforce and this marketing tool AutopilotHQ. Rather than having Salesforce continuously poll to find out when there is new information to trigger from, ...
0
votes
0answers
15 views

SelectOptions works in Chrome but not in IE

I have used apex:SelectOptions for picklist in my VF page to fetch the values from class where the logic is written to set the default value for the picklist. This works fine in Chrome but not in IE. ...
0
votes
0answers
23 views

Duplicate Record Sets - Action on “Compare and Merge”

How can i add an action (process builder or call Apex Class) on Duplicate Record Set Object when clicking this button on top right? Compare and merge? I want to add an action to somehow lock the ...