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
0
votes
1answer
19 views

How to get lightning:input field value in Controller

I'm trying to get lightning: input field value in my component controller but its either giving me undefined value if I don't define a default value in my attribute or giving me default value. ...
0
votes
2answers
22 views

Apex Class to update Rollup Summary fields for LookupRelationship

I have a Custom Lookup Relationship on Case with Ship. I want to populate Ship's Rollup fields with no of Case on the basis of Types- If Case Type is 'A'- I want to populate a field 'No of A Cases' ...
0
votes
0answers
42 views

Apex - Approval Process - getting INVALID_CROSS_REFERENCE_KEY when calling Approval.process()

The class below has a method that runs on an After Update Trigger for a custom object. It attempts to automatically Reject the approval process when a picklist field (Work_Sub_Status__c) on its Target ...
1
vote
1answer
22 views

New Line Apex Trigger on Contact Page (Not Visualforce)

For this trigger: trigger CompileQuickNotes on Contact (before update) { for( Id accountId : Trigger.newMap.keySet() ) { if( Trigger.oldMap.get( accountId ).Log_Notes__c != Trigger....
2
votes
1answer
47 views

How to merge record data and a pdf attachment and generate a single pdf in apex?

I have one pdf file as an attachment of record. I want to create a single pdf file that contains some data from the record as the first page and the attached pdf file as the next page. How I can ...
0
votes
0answers
18 views

Why is SerialBatchApexRangeChunkHandler more than the number of batches?

I am working on batch apex and I have just tried writing a simple code for learning purpose. In the start method I am querying the records limiting them to 7, and I am running the batch job from the ...
0
votes
0answers
14 views

Table created using ClassWrapper - problem with saving changed values to database

I am having problems with saving to database values from table that I created using ClassWrapper. VF: <apex:form > <apex:pageBlock id="mainTable"> <apex:pageBlockTable ...
-1
votes
0answers
11 views

I want to invoke conga url using apex class [closed]

I want to invoke conga url using apex class. When i tried It was giving me 'The Id Parameter is missing'. I verified and make sure there was no spacing issue and seems all other parameters are correct....
2
votes
1answer
22 views

Using Named Credentials with client_id and client_secret in url query params

This is more of an instructional post because I spent so long trying to find the answer on here I felt like there should be a more direct post toward people trying to do something similar to what I ...
0
votes
1answer
29 views

Update multiple object records dyanmically

I am trying to write an Apex class that could be run on a schedule. The aim is to iterate through objects and identify NULLs on a particular field and populate that field. So far I've written the ...
1
vote
1answer
29 views

How to get the default value for a Long Text Area field?

Im trying to pull in the default value set in the configuration for a Long Text Area field we created on the Case object. How do we retrieve that value through Apex? The following returns a "null". ...
-2
votes
0answers
36 views

Visualforce Rerendering of price based on pricelevel picklist option selection not working [closed]

I am passing map of price level name to price "Map". "selectedoption" to set the default picklist value. In VF on picklist change I am just rerendering the price field. But price is not apearing on VF....
1
vote
1answer
29 views

How to deserialize JSON string with serialized object as map value?

I have a JSON string which the value of 'clueContent' is a serialized JSON String. When I try to deserialize this JSON string to the resp2Obj inner class, it raise an error with message: 'System....
0
votes
0answers
7 views

Create Contact List View based on Task attribute

I have a use case that needs a contact list so that the user can send List Email from contact using email tempalte. The contact to be in the list is the one assigned to the task with certain keyword ...
0
votes
0answers
35 views

SOAP API response queryresult to insert account records in salesforce

I am trying to fetch the account records from the queryResult of Salesforce to Salesforce integration response. But unable to split from the data. Can someone please help me. string query1 = 'Select ...
0
votes
1answer
28 views

How to get week name(Week1, week2 , week3 , week4 ) or number from the month in apex function

I have a requirement to create a record on weekly basis after checking if record is not created for the previous week. how to get the week number for each month and if i am in week 2 of month than how ...
0
votes
1answer
39 views

Link incoming cases to new / existing accounts through apex

I'm trying to link incoming cases (through the UI and through our REST API). Essentially, I'm checking for a combination of first name, last name and email on the incoming case, and if that ...
1
vote
1answer
57 views

Extract all occurences of a substring from a string

hello guys how would i extract all instances of a substring pattern given a string. e.g given a string templateContent = 'hello adrian , this is for {!Contact.Name} to be delivered to {!Account....
0
votes
1answer
35 views

VisualForce Page - Apex:Repeat & Map not showing any values

I have problem showing my map value to the visualforce page, in my controller I populate the maps and create below method public Map<String, Decimal> getmapTargetCurrentMonth(){ return ...
0
votes
0answers
20 views

Error in moving audio content to azure retrieving with apex callout

I am making a callout to a 3rd party to retrieve an mp3 file The endpoint is a HTTP GET (https://media.ringcentral.com/restapi/v1.0/account/~/recording/RECORDINGID/content) The response is the actual ...
0
votes
1answer
41 views

Trigger to Increment the Number value when new Lead is created when Lead Country is india

My requirement is that when i create a lead with country as 'india', there is a custom field named 'India_Auto_Number__c' where it should update as 1, and again when i create a lead with country name '...
0
votes
0answers
16 views

How to use “NameSpace” on Visualforce Page in salesforce?

I have facing problems on the VF page when I've to use StanderdController on VF than how I get "namespace" before the default field in a package org. Here "Charge_Item__c" is a custom object in ...
0
votes
0answers
16 views

Custom self registration page not working

I am using a self registration page for guest user sign up.It is showing this error Your request cannot be processed at this time. The site administrator has been alerted.As far as i think it is ...
0
votes
1answer
23 views

Invalid conversion from runtime type Map<String,SObject> to Map<String,OrgWideEmailAddress>

I am trying to cast the type Map<String, SObject> to Map<String, EmailTemplate>, my code as follows: EmailTemplate emailTemplate = [SELECT Id FROM EmailTemplate LIMIT 1].get(0); SObject ...
-2
votes
1answer
34 views

What's wrong with this code?

string contactId = '003N000001cUWnpIA'; Contact cnt = [select id from Contact where id : contactId][0]; system.debug(cnt); I've got error Line: 2, Column: 9 Unexpected token 'cnt'.
0
votes
0answers
11 views

User Creation via Static resource gives error on Profile Id in Sandbox cloned from the other sandbox

I am getting below error when I am trying to run the test class in Sandbox which was clone from one of DEV Sandbox. System.SObjectException: To create or update users for this profile, go to Setup > ...
-1
votes
2answers
30 views

Apex - Variable declaration

I have declared boolean variable as: Boolean x; Initially variable x will hold true or false - what will be default value for x? Thanks in advance....
1
vote
2answers
213 views

Code Coverage Failure trigger deploy on production

i have a code for trigger: trigger SendDisbursement on Opportunity (after update) { if (!System.isFuture()){ for (Integer i = 0; i < Trigger.new.size(); i++) { if (Trigger.old[i]....
2
votes
1answer
21 views

What is the correct way to return validation errors from a lightning Apex controller?

What is the correct approach to return validation errors from lightning controller? Suppose we have an aura method that takes some parameters. We need to validate these parameters in order to make ...
3
votes
1answer
51 views

Do Process Builder/Workflow Actions count against DML/SOQL governor limits?

This might seem to be a fairly simple question but I cannot find documentation which clearly states this. I have doubts about these questions- Do workflow/process builder actions such as field ...
1
vote
2answers
43 views

How to correctly construct a TestClass for an API Rest Callout | Getting the error “Method does not exist or incorrect signature”

Apex Class for REST Callout public with sharing class FindAnApprenticeship { public class Payload{ @invocableVariable(label='Find An Apprenticeship URL') public String ...
0
votes
0answers
12 views

Visual Clone Record via commandLink button

I am attempting to modify some existing Visualforce & Apex Code previously implemented by our Salesforce consultant. On my VF page, there is a commandLink button called "Create Renewal" which ...
0
votes
1answer
22 views

capturing required text from table using inboundemail service [closed]

How would I use my apex class to capture "Succesfully done" from the table body of the email, and insert it into the custom field? In the same way I would like to capture "Failed" also.
0
votes
0answers
19 views

insufficient access rights on cross-reference id while updating records through community portal

As a portal user while i am updating case records getting "insufficient access rights on cross-reference id". Thanks in advance!
-1
votes
1answer
20 views

How to display Einstein Analytics dashboard on external website

I have created this dashboard in Einstein Analytics Studio. Is there any way to display this dashboard on my external website.
1
vote
1answer
34 views

Using SOSL with wildcards in apex

I have a contact with name Test Contact in the Org. I run the SOSL like below in Query Editor and able to get results of contacts containing Test in their name: Find {*Test*} IN ALL FIELDS RETURNING ...
0
votes
1answer
29 views

Account and contact soql query

I want to retrieve all the contacts that have an account with soql query How do i find them Please find below query: Select accountid from contact where accountid in select id from account
0
votes
1answer
45 views

Batch apex class for student record [closed]

I want to create a batch apex that creates a student record for every contact that is linked with a account having checkbox eligible true. Student data should be taken from contact. My student record ...
0
votes
0answers
26 views

Display and populate ContentDocument with Lightning component

I basically followed this link and tried the exact same thing. Generate PDF from Lightning components I copied his Git code and tried the same thing. but the output I get is not what I expected. ...
0
votes
1answer
38 views

Deserializing a list of JSON String in an Apex Method

I am passing a JSON string to my Apex Method. When I try to deserialize it, I get the error: Method does not exist or incorrect signature: void deserialize(List, System.Type) from the type System....
0
votes
0answers
36 views

Soql query for self lookup on account

Trying to get a sub-query within the Account trigger. Account has a lookup to itseff self in field entity__c How do i get the entity__c records related to the parent account i tried the above soql but ...
0
votes
3answers
32 views

Setting a Map value within a method for a unit test

I still learning here but I am having a bit of trouble understanding this concept. I have a method kind of like this: public static List<Contact> newContacts() { List<Contact> ...
0
votes
0answers
16 views

Approval process test class unanimous approval required

I have a trigger that grabs approval comments and updates a custom field on an opportunity record. I am able to get 100% code coverage on test class when approval process requires one approver. ...
0
votes
1answer
19 views

How to create Box.com user from Salesforce Community User record?

I am looking for a way to create a user within Box.com if the user does not exist in Box.com after a Salesforce Community User record is created. How can I create a user in box.com if one does not ...
1
vote
1answer
48 views

Explanation of an notation List<name.test> nameList

I have a piece of code as following: List<name.test> nameList In List is name a class or object. Why would we use such an annotation? Or for example: method(name.test variable)
3
votes
3answers
59 views

Can a trigger with error ruin the batch it was fired from?

Consider I have a batch class which updates 50 records of Task. The batch class ran successfully and updated the Task records.Now the Task object has a trigger that runs on after/before update. Due ...
4
votes
0answers
39 views

Clean way to vary sharing at runtime in Apex?

I may need to make many @RestResource Apex classes run either with sharing or without sharing where that option is selected at runtime. But this approach (that I am using at present): /** * Allow ...
0
votes
0answers
10 views

How to create sharepoint instance? [closed]

I wanted to build connection between sharepoint and Salesforce.For that I need a sharepoint instance. How Can I create sharepoint instance.what are the requirements for that? Thanks, Chandu
1
vote
0answers
80 views

Get Multi select picklist and update corresponding category using custom metadata type

We have a Custom Metadata Type which shows the relation between a product of interest and categories. When a product of interest is selected we would like the corresponding categories to be selected. ...
0
votes
0answers
17 views

Internal Server error:Unexpected exception from predictAsync future

I'm trying to classify image using Einstein.I wrote following function in server side controller to classify the image @AuraEnabled public static Einstein_PredictionResult ...