Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
6 views

Attempting to pass parameter in request.setEndpoint URL & call through Einstein chat-bot! Is this correct code?

I want to concatenate 'input' variable in the Endpoint URL. If i am passing hard-coded value like 'London', its working properly.(I am getting weather in JSON format back). I want to do it dynamically....
0
votes
0answers
9 views

how to create apex class handler or trigger for Case records?

When all the Orders Record related to Case have status of 'Approved', the related status of the Case record should have the result 'Completed'. If the status is Invalid, the result is 'Rejected'. if ...
0
votes
1answer
13 views

getting List has no rows for assignment to SObject error on comparing parent loaction related to parent campaign

@AuraEnabled public static List<MarketWrapper> getMarkets(string parentStoryIds){ //public static List<MarketWrapper> getMarkets(Id CampaignId){ List<CM_Market_Execution__c> ...
0
votes
1answer
17 views

How to add digital signature in APEX triggers to verify source? How to arrange this code?

I am not very familiar with salesforce or Apex. I have created a salesforce after update trigger. I intend to add digital signature to data I send from salesforce to my endpoint. My Apex Trigger ...
0
votes
1answer
11 views

Null Reference when trying to assign a value from a map

set<Id> acctIDs = new Set<Id>(); for (Opportunity newOpp : newOpps) { acctIDs.add(newOpp.Install_At__c); acctIDs.add(newOpp.AccountId); } Map<Id, Account&...
0
votes
1answer
13 views

After update trigger fires twice, first with no updated info, second with info

I'm writing a trigger that chops up a long-text field on an event activity record and puts it into the appropriate fields on the related contact's record. The problem is, the code seems to be firing ...
0
votes
0answers
17 views

Salesforce Report URL Hack for Printable View

I know that entering 'https://yourSalesforceOrg/ReportId?csv=1' produces the same result as you go to standard report UI, press the "export dedails" Button, and then select format "csv". Is there any ...
2
votes
1answer
19 views

Mapped Picklist field values in a wrapper class in incorrect format

I want to retrieve the picklist values of all picklist fields from a standard object. Below part of the code //Wrapper class public class FieldMetaDataWrapper { @AuraEnabled public String ...
3
votes
1answer
72 views

Pass an enum value from lightning controller to Apex

Is it possible to pass an enum value from lightning controller to Apex? Here is what I tried lightning component part const action = component.get("methodC"); action.setParams({p: "VIEW"}); ...
3
votes
2answers
151 views

How to check if a string contains an element from a list

What is the best way to check if a string contains an element from a list? for example: String email= 'itairu@gmail.com' List<String> domainNames = split by ; from domains in a custom setting ...
0
votes
1answer
18 views

Test class for Opportunity whose Stagename is changed to close Won/ close lost, its close date should be today, is this correct?

@isTest public class populateOpportunityTest { @isTest public static void testopportunity() { List<Opportunity> oppList= new List<Opportunity>(); for(Integer i=...
1
vote
0answers
25 views

How to change the size of Modal in Lightning

How can I update the size of the modal to fit only the size of the text inside it. This is what it currently looks like, This is the my code for this <aura:attribute name="recordId" type="Id"/&...
0
votes
0answers
27 views

How to return filled in filename on apex repeat

I have a visualforce page which has an apex repeat whit a input filname. When I add a following inputfield for a filname the line before is emptied. Is there a way to return the filled in filename. ...
0
votes
1answer
23 views

I'm giving access to the children of parents of a newly created account, but i think its not working, or else how to check if this is working

public class ManuallyShareAccount { public static void manualShare(List<Account> newList) { Set<Id> accSet= new Set<Id>(); for(Account acc:[SELECT ParentId ...
0
votes
0answers
33 views

Markup the Visualforce table

GE. I have a Visualforce page and corresponding controller with my own Custom object. I need to markup this page as follows: "Main table" - parent-child; field name and his value in a center of page, ...
1
vote
1answer
27 views

share record with account owner of all child record which is associated with the parent

public class ManuallyShareAccount { public static void manualShare(List<Account> newList) { List<Account> accList= new List<Account>(); Set<Id> accSet= ...
-1
votes
0answers
14 views

search button to display only particular child records

public with sharing class searchInvoiceline { public list <Invoice_Line__c> acc {get;set;} public string searchstring {get;set;} public String Quote { get; set; } private ApexPages....
1
vote
1answer
15 views

Different sObject record CSV file in separate tabs using Apex Script

My requirement is to send csv file as email attachment to few email IDs. Currently I can do this but fetching records in single tab of the csv file. My requirement is to get the records in separate ...
1
vote
0answers
21 views

How to create Notifications in Salesforce Lightning using Apex

I want my Task to appear as a notification in the top right corner in Lightning. This is my Apex code: Task t = new Task(); t.ReminderDateTime = DateTime.now(); t.Priority = '...
2
votes
1answer
15 views

Why Would Batchable Not Run the Specified Scope Limit?

I call to a batch class on 204 records: PaymentAgreementMonitor myBatchObject = new PaymentAgreementMonitor(); Id batchId = Database.executeBatch(myBatchObject, 66); When it runs, it is running on ...
0
votes
2answers
25 views

How to get record Owner using Apex

What is the simplest way to get the record's ownerId from a recordId when I don't know the object type of the ID. Do I need to figure out the object type and then do a dynamic query? Or is there a ...
-1
votes
1answer
29 views

trigger to get opportunity products

When Opportunity stage is set to won Get list of all opportunity products of that opportunity, and search for specific product .. If the product, is found in that opportunity, then perform following ...
0
votes
1answer
31 views

Component Error - access rights?

I have a Lightning component that works correctly when logged in as a SysAdmin. However, when logged in as a user with a different profile, the error below is received. I have without sharing set in ...
4
votes
0answers
36 views

Visualforce page not displaying correct Devnagiri words when it render as pdf

I am using Arial Unicode MS font in the visual force page. I need to render it as pdf. The HTML contains Devanagari words. HTML is displayed properly but the words are broken in the generated pdf. e.g ...
-2
votes
0answers
27 views

How to use upVote and DownVote in Apex [on hold]

I'm currently working on my visualforce page that displays the Topic and comments. Right now, I want to add an upvote and downVote to the comments added to the topic. My problem is I don't have any ...
-2
votes
0answers
35 views

Transform Json request body

I am working on an integration ,where i want to transform my Json with appended name value strings in it. Actual JSON: { "payload":[ { "YearlylCostPercentage":"4.6", ...
0
votes
3answers
36 views

Remove the last characters in string

Can anyone help me how to get the id of the case on this string? String caseID = '500k000000gcuyciad&notify=1'; I dont want to include the &notify=1 or &notify=2 and so on
0
votes
0answers
14 views

How to add Predefined Case Teams to Case in Apex Test Class?

I am trying to add a predefined Case Team member to a Case with the following code: CaseTeamTemplate ctt = [Select Id from CaseTeamTemplate where Name = 'Some Name' LIMIT 1] caseteamtemplaterecord ...
-1
votes
1answer
23 views

Trigger to create task if opportunity stage name is Closed Won. But getting error as variable “stagename” not found

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) { List<Task> taskList = new List<Task>(); for (Opportunity o :[SELECT Id,StageName FROM Opportunity ...
1
vote
0answers
34 views

Delete __Sharing object

I'm receiving the following error: TR09_MasterServiceAgreement: execution of AfterInsert caused by: System.DmlException: Delete failed. First exception on row 0 with id 02c1800002Lir2PAAR; ...
0
votes
1answer
43 views

How do I use Blob to create a PDF in my apex controller and use it in my Lightning Component without using VisualForce Pages?

This is the apex controller: public class pdfGenerate { public static final Integer limitRecords = 10; @AuraEnabled public static Blob generatePdf(){ List&...
0
votes
1answer
22 views

How to catch update exception and what kind of notification to do here?

I have a trigger with helper class and test. But I don't know how to test update there and what kind of notification I need. Thanks for any help. Trigger: trigger ArchivedTrigger on Item__c (after ...
0
votes
1answer
26 views

Need to query records based on external object relationship on another object

I have 2 lookups to two different objects: licence Type and Licence class Definition on Case Object. Licence Type is a lookup on Licence Class Definition Object. I want to filter Licence Class ...
-2
votes
3answers
49 views

Apex Callout, how to set body?

I am struggling to configure body for http request. This is what I have received from integration team. "body": { "mode": "formdata", "formdata": [ { "key": "sourceFile", ...
1
vote
2answers
53 views

Query Limit on Batchable Class

What is the best practice with governor limits with Batchable classes and queries inside of the Batchable class? I am running into query limits with a Batchable class because I have too many ...
0
votes
0answers
35 views

Error when saving Lightning Component

When saving my lightning component I am getting the error"FIELD_INTEGRITY_EXCEPTION" "Failed to save LaunchpadList.cmp: Invalid definition for null:LaunchpadListController: null: Source" I've tried ...
3
votes
1answer
20 views

Not being able to access Flow variable in Apex class

I am trying to create a flow which creates an account record and then navigates to the newly created record detail page VF Code <apex:page Controller="AccFlowController" TabStyle="Account"> &...
-3
votes
0answers
30 views

Please help me to cover the test class for siteRegistration controller

Need to cover the remaining lines of code.. Controller and test class... /** * An apex class that creates a portal user */ public class SiteRegisterController { // PORTAL_ACCOUNT_ID is the ...
1
vote
1answer
31 views

Send a JavaScript object to Apex using lightning

Is it possible to send a JavaScript object to Apex without using JSON.stringify and JSON.deserialize? Here is what I am trying to do: class A { class B { @AuraEnabled public ...
-1
votes
0answers
19 views

Failing batch class daily in prod [on hold]

I wrote a batch class which updating records. as per batch query it is returning 70 records .. but it is failing every time in production with this in prod also 70 record with batch query condition ...
-1
votes
0answers
14 views

I want to group by structure via wrapper class and normal table [on hold]

I'm trying to build a table with group by structure with the help of wrapper class and html table with apex repeat. However I find it strange the list size of wrapper class is not incremented more ...
1
vote
1answer
13 views

Displaying related cases Email data on visualforce Page for Big Objects Data

First of all i am very new in salesforce and not have anything to do with programming however i have been trying to finish my first project by getting help online. I have created a BIG OBJECT "...
-2
votes
0answers
22 views

trigger to update case before insert, update based on domain

I am trying to create a trigger that will automatically update contact on case depending on certain criteria. Let me explain more. I have cases that come from different domains and because of that i ...
0
votes
1answer
15 views

how to retrive /fire a link from a cutom object field

I am storing the public url of a pdf file in a field of a custom object. I am able to successfully retrieve the url. how can I fire the url when a user click a button? Is it possible through JS ...
0
votes
0answers
12 views

Prefill data into FeedItem body

I have a problem, and i dont know how to make it. I need to put data into FeedItem on Case which is sent as Type TextPost. It needs to show first name and last name of the account person which is ...
1
vote
1answer
20 views

Need help on Feeditem post to allusers

I need to post my status to feed item to AllUsers. As of now it is going to only internal users. Here i am using the below string to post the status. Here if i add visibility it is not accepting. @...
0
votes
2answers
27 views

Code Coverage low even though I'm calling the method

I am coding an Apex Test Class for an Apex Class. I am have trouble understanding why some lines of code are being covered while others are not. I also don't understand why the if statement in my ...
2
votes
1answer
32 views

Can we delete activityHistory records in Apex?

There is a need to delete ActivityHistory for contacts and related tickets for those contacts due to GDPR. I figured out how to query ActivityHistory, but seems like ActivityHistory Delete DML is not ...
0
votes
1answer
16 views

Bubbling up an Account hierarchy to capture top most Parent Id from query

Based on some of the answers I've browsed I think this might involve 2 queries. I feel like this is probably a pretty common problem so I was hoping someone would have a quick answer or at least be ...
0
votes
1answer
28 views

How do I architect my code to avoid this “Too many SOQL queries: 101”

I am developing some apex code that I am using to query a REST web service and storing resulting objects in salesforce. I know that this error means that I am generating more than the 100 queries ...