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
1answer
785 views

How to add a lookup field on VF page?

How to add a lookup field on VF page. I have custom field Contact__c (lookup to contact) on a custom object. I am adding that as iput field on the Vf page so user can enter that lookup value. I ...
0
votes
1answer
30 views

How to append XML root element to an existing xml string

I have XML string like below in that I have to add root element and some attribute using apex. I was searching this for whole day but I din't get any key point. I saw there is some support for DOM and ...
0
votes
2answers
22 views

How to get session id of a particular user in Salesforce

Is there any way to get session id of a user so that I want to use it in REST API call in Postman to view the response. When I do the api call using my session id, we are recieving invalid user ...
0
votes
1answer
15 views

I want to display bar chart of 10 accounts with maximum contacts. each bar chart should be clickable and redirect to concerned account

I am able to show a bar chart using static data in vfp - apex. However there are mainly two problems - 1. getting dynamic data of no. of contacts in each account and 2. making each bar clickable and ...
0
votes
1answer
15 views

How to fetch Declarative Metadata i.e. meta.xml file with Tooling API query?

Is there a way to fetch the meta.xml file via tooling api query? The meta.xml looks like this for apex class: <?xml version="1.0" encoding="UTF-8"?> <ApexClass xmlns="http://soap.sforce.com/...
0
votes
1answer
26 views

How to addError on the dynamic string field api name [duplicate]

obj.get(childFieldAPIName).addError('Required'); Error: Method does not exist or incorrect signature: void get(String) from the type Object I am trying to add the error on the fields which are ...
0
votes
1answer
21 views

Get Field value from object using string key

I am trying to do get values from the object using string key, I have typecast the Contact object into the object but not getting value. Please help how to get value from the object using string API ...
0
votes
2answers
845 views

Display addition of two fields in VF page and save it to an Object

I have three fields in my VF page and user has to input two of them manually. Once both the values are entered, I need to show the Sum of both the entered values dynamically on the screen and that ...
5
votes
2answers
936 views

How to Reproduce the Concurrent Requests Limit?

I'm trying to write code that will reproduce the Concurrent Requests limit (10 requests longer than 5 seconds, described here: https://developer.salesforce.com/blogs/engineering/2013/05/force-com-...
0
votes
2answers
664 views

get value from the look up object on change of look up field

My requirement is like below. I have two objects Student and Sports. ** Student ** Name SportActiviy SportDescription etc... **Sports** SportName SportDescription In Student creation page, I have ...
4
votes
1answer
1k views

How to catch Validation error in Flow

I have created flow + Process Builder to do a lookup relationship Count on parent object. My issues is I have a validation rule which fires when user try to deleted last child record from the related ...
0
votes
1answer
653 views

Getting Blank PDF (without content ) using VF Email Template ( By default attaching PDF)

Original question: Hi All I have creaed approval process on custom object where i need to submit a PDF document for approval process. Once I attached the PDF file and submitted for Approval, am ...
0
votes
1answer
27 views

Help creating process builder or trigger for updating task created from Opportunity

Happy Friday. I am trying to create a trigger to map fields from an opportunity to the task that was created from it.  The Related to field will be populated with the Opporunity name, but I cant seem ...
0
votes
2answers
38 views

Dynamically set columns on pageBlocksection and pageBlockSectionItem?

