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
0answers
11 views

Not return correctly Json in Method GET Apex, return error page in html

I decode a Json in a Get method via PHP and php returns the answer in correctly Json, however in apex it returns me a page with an error in html, but with the Status Code 200. My client programmer ...
3
votes
3answers
444 views

JSON.serialize: is it possible to suppress null values of a map?

I tried to serialize a map with null value (api 45): Map<String, String> bodyMap = new Map<String, String> {'key'=>'value', 'key2'=>null}; System.debug(JSON.serialize(bodyMap,true));...
0
votes
1answer
25 views

Preventing Duplicate Records to save in apex

I have created a lightning component that accepts input from user and saves the data to the custom object. Now i want to check duplication of the record based on two fields. Let suppose Name and Date, ...
0
votes
1answer
68 views

Apex Email Validation [duplicate]

String email ='shilpa..test@gmail.com' Boolean isValid = Pattern.matches('([a-zA-Z0-9_\-\.]+)@((\[a-z]{1,3}\.[a-z]{1,3}\.[a-z]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,}|[0-9]{1,3})',email); ...
0
votes
0answers
36 views

Lightning:RecordEditForm - Set values to null after form submission

I have a Lightning:RecordEditForm that creates a record after the form has been submitted. Once the form has been saved, I require the values on the form to be set back to null, as multiple responses ...
0
votes
0answers
25 views

How to get all record Ids of the View that is currently opened by clicking a button

