Stack Exchange Network

Stack Exchange network consists of 175 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 [code]

Code indicates that a question is to do with pages, controllers or similar, and not the declarative aspects of the platform.

0
votes
1answer
36 views

Delete Account that are not associeted with a case

i want to delete all Acccounts in my Org that are not associated with a case in the apex console. How can i do it? Thanks in avance
2
votes
0answers
12 views

How can i get data from a report in apex code but only from the first grouping level?

I have a report that has more than 1 grouping level but i only need the data from the first grouping level of each row returned. I have 125 rows for the first grouping level, i only want that data. ...
0
votes
1answer
36 views

Abandoned cart Jorney using data from Track Code

In Marketing Cloud (SFMC) I used the track code to add cart and purchase. How can I use the information about the abandoned cart in a Jorney? Do I need to use any event? I can see in Web analytics ...
0
votes
1answer
28 views

How SWAP(rows UP and DOWN) in Pageblocktable in Visualforce page using Apex method

Here I'm Trying to do swapping on Pageblocktable means I want my rows to be Up and down Right now it's happening through Javascript Now I want this through APEX method. Please look at the below ...
1
vote
1answer
72 views

Avoiding multiple If statements

Is there a better way in Apex to have multiple If Statements? I know that multiple if statements will slow performance, and my scenario would require me to have 36 different scenarios. Ex: I have 2 ...
0
votes
0answers
16 views

Advice on creating better unit test [migrated]

I have this controller, in which  I am trying to write good test classes. I have some test cases, corrections /advice are appreciated to make them better. public with sharing class ...
0
votes
1answer
31 views

Validating input and throwing error

So I have this field input in my UI, I need it to throw an error if it is left blank, but it is not. This is my code <div class="slds-text-heading_medium slds-align_absolute-center"> &...
0
votes
1answer
12 views

Provide an HTML URL in a Record Type Description

How can I supply a clickable URL in the RecType description when creating any type of record where you need to select a record type first?
-3
votes
1answer
39 views

How to convert the apex class into batch apex class? [closed]

