2022 Developer Survey is open! Take survey.

Questions tagged [apex-variable]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
2 answers
82 views

Lombok for Salesforce Apex

I'm looking for some solution, which helps me to write less code in Apex. Is there any tool like Lombok for Java.
user avatar
1 vote
1 answer
127 views

Flow Currency Decimal Places being dropped when passed to Apex Class

My flow has a screen where the users enters a value in a currency field that has 2 decimal places and that value gets passed to a variable in an Apex Action within the flow. For some reason, when I ...
user avatar
  • 49
0 votes
2 answers
115 views

How to switch on RecordTypeId inside a loop?

Alternative Title : How to optimize grouping each SObject records by Recordtypes public static Id sgRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Singapore')....
user avatar
  • 1,051
0 votes
2 answers
53 views

Apex variable shows as null

I have the following code below. The field generatedToken gets populated in getTokenFromA(), but when I access it in PutA() it is null. I have tried defining it as just static (without public) and ...
user avatar
0 votes
1 answer
367 views

Flow Variable of Email addresses to Invocable Apex action

I'm trying to pass in the flow variable collection of Email addresses to Apex action to send out one email to each email address. I got some idea from Question, the code works fine when i ran it from ...
user avatar
  • 55
0 votes
1 answer
300 views

Not able to set the value of global static variable from another method

I have a Boolean variable in Class A. I am trying to set it's value from class B but it is not working. Below is the sample code of which I am trying. Class A : global without sharing class ClassA { ...
user avatar
0 votes
1 answer
230 views

ORDER BY Variable in Apex Class