How to get all record Ids of the View that is currently opened by clicking a button. (I have used {!GETRECORDIDS($ObjectType.obj__c)} but for this we have to select the records, I want to get Ids ...
0
votes
1answer
10 views

How to mock test a rest API implementation

I have a method public static Map<String, Object> createNewAccessToken() { Map<String, Object> access_token = null; HttpRequest req = new HttpRequest(); req....
0
votes
0answers
19 views

Passing Javascript Array to Apex Controller always results in null values [duplicate]

I have a Visualforce page where I want to pass a javascript array in Visualforce to my Apex Controller. However the values are always null in my List in Apex. I have a commandButton that fires ...
0
votes
1answer
24 views

How to post a financial force sales invoice

We are working with the Salesforce REST API for interacting with an installed FinancialForce package. This process has been mostly painless right up until we needed to POST an invoice. The apex ...
0
votes
2answers
29 views

Cannot write test Quote object for Trigger

I have a Quote trigger for which I am trying to write tests. Here is my test class. However, I am getting some wierd errors while writing this. @isTest public class TriggerQuoteTest { @...
3
votes
1answer
116 views

LWC and complex parameters

I am trying to pass a list of objects to Apex from an LWC controller, and it looks like the Apex controller is getting the right sized list, but nothing is populated. Does anybody have any idea of ...
4
votes
3answers
193 views

How do I pass a SObject record from LWC to a custom Apex method to persist data?

Disclaimer: My answer to this question does not deal with a real business use case scenario. The approach mentioned in my answer was found to be working while going through this question. The answer ...
0
votes
0answers
11 views

Possible to fetch lightning quick actions on an object

For example if i wanted to do a SOQL query of all opportunity actions, how would i do that? Basically i have 12 quick actions that create child records on a custom object, but i want them to all use ...
0
votes
1answer
30 views

get set fields have stopped working

Get and set methods have stopped working after I customized my page with Bootstrap validator. This was working fine until this morning. I have now also tried removing all and bootstrap JS libraries ...
0
votes
1answer
13 views

The “Where is this used?” feature, does it actually work, well at least for list buttons?

I'm going through the JS buttons to convert to lightning. The list buttons... when going through them it doesn't say they're on a page layout when you click on "where is this used"...at least for 90% ...
0
votes
1answer
19 views

Issue with constructor when calling class from a Trigger

I have written a very simple trigger, but when I am trying to call the class I get 2 errors: BenchmarkProgressTriggerHandler Line 11 Expecting '}' but was: 'for'; BenchmarkProgressTriger Line 3 ...
0
votes
1answer
14 views

Salesforce XML to Gzip compressed file

is there any native Salesforce Solutions available to convert a xml file as gzip compressed file? We are trying to integrate with a 3rd party , which accepts a gzip compressed xml file and then ...
-2
votes
2answers
28 views

Method does not exist or incorrect signature: void CreateUse(List<Ent_Req__c>) from the type Usrcreation_controller

I am trying to create a user record based on other record getting created, I added all the code in apex class and I am trying to call apex code method in my trigger. I am getting incorrect signature ...
1
vote
1answer
26 views

How can I get the name of the current app to the apex controller?

I need to get the name of the current app in the controller. So far I'm trying: public static String getAppName() { UserAppInfo userAppInfo = [SELECT Id, AppDefinitionId FROM UserAppInfo ...
2
votes
1answer
60 views

System.XmlException: start tag unexpected character =

This is the full error: System.XmlException: start tag unexpected character = (position: END_TAG seen ...<source> Bicycling</source><media:contenturl=... @1:688) So from my ...
0
votes
0answers
22 views

Unable to write BestCommentId on FeedItem in test class

I am trying to write a test class to test an Apex class that uses FeedItem object. The Apex class checks if the FeedItem record has a BestCommentId and does some actions. A snippet of the test data ...
0
votes
2answers
25 views

Trigger on Sending Attachments in Related List not finding the attachments

I have cobbled together this code in an attempt attach the files in the attachment related list to the email on the change of a field in the Expense record (custom object). The code saves but i get a ...
0
votes
1answer
22 views

SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.:

Error: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds. I want to send email through the snippet in below. List < ...
0
votes
0answers
28 views

Mock HTTP Call Out In Test to Return XML

I am very new to HTTP Callouts and now I am in the testing phase. My HTTP Callout returns XML This is the link. I input a company already, soulcycle, in case anybody wanted to see what was being ...
0
votes
1answer
20 views

Formatting Time after clocks change

Background I have a simple apex function which returns a date time formatted using a time zone: public String getFormattedDatetime() { TimeZone tz = UserInfo.getTimeZone(); return ...
0
votes
1answer
27 views

How to execute Batch Apex form Visualforce Page?

I have three batch classes, I want to execute all three batch classes through button click using visualforce page at the same time. `LoanofficerBatch lob = new LoanofficerBatch(); ...
0
votes
2answers
43 views

Error: Variable does not exist: Commitment__c

I'm trying to uncheck a checkbox on the opportunity object called Commitment global class UpdateContacts implements Database.Batchable<sObject> { global Database.queryLocator start(Database....
3
votes
1answer
133 views

Salesforce LWC - Pass standard object to Apex Class [closed]

I am trying to pass a Case SObject to apex class as parameter, but is not working. I did not see the System.debug on the console. Why? //wire the record @wire(getRecord, { recordId: '$recordId', ...
0
votes
1answer
17 views

Integrate custom Quote tool with Salesforce

Is it possible to integrate a custom quote tool my company's developers created with Salesforce? Currently, when a quote is submitted via our internal tool and email outlining the specifics is sent to ...
0
votes
2answers
71 views

How to fetch data from custom object and display it into Lightning Web Component?

As its my first time working with Lightning Web Components, please help me fetching data from the custom object, I didn't understand what's going wrong in this. Below is my code Thanks in advance!! ...
1
vote
1answer
54 views

How can I set the ContentVersion.FileType when creating new File via Apex?

I'm working on a webservice to create new Salesforce Files. To validate the underlying methods, I manually uploaded a PNG file, which shows up in the file preview in Files. I can retrieve the ...
1
vote
1answer
17 views

Set focus on <apex:pageMessage/> after redirect

I am setting an error paremeter then redirecting to another VF page like this: PageReference backtosite = new PageReference('/apex/Fs_ViewSiteAddress?id='+parentId); System.debug('...
0
votes
1answer
30 views

Dynamically replace merge fields from an Email Template in Apex?

I want to replace the merge fields in my email templates with values I have in my class, with the intention of serving them in the front end for users to further edit. My template looks like this: ...
0
votes
2answers
34 views

Running Batch in Execute Anonymous but throwing error: method does not exist or incorrect signature void format string from the type anon

I need to run a scheduled batch out of schedule. It has been working every day perfectly for months. I went to try to run it in Execute Anonymous but I get the error: Method does not exist or ...
0
votes
1answer
21 views

MISSING_ARGUMENT, Id not specified in an update call: []: [closed]

I am getting an error : User can create a task from account or contact, on a task contact is a required field, but when a user tries to create a task from contact it fails. public with sharing ...
0
votes
1answer
22 views

Attempt to de-reference null object

I am trying to insert queues using metadata api but getting error while inserting sobject in the queue. MetadataService.QueueSobject obj =new MetadataService.QueueSobject(); obj.sobjectType='Account';...
0
votes
0answers
24 views

Future call firing twice on leadconversion trigger

Here is a brief of what i am doing on my trigger Before update and Before insert updates a Account lookup field After update and after insert converts the lead if the lookup field is filled in ...
0
votes
0answers
17 views

Chart Not display in visualforce

My code are saved without error but the chart does not display in the VF page portion of the VF page: <apex:page renderAs="pdf" showHeader="false" sidebar="false" applyBodyTag="false" ...
0
votes
0answers
15 views

Auto approve record after it were submitted for approval

I try to approve record automatically after it was send for approval by standard functionality. How can it be done through apex? Here is my code: trigger ITAssetTrigger on IT_Asset__c (after update) {...
0
votes
0answers
26 views

CustomLandingController seems to be not working when SSO is used for community login

I've a requirement to setup customer community(SSO based Authentication/ No Username-Password login allowed) with few Pages to be displayed if User is coming to community for the first time. Here, ...
0
votes
1answer
19 views

How to modify Contacts/Lead related to a Task with a TaskRelation upon Task Creation

We have some APEX code that relates Contacts and possibly a Lead to a Task using one or more TaskRelation objects. Therefore the pseudocode is: Database.SaveResult[] srList = Database.insert(newTasks,...
0
votes
0answers
16 views

Redirect from visualforce with basic authorization header

Is it possible to send a Basic Authorization header from a visualforce page and redirect a user to a different non-sf site? If not any way on how I can do this? I was able to send a HTTPRequest with ...
0
votes
0answers
6 views

can $Network.NetworkUrlForUserEmails be generated dynamically?

I am going to disable to 'Welcome email' and write a workflow on User which triggers an email alert with the VF email template. I tried using the field $Network.NetworkUrlForUserEmails in VF ...
1
vote
0answers
28 views

Apex Sharing of Case to All Internal Users

I am having an issue whereby I have created an Apex method to create a CaseShare record for a particular case. The manual share record provides Read access to the standard group "All Internal Users: ...
0
votes
1answer
11 views

Object New button overriden with VF, loads continously

I have a vf page that overrides a custom object's New Button. The original purpose for this was to run a custom check in the constructor, if that check passes I want them to be redirected to the New ...
2
votes
1answer
27 views

DescribeFieldResult.isQueryable returns true but field is not supported

I'm writing a component to search all possible objects a lookup can point to and am running into an issue. The code below returns a list of strings to be used in a SOSL query. I've hard-coded Task and ...
0
votes
1answer
30 views

Classic Master Encryption Keys in Apex

I'm using the Crypto class but want to leverage the built-in Master Encryption Key store instead of saving my own AES keys somewhere in the database. Is it possible to get access to the Master ...
1
vote
0answers
23 views

How to Make Sure Apex Class is Called after Campaign Member Automatically Added/Removed

Been running into this issue for a while and would love some assistance. More than anything, I think this is a question about how to work around permissions. I hope this is the right place to ask this ...
0
votes
1answer
36 views

How to serialize a custom Salesforce Class object with nested objects to json

I am a noob on serialising in SF. I have a SF object which i Want to serialise to JSON. The object contains nested data. Do I need to create all the nested data first an add these to the outer ...
0
votes
1answer
42 views

Is there a way to disable Browser Close[X] button? [closed]

We have a working solution wherein an Opportunity is closed(won/lost), a pop up opens and series of work is done(like a wizard). The pop up is created as per the below code: <apex:page ...