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
27 views

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record. Case not saving: [duplicate]

I'm getting this error when trying to save a Case: Failed to invoke future method 'static void cloneCaseWithCaseProds(String, String, Set<Id>)' on class 'CTRL_Support_ProcessV2' for job id '...
0
votes
1answer
26 views

Need help on lightning spinner

I am new to Lightning Aura Components. I have created a lightning quick action button on vf page. After the button click it will do some functionality behind. Meanwhile I am displaying a spinner on ...
5
votes
1answer
753 views

Recalculating Apex Managed Sharing

I am studying "Apex Managed Sharing" but I have a problem with "Recalculating Apex Managed Sharing". The Apex Developer Guide says: Every time a custom object's organization-wide sharing default ...
0
votes
1answer
1k views

Change the product of opportunity line item?

I am writing some code in apex that checks opportunitylineitems. In my code I am trying to clone some line items but change their product, but I cannot seem to. Code below: if(oli....
0
votes
0answers
15 views

SFDC Architecture for a Signed Sales Quote to become the “Contract” on an Account

I have the following business scenario that I need to turn into a salesforce process: A manufacturer currently has territory-specific pricebooks. When they meet a new distributor, they send the full ...
3
votes
1answer
1k views

What fields deploy with NamedCredential?

I have a callout where we use a Named Credential and it looks something like the following: public class MyClass { public MyClass() { inputHttpHeaders_x = new Map<String, String>...
5
votes
3answers
2k views

How can I get ID of the selected master object record and use it in SOQL query to filter records of the detail object

I've got 2 related custom Objects: Bgroup(Master) & Meetings(detail). I'm displaying a Google map of the meeting records in the Bgroup VF page with a custom controller. Everything is working ...
-1
votes
0answers
21 views

Reminder Emails to Users [closed]

I have a requirement where for a record I have to check if a particular field is blank for 72 hours or not and then send a reminder email to the owner. Following the reminder I have to keep on sending ...
1
vote
3answers
2k views

Rerender output panel when action method using pageReference

Can anyone tell me how to rerender a particular pageblock when the action method using pageReference? My use case is I want to rerender a particular block when I click the command button ...
0
votes
0answers
19 views

Unusual Behavior on Community Change Password Page

I'm working on a community page and trying to customize the Change Password Page. Current Problem "Change Password" language needs to be updated, but the "Change Password" ...
0
votes
1answer
34 views

Invalid integer: [closed]

Case.ExpMonth__c= Integer.valueof(Account[0].expirationmonth); I am trying to assign value here to Case.ExpMonth__c.The ExpMonth__c is number data type field.How to typecast the number field?I ...
7
votes
5answers
14k views

How to split a string by the newline character in Apex?

I wonder if it's possible to use the apex public String[] split(String regExp) method to split a string by the newline characters. The string being a csv file created on the Windows platform. I ...
0
votes
0answers
36 views

Best way of writing tests with lots of stages

So I'm trying to write out a test for our case flows as gradually we have made them more end to end finding spots to split out the tests to avoid hitting limitations is getting harder and harder. I ...
0
votes
2answers
42 views

not able to create campaign record even I have crud PERMISSION

I want to create campaign record via script as new button was not there.But when i insert record it says Line: 1, Column: 20 Field is not writeable: Campaign.Name Even i am system admin .I have full ...
0
votes
1answer
24 views

Update Custom Picklist Values Translations via MetadataService

I have a piece of code that allows me to update custom picklist field values: public static TM_EComUtils.genericResponse addPicklistValuesViaMetadata(String fieldAPI, String sObjectAPI, List<String&...
2
votes
1answer
1k views

Redirecting from Controller to standard list view page?

I'm using a custom_object and once the user save I want that page to redirect to list view page but what is happening is that right after i click save button i see the white blank screen with the ...
0
votes
0answers
14 views

Can we schedule a report to an external link like a drive? [closed]

I have this requirement to schedule a report to an external link which is a shared drive . Is it possible through Apex code Regards Anidaphi
0
votes
1answer
20 views

How to get User Photo Data from nested Object in SOQL?

So, I have Tag_Case__c Object. this object has relationship with Case Object I wanna get SmallPhotoUrl data from Case Owner I was tried use something like this following code, but it not works SELECT ...
3
votes
2answers
1k views

How to get contentData and ContentFileName for FeedComment Post

Can anyone tell me how to get the contentData and contentFileName for FeedComment ? I can get same for FeedItem using below query. [select Id,RelatedRecordId,Type,Body,CreatedDate,CreatedBy....
7
votes
6answers
28k views

i want to access only date form datetime

If i used System.debug('date='+DATEVALUE(System.now())); in developer console i am getting error msg by saying: method does not exist or incorrect signature for DATEVALUE(datetime) How i can do ...
0
votes
1answer
29 views

execute trigger in case of formula field update

Hi I have a formula field in objectA. based upon objectB's field I am updating the formula field on objectA. After update I have to perform some logic on objectA. As formula field update does not ...
3
votes
1answer
169 views

executeBatch method returning invalid id 000000000000000

One of our client is seeing this issue in their production org. Following is the line where this issue is occuring : ID batchId = Database.executeBatch(MainBatch); This line is throwing System....
0
votes
1answer
2k views

How to delete account record associated with contact record?

trigger contaccdelete on Contact (before delete) { list<id> accounts = new list<id>(); for (contact c : trigger.old){ if(c.AccountId!=null){ accounts.add(c....
40
votes
7answers
31k views

How to generate a GUID/UUID?

What is the best way to generate a GUID/UUID from Apex code (such as a trigger)? Preferably in the following format: nnnnnnnn-nnnn-nnnn-nnnnnnnnnnnnnnnnn Example: 13219ec0-3a81-44c5-a300-...
0
votes
0answers
26 views

Error! List has no rows for assignment to SObject. Error on existing Lightning Component

I have a lightning component that was built by another business over 2 years ago in my Salesforce org that is no longer working. When I try and add an opportunity to the lightning component (the ...
0
votes
1answer
607 views

Deleting all public groups from Org

We have an utility which imports all data from one org to another, this results in creating public groups every time import operation is carried out. Is there any way we can perform delete operation ...
1
vote
3answers
1k views

How to get List of test classes and associated errors in salesforce

In my Organization some classes are failing , How to get List of test classes and associated errors?
0
votes
1answer
20 views

Unable to assign Queue as Owner of a Task in Apex Test and Trigger

I have below code in my Trigger which is trying to assign a Task to a Queue. I have provided access to Task object to the Queue. Below code works in anonymous window, it works when I create a Task in ...
1
vote
1answer
33 views

OwnerChangeOptions for account team

How can we use this parameter OwnerChangeOptions and KeepAccountTeam = True in apex. Does we need to consume WSDL and generate Apex class. If we try using below, then account team is not preserved ...
0
votes
1answer
22 views

is it possible to write an algorithm in zbase32? [closed]

I have a request to generate unique codes through an algorithm. take a unique number from a sequence (maximum value 2 ^ 30) ZBase32 encoding is used to encrypt the number. The encoding alphabet is as ...
0
votes
0answers
37 views

Method X does not exist in the apex class with Id Y or Method does not exist or incorrect signature: void [duplicate]

I am trying to push my code to production, but I always get 58% coverage which I am not sure sure why since I am testing most of my classes ... Anyway I added one test to improve my coverage but I am ...
0
votes
1answer
89 views

Cannot edit checkbox (input field in User site guest)

I have a User site guest which displays fields of an object For example, if it's a checkbox If I do <apex: inputField value = "{! loggedC.Expression_rens_F1__c}" /> The checkbox ...
0
votes
0answers
39 views

Apex Test class sample [duplicate]

im a newbie in salesforce. can you guys create a test class for this codes below? public class AccountTriggerHandler { public static void methodBeforeInsert (List<Account> accounts){ ...
0
votes
1answer
48 views

How to cover a for loop in Apex Test? [duplicate]

the for loop is not being covered... I would like to know why. Thanks! Here the test: @IsTest public static void testSaveDistriverloren() { Priority_Distribution__c fetchPd = new ...
0
votes
1answer
31 views

Can I upload Java class as a Jar file in Static Resource and use that Java class components in Apex class?

I have piece of code in Java language, I need to use it in apex class. Let me know if I can upload Java class as Static Resource and use it in Apex class?
0
votes
1answer
24 views

Value is exists in custom metadata list [closed]

I have a list of Custom metadata (Part_one_metadata__mdt) which contains a list of lables (Sunday, Monday, Saturday). Then I am creating a string (public String Medicine) and passing a value. Now I ...
1
vote
1answer
30 views

Using String.split(regExp, limit) - Limit not respected beyond 11

Got an interesting situation where I'm trying to make use of String.split(regExp, limit) to chunk a big list into smaller lists within a loop. However it seems that when the limit is set beyond 11, it ...
0
votes
1answer
36 views

Aura Component not working as expected

I'm very new developer and I'm stuck. I'm trying to adapt an Aura Component that I found on internet to my needs, but I can't make it work (The original I found works fine). Basically what I want is ...
0
votes
0answers
13 views

Aura Dialog box not displaying text as HTML

We have created one lightning component. Onclick of open button Modal box will open and suppose to display contents as HTML but we are getting only static html, We want it to display as Actual rich ...
0
votes
0answers
25 views

Can we By pass - These contacts have the same related account.Open the related account record and remove redundant account–contact relationships error

We have enabled Many to Many relationships between Accounts and contacts using Account Contact relationship Junction Object. When our users are trying to merge duplicate contacts we are getting the ...
1
vote
1answer
31 views

DmlException Creating CMS Library/Folders

I have some Apex code written to create a new Account, and then create a new Library (ContentWorkspace) and new Folder (ContentFolder) within that Library to house assets for that Account. It appears ...
1
vote
0answers
32 views

Newbie needing help writing a test class for an invocable method

With a lot of help from this forum and the developer forum, I got my first invocable method to work but now I am stuck on writing the test class for it. Here's my invocable method and the attempt at a ...
0
votes
0answers
10 views

Test Class Method issue with Dispatcher Console Bulk Custom Action

I have created a Assigned Custom Action on Dispatcher Console. Follwing is my code. global class AssignServiceAppointmentsGFS implements FSL.CustomGanttServiceAppointmentAction { global String ...
1
vote
1answer
1k views

How to get the user logged in in community page?

I need get the user id logged in a web page community site.com (not is a VisualForcePage) in this page I need the user id and others user's fields.
6
votes
1answer
4k views

ContentDocumentLink Apex after insert trigger error

Edit: I've built an after insert trigger on ContentDocumentLink. On cropredy's direction, I've bulkified my code and I think improved it generally. It "works" in that it accomplishes my ...
0
votes
1answer
17 views

Retrieve All Account Contact Relationship records for a contact

I have a requirement, that I should Query all the Account Contact Relationship junctions records for a contact. Could someone direct me to the Query? I used the below Query but not able to retrieve ...
0
votes
1answer
20 views

System.TypeException: DML operation INSERT not allowed on QueueSobject

I am trying to insert a QueueSObject in test class but getting the error System.TypeException: DML operation INSERT not allowed on QueueSobject This code was working before but started giving error ...
0
votes
0answers
24 views

Create a dynamic query for each item in for loop

Hi I want to create a dynamic query for each item in for loop , but again I don't want to execute that query in the for loop, right now since I am creating a query in for loop, I am no option but ...
2
votes
1answer
642 views

Add current stock price to account page

still pretty new salesforce developer, but I was curious what the best approach was to add a companies stock price to their account page in salesforce? I've been referring to the articles below: ...
2
votes
1answer
4k views

i need to split larger set list into samller chunks

i have a requirement, where i am holding list(1000) of email address into one set, and with that i need to split them in to 100 in each sublist and make queryString need to perform sosl query. set&...

1
3 4
5
6 7
640