Questions tagged [code]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

How to apply radius for Map in Salesforce [closed]

In my requirement I have a form as shown below: In the highlighted part the customer will choose the closest regional hub where he lives, but there are close to 700 options in this picklist. I want ...
0
votes
0answers
13 views

need to update Auth provider from apex class

I have requirement where i need to update authProvider Execute as User from Apex code. I have wirtten a code but i am facing below error on update **DML operation Update not allowed on AuthProvider** ...
0
votes
0answers
6 views

How can we correct an ALT attribute accessibility issue with the igodigital tracking code?

The tracking code from SalesForce is causing accessibility issues because it's got a title tag, but no alt attribute. Assistive technology will often skip the title tag and instead rely on the alt ...
0
votes
1answer
31 views

How this method call works? 'Schema.sObjectType.Contact.isDeletable()'?

I'm struggiling to understand this line of code: Schema.sObjectType.Contact.isDeletable() I've read on the Apex Developer Guide that isDeletable is a method of the DescribeSObjectResult class that ...
1
vote
2answers
57 views

How to Document and correct indentation on apex [closed]

How can I automatically correct the indentation of my apex classes on Visual Studio Code?? I installed the Uncrustify extension but it is not working. Also is there any way to document my methods ...
0
votes
0answers
14 views

Azure Devops with Salesforce

I am new to Salesforce development and just got involved in it. And in our Org we haven't started leveraging the Azure Devops with Salesforce yet. All the development happens in an Dev instance and ...
-2
votes
1answer
44 views

If condition for Values in Map<string,List<string>in apex

I have below snapshot where i just wanted to check if map is having the value 20 in it or not. How i can write if condition for list of string values map<string,List<string>> getmap=new ...
1
vote
2answers
223 views

Code Coverage Failure trigger deploy on production

i have a code for trigger: trigger SendDisbursement on Opportunity (after update) { if (!System.isFuture()){ for (Integer i = 0; i < Trigger.new.size(); i++) { if (Trigger.old[i]....
1
vote
1answer
53 views

Explanation of an notation List<name.test> nameList

I have a piece of code as following: List<name.test> nameList In List is name a class or object. Why would we use such an annotation? Or for example: method(name.test variable)
-1
votes
1answer
60 views

Need superscript of # in apex

I have one string which needs to change with Superscript string str="ABC#"; I want add replace superscript with #. please suggest Let me Explain with Example Suppose I enetered a string **My Name ...
0
votes
1answer
33 views

Unable to view data on Lightning component but can View in console log

I am relatively new to Lightning and trying to learn it via one of the youtube tutorials and used same code for practice but I am not able to see the data on my Lightning component page. I could not ...
0
votes
1answer
43 views

Code Coverage=0%

my developer createed the following trigger and Apex Test Class. For some reason, the coverage is 0%. I need to deploy it ASAP and he already left for the rest of the week. any help is highly ...
1
vote
2answers
58 views

I do not have Prod access in my org. I want to know can we edit Lightning component in Production?

Can we edit Lightning component in production?
0
votes
3answers
94 views

Clean code way to process a list of objects

Let’s say you have a list of Accounts and you want to populate their birthday with the same date. However, you also want this method to be reusable. What is the best way to do this in APEX? So far ...
0
votes
1answer
25 views

Trigger code error

I am really new to triggers and not sure how I fix this error, please help. Thank You, Lorr
-1
votes
1answer
23 views

How to call this method from web service in my test class [duplicate]

I am not able to call this method in my test class: WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'https://www....
3
votes
1answer
38 views

Does the latest API on classes,triggers,and components provide a performance benefit over older APIs?

My thought is "no", but wanted to see if anyone had any information on this. I would assume the versions simply control how you can interact with the features in Salesforce (ex. methods you can use, ...
0
votes
0answers
25 views

Error whenever trying to insert list of records into VisualForce Page from custom controller? [duplicate]

I currently have a visualforce page with a custom controller that counts the amount of records that has a field marked as a specific status from a picklist. I need to be able to display those records ...
0
votes
0answers
20 views

Event Invitees Notification and Response in Salesforce Lightning

I am trying to build custom functionality with apex code. when Events is created in Lightning and Invitees is added to it, Email notification to invitees should be sent with Accpect or Ddecline option....
0
votes
0answers
14 views

Apex Code Coverage for if/else if test class [duplicate]

if (userList.size() > 0 ) { String profileName = userList[0].Profile.Name; if (profileName == 'CP_CorporateAdminUser' || profileName == CP_SystemConstants.CORPORATE_OPERATION) { ...
0
votes
0answers
17 views

Trigger.newMap and Trigger.oldMap not able to pass the correct values in the test Class! [duplicate]

I have a scenario to cover in the Test Class Whenever Case is assign to queue from User : particular field must get blank: public static void wmgRemoveOldGroupQueue(Map<Id,Case> newMap, Map&...
0
votes
0answers
51 views

Download Attachments and Salesforce Files from Visualforce page

I am trying to modify Visualforce code to allow for the download of an attached file to the Incident ticket. Currently the file is listed with this code, but I need it to be a clickable download ...
0
votes
0answers
76 views

update global picklist values without using tooling api

How can we update global picklist values without using tooling api. Someone told me to use metadata api, but I could not do that. Is there another way to do that? If possible, I would like to see the ...
0
votes
0answers
116 views

Avoid Using Hard Coded Credentials for Authentication

We have done the code review by salesforce,and got "Avoid Using Hard Coded Credentials for Authentication" at quite some places where ever we are setting up Authorization Header.(On the 5th line of ...
1
vote
3answers
256 views

toLabel(RecordType.Name) and RecordType.Name in the same SOQL query

How to use toLabel(RecordType.Name) and RecordType.Name in the same SOQL query? I am trying to retrieve both the values and use them. If I can get the query to work then how can I refer the values ...
4
votes
2answers
3k views

LWC get url parameters in Community

I'm trying to retrieve url parameters through a lightning web component in my Community. For exemple : wwww.my-community.com/my-page?test=true How can I, in the new LWC framework, get the parameter "...
0
votes
1answer
135 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
130 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
2answers
388 views

Abandoned cart Journey 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 Journey? Do I need to use any event? I can see in Web ...
0
votes
1answer
51 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
97 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 ...
-1
votes
1answer
87 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
14 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
54 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
54 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
20 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
166 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
49 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
493 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
258 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
248 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
41 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
459 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
117 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
31 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
272 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
956 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
3k 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
401 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
3k 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
2 3 4 5