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
3answers
24 views

SOQL Search function of Contact Name With Account Parent to Contact Child

I have 2 fields in my Search function with Account Name and Contact Name. The scenario will be, If the Contact Name has a value 'nothing' it will query in the Account to Contact relationship with ...
0
votes
1answer
17 views

Batch process throwing future method error

I have a scheduled job that executes a batch process that clones some opportunity records. When the records are inserted, it fires triggers on the opportunity that calls a future method, which throws ...
1
vote
1answer
23 views

Pass in array to salesforce platform event?

I am using platform events and trying to send in some parameters to the platform event from an external system. One of the parameters is an array, but I am getting an error from salesforce. The only ...
1
vote
2answers
816 views

Complicated FOR loop nesting. Having trouble cleaning up legacy code

I am trying to tidy up some really bad legacy code from an old developer and I'm trying to get rid of these nested for loops. The code below shows what I'm currently working with. I've fixed this ...
0
votes
0answers
29 views

Slack integration w/ Salesforce - @mention user? [on hold]

I created a webhook that I am making a callout to and the message is getting through to slack but I am wondering if there is a way to '@mention' a specify user in slack based off the owner of a ...
1
vote
0answers
23 views

How add a ServiceReport to a test class

trigger ServiceReporttoSA on ServiceReport (after insert) { for (ServiceReport SR: Trigger.new) { ServiceAppointment SA = [select Id FROM ServiceAppointment WHERE ID =:SR.parentId];...
0
votes
0answers
20 views

Custom Case Change Owner Button for lightning [on hold]

My requirement is, while transferring the Case Ownership I want to restrict QUEUE Visibility based on USERS COUNTRY. Ex: if Current Owner is from France then he should be able to see only France ...
0
votes
1answer
20 views

how can I drop just the defect record and process rest of the records in a batch

I have a batch which reads data from another system and update salesforce records the reference used is SFDC ID, which is one of the parameter from the response used to identify the right record in ...
0
votes
0answers
18 views

Comparing certain fields in two separate instances of the same object under a parent object

Certification SObject is the parent of Exam SObject. A certification instance can belong only to one Contact. A Certification can have multiple Exams(eg: exam_types - Science, Maths, English ...
2
votes
1answer
25 views

Is the Trial-Phase relaxing Test-enforcing and ToolingAPI to save APEX on Production Orgs?

As a great surprise I have noticed today at the org of a new client (his Org is running in the Trial-phase) that APEX Tests seems not to be enforced and that I could modify and save APEX quickly using ...
0
votes
0answers
12 views

Problem with uploading multiple documents in SFDC in Lightning Component

I have an issue in regards to uploading multiple document in sfdc, basically what's happening is instead of 3 different files being saved in SFDC, it will save 3 same documents in SFDC... I think my ...
0
votes
1answer
14 views

What is the window of messages in Platform event after published by sales force

What is the window of messages in Platform event after published by sales force and Is replay Id is getting reset after that
1
vote
2answers
28 views

Got error while constructing the dynamic query

I was trying to build a query to pass it in the QueryLocator. The following is the code snippet I tried to generate the dynamic query, public String buildQueryString(Object_Rule__mdt ObjectRule, ...
8
votes
1answer
89 views

Set.retainAll () on API 45 dies with UnexpectedException

I have a weird issue, can somebody help? On API 45, the following test crashes with FATAL_ERROR System.UnexpectedException: java.lang.String cannot be cast to apex.bytecodeinterpreter....
0
votes
1answer
34 views

call apex method from Form element

Is there a way to call Apex method to save the values in a form element? For example : <form id="scan-form" action="https://www.huika.com/payment/index.php/starting" method="post" ...
2
votes
1answer
27 views

Alternative for lambda expressions in apex salesforce

I know that Salesforce does not support lambda expressions and query syntax (like in LINQ) queries in apex collections. But, It would be a nice feature for developers. Has anyone tried implementing ...
0
votes
0answers
18 views

How to send data which increases after the base64 encoding?

I'm trying to send an attachment through api call, my file size is 4.5mb which increases to more than 6mb after base 64 encoding. and it start throwing error of 6 mb limit which salesforce support for ...
0
votes
0answers
14 views

Navigate to other Url after Post request from VF Page

I have a scenario when a user needs to fill a form in vf page and after submitting, it should save the data in SF and also send the data of the form using POST API to the URL hosting's server- the ...
0
votes
0answers
26 views

Test class for pagereference in a method [duplicate]

I am unable to get code coverage for my pagreference, my code is code: public class selectedcase { public list<recordtype> record {get; set;} public id ids; public selectedcase(){ ...
0
votes
0answers
13 views

connect salesforce to Microsoft azure using apex callout [on hold]

I have a requirement when ever employee is marked as active we need to create Microsoft azure id with first name . last name ? any idea about how we can authenticate the Microsoft azure active ...
-2
votes
0answers
24 views

want to write helper class that can be call in after insert, after update trigger [on hold]

I am having one child object where 2 fields are status and date. the parent object is opp. so want to create a field on opp looking to child object so that this new field will populate whenever the ...
0
votes
1answer
17 views

Insert a List collection into a Map Collection with the same index

I am trying to add a List of collection to a Map Collection with the same Index. I have this Code: List<Account> accountContactList = [SELECT Id,Name FROM Account]; Map<Integer,List<...
3
votes
1answer
116 views

Trigger: Find out the name of the object the trigger is firing for?

Is it possible for the trigger to see the name of the object it's firing for? Say can I make the OpportunityTrigger be aware that the object name it's firing for is Opportunity without hardcoding the ...
2
votes
1answer
23 views

Subquerying filtering on main query field

My intention is to filter the child records which are != to a field of the master. Account: Master Application__c : Child Using Subquery: select acc.id,acc.Callista_Org_Unit_Code__c , (select ...
0
votes
1answer
14 views

Validation rule for non testing context

In Apex to separate code execution for test and non-test context we use the following method Test.isRunningTest() Do we have any such thing for validation rules i.e the validation rule should be ...
0
votes
1answer
39 views

Need Help on Modifying Code [on hold]

I found this example on a dynamic hierarchy for Accounts and I need help as to how to modify it to display an account hierarchy. I am unable to figure out why I recieve this error message when testing ...
0
votes
1answer
27 views

Help With Method Increment A Score

I have a class that increments a custom field on the Contact record. If the contact has a campaign member status of Opened then the Pardot_Emails_Opened__c field increases by 1. If the status is ...
0
votes
1answer
31 views

How to Loop through a map that contains multiple object IDs?

Must be really simple but I am struggling with how to loop through this map. Gone through some examples but was unable to figure it out. Question is, how to loop through user IDs from TargetActorMap ...
0
votes
0answers
29 views

Lightning Error Message Question

I'm trying to create my own Account Hierarchy link that displays more than 500 accounts and its children utlizing lightning componenets and lightning out. I keep recieving this error whenever testing ...
0
votes
0answers
33 views

Get Values for a Picklist Field Based on RecordType [on hold]

When I hit this URI: /ui-api/object-info/{objectApiName}/picklist-values/{recordTypeId}/{fieldApiName} I get this response: System.HttpResponse[Status=Not Found, StatusCode=404] I am receiving ...
-2
votes
0answers
26 views

ASCII Characters [on hold]

I have one requirement where submitting answers in the field boxes the user should only be able to submit ASCII characters in visualforce page.
0
votes
1answer
46 views

call Messaging Queue every 5 Minutes [on hold]

I want to make Integration between Salesforce and ActiveMQ(Is is a messaging server where the company send and save messages in this service). The Context: Every 5 Minutes should salesforce a ...
0
votes
0answers
29 views

Test class for RequestData class [duplicate]

@HttpPost global static List<HHSurvey> getHHSurveyList() { RestRequest req = RestContext.request; RequestData mRequestData = (RequestData)JSON.deserialize(req.requestBody.toString()...
0
votes
1answer
23 views

Working on Search Criteria and limit the number of filters displayed on Search Criteria section

I am working on a Search Function using custom controller. I have 4 Filters (Account Name, Country, Account Type, Contact Name) in my Search Criteria Section. I have a requirements that, it must have ...
0
votes
1answer
19 views

Passing array from Visualforce Javascript to apex class

Before posting this question let me tell you all i have already referred below posts for reference Post1 Post2 But was unable to proceed with the solutions provided.So posting my query here As my ...
0
votes
0answers
20 views

Test method for doGet() [on hold]

@RestResource(urlMapping='/getTL/*') global class WS_GetTLList { @HttpGet global static User doGet() { RestRequest req = RestContext.request; User user=new User(); String ...
-1
votes
0answers
15 views

Append case id in subject on reply to email

I am working on email to case. My requirement is: Whenever a user send email from outside to salesforce generated email service address, case record should be created. After that user should receive ...
1
vote
1answer
14 views

Issue with matching password with javascript in Visualforce Page

Here I had write javascript to match password and confirm password < script > function check() { var p1 = $('.password11').attr('value'); var p2 = $('.confirm_password').attr('...
0
votes
1answer
20 views

Trouble writing Help Class for JSON de

This test class is driving me crazy. I have can prove an array is passing through the class from the test class, but I can't seem to get code coverage. I did use the Json2Apex tool to build the class. ...
2
votes
2answers
33 views

Salesforce: Issues in removing the entire child node in an xml

I have an xml , and I tried to remove an entire child nodes using the xml DOM process. Even i use the remove child method , the result says true but if i print the dom it still holds that child ...
0
votes
1answer
18 views

How to have Apex Trigger post Chatter field updates in one post?

I currently have an apex trigger that posts to chatter for when a field is updated on a record. Currently, the trigger works but posts each update as a separate chatter message: I want to have it ...
0
votes
1answer
16 views

How to update contact owner value

I have this SOQL: SELECT Id, mudouProprietario__c,(SELECT Id, AccountId, OwnerId FROM Contacts) FROM Account I need get value of owner account and set the value at the contact owner I created a ...
0
votes
0answers
16 views

Lightning - Context URL - Get get Id from URL

We are using Lightning. Context URL https://stiyej--sdsd.lightning.force.com/lightning/r/ContentDocument/0690D00000sdsdRQAS We want to get the conten id from the url in Apex. Is there any way we ...
0
votes
2answers
46 views

Race condition Soql with order by

I have a lead owner assignment logic with many conditions. When user presses a button "Get lead" a lead in the org is searched and ordered by the field rank (Soql order by rank__c), and when the lead ...
0
votes
1answer
45 views

Multiple Nested Loops in Apex

Background: I have 3 objects: Contacts, Accounts, Campaign, that are involved in the scenario. Contact is the parent object, Accounts and Campaigns are child objects to contact(Related Lists) There ...
0
votes
1answer
21 views

Why does number field comes as Decimal type even if Decimal places is 0 in field definition

A very basic question. We define a number type of custom field and try to fetch it in apex. After this suppose I write following code : Set<Integer> validCounts= new Set<Integer>{1,3,6,9}...
-2
votes
0answers
21 views

can we disable inline editing for a particular data type for a particular field? [closed]

I have used InlineEditSupport in VF. I have a Number field and I want if user try to insert any text in that field then the input will not take , but user can insert or change the field value with any ...
0
votes
0answers
25 views

Lightning Custom Caching

Hello Lightning Experts, How to implement custom caching in Client Side for Lightning. Is HTML 5 Web Storage is right option for this? Use Case: Based on the service address, show the service ...
0
votes
1answer
18 views

Json2apex - Message consuming unrecognized property

I am not able fetch all details for message & text fields node. Getting error as: Message consuming unrecognized property: name, Message consuming unrecognized property: userId, Message ...
1
vote
1answer
29 views

Test Class for Controller Extension Visual Force Page

I am trying to test my controller extension, Although the final score coverage hit into 100% but when i checked my tests log in my dev console i got Error. This is the ERROR Message: System....