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
2 votes
0 answers
631 views

Test class for Continuation Chaining

Has anyone ever done a test class for continuation chaining (Multiple Asynchronous Callouts)?
S..'s user avatar
  • 1,205
2 votes
3 answers
6k views

Get 10+ Level Hierarchy Relationship

I have an account A10 its parent Id is A9 further A9 has parentId A8 and it goes on and on say upto A1. Is there any way to get all the parent accounts ? A10 -> A9 -> A8 -> A7 -> A6 -> A5 -> A4 -> A3 ...
Anzar's user avatar
  • 954
2 votes
1 answer
155 views

Formdata isnt working in Apex

I was trying to Post a document to an api using LWC and ran into a cors issue and moved the code to Apex. I'm attaching a picture of the postman that shows what it looks like. So looking up solutions ...
kimberly modeste's user avatar
2 votes
0 answers
178 views

Why doesn't the System user have access to the CollaborationGroup records?

I've created a test class and a simple flow below that illustrates the issue with the System user. Two test methods are doing a simple SOQL query on the CollaborationGroup records (one with a Standard ...
Dr.J's user avatar
  • 41
2 votes
1 answer
693 views

Confused with transaction terminology related to Visual flow limits

I am going through Apex Governor Limits that Affect Flows documentation and came across two new terms "larger transaction" and "batch transaction". I thought we only have Synchronous transaction, ...
javanoob's user avatar
  • 8,877
2 votes
1 answer
1k views

Named Credential authentication with GoToWebinar (OAuth2)

I am trying to connect Salesforce with GoToWebinar (GTW) to automate webinar activities within my Salesforce app. I am attempting to use Named Credentials (OAuth2) to authenticate with GTW. I have ...
Deployment Failure's user avatar
2 votes
0 answers
1k views

Apex: Copy all populated values from one SObject record to another

I like the way JavaScript lets you easily overlay two objects, retaining the properties of both: let obj1 = {name: 'Foo', quantity: 3}; let obj2 = {name: 'Bar', description: 'A very nice bar'}; // ...
Matthew Souther's user avatar
2 votes
1 answer
21k views

How to write an if else statement in Aura

I tried to write out the aura if statement but I am getting stuck if someone can explain it to me in detail. thank you <aura:if isTrue="{!lessthan(v.Tl.time, v.Tl.End_Date_Time1__c)}">...
mia's user avatar
  • 21
2 votes
1 answer
4k views

Scheduling Emails in Apex

I need to send emails based on the Number of Days.....Say suppose in my Policy1---- Send Email should be 10 days Before Due Date & in my Policy2----Send Email should be 5 days After Due Date... ...
Eagerin Sf's user avatar
  • 1,085
2 votes
1 answer
707 views

Verifying registerNew and registerRelationship (fflib_ISObjectUnitOfWork) with Apex Mocks

Given the following method, I would like to verify the registerNew/registerRelationship using Apex Mocks on my unit tests, basically to know if the record is going to be created as expected. public ...
lopez.regalado.fj's user avatar
2 votes
1 answer
2k views

Rerun a Async Apex Job

When I get an error on some of my @future methods and would like to dynamically rerun the records that have failed at a later stage or have a list of records that failed and click rerun button to ...
Thys Michels's user avatar
2 votes
1 answer
908 views

Schedulable equivalent of Database.Stateful?

I'm looking to implement a class that I can schedule every 5 minutes. This class will carry out some basic monitoring activity. But in order to know what to monitor, my scheduled class will need to ...
coldspeed's user avatar
  • 701
2 votes
2 answers
2k views

How to avoid soql query inside for loop ? I want to use that query only for trigger.New record

I created a trigger which will insert two new records based on field update on Lead object. Every thing is working fine but to avoid governor limit I am not able to remove Soql query from for loop. ...
Nani's user avatar
  • 35
2 votes
2 answers
644 views

Configure Auto-Number with initials related to another object

I have an object called Project where stored the name of the project and its key, respectively: My Project Name, MPN Then I have a direct child object called Sprint followed by Issue where I have a ...
susaneme's user avatar
  • 133
2 votes
3 answers
5k views

A Chatter Feed related to a Record as well as a Chatter Group

I have a business case where currently we post chatter feeds to a Chatter Group using Apex. This is done by assigning the CollaborationGroup (chatter Group) Id to the ParentId field on the FeedItem. ...
Vishal's user avatar
  • 325
2 votes
3 answers
16k views

Non static method cannot be referenced from a static context: Integer Date.dayOfYear()

