We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [static]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
15 views

Static method cannot be referenced from a non static context - Test Class

I'm trying to write a test class for this class but not sure how to provide code coverage for what I'm doing here. In my class I'm just running a query, looping through the query and creating a list ...
-1
votes
1answer
22 views

Static Methods and Return Values?

Do Static Methods In Salesforce Return Values Like public static integer MethodName(){}
0
votes
1answer
25 views

@AuraEnabled methods and fields : field declared as @AuraEnabled not available in @AuraEnabled method

I am new to lightning and i have written a controller for the component. public class TScontroller{ @AuraEnabled public Case caseDetail {get;set;} . .// few @AuraEnabled variables declared as above ....
1
vote
2answers
1k views

Why am I getting “Static method cannot be referenced from a non static context: String String.valueOf(Object)”?

I have this static class called from my lightning component, but am getting the error "Static method cannot be referenced from a non static context: String String.valueOf(Object)" on the line ...
0
votes
0answers
20 views

fast access object storage

Lead routing is a common task, the problem in my case that routing rules must be described as sObject, so APEX script should read it and convert into some mapping rules. The problem that 'static' ...
1
vote
3answers
99 views

How can I get Id from @AuraEnabled method in simple method?

I have a Lightning cmp with some logic, and I need to get Id to continue work with it in Lightning. But I get null. How can I fix it? public static Id toolId; @AuraEnabled public static void ...
0
votes
1answer
132 views

What is the life-cycle of static properties in Apex classes?

Sometimes when developing Apex, I've populated some static property. But then later -- most often in an Async or Test context -- I go to access it again and discover SFDC is behaving like it is ...
0
votes
2answers
687 views

Variable does not exist?

I know I am missing something very small, but I cannot get my head around. This is what I've tried public class SampleClass { public String currentUserId {get;set;} public SampleClass(){ ...
1
vote
1answer
64 views

Is it possible to call a future static callout method from a scheduler

I have a static callout which i want to schedule every 5 minutes. How would i approach this I have tried the following but the the incorrect signature error: Callout public class or_service { @...
5
votes
2answers
215 views

Maintain state in Visualforce Page without using View State

I would know if there is some way to maintain state across different transactions without using View State. For example, if in my Custom Controller, for every action method, I need 100 Account's ...
0
votes
2answers
33 views

Create list of records in Before and delete the list in After Context

I need to write a trigger on Case object where I need to delete the placeholder records and relate the case to existing records. I need to prepare the list of placeholder in before context and delete ...
0
votes
1answer
57 views

Update list from static method

I have a static method and it has this annotation @RemoteAction so it can be called from java script, I query a list in this method and I want to change a field value and update the list, this doesn't ...
1
vote
1answer
62 views

Call Excel VF Page from a static method in controller

I have a MS Excel VF Page that perfectly downloads data. Now in main VF Page I am having a remote action static method called using vf remoting from button on main page. From that method I need to ...
0
votes
2answers
546 views

Pass Set to static method

My understanding of static methods is that they hold the data until the end of the transaction, right? So, if I wanted to pull information about a set of ids that would be referenced during a for loop,...
5
votes
1answer
60 views

Using a single trigger approach - how to manage the object changes - Before Insert mainly

I am trying to follow a single trigger approach. there are several resources and patterns for it. I am doing something very simple My main question: Whenever we need to add new functionality to the ...
-1
votes
1answer
502 views

(Why?) Is it good for Apex methods to be static? [closed]

Many native objects in Apex rely on static methods and properties. This seems an abnegation of S.O.L.I.D., or at least of the Dependency inversion principle. As a developer who values the test ...
1
vote
1answer
74 views

Attempt to dereference a null object : Static method add Id to set

I have below static method where I am trying to add an Id to a set of Ids. This throws subject line error. Can someone please let me know where i am doing wrong? Apex Method public Id ...
-2
votes
2answers
478 views

String class- static vs Instance method

I want to clear my understanding on when to declare a method as static or an instance method. In the apex string class itself, some methods are static like isBlank() while others are instance method ...
3
votes
2answers
949 views

Updated the value of a local variable using different class

I was able to update the value of a local variable in a method from a different class. I am trying to understand how is it possible! Isn't that variable out of scope for another method. Moreover the ...
0
votes
1answer
702 views

Save Error in Test Class for @InvocableMethod: Static method cannot be referenced from a non static context

I'm trying to write a simple text class for another simple class that has an @InvocableMethod method, but receive the save error in the question's title. I can't figure out its cause or how to ...
0
votes
1answer
42 views

Method does not exist even method is static

Simple Code I am putting, Complex one working :( public class Kat { public String name; public Integer age; public static void accentureDetail() { System.debug('Anything to fix bug'); } ...
1
vote
2answers
593 views

SObjectType for RecordType?

Is there a statically accessible SObjectType for RecordType? System.debug(Account.SObjectType); // Result: Account System.debug(RecordType.SObjectType); // Result: SObjectType RecordType class ...
4
votes
2answers
28k views

Static method cannot be referenced from a non static context: List<String>

I believe this is a basic query and am missing something out. However am exasperated finding an answer to the issue and thus seek your guidance. The intent is to create a static method ...
0
votes
1answer
2k views

accessing static variables in method

I have static variables declared outside class and i am instantiating the variables in one method and access the same value in other method.But in spite of variable being set to static its still ...
1
vote
2answers
941 views

Is it possible to get value of a static String dynamically from an apex class

I have a apex class consisting some static variables, is there any way to get the value of one of these variables dynamically? Example : public with sharing class ConstantsClass { public ...
3
votes
3answers
677 views

Significance of Static variable in a Trigger [duplicate]

Can anyone help me in understanding the significance of having a Static variable in Trigger with any real time example. For Example Trigger on Account(after Insert,after Update) { Static String ...
7
votes
3answers
3k views

Include custom font in lightning components

I am trying to include a custom font in my lightning components. Unfortunately I am not managing in doing that. I uploaded a .eot file to my static resources and now I am trying to reference to it. ...
1
vote
1answer
26 views

TestClass Codecoverage coming in CodeCoverage Section [duplicate]

I have written a simple Trigger as part of my learning. As per my trigger based on all new Account created a Case is created using Trigger. I have written the Test Class as well and everything looks ...
0
votes
1answer
182 views

Create a BaseTest class with common variables and methods

I'm trying to create a class that will act like a BaseClass for my Test classes. It must include several variables, constants and methods common to my test methods. The kicker is that Test methods ...
2
votes
1answer
2k views

Lightning Component - maintaining a counter in Server Controller using Static Variable

I have a very simple sample lightning component to understand the concept. I have button and on click on the button, I am incrementing a static variable in Apex Server controller. I am expecting that ...
1
vote
2answers
44 views

Do trigger contexts in 2 different packages share the same record references?

Assume there are 2 managed packages, PKGA and PKGB. Both have a static list of trigger records. Will changes made to a record in PKGA be reflected in PKGB as well? To paraphrase, here's how the ...
0
votes
2answers
225 views

how to add library to static resource

<apex:page standardController="Account" > <apex:form > <script type="text/javascript" url="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <...
0
votes
0answers
876 views

Static method throwing common.apex.runtime.impl.ExecutionException: Attempt to de-reference a null object

This is the Exception I am getting common.apex.runtime.impl.ExecutionException: Attempt to de-reference a null object I'm getting a Exception thrown while running a unit test. I'm looking at it ...
2
votes
1answer
154 views

Central class for calling static methods in Data Access Layer

Much like the Factory pattern I am looking for a good way to call the desired Data Access methods through a central class. Unfortunately, my DAL classes are static (as I need them to cache records) so ...
5
votes
1answer
1k views

Public Static List Method

I have been studying Salesforce Dev for the past few weeks and can't find any documentation on something very simple. Can anyone explain why I would make the public static method a type of list rather ...
7
votes
2answers
470 views

Why do static and non-static lists behave differently in batch and test contexts?

Given the following batch code: global without sharing class POCBatch implements Database.Stateful, Database.Batchable<Sobject>{ public static List<String> staticList = new List&...
0
votes
1answer
527 views

Static variable used for Recurssion check

Scenario: I have two objects - Object A and Object B.Object A has recursion checking mechanism using Static Boolean variables covering different events(IsBeforeUpdate,IsBeforeInsert etc..) I have two ...
2
votes
1answer
1k views

Dynamically expanding a wrapper class for an object as custom fields are added.

I've reached a bit of a dead end in my latest programming endeavour. To give a brief overview I'm creating a console that houses data for four custom objects linked together loosely only by their ...
1
vote
1answer
59 views

Static Property value depends on another Static Property value?

When writing a future method, I wrote 3 static properties for this future method. Here's an example: global class MyTestClass { private static Date month1start { get { if ...
0
votes
1answer
2k views

Non static method invocation in static test method

I have a controller class where I have a non static field leadObj which is initialized in constructor with parameter: // Constructor public LeadToMerchantController(ApexPages.StandardController ...
1
vote
1answer
280 views

Why would I NOT want to use static controllers?

For starters, using static variables/methods resolves view state issues. I don't seem to notice any difference in VF behaviour when using static versus non-static methods either. So when would I use ...
7
votes
1answer
764 views

Execution of Trigger multiple times

We've an inbound web service which is inserting/updating 1000s of records at a time. We've trigger which fires on update, but we noticed, it is 'only' firing for first 200 records at a time and ...
6
votes
3answers
680 views

Static variables across multiple triggers in same context

So I like many of you am using the static variable "trick" to prevent recursion in my triggers. But I have one object with many triggers on it all of which are using the method outlined here https://...
0
votes
1answer
57 views

Public list variable is empty

I have a class with 3 methods (1 static and 2 normal) - A,B,C methods. B is the static method. A calls B method, B calls C method. There is master list variable which is updated in C method. In ...
1
vote
0answers
39 views

trigger doesn't increase static value

I have Company class with static field total_amount public class Company{ public String name = 'BazuBazu'; public static Decimal total_amount = 6; } I have my custom object Employee. I have ...
0
votes
1answer
1k views

How can i call my Apex class from visualforce?

I created Apex class with static field. I would like to use it as a value in on my custom visualforce page. On that page I use my custom controller as well. How can i access this field? <apex:...
0
votes
1answer
51 views

I can't access static apex field in my visualforce custom page

I am newby. I've got my custom page: <apex:page controller="opportunityList2Con"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!employees}" var="o" > ...
10
votes
1answer
563 views

Why are static variables allowed only in outer classes?

According to the documentation, static variables are allowed only in outer classes. Why is that? Is it because you'd need to instantiate the inner class first?
1
vote
1answer
20k views

modal pop window backdrop static not working [closed]

I have bootstrap modal pop-up window. I want the background to be non-clickable. I have close button to close the modal pop-up, so the users should use only that. Clicking outside the modal pop-up ...