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.

7
votes
3answers
152 views

How to Aura Handle multiple DmlExceptions

How should I handle multiple DmlException messages when using AuraHandledException inside an Apex Controller. If I do this: try { upsert value; } catch(DmlException e) { throw new ...
0
votes
0answers
15 views

Resize the Scrolling Div dynamically base on Content from the Server

I have a Div with input text and scrolling, which a click on that input, will bring accounts from the server using action function and allow the user to search for his account dynamically. Until that ...
0
votes
1answer
13 views

Sending E-mails in a schedule that changes with time

I have got two scheduled apex class running. It sends two E-mails and two Texts twice a day. 1) I wish to send only one E-mail and text after 3 days. 2) After 7 days E-mail and text twice a week. ...
0
votes
2answers
17 views

Rest API Composite - Error 302

I am using Composite API to get the opportunity record but facing 302 error { "compositeRequest" : [ { "method" : "GET", "url" : "/services/data/v42.0/query/?q=select+id,...
0
votes
0answers
12 views

Dynamically generate {!Community_Url} [duplicate]

Is it possible to generate {!Community_Url} dynamically in the apex and then pass it on to VF email template? Does the link created programatically have the encrypted key to take the user to the ...
0
votes
0answers
10 views

User Workflow email alert - VF Email template unable to access {!Community_Url}

There are questions on the topic of 'How to disable OOTB welcome email' on communities and I am unable to find answers on any of them. I have created a User workflow email alert and used a VF email ...
0
votes
1answer
30 views

Apex code to add related Affiliation to Contact

I have a static Account and a Static Contact which works other than the fact I don't have a fix for if exist skip upsert. I will be placing this code inside another but I'm having a hard time working ...
7
votes
2answers
475 views

How can I determine if the org that I'm currently connected to is a scratch org?

When I'm within a Salesforce org, how can I tell if that org is a Scratch Org or not? Ideally this would be via Apex, but it could be an API call if required. This would be useful information for ...
1
vote
1answer
45 views

[APEX]: Way to iterate over method parameters

I have a method that accepts 4 parameters. I want to do the same action for every parameter if it's not null. Is there a way to iterate over all parameters rather than building if blocks? So for ...
1
vote
1answer
82 views

Method Does Not Exist error message

My class subtracts the values of child account number fields from the current values of it's parent account number fields in a hierarchy. I need this class to run everytime a child account changes its ...
1
vote
1answer
27 views

How to combine multiple batches doing same operation on different objects into Single Batch?

Every Month, we have to reset a flag(of type boolean) on Custom Objects A,B and C. For this, I have written one batch class per object. ObjAResetBatch.cls public class ObjAResetBatch implements ...
0
votes
0answers
23 views

Record Lock Issue for REST endpoint

I have built a REST endpoint, which writes data(Accounts) to Salesforce. Currently, for a single record, there could be multiple (20-30 times) upserts within 1-to-5 seconds. Behind the scenes, it's a ...
0
votes
1answer
26 views

Not getting the right time in apex

DateTime.now() return time stamp which is 10 hours more than the current time, I am currently using the Hawaii standard time please find below the snippet now current time is 6:11 am but if I use ...
0
votes
1answer
33 views

How to get value from object Json.deserialize

I have deserialized a JSON object as follows: MyObjects MyA = (MyObjects) JSON.deserialize(req.requestBody.toString(),MyObjects.class); When I do MyA.get('Accounts') my result is as follows ({...
0
votes
0answers
16 views

Track Knowledge Article Views by User in Apex

Do you know how to obtain the articles viewed by each user in my community? I would not like to create a custom object because I would have many records. I would like to add this functionality to my ...
0
votes
3answers
52 views

System.AsyncException: Maximum stack depth has been reached. while writing in test class

I've got a requirement to perform queueable apex in a trigger my class working fine, but while writing a test class for queueable apex I'm getting an exception. Could anybody can help me. Trigger ...
0
votes
1answer
27 views

Two factor authentication using Security token

I need to implement 2fatcor authentication but the requirement is to get login to envirnment using client provided Secrurity token(Hardware token). Once user entered username and security token ...
1
vote
1answer
20 views

Compare DateTime in Apex

I have created 2 dateTime Instances as below to compare DateTime.now() if it is greater than 8 pm and less than 7:59 am then I want to execute some code but it is difficult to compare dateTime as the ...
0
votes
1answer
15 views

display rendered values on the same line

I made a < apex:reapeat> tag within a table and I want to use rendered to display or not values from a list, base on an input search. The problem is if I have 5 values in the list for example: ...
0
votes
0answers
16 views

Passing sObject to a function as perameter remove some fields

I am passing an sObject as the parameter to a function and when I print this object before and after passing to the function, both are different. The First debug have more fields and debug in function ...
-2
votes
0answers
27 views

How to add new value to Multi Picklist using apex

I want to add new value to the Multi Picklist using apex, it not should be an existing value and also the new value must be selected, how we can achieve this. please help me
1
vote
2answers
44 views

“Note can't be saved” error on ContentNote insert

I'm trying to create ContentNote records from Note ones but it's always giving me this particular error: FATAL_ERROR System.UnexpectedException: Note can't be saved Code: List<Note> noteLIST ...
0
votes
0answers
12 views

Permission missing for creating Notes in Lightning Experience

I have a custom link to redirect the user to create a new note. In Salesforce classic, the custom link works and the user is able to create a note. When I switch to Lightning Experience and click the ...
0
votes
0answers
8 views

communtiy URL Redirecting to another community

I have 2 active communities in my org. When I log in using second community, it is redirecting to First Community URL. instead of https://my-domain/community2name, it is redirecting to https://my-...
1
vote
3answers
41 views

Apex heap size too large: 14070486

I have implemented Batch apex for creating the custom records. Please see the details below. I am sending the each territory Id to execute method and this method will get the list of Goal object ...
0
votes
0answers
23 views

Omni Routing Configurations Overflow Assignee

we have configured Omni Routing Configurations in my Org. in Routing Configuration "Overflow Assignee" currently we are assigning to user called "John Test". lets say after few days "John Test" ...
3
votes
1answer
78 views

Bug? String.split chopping off empty trailing value

I have found this strange behavior by trying to write a unit test against a CSV Generator. It seems that if I try to split a string by comma, and there is an empty trailing cell, these values are ...
1
vote
0answers
14 views

Accessing contents of a file while trying to read uploaded file

I am trying to load and read a CSV file, but I want to iterate through the lines of a file in APEX rather that JS. The reason is that we expect the CSV files to be large and want to handle that job on ...
0
votes
0answers
17 views

Is it possible to reference custom field names of a child object in a text field to be used like a merge field on the child object?

I am trying to create a way to use templates and merge fields on custom objects just like you can use merge fields on email templates using text fields and a field updates. For example: I have 2 ...
0
votes
1answer
28 views

How do you write a test for a class that clones? [duplicate]

I have the following code that clones an asset and its' children... public class Cloner { public Asset root_asset { get; set; } public Asset cloned_root_asset {get; set; } public ...
0
votes
0answers
31 views

Order by (multi-select picklist value alphabetically) Order by LastModifiedDate

I am attempting to bring back a list of contacts per account, but I need the contacts with type of Billing to be returned before contacts of type Account Owner, then in addition to this I would like ...
0
votes
0answers
12 views

Lead Status and custom field not viewable and editable in VF page for other profile

I have a VF Page for Update of Mass Lead. There are 2 profiles, "Profile X" and "Profile Y". In the "Profile X", I can view and edit the standard field Lead Status and custom field Lead Status Reason. ...
2
votes
1answer
101 views

Calling apex imperative method in lightning web component needs two click to show data

I have an apex method that has an attribute and calls a web service: @AuraEnabled() public static string getDetailEta(Integer idE) { system.debug('>> getDetailEta '+idE) ; ...
0
votes
1answer
20 views

Unable to edit/view Archived Task when using VF Override

So, a while back I wrote a custom vf page for our tasks detail view. We wanted to add some way to track task edits, which is the <c:TaskHistory />. Now thats not the problem - just the starting ...
0
votes
0answers
9 views

Salesforce Einstein - Create and Train the Dataset - Trailhead Challenge

Trailhead consists of creating a Dataset with the given URL(https://developer.salesforce.com/files/Cats.zip) But how can we create our own Dataset, if we have saved all the images in Local system.
1
vote
1answer
12 views

Insert Case Apex - Disable Active Assignment Rules

I am trying to insert a case in apex and set the owner to a specific user id. However active assignment rules are rerouting the case. In apex, how would I disable the use of active assignment ...
4
votes
2answers
148 views

Send out email when Apex Queueable fails and test it

This question definitely is a duplicate of many questions here, but after reading most of them I am still somewhat clueless. Question 1: why I can't just catch exceptions in the execute and send an ...
0
votes
0answers
17 views

Amending Block Price Product - Salesforce CPQ

Pricing Method: Block Block Pricing Field: Custom_Field__c //NOT BASED ON QUANTITY Block: 1-50 $100 50-100 $200 100-150 $300 Selected this block pricing product with ...
0
votes
1answer
28 views

Error in $A.getCallback() [erors is not defined] Callback failed: apex://createleaddata/ACTION$saveLead Failing descriptor: {c:createleaddatacmp}

component : <aura:component access="global" controller="createleaddata" implements="force:appHostable,flexipage:availableForAllPageTypes" > <ltng:require styles="/resource/SLDS0122/...
0
votes
1answer
21 views

calling to the server with actionfunction and settimeout

I have a search input on VF page which every character that printed on the keyboard will show the closest result, using actionFunction. for example : If I printed "uni" all accounts that they names ...
1
vote
1answer
18 views

Unable to get content in plain text from notes and attachment file [closed]

Attachment att=[Select Body From Attachment where id='00P7F00000F8EQs']; string stringvalue = EncodingUtil.base64Encode(att.body); blob blobvalue =EncodingUtil.base64Decode(ss);
0
votes
0answers
20 views

I have 2 lookup fields in Lead for 2 different custom objects. I want to map both of them to 2 Opportunity custom fields upon Lead conversion

Brands__c , Corporate__c are two custom object. I have two look-up fields in Lead form to set Lead's Brand and Corporate Just as Account and Contact. Now I want to move both fields to opportunity upon ...
-2
votes
2answers
37 views

Can we invoke data from class without getter and setter methods [closed]

Is it possible for visualforce page to get values from apex class without using getter and setter methods? if yes means Please provide an Simple Example
0
votes
1answer
14 views

Find job status using the id returned from Database.executeBatch?

I have a class that is Database.Batchable which I execute via Database.executeBatch. How do I find the job status Id using the id returned from Database.executeBatch? It doesn't seem to match the Id I ...
0
votes
1answer
33 views

List.clear() not emptying my List

The project that I am working on has an API endpoint that is meant to upload a large number of records into three different tables: Careers, Degrees, and CareerDegreeRelationships. The endpoint is ...
3
votes
1answer
351 views

Salesforce opportunity stages

Is that possible to get the stage name, probability and forecast category using SOQL/Apex/APIs ? and I could not find that you can pull that data.
0
votes
1answer
33 views

how can i query all attachments related to a case?

I need to be able to query for all attachments related to a single case, even the attachments related to emails on the case. I also need it this code to get all attachments if there are multiple ...
1
vote
1answer
56 views

How to make ContentVersion public using Apex

I want to make a ContentVersion record publicly available using Apex. I know I can get the DistributionPublicUrl value from the ContentDistribution object. But I don't know how I should configure ...
2
votes
2answers
71 views

jsPDF in Lightning component: get blob in Apex controller

I'm trying to use the library jsPDF on a lightning component. The lighting component handles the creation, and needs to pass it to my apex controller (in order to save the file in Salesforce). ...
-2
votes
0answers
31 views

how to use constructor with two parameters in batch apex and how to write test class for the same?

While covering the below batch apex im getting a error 'System.UnexpectedException: Start did not return a valid iterable object.' I exected the batch class like: batchClass b = new batchClass(idSet,...