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.

Filter by
Sorted by
Tagged with
3
votes
1answer
58 views

How to determine Omni-Channel Agent's current capacity in APEX?

I have a requirement to get the list of online agents with available capacity. I could get the online agent list by querying UserServicePresence, But I can't figure out how to get the current ...
0
votes
1answer
56 views

Passing custom apex class to aura attribute

I have an apex class like this: public class AccountController { public class MeterInput { @AuraEnabled public String ME_Name { get; set; } @AuraEnabled public String ME_Meter_ID {...
0
votes
1answer
30 views

Test method does not cover line even though it's populated

I'm working on a test method for a trigger that I wrote that when a user is deactivated it sends an email to the manager. My problem is that in my test I populate the ManagerId field but the test ...
2
votes
1answer
25 views

How to get compactLayouts through apex Metadata API

I am trying to get compact layouts using metatadataapi. I am using https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls this repo to get ...
0
votes
1answer
30 views

Lightning init not getting second time

I have written a lightning component to update a field value & return back the detail page. This lightning component is getting invoked through a formula link on a detail page where i am passing ...
1
vote
0answers
69 views

Dynamic pdf filename to my visualforce page using iframe

Here is my visualforce page code where i am displaying pdf in iframe but i am not able to set "file name" of this pdf, <apex:page standardController="xyz__c" title="XYZ Form" action="{!Mergepdf}" ...
0
votes
1answer
22 views

How to include reminder in custom visualforce page with apex class

I am working on a visualforce page with custom pop & other requirements. But I am not able to include the Follow up time field. Now I am able to include remainderset checkbox. But how to add the ...
-2
votes
1answer
26 views

Method does not exist or incorrect signature: void CommentRequiredOnRejection(Map<Id,SObject>) from the type AP03_CommentRequiredOnRejection

public class AP03_CommentRequiredOnRejection { public static void CommentRequiredOnRejection(Map <Id,case >newMap) { Map<Id,case >rejectedStatements = new Map<Id,case>{}; ...
-1
votes
1answer
34 views

How to work with event.getParam?

Event.getParam('getString') is Returning undefined. Event.Param('name') is returning value. Image shown down is what returning from apex. Appended to Workspacelist `` This is lightning Component &...
-2
votes
1answer
30 views

How to get child object name from child relationshipname using Apex? [closed]

Example: Parent Object Name: Opportunity Child relationship Name: OpportunityLineItems Child object Name: OpportunityLineItem
1
vote
1answer
28 views

iterating list values to update multiple fields

Though the below code is working fine, since its not the right practice to hardcode index numbers so is there any alternate approach for the below code. - thanks List<Contact> cntList = [...
0
votes
1answer
32 views

Unable to view data on Lightning component but can View in console log

I am relatively new to Lightning and trying to learn it via one of the youtube tutorials and used same code for practice but I am not able to see the data on my Lightning component page. I could not ...
2
votes
1answer
89 views

SOQL Query For To Get the Tabs of Particular Application

I want Soql Query for to get the tabs(Navigation Items) under one application (App) in salesforce. Suppose Application Name is Data Management under these We have Database,Table,Column tabs as Custom ...
0
votes
1answer
18 views

Knowledge article created in test class not returning in SOSL

I have a class which is used in Chat bot to return the article links to the customer according to the product he selects. This is the class that I have created : public class ...
0
votes
1answer
24 views

How can i test inside for loop apex test? [duplicate]

public static List<priceBookEntryWrapper> searchproduct(String sampleId, String seriesValue, list<string> gradeValues){ system.debug('seriesValue->->->->->->->->...
1
vote
1answer
34 views

Changing Date time using DateTime - format(dateFormatString, timezone)

In below execute anonymous code I am seeing a strange behaviour. DateTime myDateTime = DateTime.newInstanceGMT(2019, 12, 30, 0, 0, 0); system.debug('myDateTime === ' + myDateTime); DateTime ...
2
votes
1answer
45 views

JSON Deserialize Error Question

On workbench I am getting: message: Unexpected parameter encountered during deserialization: response at [line:2, column:18] errorCode: JSON_PARSER_ERROR I validated the JSON so I don't know ...
0
votes
0answers
52 views

Break a list of id's to multiple list into equal number of records [duplicate]

I have created a list of id where i am adding record id of a custom object. List<Id> validProjectId = new List<Id>(); validProjectId.add(project.id); Now that this list has suppose 1000 ...
0
votes
0answers
30 views

Retrive the Ip Address of SF instance which the callout is performed

We gave third party service to whitelist all the IP's range which salesforce recommended to whitelist. when I make the Integration and call to their service, I get the following error from their ...
0
votes
1answer
40 views

Files are not uploaded into the content version

I had createed the component to upload the files. When i am using the component in salesforce it is uploading the files into the contentversion but when i am using these component in production after ...
0
votes
1answer
61 views

Unauthorized Access using Named Credentials [duplicate]

I am using Named Credentials oAuth2.0 protocol to connect with Xero. I have setup Auth. Provider and Named Credential. Named Credential is also authenticated. I have followed the steps mentioned here ...
1
vote
1answer
25 views

Deployment failed with Apex test class : CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

I'm trying to create test class for a custom object called "Partner Involvement" under opportunity, which identify the associated reseller or partner for the opportunity. it was working fine with ...
1
vote
1answer
35 views

How to render a Currency field with decimal places as specified on the Custom field without trimming zeros in APEX [closed]

When we add a Custom field of these data types 'Currency field/ Number field/Percent' as merge fields on email template or adding the merge field on a document, trailing zero's are removed. Trailing ...
1
vote
1answer
19 views

I need an InputField picklist to change the value displayed on vf page when I change a different InputField picklist value

The way I am currently getting the inputfield picklist values into my custom controller is by using a javascript to find the selected value like this: function CallPick1(id) { var type = ...
2
votes
1answer
49 views

How to add onload event handler on dynamically created iframe component in lightening?

i am dynamically creating and adding an iframe like this - $A.createComponent( 'iframe', { 'aura:id': 'iframe', src: iframeUrl, }, function(createdIframe, ...
1
vote
0answers
38 views

Logic written in Platform Event Trigger doesn't work, but the same logic works from ProcessBuilder

I am using Platform Events, to fire a webservice(HTTP request) call post transaction commit, let us say Once Account is Created or Account Updated. In the process of doing so, I am able to create/...
2
votes
2answers
57 views

How Apex Replay Debugger works in the background?

I am just wondering how apex replay debugger works with just a log file. It seems the log does not necessarily provide all the variable states in the log file. I have written a code in the developer ...
0
votes
1answer
38 views

Force logout User from Connected App [duplicate]

We have a connected app which is android mobile app. We want the Users using that app to force logout of the app and re-login again. To do so, I have given the session time out value to 15 mins in ...
0
votes
1answer
27 views

After Insert trigger behaviour if insertion execution fails

I have a custom object named 'shift_cancellation__c'. This custom object records are being populated by parsing an email. I have a class named 'shiftCancellationListener' that parses the emails and ...
1
vote
2answers
42 views

Error 'Ending position out of bounds: 7' in LightningSelfRegisterControllerTest.testSelfRegistration

Seeing the following when we run the LightningSelfRegisterControllerTest: LightningSelfRegisterControllerTest testSelfRegistration System.AssertException: Assertion Failed: Expected: Passwords did ...
1
vote
1answer
23 views

Not able to search fields using SOSL for Case module

I am trying to fire a SOSL query in Apex to find phone number exits in Case module. Below is the example of one of the cases that I am trying to search. I am using following query to search the ...
1
vote
2answers
63 views

Geting 88% code coverage while running test class but while deploying it in production it is giving 63% code coverage

I am getting 88% code coverage when I run the test class but when I am deploying it in production it is giving 63% code coverage Below is the apex class code public class ...
3
votes
2answers
108 views

How to use Stub API in the following scenario?

I am trying to understand Stub API a bit: My Class: public class DistributedMSelector { public static Map<string, user> getUserMap(Set<String> employeeIdSet){ Map<String,...
1
vote
1answer
33 views

How user is able to Update Record

I have a custom object whose OWD is Public Read/Write and the profile of user has Read and View All permission for that Object. Now I have a Custom Button on that Object using Aura component I'm ...
1
vote
2answers
33 views

Unable to save a new Contact through a custom VisualForce form

Using VisualForce & APEX to submit a new Contact record. Generating a custom form and trying to save the records as a new 'Contact' on my SF instance. Once I click on 'Save' button below error is ...
1
vote
1answer
32 views

How to Prevent inserting attachment for a custom object based on Parent record condition? [closed]

I need to Prevent inserting attachment if parent record's status is "Closed". I have tried with before insert where i couldn't get parentid so it is not working. Any directions/suggestions will ...
2
votes
2answers
32 views

RestResource extracting array from JSON packet

I am currently receving a JSON packet from an external server and placing the values in variables for further use. The JSON packet has an array that can and will grow depending on the amount of assets ...
2
votes
1answer
30 views

SOQL query for all Users who have read access to Task object

I am trying to write a SOQL query to find a list of Users who have read access to the standard Task object but my query keeps coming back empty. Is there a better way to do this? I have a dropdown ...
3
votes
1answer
56 views

How can i create a Map for unrelated objects?

Background We create shadow records for Contacts that are Inactive (record type) and I am working on building a UI for the user to Activate one or more shadow records associated to that Account. ...
0
votes
1answer
53 views

APEX CPU Limit Exceeded

I am currently receiving an APEX CPU Limit Exceeded error when trying to save work orders. This is happening with any field updated. The error received is RG_WorkOrderTgr: System.LimitException: Apex ...
5
votes
1answer
55 views

Why are my matchers not working after adding an overloaded method?

To help getting past our permission checks during unit tests to test actual functionality, I created a mocking class so people could just call the mocking method they needed from that class for the ...
0
votes
1answer
31 views

Is it possible to add the all standard and custom objects list to the custom settings and use it in batch apex?

We are doing full org deployment, we need to update the record owner to system admin for all the objects records. So initially we created batch apex to implement this for accounts object. But we have ...
4
votes
1answer
83 views

Static variables work differently in Apex?

VF Page <apex:page controller="StaticTestOne"> <apex:form > <apex:commandButton id="smtng" action="{!someaction}" value="save"/> </apex:form> {!someoutput}...
2
votes
1answer
41 views

@AuraEnabled method - when I call this from client I get an error

Apex methods that are to be cached must be marked as @AuraEnabled(cacheable=true) client side @wire(updateLots,{victim : '$payedLots'}) updateLots(data, error) { console.log('inside payed'); ...
1
vote
1answer
44 views

Is there any way to Prevent Upload a file in notes & attachment for a custom object?

I need to prevent uploading file in Notes & Attachments when parent record's status is set to some value. ex: If parent record's status values is Submitted then user should not be able to upload ...
1
vote
2answers
29 views

How to access Owner of Parent Record of FeedItem

I am trying to send emails to the owners of cases when people post to the case feed. Traversing up through parent records seems to have some strange functionality: for(FeedItem FI : FeedItems ) { ...
1
vote
1answer
15 views

Invalid date and time error [duplicate]

I have a @restResource that's receiving a JSON payload as a string. I am taking that payload and placing it into a Map<String, Object> variable. I'm trying to save the date/time into a variable ...
0
votes
1answer
45 views

Unable to update to null value

I have the following code. The SAP Matrix__c Field is a lookup field. When it references another object. If it finds a match it will update to the proper Id but when it does not find a match, it does ...
4
votes
1answer
59 views

Is there a way to prevent SOQL from returning records that have been locked with FOR UPDATE?

If I have a class that is using FOR UPDATE to lock a record. Is there a way to prevent another instance of that class from calling those records that have been locked before the previous class is done ...
1
vote
1answer
33 views

How to make sure managed package trigger can be executed by everybody

Our managed package adds a trigger on Contact and Lead insert/update. After an organization installs the package, the trigger is executed whenever a Contact or Lead is inserted/updated, even if the ...