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
24 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
11 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
38 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
32 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
68 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
28 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
148 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
89 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
176 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
32 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
167 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
50 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
26 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
90 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
379 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
1k 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
188 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
87 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
325 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
57 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
145 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
121 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
294 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
122 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
346 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
149 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
64 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
613 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
538 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
66 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
584 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
180 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 ...
5
votes
2answers
189 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
226 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
587 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
568 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
41 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 ...
0
votes
1answer
22 views

need to pass data from one page to other page using only one controller

I have 2 VF pages Pag1 <apex:page controller="controller1" > <apex:form> Enter Text<apex:inputText value="{!input1}" /> <apex:commandButton action="{!show}...
0
votes
1answer
2k views

How to write a test class for a wrapper class [closed]

I have created a Class called "SalesMarketing" and i am writing the test class called "SalesMarketingTest" although the test class is passing the "SalesMarketing" class has 0% Code Coverage /*********...
1
vote
3answers
1k views

Test Class for WSDL2Apex class generated by Salesforce Partner WSDL

I'm using Partner WSDL in my org and generated an APEX class (WSDL2Apex) to connect my org with another salesforce environment. Have anyone done such earlier and if written the test class for its ...
0
votes
2answers
40 views

Include formula in manual Custom Percent Field for one Record Type while manually filling it out for another Record Type

I have two Opportunity Record Types, Record Type 1 and Record Type 2. For Opportunity Record Type 1, a custom percent field 'Profit Margin' must be manually input. For Opportunity Record Type 2, is ...
1
vote
1answer
182 views

Radar Chart Help2

So I have a Radar Chart which is working well. I would like to make an improvement to it but not sure how to. Currently the Radar Charts 'axis' defaults to the highest value inputted in the Fields ...
-1
votes
2answers
57 views

Help with regex

I have a string with the following format: "01/12 : Some random comment here. 12/12 : Another comment.". I want to extract the following data using regex (or some other way): Date 1: 01/12 Comment 1:...