I am trying to run a query that allows me to sort data inside a table. Depending on the value that gets chosen to sort by I have different queries: if(selectedField == 'Name'){ warehouses = ...
user avatar
0 votes
1 answer
127 views

Modify Date Range

How do I modify the code below to have the week range from Thursday 12 PM Central Time Zone to the following Thursday 12 PM, so setting the Start date of the week to be Thursday and end week to be ...
user avatar
  • 33
1 vote
1 answer
241 views

How to pass phone and email to invocable method

I have a visual flow from which I want to pass some person account info to an invocable method. It seems that when I use a phone and email field I can't assign them to my invocable class. Is this ...
user avatar
  • 2,068
0 votes
1 answer
652 views

Variable does not exist - Batch Apex Query

I have a Batch Apex which is invoked from process builder. I can see Ids are coming into the variable (please see debug log) but same variable inside the query gives "Variable does not exist" error. I ...
user avatar
  • 379
0 votes
1 answer
199 views

Can i create changing variable in apex class

Hello guys i wrote to update class for case object and this object have a many records thats why i cant execute Soql queries, I encountering error: "So many soql queries",i searched i found one way, i ...
user avatar
1 vote
2 answers
1k views

Variables in Interface in Salesforce

Can you declare variables in Interface in Apex (Salesforce). In Java, it allows you to declare and initialize variables with public static final keywords in Interface. Also in Apex, are all abstract ...
user avatar
  • 21
2 votes
1 answer
378 views

Pass value from apex component to controller

I have a visualforce force component: <apex:component controller="NewITAssetController"> <apex:outputPanel> <label>Date field</label> ...
user avatar
  • 360
0 votes
1 answer
73 views

Soql on Account returns empty Id

I have a controller where I get a token from a visualforce page with account as a standard controller and controller extension. In my unittest I insert the variables but the accid throws an exception ...
user avatar
  • 2,068
0 votes
1 answer
254 views

getting Must trace apex_code at finest when checking the variable panel

I have already set the apex debug level at FINEST but still when I check the variable panel I still see the message must trace APEX_CODE at Finest can someone please suggest on the same? Below is the ...
user avatar
  • 2,215
4 votes
1 answer
118 views

What is the difference between a variable and an automatic read-write property?

Accordingly to the Apex Developer Guide, An Apex property is similar to a variable; however, you can do additional things in your code to a property value before it is accessed or returned. ...
user avatar
0 votes
2 answers
55 views

Removing record reference in class

Expansion to original question: Error: Future method cannot be called Need to remove record variable from reference. Can someone help me and explain the process? Error: Error: Compile Error: ...
user avatar
2 votes
2 answers
1k views

What is this technique called?

public static List<Holiday> holidays { get { if(holidays == null) holidays=[Select h.StartTimeInMinutes, h.Name, h.ActivityDate From Holiday h]; ...
user avatar
0 votes
1 answer
143 views

How to pass query variable from soql into loop

I am trying to bulkify a callout where I want to pass the recordtype in my loop but I get: Error: Variable does not exist: RecordType If I try public RecordType personAccountRecordType I get ...
user avatar
  • 2,068
0 votes
1 answer
92 views

Add a starting value to an Apex:Variable in a Apex:repeat Table

I have created a simple table of data in a VF page, which uses Apex:Repeat to list records. There is a column that contains a cumulative amount, by way of apex:variable. The cumulative amount works ...
user avatar
0 votes
1 answer
368 views

How to make variable show the count of records from a dynamic soql query [duplicate]

I have a custom controller with a variable 'count.' I want this to update on the page every time the account list updates. Right now it's static. It just displays the original number of records in the ...
user avatar
0 votes
1 answer
3k views

Variable does not exist in test class

ProcessHandlerShowAccounts class works, but I am trying to get my test class up to par to validate my data. I am getting a variable does not exist, not sure why Did I initiate the class wrong? Also ...
user avatar
0 votes
1 answer
807 views

Variable does not exist within invocable method

I am trying to access the variables sent from the Process Builder within the apex class. It says the variable accountParamter does not exist, which confused me because I declare it in the parameters ...
user avatar
12 votes
4 answers
2k views

Is there any benefit, performance-wise, to declaring Apex variables as final?

In other languages (see, for instance, Swift), stating explicitly that a variable is final lets the compiler optimize the code accordingly. Is this the case with Apex?
user avatar
1 vote
1 answer
577 views

Dynamic Fields in for Loop

Is there a way to dynamically change the fields within a for loop? As an example, if I have for loop: for(Account a: myQueryResult){ if(a.parentId = fieldVariable){ Do something ...
user avatar
  • 1,018
0 votes
1 answer
1k views

Issues updating a apex variable on visualforce page

I have an apex variable that is the summed value of record amounts in a pageBlockTable. The idea is when an amount value is changed, a javascript function is called to recalculate the amount for all ...
user avatar
0 votes
3 answers
293 views

Variable does not exist on trigger class

For the following class, I get the error 'variable does not exist: mq' on lines 25 - 27 Public with sharing class InspectionQuotasHandler{ public static void UpdateMonthlyQuotaOfInspection(List&...
user avatar
3 votes
1 answer
733 views

Flow and InvocableMethod Simple Question

How would I create an array of the values from the flow and pass them into the APEX @InvocableMethod? My method is taking in a list of Strings: @InvocableMethod public static List<String> ...
user avatar
  • 3,167
0 votes
1 answer
506 views

Variable does not exist in global method - batch class

I have tried to put together a batch class to update parent Account records with credit scores.. I need to make 2 list variables public so I am able to access them in the finish global batch method, ...
user avatar
  • 57
2 votes
1 answer
191 views

VF Component modifying an apex:variable outside of its scope

I just stumbled upon a weird behavior of Visualforce Components (or apex:variables). Please see the code below and then the end result: VF Page <apex:page> <apex:variable var="foo" ...
user avatar
  • 5,213
0 votes
1 answer
775 views

Escaping variables in Email templates

I am trying to build the body of an email by using the fields of a given custom object(SObject). On this given SObject I am including some variables. One of those variables is the title of the Contact....
user avatar
  • 1,410
1 vote
3 answers
9k views

Round off an apex variable upto two decimal places

I have apex variable in my visualforce page, which is calculated as below - <apex:variable var="cntFinal" value="{!IF(cntVar1==0,0,(cntVar2+cntVar3)*100/cntVar1)}"/> Now, I want to set this ...
user avatar
  • 43
2 votes
3 answers
520 views

Accessing passed variable from Visualforce page OR pass Controller.addFields in TEST

I want to pass the pricebook2id from an opportunity to my apex class and then use this when querying. I can get it using the Controller.addFields when declaring the controller like this: public ...
user avatar
  • 1,268
0 votes
1 answer
271 views

Accessing the deserialised object from a different class

I am using the following class to deserialise a JSON object: //Method to deserialize the response body public static responseResource deserialize(httpResponse res){ return (...
user avatar
1 vote
1 answer
138 views

Compile Error on Map: Variable WhoId Doesn't Exist

Got the compile error for the snippet of code below. Says variable record.whoId (bolded) doesn't exist. Tried adding more brackets to the if statement, capitalizing WhoId and didn't work. Here's the ...
user avatar
0 votes
2 answers
1k views

Get value from custom setting

I have a batch process that I want to be able to dynamically tweak the batch size without changing the code in sandbox and then deploying each time. I figure I can use a custom setting as I have been ...
user avatar
  • 3,334
1 vote
0 answers
298 views

SOAP Call w/o WSDL body too large error

I am working on integrating an asmx webservice into salesforce. I was unable to parse the WSDL into apex, so have to build the calls manually. The call I built works and is received when literal ...
user avatar
  • 113
1 vote
2 answers
338 views

New Line in Apex Variable

I am trying the following code: <apex:variable var="variable1" value="{!CASE(object.field, "val1", "line1 line2", "val2", "...
user avatar
1 vote
1 answer
705 views

Variable does not exist: insert record

I'm trying to insert a new record into an object where I pull information from OpportunityLineItem, Product, Opportunity, and Account. I did a query and get the results I want. Then I go to create a ...
user avatar
  • 3,334
2 votes
1 answer
605 views

Pass a variable from Javascript to Apex Controller

I'm trying to pass a variable from a javascript inside a VF page to a varibale in the Apex Controller. The VF page code is: <apex:page controller="uploadDataTosObject" apiVersion="36.0"> [...
user avatar
0 votes
0 answers
636 views

Stop increment of apex variable

In my VF page I have: <apex:pageblockTable value="{!interview.Skill_review__r}" var="skillreview"> <apex:column headerValue="Rating"> <apex:...
user avatar
  • 4,521
1 vote
2 answers
3k views

Trouble passing variable from Apex to VF Page

I'm trying to pass a simple string to a vf page, but can't seem to. What am I doing wrong? APEX public class ControllerJSGeo{ public String pId; public String testString {get;set;} ...
user avatar
  • 345
1 vote
1 answer
507 views

Define apex:variable in apex:inputText

I'm trying to pass parameters while using immediate=true. (actionRegion is not an option) Since this won't work: <apex:inputText value="{!searchValue}" /> <apex:commandButton value="...
user avatar
  • 6,100