Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
15 views

Send email add the attachement and all the records

Error System.QueryException: List has no rows for assignment to SObject Error is in expression '{!sendEmailFunction}' in page sendemailcontroller: Class.SendemailController....
0
votes
1answer
37 views

testing upsert campaign members gives error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

Testing my apex controller in my dev org runs fine. However, testing the same file in another dev org gives error INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Here is the controller ...
0
votes
1answer
25 views

No response from server when calling apex controller?

I have a lightning component which calls the client side controller, which then calls the server side controller. The server side controller is linked to a method i have in one of my classes. ...
1
vote
1answer
28 views

How is JSONParser object structured / stored? [on hold]

I am exploring the JSONParser methods and trying to understand how its objects are structured and stored in Salesforce database. Here is my JSON string - String input = '{"name":"paulo","age":42, "car"...
-1
votes
1answer
25 views

Call method from apex class in lighting component [closed]

I have a lighting component and a controller. What is the easiest way to make a call to a method i have in one of my apex classes and then using the return value to update the current record with that ...
0
votes
0answers
16 views

How to store and use named credentials with OAuth

I have read this Where to Store Token Auth? and as far as I understand this, the best way for an OAuth based auth. is to use the named credentials. But I do not get the point how this work. In my ...
5
votes
0answers
38 views

Issue with receiving HTTP with Content-Type:application/x-www-form-urlencoded

I've faced a strange issue during my development related to the API. My goal was to create a web service that will receive POST requests from different sources. First service: It passes all the ...
0
votes
0answers
18 views

Values of Related to field in Activities [closed]

Scenario : Say If I am creating an activity and I populated an Opportunity in Related to field, I got two fields in activities say Field1 & Field2 which should contain the stage & closedate in ...
0
votes
1answer
24 views

Passing a JSON parameter from test class to class method

I have a class which has a method with a parameter of JSON type. Now my goal is to create a Test class to test the method with the parameter of JSON. Please see my codes. This is my method in my ...
1
vote
0answers
25 views

Validate inputs on server side

BACKGROUND I am working on a lightning component which is a simple form that takes from, to emails and a message body as user input and passes this data to an apex controller. Apex Controller ...
0
votes
0answers
19 views

Call Apex Controller method from button in Visualforce component table row

I have a Visualforce page which has a few Visuaforce Components to display sections of data, one of which contains a table with an "apex:repeat> for each row. Each of these rows has a button, which, ...
0
votes
0answers
7 views

Salesforce 1 - Capture Location

I've come across a requirement where User's location needs to be captured at every 1 minute (Without any user intervention). Application - Salesforce1 Is there any way by which we can achieve this? ...
1
vote
0answers
23 views

Has anyone been able to set the User.IsCustomerPortal field from a unit test class?

I know the field is not editable but I mean by associating a User record with a Contact/Person Account record in your test data, somehow it gets enabled? Do you know? The reason I need this ability ...
1
vote
2answers
53 views

Is it a good practice to use a static variable in a Test Class and use that in the actual class instead of Test.isRunningTest()?

