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.

0
votes
2answers
10 views

Inner Class Cover in Test Class

Please help me why my code coverage is showing 0% . See my class code and test class code where I have written wrong? Class public class InnerClass { public class Wrap { public string ...
0
votes
1answer
19 views

Trigger to add contact in Account Related list when contact is added through lookup on Account

I have one lookup field (Add contact) on Account. My requirement is that when we update the account lookup field and select a contact. Then that contact should get attached in the related Contact List ...
0
votes
2answers
14 views

Locking rows at the last minute

I have a utility routine (pasted below) that I use for all writes to the database which lets me catch errors. This works perfectly in all but one of my orgs. In that org, I generate a ton of ...
0
votes
0answers
10 views

Apex Multipart HttpRequest - With JSON and BLOB

I am trying to consume a Google Drive API to create a file in an ApexController. I was successful in creating a file in the root folder without specifying a name using the code below http h = new ...
0
votes
0answers
11 views

lightning component to sort task based on status then second priority is created date

I am trying to sort the lightning component of task based on status then by created date. When I click on sort by Status, it should update the second sort of created date by ascending. So in the below ...
0
votes
1answer
10 views

Combine two List<Map<String, String>> for unique list

How can I combine two lists of maps so that only the unique values in the list remain? I thought about doing some nested for loops to compare the two lists, but it seems a bit messy. Is there a ...
2
votes
2answers
56 views

How do static and member variables behave in a. stateful batch classes?

Suppose I have a batch job and I want to maintain state (i.e. want to keep a log of the record ids that I've processed, or keep a running total, or something). When would I use class variables vs. ...
4
votes
2answers
130 views

SOQL Query Where Id “In” Versus “Equals”(=)

I just stumbled upon a soql query where somebody did the following List<String> names = new List<String>{'John', 'Moe', 'Jeanette', 'Tony'}; List<Client__c> clients = [ SELECT ...
0
votes
2answers
21 views

System.TypeException: Invalid date/time: 2019-01-03T00:26:01.711-02:00

Im trying to format this String into DateTime. String 2019-01-03T00:26:01.711-02:00 Code String data = '2019-01-03T00:26:01.711-02:00'; Datetime dt = DateTime.parse(data); Exception System....
0
votes
1answer
19 views

Lightning component button refresh

I have a lightning component button that updates the status of a case when clicked in Lightning. Is there a function that I can use to have the page refresh when clicked because as of now, I have to ...
-2
votes
0answers
15 views

convert Bulk of Leads,ten thouand. one by one serially.my leads are in csv.any ..? [on hold]

global Database.QueryLocator start(Database.BatchableContext context) { return Database.getQueryLocator([SELECT Id,LastName,LastModifiedD__c FROM Lead ]); } global void execute(...
1
vote
1answer
37 views

Select Knowledge object in SOQL query

I'm trying to get all articles which are published and online. In my user I turned on all permission set and so one to have access to Knowledge. List<Knowledge__kav> myList= [SELECT Id, ...
0
votes
0answers
13 views

How to get column values properly in excel from vf?

We have created vf page that returns excel file. for 4 columns the values are updating randomly in excel. Please check the screen shots and code. The node1,machineid1, node2,MachineId2 columns are ...
-1
votes
2answers
22 views

Disclaimer Popup on Chatter Group [on hold]

I want to add a disclaimer message on a chatter group. When new user join chatter group he/she needs to accept disclaimer message. Can anybody help me on this because there is no standard way to do ...
0
votes
0answers
16 views

how to conditionally render a gauge chart based on values of a numeric array in Visualforce

controller--snippet if(pos >=0 && pos <assTElist.size()){ lstTrans = [select Maturity_Assessment_Question_ID__r.Transformation_Element__c fa, ...
0
votes
1answer
24 views

My Test Class Isn't Passing

I have a test class which is testing a controller but I cannot get the test to pass. Here is the controller class: //a controller class to get incidents for display on VF page and then //anonymise ...
0
votes
2answers
25 views

can we use multiple extensions with custom controller

My first doubt is can we use multiple extensions with custom controller. If yes, please check below code and let me know can I call "dosomething" method of Ext2? Ext1: public with sharing class Ext1 ...
-1
votes
1answer
15 views

queried inside controller so how can i access id in that through apex test class?

How can I test below code which is inside controller? public with sharing class AccountDetails{ public Id accRecId; public List<account> accRec { get; set; } public ApexPages....
0
votes
1answer
17 views

How to insert a dummy value for custom metadata setting

I have a batch class and in the constructor of the class, I have a query in which it queries for a Queue. Constructor: public BatchClass(){ final String QUEUE_NAME = GlobalPropertyCache.getValue('...
0
votes
0answers
17 views
0
votes
1answer
22 views

getting Unexpected parameter encountered during deserialization using REST service

why below REST web service does not properly deserialize the input argument?Please help me out? @RestResource(urlMapping='/HH_Survey/*') global class HH_SurveyController { public ...
3
votes
2answers
37 views

Need help understanding this apex trigger example

I'm just starting out in apex. I want to create a trigger that counts the number of attachments in a record of a custom object. I came across an example here. Here's the trigger code: trigger ...
0
votes
2answers
23 views

Second apex method executing before the first one finishes

I have a vf page displaying several Multi select custom buttons. And I am calling a apex method every time one of the button is clicked from VF page using actionfunction. But if I click 2 buttons in ...
0
votes
0answers
11 views

unable to convert WSDL to Apex, getting Error: Failed to parse wsdl: targetNamespace not specified in wsdl:definitions

below is code <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <wsse:Security xmlns:wsse="...
4
votes
0answers
18 views

Cache.Session not honoring ttlSecs argument?

I'm using session cache and trying to set the TTL (lifetime) to 60 minutes. However it is expiring much more quickly (it appears to be using the default 5 minute expiry). The docs say TTLs is ...
0
votes
0answers
15 views

Maintain the State of a Controller when Opening a Shared Controller VF page as a Console Tab

I am trying to pass all of the values from an object from one Visualforce page to another. objX is queried for two fields id and fieldOne and stored in a list on the controller: listObjX The object ...
-4
votes
0answers
25 views

Convert Process Builder logic to code [on hold]

I am trying to convert PB logic to Apex class and call the Apex class from a trigger on custom Object. Can anyone help me with writing the Apex class? The Process Builder updates a checkbox on ...
0
votes
0answers
22 views

Insert ContentVersion without VisualForce

I've got a CSV file stored on the user's hard drive and I want to store it in Salesforce. The code I have uses Visualforce and Apex to, I think, open up the file and place the contents on a hidden ...
2
votes
2answers
49 views

How to access Class members decorated using { get; set; }

I'm trying to save on boilerplate code so tried to use { get; set; } idiom, but the function will not resolve. This is the class with decorated properties. public class Counter { private static ...
-1
votes
0answers
15 views

Get Wrapper Fields Names Run time [duplicate]

Suppose, i have a wrapper class with 5 variables to fill. So just wondering can i create a list of all these values and while calling a wrapper, can i use the map to retrive variable names of wrapper ...
0
votes
0answers
12 views

Not full URL in Referer header in a controller of a Visualforce page

I added a custom VF page in a Dashboard. I want to have the Id of the Dashboard in my controller because I need it in my script. So, I used ApexPages.currentPage().getHeaders().get('Referer'). In ...
0
votes
1answer
20 views

Salesforce SOAP Integration

Req :- Custom Settings :- Vacancy Media Fields:- Name Type Area Path Map -- ...
0
votes
2answers
42 views

How to login salesforce user programmatically?

I require to login certain users among the test users created in test classes. Each user is created as follows: User user = new User(Alias='test', Email='test@none.com'); insert user; I create ...
1
vote
2answers
22 views

Could not resolve the entity from <apex:inputField> value binding ---

Could not resolve the entity from value binding '{!pizza_name}'. can only be used with SObjects, or objects that are Visualforce field component resolvable. apex class public class pizza_menu { ...
0
votes
2answers
19 views

How to create a condition for apex:inputField value field which gets a boolean expression from a method from controller?

I have the function which returns the boolean value and I want to use it in the VisualForce page in the following way: <apex:inputField id="reason" value="{!if(!isReason()): Case.Reason__c = 'No ...
-1
votes
0answers
23 views

Create a task based on Date/Time field value [on hold]

I have a requirement where i need to create a task based on a field value: In case object I have a custom Date/Time field called 'call_me_Back__c' that I wish to create a new task ('subject= call', '...
1
vote
1answer
20 views

unable to fetch latest attribute value in lightning

I have picklist in lightning. On onchange fuction it is getting a data from apex method and setting it in a attribute. And just after that when i trying to fetch the value of that attribute. I am ...
1
vote
1answer
26 views

Invalid character in identifier in Wrapper class

I am doing a rest call with the below endpoint string endPoint = 'https://test.salesforce.com/services/data/v43.0/query?q=SELECT+Name+,+RecordTypeId+,+Code__c+from+Account'; I have the below class ...
0
votes
2answers
46 views

Not able to insert multiple records on other object by using trigger

I have two custom Object name Loan and EMI. Now whenever new Loan is created with Fields Loan_Amount , No_of_EMI and others fields , multiple rows(=number of emi accounts) should be created in EMI ...
1
vote
2answers
65 views

Is there a way to determine if an object supports list view?

Is there a way to determine if an object supports list view? I've developed a VF page which shows a list of Objects and based on Object selection it shows list views of that selected object. For some ...
0
votes
0answers
25 views

Getting parent Id when clicking new button from related list

Object A is the parent object and object B is child object. object B has new button override with VF page. when I am clicking the new button of obj B from related list A I need Obj A's Id. For this I ...
0
votes
0answers
12 views

Saving reply's email to salesforce

I have a requirement to save email conversation inside an Object. In Lightning view - I can get to every Object and send an email through the activity send an email button. After doing it, it saved ...
0
votes
0answers
6 views

Authenticated Callout to Webservice using SSO

We are facing the following problem. We need to make webservice callout through Mulesoft in a way the user is making the call is not a service user, but the logged one: Both Salesforce and ...
0
votes
1answer
34 views

Apex convert string mm/dd/yyyy hh:mm:ss to standard system date (yyyy-mm-dd 00:00:00)

I am trying to convert string from google docs "1/16/2019 11:52:38" to standard system date "2019-01-16 00:00:00". I was able to achieve that using substring method but I am pretty sure there is a ...
0
votes
1answer
13 views

Custom iterable class Issue

I have written a batch class with Iterable interface  and the custom itrable is below. My question is i am comparing the value of i in the code to 8 if the records are more than 8 it throws CPU Time ...
0
votes
1answer
19 views

Dispaly an Error Message on unsuccessful POST function

I have a requirement where the user is updating a table and when he/she clicks on the Save button a POST service is called and the data gets saved. The requirement is now enhanced where by the user ...
0
votes
2answers
29 views

validation on lookup object

I have lookup on account of Sell_Request__c object. I want validation on Sell_Request__c to check if account-status is Inprogress then thrown an error.but i am not able to achieve this as not able to ...
0
votes
0answers
21 views

MIXED_DML @testSetup TestMethod [duplicate]

So I am seeing a very weird issue. I am getting a MIXED_DML error in one of my test methods. In the @testSetup annotated method, I am indeed perform a mixed dml transaction (shame on me). However, ...
3
votes
3answers
405 views

Storable Action - System.LimitException: Too many DML statements: 1

@AuraEnabled(cacheable=true) public static String deleteContacts(List<String> contactIds) { List<Contact> returnList = new List<Contact> (); String query = ' SELECT Id,Name, ...
-2
votes
0answers
23 views

click color of bar char for particular month it should goes into report page [on hold]

I have a customized bar chart page.When am clicking the blue color for the particular month it should go to the report and the report filter by month.How can we do in visualforce page.Plz help.