public class MonPipelineReport{ public static void Get_Officer() { Date startDate = Date.today().addMonths(-1); startDate = Date.newInstance(startDate.year(),startDate....
0
votes
3answers
37 views

Trying to increase code coverage for a trigger that deletes events

So I'm trying to write a test class to meet code coverage requirements to push up this trigger: trigger DeleteEventsOnCancellation on Case (after update) { for(Case c : system.trigger.new){ ...
0
votes
1answer
17 views

Apex Code for Account Owner update based on Region of the user

Account Owner Lookup field needs to be updated based on the Region field of the user. Admin Will run the anonymous apex, If the users region and Account's Field Dealer Code Values match the Account ...
3
votes
2answers
73 views

Accessing Object properties

When accessing Object properties like 'Account.Name' multiple times throughout the code, is it better to create a variable and assign the property value to the variable once or is it fine to ...
1
vote
1answer
31 views

need to throw an error on specific record from list

I have below method and error is coming beacuse of some validation/trigger is on account and need to catch the exception If i am runnning this from Ui for one record this will throw an exception as i ...
2
votes
2answers
207 views

Can you code on an iPad?

I've been thinking of buying an iPad and I was wondering if I could write my apex classes on an iPad? My iPhone's browser redirected me to the Salesforce1 app after I tried logging in to my sandbox. ...
1
vote
1answer
99 views

I have written one trigger for update child records count on parent record and it's working fine but I want to know my approach is correct or not?

Trigger Trigger ContactCountTrigger on Contact(After Insert, After Delete , After Undelete, after Update) { ContactTriggerHandler cth = new ContactTriggerHandler(); if(trigger.isAfter) { ...
0
votes
1answer
180 views

Social Sign On for Salesforce Reg Handler Class and Test Class-System.NullPointerException: Attempt to de-reference a null object

My org is setting up social sign on with Google and I am running into an error I have never seen before: System.NullPointerException: Attempt to de-reference a null object Does anyone know a ...
0
votes
1answer
35 views

List of Salesforce Formula Values?

Is there some sort of master list of values like that with a description? I apologize as I don't know the exact terminology as to what I'm looking for but relevant to Process Builder, I'm looking for ...
0
votes
1answer
214 views

test class coverage for return statement

How do i cover code coverage for a return statement.I am not using pagereference. if(atleastoneselected==false){ errMsg='No contacts Selected';//not covered return page....
-2
votes
1answer
65 views

How to increase code coverage?

My test class is passed but test coverage is 0%. Can any one help to increase tets coverage: APex Class: public class TopicOfInterestUserAsgmtDataAccessor implements ...
0
votes
0answers
27 views

Lightning component on field number doesnt allow component.set in production but ok in sandbox

I have created a component, that consist of 2 checkboxes, and 4 fields (3 currency fields, 1 number), and a button that save this into a related record. I have seen some similar questions asked ...
0
votes
2answers
114 views

Want to show an error when the user presses the CongaSign button and they haven't filled in certain fields

I have a CongaSign button that sends a contract when clicked, but I need it to show an error or alert if the user hasn't filled in certain fields. I tried itenter code here with JS too but because of ...
0
votes
1answer
464 views

How to use JSON class as a inner class instead of seprate class

Main Class: @RestResource(urlMapping='/cases/*') global with sharing class InsertCaseHelper { global static string responsePayLoad; @HTTPPOST global static void insertCase(){ ...
0
votes
1answer
2k views

Method does not exist or incorrect signature: void format(String) from the type Date

The below code is throwing error Line 2931: Xmlstreamwriter.writeCharacters((Account.Date_From__c==null)?'':Account.Date_From__c.format('MM/dd/yyyy hh:mm a')); Compile Error: Method does not ...
0
votes
1answer
224 views

DML requires SObject or SObject list type: String (line 31)

For the below code I got this error on line 31 i.e upsert z; global class updatezone implements Database.Batchable < sObject > , Database.stateful { string query; string z; //Start ...
-1
votes
2answers
1k views

Not able to cover catch block in test class

I have below batch class which having finish method global void finish(Database.BatchableContext batchableContext){ Savepoint sp = Database.setSavepoint(); try{ if(ErrorCount > 0)...
1
vote
1answer
121 views

Help with writing test class for simple Apex soql query

I know similar questions have been asked before, however, I cannot find an example that would lay out how to test my query online. I am trying to roll out a lightning component that queries a custom ...
1
vote
0answers
370 views

Einstein (Wave) Analytics - Firing an update event from lightning component not working

I am trying to create a lightning component which will apply filter to a dashboard using wave:update event. This feature is available from Summer'17 release. Code for component: <aura:component ...
1
vote
1answer
62 views

User Trigger and User Validation rules firing in different transactions

I am trying to create a User Trigger that has a before insert operation which is supposed to bypass a Validation Rule. But both the validation rule and the Trigger are running in different ...
1
vote
0answers
172 views

Code Coverage 95% in sandbox and 47% in production for a class

I am at a loss right now why my code coverage is off for a particular class. I have @isTest(seeAllData = false) in my test class and I am creating my own data. I have also cloned a new sandbox from ...
0
votes
1answer
163 views

Trigger does not fire on test class

Got following logic in helper class for Task object trigger public class TaskTriggerHelper { public static void UpdateNextActionDate(List<Task> taskList) { Set<ID> rfpIdSet = new ...
1
vote
1answer
324 views

Code/Trigger to get count of number of different Product groups, the Assets of each Account belong to at the Account object level

I am trying to achieve a solution for the following problem - For each Account, I want to know the assets of an account belongs to how many different productGroups (to see products belonging to how ...
0
votes
1answer
137 views

Test Class run complete but no code coverage

I created a before delete trigger on Email Message. Everything seems to work fine but when I run the test class, the code coverage is still 0. Do I overlooked something or is something wrong with the ...
0
votes
1answer
397 views

Display message after custom button confirmation

I have created a custom button and i need to have a "Record created successfully" and redirect to the newly created record after clicking yes on the confirmation. I have returned the message from my ...
0
votes
1answer
152 views

Code coverage page reference method [duplicate]

Hi am new to salesforce , how to do code coverage for this class - page reference method is written. below is the code: public with sharing class AttachmentController { public Attachment ...
0
votes
2answers
4k views

How to set default value of inputselect in lightning?

I have tried several methods already but this still wont work. It defaults to the first option in the list. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/...
1
vote
0answers
68 views

Lightning for Outlook Code

Does anyone know whether the code for Lightning for Outlook is open-source? If yes, where would we download the source files? If no, does anyone know whether there is an API available? We were ...
1
vote
1answer
632 views

How to cover 'addError' in a test class?

I need to cover AddError() in my test class. Apex Class: public void beforeDelete(SObject so) { Task task = (Task) so; Id sysAdminProfileId = [Select Id From Profile WHERE Name = 'System ...
0
votes
1answer
56 views

apex development

I have a scenario, In which I have one custom field on opportunity and when I enter some value in the field it should search that account name in account object and if relevant account is found add ...
0
votes
2answers
584 views

community - reuse code between lightning component using aura:method

I want to share code that calls server for data ... like a service called from multiple components that are not in same containment hierarchy. I want to do this on a lightning component in salesforce ...
4
votes
3answers
1k views

Is there an Apex Linter out there?

I haven't seen an Apex linter and was wondering if anyone knew of one or had repurposed a Java linter? I'm so used to having this available when writing JavaScript or Ruby, it would be awesome to see ...
0
votes
1answer
67 views

can someone please tell Test coverage for below code

global static String saveSignature(String signatureBody, String parentId) { try { //parentId = System.currentPageReference().getParameters().get('Id'); system.debug('Record Id ...
0
votes
1answer
38 views

Need to check trigger perfomance

I have created one trigger which checking if account owner and associated contact owner is same or not.Its giving me output correct.but when i am updating account using dataloader then its looping in ...
1
vote
3answers
620 views

Logically comma separating address field to form a String

I am trying to create a string of address in this format: Street, City, State, Country, Zip. Assume that there is an Address object called addr which has account's shipping address. Address addr = ...
0
votes
1answer
189 views

Increase code coverage

folks, I have a scheduled class from which I am calling my future method but I am not able to increase test coverage for certain section please help me with it. Scheduled class (100 % covered) ...
0
votes
1answer
24 views

test class for trigger where i am calculating contacts created by every user [duplicate]

I have written this trigger and trying to write the test class but the code coverage is not happening. Can anybody suggest where i am missing something? Trigger Benchmarks on Recruitment_Benchmark__c ...
4
votes
2answers
195 views

Uploading file to Facebook from Salesforce

I'm trying to upload an image file to Facebook from Salesforce and current this is my codes and it is not working can anyone help me fix it? Please Note that my Image file is inside the Accounts ...
4
votes
2answers
233 views

Code review checklist to identify governor limits exceptions

I am reviewing apex and visualforce code from a client org and would like to know if anybody has a code review checklist which is focussed on governor limits. I want to identify key areas in ...
0
votes
2answers
629 views

How to alter Parent id of an email in email to case

I have email to case implemented However I want that if a case status is resolved and email is sent to same ref id then instead of having that email attached to same previous case , a new case is ...
0
votes
1answer
619 views

How to add multiple values in single text field?

What i am trying to do is I am querying a record if it has more than one result trying to store all those ids into a Text field. is it possible ? Part of Code: OppList = [Select id,Name,StageName,...
0
votes
1answer
42 views

Send rule for single data extension

I'm working on getting one data extension to display for 3 email templates using content builder. Each email template will have different content within it, but I only want 1 email template to be sent ...