I've read about using a static variable from a class in the test class but I'm wondering if this is legal enough to do. @isTest public class myTestClass{ public static Boolean mySwitch = false; ...
1
vote
0answers
16 views

Use Semantic Completion with Tabnine in VsCode

Have any of you tried to use TabNine Semantic Completion with VsCode? I tried to use the configuration below but it always crashes. Just want to make those three great tools to work smooth (VsCode, ...
1
vote
1answer
23 views

Real time synch with external application on insert and update of frequently changing records

In order to synch very large amount of frequently changing data to an external system, what will be best way to do it ? We can't use trigger or schedule batches as these will fire so many times that ...
0
votes
0answers
17 views

Please assist me in writing test code for this working piece of code. I am new to testing [duplicate]

I'm stuck at 38%, Its just cover the last part of code(callout portion), I have tried several ways but it just cover till line ' parse_id.nextValue(); ' and after that line it mark as red all the ...
0
votes
0answers
16 views

Unable to parse unicode characters as a string anymore

A few week ago, my api code that parsed a String just fine, all of the sudden doesn't work when the passed in string is unicode characters.. Here is my code: class Degree { String title; } class ...
0
votes
0answers
15 views

Unit test for a update list Apex Class [duplicate]

i need to write the Unit test for my class in apex, but i don't understand how to function a Unit test, i read many articles for unit test but i don't understand how to work, my class is this, please ...
2
votes
1answer
37 views

Get name of standard action overriden in Visualforce contorller

I have a visualforce page that overrides both the 'New' and 'Edit' Buttons of a custom object. In my controller extension how can I get the name of the action that called this page ? I don't see ...
0
votes
1answer
33 views

Null reference error in trigger on required field

I have this trigger that changes the Name of a record based on a custom title__c field: trigger assignDegreeName on Degree__c (before insert) { /** Variables **/ integer maxSize = 80; ...
0
votes
1answer
12 views

Extension Controller for a parent record return all the child in the Database instead of child related to the specific parent

I have an Object Called Container__c with a child called Article__Container__c. I create a visualforce page to display all child with an Extension Controller. But when i Hit the button on the layout ...
0
votes
1answer
16 views

How Do I Use The “oncomplete” Function To Refresh A Different Visualforce Page?

Is it possible to update a different visualforce page using the "oncomplete" function? I have a visualforce page that I would like to have the ability to refresh various other Visualforce pages when ...
0
votes
1answer
22 views

JSON structure in Salesforce?

How would i store this kind of JSON structure in salesforce? "elementOne": [ { "itemOne":"valueOne", "itemTwo":"valueTw0", "embeddedElementOne":{"embeddedItemOne":"embeddedValueOne"}, ...
0
votes
2answers
38 views

Fatal Error while deploying apex classes to production [closed]

I have created 3 new apex classes and test classes for the same.In sandbox, test class code coverage is more than 90% for all the classes. While trying to deploy to production, I am getting error as ...
0
votes
0answers
17 views

E-mail being sent to spam folder [closed]

When I send an e-mail from Salesforce, they get sent to my spam folder. I have tried e-mail tests and one particular Salesforce IP does not get blocked. Question) Is it possible to send all E-mails ...
1
vote
1answer
60 views

How can we get custom field Ids in apex from a different user

We need to get some custom field ids thru apex - we used to do it by invoking tooling api request, but now this requires the user has to have the permission "View Setup and Configuration" on his ...
1
vote
1answer
23 views

User settings (Default Recordtype) in Apex

is it possible to find out in apex, if the user selected a recordtype as a default in the user settings?
0
votes
1answer
28 views

How to call future method from lighting controller

Is there a way to call future method from lightning controller? @auraEnabled and @future can co-exist together? example: Class ABC{ @auraEnabled public static void callfromFuture() { //...
0
votes
1answer
28 views

Platform events and asynchronous calls conflicting with SOQL statement

I am using platform events to send an event in from an external system that triggers a lead to be converted via apex. The incoming platform event sends data that is needed to convert the lead and ...
7
votes
0answers
45 views

Rethrowing an exception is missing the stackTraceString

I have code that is wrapped into a main try-catch block and then inside of that I have another try-catch which I am using for a specific use case. If the inner try-catch gets triggered I then use a ...
0
votes
1answer
29 views

Mapping to a user

so I am trying to map a note that a user has entered to one's id. The errors I am getting Illegal assignment from Map<Id,String> to Map<Id,MTX_Matrix_Note__c> DML requires SObject or ...
-1
votes
1answer
23 views

Auto creating subfolders in box.com through salesforce

Below is my code for auto creating the folders in opportunity but it is throwing me the below error for my code... Error: List has no rows for assignment to SObject Code: public void ...
0
votes
1answer
26 views

Is there any performance benefit of using Id field in Map instead of String in Apex Code

In my apex code I need to change data type of one variable from Map<Id, List<CustomObject1>> to Map<String, List<CustomObject1>>. This change is required to full fill one ...
0
votes
0answers
12 views

Lightning component - render VF page over account details on button click

I need to build out a custom lightning component which houses 1 button that will set the account details to an imbedded iframe. I have found a few examples of components which render a vf iframe ...
0
votes
1answer
41 views

List items not getting removed

I want to remove Accounts from List to which user doesn't have access. Here is my code. However in the debug logs, I can see all the accounts, that is none of them are removed. query += QUERY_BASE + ...
0
votes
1answer
25 views

How Do I Get A Child Record ID Into The Master Record?

Currently i'm using this simple iframe to show a visualforce page built on a custom object called Paperwork__c which is a child relationship to Apprentice__c where I currently have it displaying. &...
0
votes
1answer
21 views

Apex Rest API : Is it possible to support accept parameter with “plain/text”

I am trying to implement a webhook from a 3rd party application (Eventbrite) using a Custom REST API in Salesforce.The issue here is that 3rd party API uses "Accept: text/plain" parameter in their ...
0
votes
1answer
23 views

unit testing - if record is created with certain record type

I have a function createWithRecordTypeIfExists(String recordType). Its logic goes like this: Check whether a record type for this object exists in the org. If yes, create a new record with this ...
-2
votes
1answer
43 views

I am getting stuck here, I just need test apex /snippet /mock for this. Any input will be highly appreciated [closed]

I am just new to apex testing, I am getting responce from Trigger upon that i am moving further in my class. let me know id there is a way around to get better understanding to develop test cases. ...
0
votes
0answers
32 views

System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop: External entry point [duplicate]

for (Account acct : [SELECT ID, Name, Type, DBE_Flag__c, sendToSAP__c, sendToDwnSys__c,Primary_Partner__c,Validation_Override__c ,Address_Status__c,...
0
votes
0answers
21 views

Does the Messaging.InboundEmailHandler class handle multiple mails parallelly or serially?

I have an apex class that implements Messaging.InboundEmailHandler class for handling emails received by an email service address. Then, the mails are handled by handleInboundEmail() function where a ...
0
votes
2answers
39 views

Elegantly handle the null object check after JSON.deserialize()

I have multiple-layer predefined classes that JSON.deserialze() can successfully map the JSON data into. The challenge is in processing the deserialized data. In each layer I need to use if to check ...
0
votes
1answer
20 views

Apex - using List Question

I created a Apex class : public class HellowWorld{ public List<Contact> getContacts() { List<Contact> contacts = Database.query('select a,b,c,d,e,f,g,h,i from alphabet'); ...
1
vote
0answers
11 views

How to verify existing Community users mobile number?

I have implemented passwordless login using users mobile number for community and its working as expected. But It allows only verified mobile numbers. We have several existing community users in our ...
0
votes
1answer
23 views

User can't access APEX controller

I'm developing a Lightning app that uses Custom Apex Classes. I have admin privileges and through the app can execute methods in the Apex class without issue. When logged in as another user, I can't ...
0
votes
0answers
57 views

NO_APPLICABLE_PROCESS, No applicable approval process was found, yet the criteria is met, no code change in years

Having an odd issue in our prod org recently. Code and approval items haven't changed, yet for some reason after our last monthly release we've been getting the no_applicable_process error here. The ...
0
votes
2answers
19 views

Create exceptions in test classes for a process builder?

Is is possible to create exceptions in a Test Class for (example) Process Builder "XYZ NAME"? To avoid the test class running that process. Right now my work-around is to manipulate the criteria in ...
0
votes
1answer
33 views

The best way to enable a button after the min char requirement is met

So I have this 'Update' button and I only want it to be enabled in my modal only if the user has entered at least one character. <aura:if isTrue="{!v.displayEditMatrixNoteModal}"> <...
0
votes
0answers
19 views

Placing business logic out of trigger to handler

I had to add some business logic to our code base. I am trying to follow a "loosely coupled" architecture. So I was able to design the code where my trigger calls a class which does some business ...