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.

6,104 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
364 views

Trying to call API through Apex with custom security certificate but getting CalloutException

I'm trying to use Apex to call some API endpoints to do some validation for my company. There are some specific properties of these APIs that make it a bit tricky: The APIs are hosted on self-...
3
votes
0answers
2k views

getRecordTypeInfosByDeveloperName doesn't work with duplicate Developer names

Our product comes with a couple objects including RecordTypes. In our customer org I'm adding some RecordTypes and experienced, that I can give them names that the packaged types already have. So now ...
3
votes
0answers
128 views

Scheduler test class fails while packaging

Scheduler Class: global with sharing class Demo_Scheduler implements Schedulable { global void execute(SchedulableContext sc) { Database.executeBatch( new Demo_Batch(new List&...
3
votes
0answers
653 views

Opportunity Territory Assignment in Progress… forever

I've just setup Enterprise Territory Management for a very simple org (1 type, 8 territories). Accounts assignment rules work fine but I'm struggling to get opportunity territory assignment working. I'...
3
votes
0answers
354 views

Platform Events allow REST API JSON inputs to bypass field Required-ness?

We are finding that when feeding data to a SF Platform Event via the REST API (/services/data/v43.0/sobjects/My_Pletform_Event__e), Required field inputs can bypass endpoint validation by supplying an ...
3
votes
0answers
380 views

Object View override doesn't work on lightning and mobile

I'm trying to replace the view of a standard page with my custom VF page. This works great on the classic theme but not on the lightning theme and mobile application. In the VFP I checked "Available ...
3
votes
0answers
578 views

When is User.ContactId nulled during community/portal user deactivation?

When deactivating a Communities User in code, you can't directly update the User.ContactId field. Rather, setting User.IsPortalEnabled to FALSE has the side effect of nulling out User.ContactId. I ...
3
votes
0answers
572 views

Conga Composer Attachment creation Lightning Component

I'm trying to generate a PDF attachment using conga composer and attach it to my custom object. Find below the apex code used to construct the URL : Map<String, String> parameters = new Map&...
3
votes
0answers
127 views

Apex method signature change does not reflect

I have an apex method for eg: public static Boolean doSomething(String a, String b, String c) {} When I update this method to public static Boolean doSomething(String a, String b, String c, String ...
3
votes
0answers
364 views

Make Chatter Profile Photo available externally?

I'm working on making some email templates, made of various visualforce components. One of these includes some information about a user they'll be interacting with. Additionally, this component ...
3
votes
0answers
206 views

How to populate XML

I saved an XML template file like the below in a library. Please note the text ApplicationTypeHolder and SubmissionTypeHolder in the file. I modified the original XML file and added those texts there. ...
3
votes
0answers
83 views

schedule jobs to be run in the past

I have a scheduled job whose "Next Scheduled Run" is set to a date in the past: Cron expression: 0 30 20 * * ? * Does it mean that this scheduled job will never run? What could be the reason for ...
3
votes
0answers
99 views

VF : Persist data between two VF pages

This is my VF Page <apex:page showHeader="false" sidebar="false" cache="false" contentType="text/html" controller="AWS_Upload" > <script src="https://ajax.googleapis.com/ajax/libs/...
3
votes
1answer
819 views

Redirect visual flow to external URL

Good day Everyone I have created a flow which I embed inside visual force page. After the flow process, I want to redirect the page to external url like 'www.google.com'. The problem is that encounter ...
3
votes
0answers
4k views

Soap webservice callout throws “Policy Falsifed” error : Error code 500

I am trying to make a web service call to an external system. The Gateway to the application server needs a soap signed request (WSS Security). The service provider confirmed authetication happens ...
3
votes
0answers
82 views

First event/event relation insert taking a while

I have an application that inserts events and event relations in an org's database and has a loading icon to prevent the user from doing anything until the event and relations are properly created and ...
3
votes
0answers
458 views

How to return all users that have access to a specific record

Is it in any way possible to return a list of users that have access to a specific record together with their permissions? What I want to do is the equivalent of the SOQL query SELECT RecordId, ...
3
votes
1answer
2k views

Trigger.new and Trigger.Old Map hold same values for a field on Opportunity

I have a trigger on Opportunity which calls a handler and Handler calls an apex class. here is the code: //Trigger trigger MasterOpportunityTrigger on Opportunity ( before insert, after insert, ...
3
votes
0answers
136 views

Case Assignment Community Portal. Insufficient access rights on cross-reference id when enabling email

I have a trigger to assign cases when they are entered in our community portal. It works great for guest users, and for regular salesforce users, but for users in the community users profile I get an ...
3
votes
0answers
65 views

Why mass uploads cancel out scores calculated by Apex code?

We recently implemented this Apex code "Account Grading Method" (attached below) in our system. When an account record is created or edited, a process in the Process Builder calls the Apex code to ...
3
votes
0answers
455 views

Queue/Serialize Incoming REST API Requests

I'm looking for a way to queue incoming HTTP Post requests. Apex REST API handlers are executed in parallel on separate threads. This introduces race conditions if any new records are inserted by ...
3
votes
1answer
525 views

InvocableVariable Amount field not visible in Process Builder

Using Amount field in a webhook I've created an Apex class webhook to post from Salesforce to Slack. I have tried with Opportunity.Amount field is defined as a Double or Decimal. @...
3
votes
0answers
228 views

Salesforce handling event onTabClosed not working in lightning

I want to show a popup message on closing a lightning component to prevent data loss and as a user warning in service console app. For this I have implemented the below: cmp: <aura:component ...
3
votes
0answers
105 views

Execute Method in Batchable Class does not execute on all records returned in Start method Querylocator

I am seeing a very similar issue to the one discussed in this question, which was due to a bug in Spring '17. The Querylocator returned by the Start method returns 9,989 records, which I can verify ...
3
votes
0answers
93 views

Resolving UNABLE_TO_LOCK_ROW issue

Is there any way to identify which transaction/class took the lock the record when we get this UNABLE_TO_LOCK_ROW issue. Simply giving UNABLE_TO_LOCK error and not giving the idea about he potential ...
3
votes
0answers
665 views

Is File Upload through Lightning Components counted as part of Apex Heap Size?

In Winter 2018 release salesforce has released a new beta lightning component for uploading file through the lightning:fileUpload (Beta). The documentation in this link says we can upload a file of ...
3
votes
0answers
460 views

Assigning Knowledge Articles to a queue in apex

I'm trying to use the KbManagement.PublishingService class to assign a KnowledgeArticleVersion back to a queue after it was programmatically updated after creation and got assigned to the the current ...
3
votes
2answers
818 views

Merge duplicate Contacts across different Accounts does not create AccountContactRelation

In cleaning up our database and using the new AccountContactRelation to allow a Contact to link to multiple Accounts, I need to merge all the duplicated Contacts into one Contact with ...
3
votes
0answers
621 views

Apex Encryption to AMPscript Decryption

I receive a string encrypted using the Apex function Crypto.encryptWithManagedIV() using AES256 as a url parameter, and I need to be able to decrypt this string on a marketing cloud landing page. I ...
3
votes
0answers
2k views

Test class for community to get network id

i am facing problem with getting network id in test class, while executing visual force page, controller returns proper network id, when try to write a test class for this 'ClassNetwork' controller, ...
3
votes
0answers
983 views

INVALID_CROSS_REFERENCE_KEY Error in Approval Process

Following error is popped up when trying to approve the approval step by code.I can sense this error is because of wrong work item id but I am unable to do so. Approval Process error: System....
3
votes
0answers
112 views

Does an Email Service accept Emails sent by phpmailer?

I have issues setting up an Email Service which should receive Email sent by an web-form using phpmailer. Now I've configured it like this: I've set no restriction to "Accept Email From" in order to ...
3
votes
0answers
523 views

Rendering VF page as PDF in Lightning

I have a question about an issue with rendering VF page as PDF in Lightning Experience (same code works fine with Classic). I have a button that calls visualforce page which calls VF page and saves ...
3
votes
0answers
164 views

why extra string append with the REST request?

I am trying to send this data to another salesforce org REST endpoint. map<string,Set<string>> mp = new map<string,Set<string>>() ; mp.put('Data1',new set<String>{'...
3
votes
0answers
152 views

How to pass values between two apex:selectList asynchronously

I'm building a VF that's meant to query for Thing__c. The fields that are meant to be filtered are set in a fieldset. I'm iterating the fieldset rendering an apex:inputField for each and have an ...
3
votes
1answer
2k views

How to determine page mode (Edit/View) in Lightning Experience

Please note that this is about Lightning Experience (with actions overridden), not Classic. So, getParameters() doesn't work here. Here is the output if someone needs to see it's output. {id=XXXXX, ...
3
votes
0answers
71 views

Case' contactId always changes back when I try to change it

In our org in case object, when I tried to change the contactId field (Or contact as it appears on the filed list), it always changes back. Say if it originally is of contact A, if I change it into B, ...
3
votes
0answers
275 views

Report data truncated in Apex

I have a client who has asked me to run an automation based on some report data which includes long text fields. I was playing around with sample code: String reportId = 'insert a tabular report ID ...
3
votes
1answer
168 views

Locating execution logs for SandboxPostCopy script?

I have a Apex SandboxPostCopy script that should have been executed when I refreshed a sandbox recently, but it appears to either be not executing or failing to execute properly. Is there anywhere I ...
3
votes
0answers
261 views

Where to find a documented reference for Test.testSandboxPostCopyScript

I'm looking at the SandboxPostCopy interface for creating a sandbox post copy script. I found the Salesforce documentation covering the interface and even an example (albeit, syntactically incorrect) ...
3
votes
0answers
159 views

Ajax REST Tooling Queries Return Null SymbolTable?

Background I'm trying to build upon Daniel Peter's approach in his HyperBatch library to build a HyperQuery tool that will allow me to get better insight into some large tables we have without ...
3
votes
0answers
306 views

How to parse the matrix report data in to apex controller to show it in chart?

I am trying to pass the matrix type report into a google chart, but for that i need to parse the data.i have tried to do that but i didn't get any matrix grouping function since i am new to report ...
3
votes
0answers
461 views

Test passes when run alone; fails when run with other methods in the same class

I've got a test that passes when run by itself, but fails when run alongside another method in the same class. No changes were made between test runs, and I have made sure to select Disable Parallel ...
3
votes
1answer
515 views

Case Owner changing upon case insert (all case triggers are inactive)

I'm trying to run a unit test to see if the case owner upon insertion matches an expected value. In this case, the expected case owner will be the account owner. However, upon inserting the case, the ...
3
votes
0answers
1k views

System.DmlException: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST

I am getting the below error: Errors Treatment Code: bad value for restricted picklist field: 95972 System.DmlException: Upsert failed. First exception on row 0; first error: ...
3
votes
0answers
49 views

Access HomePageComponent via SOQL or Apex

Outside of using the SOAP API (and Metaforce), is there any way to access HomePageComponents and which WebLink records are in each? Even better would be finding a way to access the Home Page Layout ...
3
votes
1answer
166 views

ApexMock FileNotFound Exception

I am trying to learn how to write tests for apex services using ApexMocks framework. I want to generate Mock classes through apex-mocks-generator and I am following simple instructions given in this ...
3
votes
1answer
351 views

Getting record data from a DELETE operation using Streaming Api

Is it possible to consume record data (not just the record id) via the Streaming Api for a delete operation? The only thing that seems to come over is the recordId. Here is an example of the ...
3
votes
0answers
691 views

Send emails from Salesforce with attachments to create tasks in Outlook?

One of the requirements for the project is to automatically send mails with events/tasks from Salesforce whenever an event/task is created/edited/deleted. I was able to send events and updates, but ...
3
votes
1answer
125 views

FOR VIEW SOQL for another user

Is it possible for me to use the FOR VIEW clause in SOQL for another user instead of the CurrentUser. For example I want to see how many records on the Case object a certain user has viewed in one day....

1
3 4
5
6 7
123