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
0answers
23 views

AWS Signature version 4 using Named Credentials callouts - how to add request parameters [closed]

Name- aws_WScallout url - https://servicename.amazonaws.com Identity Type - Named Principal Authentication Protocol - AWS Signature Version 4 AWS Access Key ID - ****** AWS Secret Access Key - ********...
0
votes
0answers
13 views

FullCalendar.io timezone issues while rendering events

We're trying to render salesforce events in fullcalendar using jquery. We're facing some issues with timezone when rendering events in dayview/monthview/weekview. I'm rendering full calendar using ...
0
votes
0answers
26 views

email template to be used in apex . Email template used approval.id

I am trying to send emails through email template in my apex class . This is the code I am trying Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(...
-5
votes
0answers
35 views

Salesforce admin and developer [closed]

This is not interview or exam question. We have an issues where while creation of account, if no gender is speicified , it defaults to U. So just want to know if there is anything wrong in the below ...
-1
votes
1answer
21 views

Display Profile Photo of Partner Users in a VF page [closed]

I have a requirement to display FullphotoURL of Partner Users in a VF page which are of 700 (Pagination can be applied to display in multiple pages). It should be displayed with the name of the User ...
-2
votes
0answers
27 views

Can someone please post an example code to update assignment rules using Metadata API? [closed]

I want to update the Case's standard assignment rules using metadta API but can't find any success in it. Here is the steps I am following: 1. Using Read metadata API call on "assignmentRules", I am ...
0
votes
0answers
26 views

Batch Apex - Try to create order while loading data

I have a batch apex that runs thru some attachments of a custom "Job" object that I made. There are 5 CSV files attached to this Job object, which I parse & create Salesforce records from. Now ...
0
votes
1answer
27 views

only root queries support aggregate expressions

I was working on one trigger and using sum in query but I am getting the following error when I tried to save record. only root queries support aggregate expressions Can anyone helps me out in this ...
1
vote
0answers
15 views

Barcode scanning through Salesforce mobile - 2019

I looked at previous questions and it seems that this blog post from Bob Buzzard from 2014 shows that it's possible to scan barcodes through a VF page. I want to know if this is possible with recent ...
2
votes
0answers
19 views

Surprising compilation error: “A non foreign key field cannot be referenced in a path expression: ChangeEventHeader”

Why is it that this will not compile: trigger AccountChangeTrigger on AccountChangeEvent (after insert) { String dmlType = Trigger.new[0].ChangeEventHeader.changetype; ... A non foreign ...
0
votes
1answer
16 views

Passing List<sObject/Wrapper> vs JSON.serialize(List<sObject/Wrapper>) when using action:Function

To avoid view state, I know the best practices would be to mark variables transient where ever possible or to use javascript remoting, which does not transfer view state info with it. But lets say I ...
2
votes
1answer
44 views

VS Code Debugging Class

I am new to VS Code, I have read up on it. I can write APEX very well but only in the developer console. I am used to System.Debug Logs. I see that in VS Code you can put in Breakpoints versus debug ...
1
vote
1answer
28 views

Default account team in apex code

I was wondering how one would create a default account team in apex code. I'm trying to create a test class where it is being used but I cannot figure out how to add a default team.
1
vote
1answer
17 views

Run report from Apex

My users want more control scheduling reports. The scheduler only offers a limited set of times and frequencies. I know how to schedule apex scripts using System.schedule and a cron string. Is ...
0
votes
0answers
12 views

How to retrive invalid phone format data from salesforce [closed]

Basically the phone format data are available in 0-9 but in my org there are lot of phone data for account object is in invalid format. I need to extract those data from org. Is there any apex code so ...
0
votes
1answer
25 views

Unable to identify REST API status code

I am testing a REST service in dev console and I'm getting a status of Found and a status code of 302. However, the body is empty and I know the parameter value returns a record from the system that I'...
2
votes
2answers
64 views

Datetime.parse() start to fail in Apex Controller

An apex controller invoked by vf page in Salesforce orgs (both sandbox and prod) start to fail recently. No code update was made for years on this apex file. The failing line is like Datetime.parse('...
0
votes
1answer
21 views

Hot to get value of relationship dynamic Soql

I am using the following string in a dynamic soql: SELECT id, name, orderdate__c, status__c, sold_To_Customer__r.id, sold_To_Customer__r.name, sold_To_Customer__r.customerreference__c, ...
-2
votes
3answers
52 views

how to update parent object field when we make any changes in child object field?

i have a parent object 'salesforce project' and child object 'salesforce ticket' whenever i will select the priority of child object 'high'( then it should update the description field of parent ...
0
votes
0answers
31 views

Create Calendar with apex

I need to automate public calendar creation with Apex. The problem is that when instantiating the calendar object, it tells me that its fields are not writable. List <Calendar> calendars= new ...
1
vote
1answer
38 views

lightning:datatable with wrapper object rows question

I am trying to set a list of string values from a wrapper object dataClass @AuraEnabled public List<String> plannedDates; Relevant column of the datatable I am using is below: {label: ...
-1
votes
0answers
12 views

Apex Test class for ProcessInstanceStep [duplicate]

Please let me know how to cover below query in apex test class. [SELECT StepStatus, Comments, id, ProcessInstance.TargetObjectId, createddate FROM ProcessInstanceStep limit 1];
-1
votes
0answers
15 views

problemin getting code coverage for apex class [duplicate]

I am working on one test class for apex class but getting only 37% code coverage only, can anyone help me out in this issue here please. apex class: public class ProjectGanttControllerExtension { ...
-3
votes
2answers
41 views

could some help me to avoid 101 error in below code please

trigger removeMember on CampaignMember (after delete) { removeMemberOnCampaignMemberHelper.afterdelete(trigger.old); } public class removeMemberOnCampaignMemberHelper { public static void ...
0
votes
1answer
21 views

Pagination REST API, Multiple request, DML End problem

I was share 1 more question before in my profile, and i changed my apex code, My old question. Now i wrote my callout function in batch apex class, My problem is when i want to send second request ...
0
votes
2answers
36 views

For loop limit 1 - idiomatic apex? [closed]

I came across this today: for(custom__c custom: [SELECT field__c FROM custom LIMIT 1]){ \\record processing goes here } At first this confused me since it seems strange to have a for loop when ...
0
votes
2answers
35 views

Every time i append a string in for loop , i get a null in between

So I am running a string append statement inside a for loop String apComment; apComment = ''; for(Processinstancehistory p:lispros) { apComment +=p.Comments; } So after this, I get the ...
-1
votes
0answers
22 views

Unit test for Queueable callouts

I am trying to write test class for Queueable callouts. Can someone help me how to write test class for the below code in salesforce public class CalloutQueueable implements Queueable, Database....
0
votes
1answer
27 views

Want to add Amount field of Opportunity on custom object field

I want to add Amount field of Opportunity on custom object field. Objects- Opportunity, Sector Target. Fields- Amount on both objects Currency(16,2). Criteria - If Opportunity Stage = Closed Won. I ...
0
votes
1answer
49 views

dont know why '\n' is not working for next line

I am using '/n' in below way public String appComment{get;set;} for(Processinstancehistory p:listp) { appComment=appComment +'\n'+ p.Comments+'\n'; } I am getting result in one line . I need every ...
0
votes
2answers
38 views

SOQL to concatenate column values from multiple rows

From contact object I have to concatenate the row value from Column based on the accountId For Ex: AccountiD ='1234567890' for this account we have 2 email in contact object AccountID Email ...
0
votes
1answer
17 views

Generate SSH in Salesforce to connect to external SFTP server [duplicate]

Thanks for your help! I have a case where I need to generate an SSH key in Salesforce and share the public key with my client where SFTP server is installed. And then use this SSH for authentication ...
0
votes
0answers
22 views

Visualforce - image resize when render as msword

I have a visualforce that builds word documents dynamically and I'm having troubles with the images opening in the original size. The document only resizes if the tag is set like so: <img alt="" ...
-2
votes
0answers
22 views

Is there some Trailhead API? [duplicate]

The Endpoint return only html. I want to restore points, badges and trails in Trailhead, but after change web site trailhead, it is no longer possible. public class RESTGetHttpContentCallout { ...
1
vote
1answer
43 views

Build table with for:each and Field Sets (LWC)

I'm making a table that displays a custom object with fields retrieved from Field Set on that object (that can, of course, be changed). I have apex logic that returns the List of CustomObject__c and ...
0
votes
1answer
25 views

Update Parent based on changes in 3 different child object records

I have a parent "Contact" object which has 3 different child objects (Paid__c, Received__c, Forum__c) . Based on changes in these 3 different objects, I would like to have a multi select picklist ...
0
votes
0answers
33 views

DML operation inside a loop

I need to make an apex class that needs to upsert hierarchically three times the same object. Currently, the only way I found to do this was this way: private void upsertLevels() { for(List<...
4
votes
1answer
58 views

Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System.HttpRequest

Currently stuck at trying to send a JSON structure through web services but keep receiving the error: Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System....
3
votes
1answer
49 views

Where is Users Identity Verification info is stored?

The View Your Users’ Identity Verification Methods article describes how we can view information about each user’s identity, yet it is not clear where this data is kept? In what object? I can create a ...
0
votes
0answers
22 views

Why TwoFactorMethodsInfo is not accessible?

I want to run a SOQL query on this object TwoFactorMethodsInfo. Yet by some reason it is not supported: This documentation references it https://developer.salesforce.com/docs/atlas.en-us....
0
votes
1answer
24 views

Shortcut to see result of a Query in VS-Code itself rather than keep checking in Developer Console?

I wanted to know if there is any shortcut, with which we can instantly check result of SOQL query written in Apex class in VS-code itself rather than every time keep checking it in Developer Console??
1
vote
0answers
22 views

How to track when user verified their email by clicking on the verification link?

I use the System.UserManagement.sendAsyncEmailConfirmation method to send emails with a validation link. Now I want to execute some logic exactly when they click that link. Or at least when the User ...
0
votes
1answer
24 views

How to Allow Duplicate Contacts when Saving on Overridden Contact Edit Page

I am creating a Visualforce page that will override the Contact New and Edit pages. I know that when a duplicate (based on Email or SSN) Contact is saved from the standard Contact page, the user has ...
0
votes
1answer
23 views

URL.getOrgDomainUrl() call from different places [closed]

Is it possible to call not from ApexPAge, but for example from the RemoteAction, AuraEnabled method. either in the trigger is better, or in the batch in the Execute method
0
votes
1answer
29 views

Run a Autolaunched Flow with Trigger type Scheduled

I have a flow as described in the title. If I click on the 'Run' button i receive the following error: The flow failed to start because the provided values were not valid: Scheduled Flow could only ...
0
votes
1answer
27 views

I am getting the below error :-System.QueryException: Inline query has too many rows for direct assignment, use FOR loop

I am getting the below error :- System.QueryException: Inline query has too many rows for direct assignment, use FOR loop I am new to salesforce and getting below mentioned exception in one of ...
0
votes
1answer
24 views

How do I check if a list-value from my Map is empty?

I get this error in case if Opportunity__c has no OpportunityInfo__c. I try to check it with the condition if(opportunitiesMap.get(actualTool.Rent__r.Opportunity__c).OpportunityInfo__r != null), but ...
2
votes
0answers
39 views

Will trigger fire when cross object fields update?

I have written Trigger on Object 1 and I am manually updating a field on Object 2 which will automatically update one field on Object 1. So will trigger fire when the field in Object 1 is updated? ...
0
votes
1answer
37 views

Is there a simple way to get the values of a list in a comma separated string all in once

I have a custom metadata type in which I want to add the API names of some custom fields to use the values in a Dynamic Soql. I used a list to get the values of the custom metadata fields. Is there a ...
0
votes
0answers
35 views

REST API Create Multiple Records

Create multiple records with reference to the official documentation:Create multiple documentation url But I need to fill the lookup field value, I found the official document again:update ...