Stack Exchange Network

Stack Exchange network consists of 174 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.

1
vote
2answers
27 views

How to get the Connected App used from an Apex trigger [duplicate]

I have an Apex Job that is being triggered from an 'afterInsert' trigger, but I don't want that Job to be executed if the insert is being performed by a specific external application. I just need to ...
0
votes
0answers
14 views

How to encrypt using ECB Mode in Apex? [duplicate]

My client asks me to use AES ECB PKCS5 128 encrypting method. I found a way to do it via JavaScript but that can presents some security issues. Unfortunately, ECB mode is not supported in Salesforce (...
-3
votes
1answer
50 views

How to write a method to remove non alphanumerics in a string and display it in a list [duplicate]

method to remove non alphanumerics in a string and display it in a list. public static list<string> s(){ String stg = 'ABC,DEF,GHI,JKL'; List<String> lst = stg.split(','); ...
1
vote
1answer
28 views

Test Class for the below code

i have written a test class for the following code, but it throwing a error like "Attempt to dereference a null object". can anyone please help me to overcome this. public class leadclass { ...
2
votes
1answer
22 views

Trigger unexpected behaviour when used in bulk but not in single update

I have a trigger in the contact (before update and insert) that when a boolean field is true (in insert) or when it changes from false to true (in the update) it goes and find all the opportunity ...
1
vote
1answer
26 views

How can we keep the global variable at Apex Batch

I have a use case to run sequence of Batch to execute my logic. There I need to have a way to start the Batch and terminate it, So for that I keep a global variable to store the records and according ...
0
votes
1answer
16 views

How to round to end of month from a date

I am trying to round a date to end of the month.How can we achieve it? Eg: I have a date like 13/03/2019 it is middle of the month.i want it to be rounded to 31/03/2019 i.e, end of month. I tried as ...
-2
votes
2answers
21 views

Have custom map as return type in a class!

I am trying to have a class with map as return type. I am not sure how to return a custom map. Here is my code: public static Map<String,Integer,Integer,Integer> getMdus() { Map<String,...
1
vote
1answer
24 views

Error: Invalid conversion from runtime type Map<String,ANY> to List<ANY>

While I am working on my Apex Specialist super badge, I am got this error message while I am testing my WebService class. Here is the Callout class: public with sharing class WarehouseCalloutService {...
0
votes
1answer
17 views

Trigger On Campaign Member Status

I have a method that is called from my Campaign Member Trigger Handler. If a Campaign member's status changes to "Opened" then Email Opened__c field on the contact object should be incremented by ...
1
vote
1answer
127 views

Checkmarx Code Quality Warning

After running a Checkmarx scan it returned a code quality warning on a method due to Query: Bulkify Apex Methods Using Collections In Methods. The method is very simple: @AuraEnabled public ...
0
votes
3answers
27 views

Trying to increase code coverage for a trigger that deletes events

So I'm trying to write a test class to meet code coverage requirements to push up this trigger: trigger DeleteEventsOnCancellation on Case (after update) { for(Case c : system.trigger.new){ ...
0
votes
0answers
17 views

How to change UserServicePresence in Salesforce and How to get the list of Status shared to a profile?

I have a requirement to create a Global Quick Action that would display all the "Service Presence Status" available to a Live Agent and Change the status when he selects any of the status available. ...
0
votes
1answer
22 views

can I update platform version on new sandbox

I created a new sandbox but since its a copy from production it is on API 44 all other sandboxes are API 45. is there a way to manually update the API version on the newly created sandbox to API 45?
0
votes
0answers
21 views

Issue in querying in apex aura enabled method vs execute anonymous

Hi I have an aura enabled method that returns a Cycle Record, The issue is some of the fields are returning null in the aura enabled method compared to querying in execute anonymous and workbench. ...
-2
votes
1answer
25 views

how to create dependent picklist in vf page

I am having a multiselect picklist in that am displaying the list of profiles in the org using SOQL Query.My usecase is like when i click on any profile/profiles those related applications should be ...
0
votes
1answer
14 views

Want to fetch field from AggregateQuery

I created a Custom Settings and add some records in it. On the basis of that value i write an aggregate query and i want to store that field value in String. // List to fetch all records from ...
-2
votes
1answer
48 views

Test class for delete method for RESTAPI for Delete

how to write test code for below rest api service global with sharing class Create_HH_Survey { @HttpDelete global static void doDelete() { RestRequest req = RestContext.request; ...
1
vote
2answers
29 views

Adding a new method to Controller of Lightning component resulting a constant error

Every time a new server-side method is added to existing component that has controller tag and it's successfully calling other methods in the same class, that component has an issue with recognizing ...
0
votes
1answer
22 views

convert javascrip function CryptoJS.HmacSHA256() to apex

I am trying to convert the below javascript code into apex. The javascript code is below- timestamp = Math.round((new Date()).getTime() / 1000); var method = request.method; var path = request.url....
2
votes
1answer
116 views

Unable access to opportunity object fields in apex classes and trigger?

Unable to access opportunity object fields in apex classes and in triggers also .even in the standard way of creating apex classes. getting an error as variable doesn't Exist, even field is available. ...
0
votes
2answers
26 views

Convert List<String> into List<Schema.SObjectField>

I have a below code public PageReference SyncCandidatewithMirror(map<Id, cxsrec__cxsCandidate__c> NewMap,Map<Id, List<String>> fieldChangedMapChanged, List<...
0
votes
0answers
24 views

Sublime Text with Mavensmate reverts changes made to package versions in Org

I have Sublime Text with Mavensmate plug-in. I have Mavensmate application which is connected to the Org. I made a change to the version of a package in an apex class. After that, I refreshed all ...
0
votes
1answer
37 views

unable to save record which is created through vf page

I have created vf page for new record creation of custom object. when i click to new button i am gettting vf page where based on case field value (i.e. CaseNumber) i am able to prepopulate other ...
4
votes
0answers
76 views

Apex trigger takes a lot of time to access items in list

I have a simple Contact trigger in a sandbox org that is exhibiting some serious performance issues. After doing some debugging it looks like the issue boils down to accessing the items inside Trigger....
1
vote
1answer
32 views

system.runas and user's time zone

I am writing a test class for testing an API, which populates the value of an iVAR with the logged in user's time zone. In real time, this API works fine. If the logged in User's time zone is EST, I ...
1
vote
1answer
19 views

Trying to flip checkbox values

I am trying to create an Apex page attached to a List Button that will take the selected records and flip the boolean value of a particular column. I have the page basically working the way I want it ...
1
vote
2answers
45 views

Reload Lightning Data Service after updating the record on the server

I have a parent component that uses lightning data service (lds) to get the record. This record is then shared to all of it's children as needed using data binding. I need to update the record using ...
2
votes
1answer
86 views

Ant Deployment Tool deployment not connecting with API to Production since Spring 19

Since the Spring release has updated in our Production environment, we are seeing strange errors when validating with the Ant Deployment tool which seems to suggest that it suddenly stops being able ...
6
votes
1answer
37 views

Apex Approval.lock, programmatic locking and record editability

Background: In Winter '16, Salesforce introduced the Approval class for setting approval locks and unlocks through Apex (release notes). Since then, my company has been leveraging this functionality ...
0
votes
2answers
33 views

How to insert ContentVersion with preview in files?

I can insert an image, but it's without preview. I can open the image after downloading, but a need preview. It writes in files "No preview available". How to fix that? Here is my code. js: ...
1
vote
1answer
55 views

How to compare custom label value in controller with '!=' operator

Controller: public List<SelectOption>FlagPickList{ get{ List<SelectOption> FlagOptions = new List<SelectOption>(); FlagOptions.add(new SelectOption('...
1
vote
0answers
23 views

How to fetch multiple selected record Id in conga composer from visualforce page?

When i selected multple record and click on the Button then On redirect conga composer then showing this error like:Not authorized. The [a0q6C000005aoY3QAI, a0q6C000005aoXoQAI] parameter ID is not ...
1
vote
1answer
44 views

Creating Test Class for Einstein Bot Invocable Apex Class to Search Articles

I've created an Invocable Apex Class that allow us to search articles and return the resolution to the bot. The Apex class works as expected in the sandbox. However, I'm struggling to create a test ...
0
votes
2answers
44 views

notify user by sending an email to user whose last-login is more than 1 day

Here is my code, please check global class LastLoginEmail implements Schedulable { global void execute(SchedulableContext SC) { List<User> uds =[SELECT Id, LastLoginDate, Email FROM ...
0
votes
0answers
11 views

Is there an api to extract service resource and their available slots in fsl [duplicate]

I need a way to get all the service resource with available slots in fsl.
1
vote
1answer
26 views

How to do inline editing in pageblock table values

I am passing a list to the pageblock table and my table looks like below i want to edit the table values. I tried the below code. This is my VF Page code <apex:pageBlockSection id="section2" ...
0
votes
2answers
19 views

Error while logging into salesforce using Google Oauth

We have our Org connected with google using open-id configuration. When User tries to log in to Salesforce using Google, the system checks for the user's gmail id in slaesforce user profile and if it ...
0
votes
0answers
17 views

What is best way to delete records all parents and childs in salesforce

I have a use case where i have to clean up of data. I want to delete around 1000 records out of 10,000 records. Is there any way i can delete A->all lookups and All Master, then all lookups-> all ...
0
votes
1answer
33 views

Dont want to associated contact to other objects if status is pending

i want a rule where i dont want to associated contact to other objects if contact status is pending.I am not sure how can i achieve this .any suggestion
0
votes
1answer
19 views

Delete Duplicate Opportunity Record, Keep Original Record

My goal is to write an apex trigger that will delete duplicate Opportunity Records based on the Opportunity Name but retain the first record that is created. I believe a before trigger would be the ...
1
vote
1answer
22 views

How to get checkbox value and change tht button's class with <aura:if>?

I want to change the button's style (class) by clicking and changing checkbox field Selected__c. But I always get class="blueColor" even if checkbox is true. When I write <aura:if isTrue="{!v....
0
votes
1answer
20 views

Batch Class execute using Cron job Schedulable

I am trying to run my Batch Class called UltimateParentAccount for every 6am and 12pm using a Cron Job Schedulable name ScheduleUltimeParentAccountBatch. I tested my batch class and it works well, ...
3
votes
2answers
184 views

SOQL getting the grandparent of an account from contact

I am trying to get the Ultimate Parent Account from my contact up to 3rd level parent. Here is my SOQL code: SELECT Name,Account.Parent.Name, Account.Parent.Parent.Name, Account.Parent.Parent.Parent....
-3
votes
1answer
39 views

Test class for sobject record type [duplicate]

I am trying to cover the below class. I am getting 71%. Can you please let me know how to cover . public class OpportunityRecordTypeSelectionCtr { @AuraEnabled public static string findRecordTypes(...
0
votes
1answer
23 views

Custom Hierarchy Error

Hello I am relatively new to Salesforce and am trying to create a visualforce Account Hierarchy page that displays more than 500 accounts. I'm receiving this error whenever I test out my link on most ...
0
votes
1answer
35 views

Aggregate SOQL Query Cannot Aggregate

In my Product Object there is a list of ProductMatrices. I want to total sum of matrices field. So for that i used Aggregate soql. But its not showing aggregate result. public List<AggregateResult&...
3
votes
1answer
24 views

How can I set the data for a report testing?

I have a schedulable class that runs a report and send an email with the results of that report. Everything works fine when I'm testing it with the report filled with data, but when the report is ...
1
vote
1answer
42 views

How to pass selected multiselect picklist and pageblock table values from one vf page to another

I have a multiselect picklist and pageblock table in a visualforce page i want to send the selected multiselect picklist value and modified page block table value to the next visualforce page This is ...
1
vote
1answer
22 views

Get the Id of a Layout from its name

Im looking to use a combination of the tooling api object ProfileLayout and the SetupAuditTrail object. I can query the SetupAuditTrail and with a bit of parsing extract the names of any layouts that ...