I am new to the salesforce and trying to do the following System.debug('Date :'+ Date.today()); System.debug('Date + 1 :'+Date.today().addDays(2)); System.debug('Add Months : '+Date.today()....
user4567570's user avatar
  • 1,616
2 votes
2 answers
1k views

Can I remove this for loop within a for loop?

The following code is called by an after update trigger on Account. It finds all an account's children Account_Configuration__c records (child name for SOQL is Customer_Credentials__r) and -- if the ...
Gabriel Rivera's user avatar
2 votes
1 answer
6k views

How to surpass/ignore Duplicate Management Rules in Apex? [duplicate]

I have activated the standard Duplicate Management Rule on Contact to prevent duplicate records. When I try to create duplicate Contact records form SalsesForce side, it shows me a warning message ...
Ram Dhayalan's user avatar
2 votes
1 answer
1k views

Update Record on View()

I´ve been thinking about this today and found one solution using a formula field, but I want to know if there´s any chance that every time a user clicks the view on a record, it gets automatically ...
Emilio's user avatar
  • 362
2 votes
1 answer
435 views

What is the correct endpoint for a managed released apex REST class?

I developed a managed package with namespace, let's call it "MyNameSpace" and an exposed APEX REST class, let's call it "MyEndPoint". : @RestResource(urlMapping='/MyEndPoint/') ...
Bill Software Engineer's user avatar
2 votes
1 answer
12k views

how to make call to apex rest api?

im trying to make rest api with apex and i created class with the developer console but i not understand to wich url i send the request i also have accsess token. i just want to see im getting some ...
Alex Koretzki's user avatar
2 votes
1 answer
2k views

Rest UserName/Password authentication not working!

I am trying to get aouth token from using the username and password authentication for Salesforce rest api. I am using this url: https://login.salesforce.com/services/oauth2/token I am using this ...
user614946's user avatar
2 votes
3 answers
2k views

Page redirect after export to XL

I have a a VF page that that exports a set of data to excel, the export button correctly redirects to the export page and the file is downloaded. public PageReference exportData() { system....
paul's user avatar
  • 1,502
2 votes
1 answer
977 views

Error Message in Visualforce page

I have a visualforce page which has a apex:pagemessage tag. A method on the controller is checking if a field in the visualforce page is valid. I want to display an error message but I do not want ...
Rimii's user avatar
  • 225
2 votes
1 answer
710 views

Pagination is not working for my VF page

I have search page where it will search for Opportunities based on some filters. I added pagination,but the issue is it is showing only 10 records out of 125 records and when I click on next button it ...
Learner's user avatar
  • 71
2 votes
1 answer
3k views

Assign account to Territory Rule in apex code

We have an issue with Accounts in wrong territories. Basically, we have an apex controller for Cases which modifies the account field that we are using to manage territories, but reading this link ...
Javier Vazquez's user avatar
2 votes
1 answer
804 views

Data export from app on app exchange

I have a SFDC App which does data (Account, Contact, Lead) segmentation and flags them according to segmentation rules. I want to be able to provide a link on visualforce page to download certain ...
Bhushan Lodha's user avatar
2 votes
2 answers
14k views

get data when click on row in pageBlockTable

I have a pop-up display a table with some columns (Name, ID) of Accounts for example, I want to display additional information of the selected account when I click on specific row. I used something ...
user3003810's user avatar
2 votes
1 answer
4k views

How to use assert methods in APEX tests

I am fairly new to making and/or using tests, and I have come to realise how important these are. I have never actually looked into testing but I have heard of the assert methods. I was wondering how ...
user avatar
2 votes
2 answers
4k views

Time conversion LWC datatable - Apex

I have two Time field in my Custom Object Start Time and `End Time Start Time Value ==>8:30 AM End Time Value ==>6:00 PM From Apex Wrapper class I'm returning the time values. @AuraEnabled public ...
SFDC_Beginner's user avatar
2 votes
1 answer
742 views

Governor limits in dispatching BatchApex jobs - how much and where to find them?

As a follow up to this question, here are some questions I've not been able to find an answer for: How many batch jobs can you dispatch before you exceed governor limits? 100 or 105? Do scheduled ...
coldspeed's user avatar
  • 701
2 votes
1 answer
934 views

Simulate/fake long running REST request

I want to simulate / fake a long running transaction context - does anyone have any code which I can use to artificially extended my transaction context in a controlled way? Thanks
Michael Gill's user avatar
  • 2,202
2 votes
1 answer
333 views

How to test Feature parameter in the beta package

We have beta package[package passed in the salesforce security review and released in the appexchange product] which contains Feature parameter. In LMO, beta installed orgs are not shown in the ...
Ranjith U K's user avatar
2 votes
1 answer
1k views

Why does my SObject Checkbox field always return false in a VisualForce Page on a public site?

I have a VisualForce page that is displayed on a force.com public site and always evaluates a checkbox field on my SObject as false. In the following example, my SObject is Survey__c and my checkbox ...
neoscrib's user avatar
2 votes
2 answers
2k views

How to solve the apex:attribute and assignTo naming conflict?

So consider a component with an attribute like this: <apex:attribute name="rentalContract" type="RentalContract__c" assignTo="{!rentalContract}"/> And this is how my controller looks like: ...
Semmel's user avatar
  • 2,457
2 votes
1 answer
5k views

Trigger to copy Account Team to Opportunity

I built out a trigger that upon an opportunity reaching a certain stage will query the Account Team members of the related account and insert those records matching a certain criteria as Opportunity ...
Coffee's user avatar
  • 527
2 votes
2 answers
986 views

Reporting API via APEX: Get Instances

I was under the impression that when I runReport() using the ReportManager class that a rolling 24 hour instance would be cached so that if I need the data in a subsequent call I would not need to ...
Xtremefaith's user avatar
  • 4,560
2 votes
2 answers
240 views

Need Help With Test Class

This has already been asked and answered and is working except for the errorCase.SuppliedName returns Null after my error message. How do I write a Test Class for this. I'm a newbie and this has ...
Troys Girl's user avatar
1 vote
2 answers
2k views

Before Trigger is not picking up BillingCountry on the Account Object

My class is suppose to pick up The Billing Country and Billing Postal Code and populate the state based on those two fields, however when debugging the before trigger It doesn't pick up the Billing ...
user avatar
1 vote
2 answers
2k views

LWC Continuation Issue: Apex methods for continuation can not be invoked from a non-continuation action

I`m trying to call Continuation method from Apex that has @AuraEnabled(continuation=true cacheable=true) but getting next error: Apex methods for continuation can not be invoked from a non-...
m_konyk's user avatar
  • 546
1 vote
1 answer
682 views

Spring 22: DML operation Delete not allowed on List<CUSTOM OBJECT> [duplicate]

Similar situation to wanwan at: DML operation Delete not allowed on List<CUSTOM OBJECT> But I dont have reputation to be able to comment :-( Customers of our app started getting issues as soon ...
Mark Spooner's user avatar
1 vote
2 answers
2k views

Find if records exist with custom field comparing and as little SOQL as possible

I'm writing a trigger that needs to create a record based on a newly inserted one. The trigger I have now works, but only for small amounts of records. The problem is where I need to check if there is ...
Valyrion's user avatar
  • 1,144
1 vote
4 answers
5k views

Trigger to validate selection of Pick-list values

I got an object called 'Category' which has a master detail relationship with 'Scheme' object, 'category' has a pick list field called 'Type' & it has different values Ex:Cost,Time etc. I need ...
Tinkerbell's user avatar
1 vote
2 answers
5k views

How to get Page layout name dynamically in apex?

I have a requirement where i need to get page layout name dynamically in apex on the basis of record type(page layout associated with it) selected by user. I am overriding account's new button in ...
NEELESH's user avatar
  • 61
1 vote
1 answer
914 views

InvalidUrl Bulk API creating a bulk job using postman

URI i'm using is: https://yourInstance.salesforce.com/services/async/46.0/job so in my case example is https://cs89.salesforce.com/services/async/46.0/job but it still says InvalidUrl. X-Session-Id ...
Jefferson Fernandez's user avatar
1 vote
1 answer
272 views

multiPicklist query

I have a few global picklists which I using for multi picklists. I'm trying to retrieve a data via SOQL but something goes wrong - not all the rows are back or sometimes none of them. It depends if I ...
Salvation's user avatar
  • 1,189
1 vote
1 answer
863 views

Need help on Salesforce Login Discovery using My domain

requirement- When user enter username then it will redirect to SSO setup in salesforce and if user entered correct details then second sso needs to get called and if user enter correct credentials ...
sudhanshu's user avatar
  • 115
1 vote
1 answer
788 views

Test class for Transaction Finalizer is not working

I am stuck in the test class for the Transaction Finalizer class. Every time when we create an exception for Queueable class then Finalizer class executing and then the test class throws the error on ...
Naveen Tiwari's user avatar
1 vote
1 answer
3k views

How to abort current scheduled job?

I would like to schedule a job to run once in 15 minutes time. According to this article: Run Scheduled Apex job once I need to add some code to the finish method: public void finish(Database....
Robs's user avatar
  • 9,336
1 vote
0 answers
81 views

How to prevent the parent Queueable Job from having a 'Complete' status until the chained child Queueable job completes?

This is more of a theoretical question. I have an action button on a VisualForce page which downloads a PDF with large data. When the action button is clicked, it invokes a Queueable job through the ...
Knight of the Vale's user avatar

1
51 52
53
54 55
70