Page : <apex:page id="ContactDetails" extensions="ContactsController" standardController="Case"> <script> function showFieldsOnClickAction() { showFieldsAction();...
0
votes
1answer
104 views

Trigger not updating checkbox properly

My Opportunity object has an child object P_ODR__C. Opportunity obejct has checkbox field Nd_Check__c. I am updating it by trigger. I have a trigger on P_ODR__C updating checkbox on Opportunity ...
-1
votes
0answers
25 views

Display list with combinations in visual force page before saving the record [on hold]

I have a requirement, Suppose in visual force page these is a text box has a,b,c,d values display these values in rows like A-B,B-C,C-D,D-A before saving the record
1
vote
1answer
31 views

How to generate pptx files with the VisualForce page and Apex Controller

Unable to open the generated file in OpenOffice unfortunately. My requirement is to generate a ppt file using dynamic data from Salesforce. Here is my snippet of Visualforce Page. <apex:page ...
0
votes
1answer
39 views

Issue with REST API in Production

We have a mobile app(Not Salesforce1) where the data is pulled from Salesforce using REST API. The basic functionality of the app is to return GranChild records when any Search Term is entered in ...
2
votes
2answers
1k views

Images are fetched from attachments for Visualforce page rendered as PDF displaying broken images

I am trying to fetch the images from the attachments and trying to display these images in a visualforce page which is rendered as pdf. But in the pdf I am getting broken images. If I remove the ...
0
votes
1answer
37 views

Queueable Apex in a Before Trigger

I am attempting to create logic that, on Contact record insert or update, will compare the Phone value of the record to another reference object and conditionally populate a checkbox as a result of ...
0
votes
1answer
774 views

System.TypeException: Collection store exception

Hi I am running a test class but one method fail giving:System.TypeException: Collection store exception putting ScenarioDumpJob.args_element into Map Here is my mock class: @IsTest global class ...
1
vote
1answer
33 views

On creation of ContractLineItem getting FIELD_INTEGRITY_EXCEPTION

I am creating a ContractLineItem record on the creation of ServiceContract by using a trigger. Below is the error I am getting Error: Invalid Data. Review all error messages below to correct ...
0
votes
2answers
2k views

Get Picklist Values based on Record Type

Am designing a JQuery AutoComplete search box in visualforce page and getting the data source from controller class from two picklist fields(Controlling and dependent). The autocomplete search box ...
1
vote
1answer
15 views

How to validate a encrypted field

on the best practice section of this documentation: https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/fields_about_encrypted_fields.htm it says: You can ...
1
vote
0answers
29 views

Need to reconfigure Process builder formula

Person Accounts is enabled Have multiple record types on Accounts (a few for 'Accounts' and a few for 'Person Accounts' They have an old process that was implemented, but we re-architected the ...
0
votes
2answers
333 views

How to get FILES associated with a record?

I trying to get all files associated with a record. I tried query but not sure is it correct? SELECT Id,ParentId,Title FROM ContentDocument WHERE ParentId = '<recordID>'
2
votes
1answer
26 views

Error not bubbling up from delete trigger

I need to prevent deletion of our dummy account, which is part of the Lead conversion process under certain conditions. And it does prevent deletion. However, the error I am adding to the account ...
0
votes
1answer
23 views

Trigger is only updating one record per batch

I have a trigger that creates an AccountTeamMember object every time there is an update to an Account_Ownership__c object (this is a custom object that we've created in house to act more in line with ...
0
votes
1answer
24 views

How to See Scheduled Job Run History

I have a scheduled job that is supposed to run every night at midnight. Recently users have said that the job didn't run; however this is sporadic, some nights it works and others it doesn't. Is ...
0
votes
2answers
45 views

How to get the response data in @future(Callout=true)

I need to catch the response of a callout method and insert it into a database. But what the problem is, the callout method called from a trigger. Therefore, I have to add the annotation @future(...
0
votes
1answer
690 views

Get PickList Value of StandardObject on Angular JS page

I wanted to show Picklist value from Account object Type Field. As I am Using Angular JS i can't use <apex:outputPanel styleClass="form-group" layout="block"> <label>Type</label>...
-3
votes
0answers
26 views

unable to get the row id on click of Add button in vf page [on hold]

I have a one vf page where i am displaying list of rows and each row with one add button. My requirement is on click of Add button i need Id to be captured in list in controller.
0
votes
2answers
1k views

FIELD_CUSTOM_VALIDATION_EXCEPTION Error

I have custom object called - Billing and custom field called Default Billing and Default Shipping(both are checkbox field) Replication steps: Open any record which is Default Billing and Default ...
1
vote
1answer
977 views

Redirecting from Controller to standard list view page?

I'm using a custom_object and once the user save I want that page to redirect to list view page but what is happening is that right after i click save button i see the white blank screen with the ...
0
votes
0answers
15 views

Copying fields data when checkbox is checked in multiple rows(Visualforce Page)

I have challenge I'm working on a visualforce page I want whenever the checkbox is checked I want to copy the values into input text fields in visualforce page. So here I have multiple rows and ...
0
votes
1answer
36 views

System.QueryException: Inline query has too many rows for direct assignment, use FOR loop [duplicate]

I have a batch executed : 1 out 4200 is failing with : inline query has too many rows for direct assignment,use FOR loop My code in the exec function: List<String> personAccountsIDs = ...
1
vote
1answer
60 views

How can we get custom field Ids in apex from a different user

We need to get some custom field ids thru apex - we used to do it by invoking tooling api request, but now this requires the user has to have the permission "View Setup and Configuration" on his ...
0
votes
0answers
10 views

Group mention is not working with custom chatter functionality

I am using the Connect API to create a custom feed. This is working fine when I am using user in @mention but when I am using the group in @ mention it is not doing the feed post an exception is ...
0
votes
2answers
30 views

Delete AccountTeamMember

We have .Net service which does CURD on account team members for a given Account. Whenever there is a change in the role of the members/person moved from one account to another, the service will ...
0
votes
1answer
94 views

Question on trigger to roll up on formula field on detail object

I am writing a trigger to roll up a formula field, Elapsed_Time_days__c, in a detail object, NEW_KIND_Ticket_timer__c, and have it display in a number field, Total_Time_Case_Elapsed_Days__c, on ...
0
votes
1answer
70 views

Why is my apex test class failing?

There might be a lot of other ways to achieve what I am trying to do here but for practice I am using trigger. The trigger is to update a field acc_number__c in contact if the finalize_number__c ...
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 ...
1
vote
0answers
23 views

Has anyone been able to set the User.IsCustomerPortal field from a unit test class?

I know the field is not editable but I mean by associating a User record with a Contact/Person Account record in your test data, somehow it gets enabled? Do you know? The reason I need this ability ...
3
votes
1answer
19 views

What are “LOB fields” in an asset? Querying all the fields on the asset causes a limit exception, why?

First of all: what are LOB fields? Secondly: I have a complex apex automated process in which I need to make an exact copy of an Asset object (all of its fields). To do this I created a method that ...
2
votes
2answers
82 views

Illegal assignment from sObject to Id

I'm trying to insert two master-detail lists at the same time. I'm looking through Bob Buzzard's blog post: http://bobbuzzard.blogspot.com/2012/03/create-parent-and-child-records-in-one.html Where he ...
2
votes
1answer
22 views

Adding null to Set<Id> doesn't return an empty Set

Set<Id> testIds = new Set<Id>(); testIds.add(null); system.debug('testIds are ' + testIds); system.debug('Size of the set is ' + testIds.size()); system.debug('isEmpty result is ' + ...
0
votes
0answers
21 views

Invocable Apex working when called from Process Builder but not Flow - what's wrong?

I have an invocable method that works just fine when I pass a Contact record Id to it via Process Builder. I'd like to use Flow to do this rather than PB, but get this error message: Error Occurred: ...
1
vote
1answer
16 views

How to resolve Attempt to de-reference a null object in Apex Controller

I am trying to bind my map value to wrapper class in apex controller . I am getting System.NullPointerException: Attempt to de-reference a null object. I couldn't understand where I am going wrong. ...
1
vote
4answers
275 views

Multiple OR (||) Conditions in If Statement

Can anyone explain why the following If statement does not work with multiple OR conditions. The goal is when this trigger runs, if the user's Id who is updating the record is not equal to a specific ...
0
votes
0answers
32 views

How to organize Apex Classes for large projects in a single folder? [on hold]

A traditional Org stores all its Apex classes within a single folder. If you are working with a dozen developers on a large project, this leads to chaos: You end up with either hundreds of small ...