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

Adding css/js code resources into a Marketing Cloud Landing Page (Preference Center)

I want to start by saying I am very new to html, css, and js. So this may seem like a stupid questions. After I upload my CSS file upload into Marketing Cloud using the code resource, I have added the ...
0
votes
1answer
40 views

Alternatives for multiple If statements

I need to compare the fields and depending on that if its true then update a boolean variable and if its false then capture this field and get the label and append it to a string. I have like 10-12 ...
-3
votes
1answer
41 views

Trigger Apex Trigger if a custom field (bool) is true

I have this code that sends information to a webhook, I only need to send information when the field WebTrig__c (checkbox) = True. I wrote this code but for both cases it sends the information to the ...
-1
votes
1answer
18 views

How to validate if records are inserting /updating through external tool(dataloader,workbench) and not from UI

I have requirement where i need to run method inside trigger only when if records are inserting/updating through UI not from (DataLoader/Workbench). Please suggest if we have any solution ..Not able ...
0
votes
1answer
21 views

Do we need to perform static and dynamic code analysis for packages that are published as unmanaged packages in salesforce?

Do we need to perform static and dynamic code analysis for packages that are published as unmanaged packages in salesforce? Or the salesforce platform take care of them?
0
votes
1answer
36 views

Edit Lighting Web Component and retrieve code

My org recently had a lighting web component written launched into production. Unfortunately, the team we outsourced this to left off a necessary field. I would like to edit this code to include this ...
0
votes
1answer
47 views

Update fields but only if the value is changed [closed]

I would like to update a field in an object, only in case a value was received, otherwise nothing changes in that field. Is that possible? If yes, how? I can't use the following code because I want to ...
0
votes
0answers
24 views

Unable to show a pop up message in visual force page when city (field) is blank

Here, I need to show a popup message in VF Page, But my PDF(command button) having some issues, So please let me know what I am missing here. my javascipt code is <script> ...
0
votes
0answers
35 views

Page Reference and If Statement

I am looking to add another if/or statement that will also look for if the phone number is Anonymous to be redirected to the contact page. Here is what I have. It is working but I need to add ...
0
votes
1answer
67 views

Split the string from right side to get the required output after second occurrence of special character

I have requirement to get the string by splitting right side Ex 1.abc-sgd-ajj-test output needs to be in string = abc-sgd test-string-split-exam-demo output needs to be in string = test-string-...
-2
votes
3answers
50 views

How to pass a list from one method to another

I have three methods: Method1: public static void method1() { // call method 2 that returns a list method2(); // call method 3 and pass list retuned from method 2 method3(myList); } Method 2: ...
1
vote
1answer
58 views

PMD showing errors for one class, but not another class with the same issue

I just installed PMD and its pretty janky from my experience, for example I have two classes and it shows the "same name" error for one class but completely ignores it for the other class.......
0
votes
0answers
53 views

Code duplicate APEX

I am trying to find a tool that will perform static analysis of apex source code in both classes and triggers and detect code duplicated that can be used in continuous integration server such as ...
0
votes
0answers
20 views

How to access auto-property value (get,set) from an outside class?

hope you are doing well. Suppose, currently, I've the following code in my controller class: global with sharing class controller{ public String input1{get;set;} public String input2{get;set;}}...
0
votes
1answer
39 views

How to avoid for loop and use map or some other technique for below logic [duplicate]

I have below code ,but not able to understand how i can avoid second for loop inside account please suggest public static void getOpenCaseOnAccount() { Map<id,user> userIds = new map<...
0
votes
0answers
419 views

Parent change does not update child component lwc

I am trying to create a dynamic input component in LWC, which always send the value to the parent component when the user changes it. The parent handles the value sended by the child input component, ...
-2
votes
1answer
58 views

how to compare old and new values for specific fields in trigger

I have requirement where I need to compare few fields in account object, If there is any change in the value of any of the field I need to insert into log object. Those fields can be change later as ...
0
votes
1answer
109 views

How to get unique user count logged into salesforce with specific permission Set

I am trying to get count of users logged in to salesforce in specific time who is having specific permission Set. I am getting row more than 500001 error.. can we apply any filter in LoginHistory to ...
0
votes
0answers
54 views

Generate random Password with Special Characters? [duplicate]

Is there a way to use the below code, but also add special characters? I need to generate a random 8 character password, that includes special characters. Is this possible? Any assistance will be ...
0
votes
0answers
21 views

Is there any method in Salesforce (or 3rd party apps) to auto-check if User Roles are used in any automations or code?

Is there any method in Salesforce to check for automation or code dependencies on User Roles? Or perhaps there's a 3rd party app that can do this? I want to migrate updates to the role hierarchy ...
1
vote
2answers
605 views

How to find duplicate records from the list based on 2 fields values?

I have a requirement where I need to find duplicates and remove from the list, but I am unable to figure how to iterate and remove duplicates. Can anyone please help me with this? I don't want to use ...
0
votes
1answer
158 views

Illegal conversion from List<OpportunityLineItem> to List<Opportunity>

Good day, Still finding my way around Apex. Please assist with the mentioned error. I'm not sure what's wrong with my code. In essence, I'm trying to retrieve information from a related list(Opp ...
0
votes
0answers
208 views

Session cache is only supported in Data Silo tests error while running test class

I have the following piece of code and whenever I am calling it from a test class it throws me an error public static void storeAssetMap(Map<ID,List<AssetLineItem>> assetMap, String ...
1
vote
1answer
87 views

Help fixing Apex Error

Does anyone know how I fix this error in my aura lightning component? My action isn't retrieving the Opportunity records anymore. It was working fine last month, but has stopped working. I am new to ...
1
vote
0answers
180 views

Problem : Behavioral trigger abandon basket

I try to set up the behavioral trigger on the abandoned basket. I created the product catalog with the required fields including the product_code which seems important. I made sure that avaibility on ...
0
votes
1answer
237 views

Assigning Task when opportunity it closed won

I have this code that creates a task when opportunity is closed won, however it needs to be assigned to one specific person only. trigger ClosedOpportunityTrigger on Opportunity (after insert, after ...
0
votes
1answer
311 views

How to add session cache in apex class to call

I have one method from which i am calling onother method which is having soql query. Every time method calls .Soql will get executed.to avoid any performance issue i have created session.catche code ...
0
votes
1answer
93 views

Combine two variables in lightning component

How to combine two variable in same variable . I want to get both of values in another variables groupMembers3. const groupMembers = component.get('v.usersToAdd').map(u => u.Id) ; const ...
0
votes
1answer
182 views

Field Not Writeable

I have an Apex Class which updates the User.IsPortalEnabled field. But it throws the error: Field is Not writable. How can I fix this error? public without sharing class UserHandler { public ...
0
votes
0answers
35 views

Code coverage issue RecordType.Name required [duplicate]

I am trying to fetch the RecordType.Name in a list, but my list doesn't has the value displayed. Please find below the block of code and the list 'clist' where I need the RecordType.Name This is in a ...
0
votes
1answer
82 views

How to put in SQL to see only records that in the field do not have specific data in the marketing cloud?

I am facing a problem when trying to filter the leads and contacts that come from CRM to be used in email marketing. The idea is that the filter does not add people who have the field conta.Name equal ...
0
votes
0answers
41 views

Your code coverage is 73%. You need at least 75% coverage to complete this deployment [duplicate]

Already run test but no luck. public class UNILAB_NMAP { /* wrapper class to store required properties for "lightning:map" component' */ public class accountLocationWrapper{ @...
0
votes
2answers
43 views

Optimization of code removing extra if and else block

I need to remove the extra if and else loop as per the req and need to make it short for reading of the code should be easy. can anyone suggest some better for below: if (data[0].FA_N__c) { ...
0
votes
1answer
260 views

Is it possible to use <pre> / <code> preformatted text field within a LWC component HTML file?

I'm trying to display code as text, unrendered. However, when I use the <pre> or <code> tag with html tags within it, LWC is rendering what is inside those tags in the browser instead of ...
0
votes
0answers
69 views

SOQL EventRelation is Test Class

The issue with SOQL on EventRelation filtered by Relation.Type is working as expected during normal execution. However, while executing the following LOC in test class it causes failure. Code: List<...
0
votes
2answers
210 views

Relationship queries

I have started learning relationship queries. I have created a new field in case, contacts and opportunities which are related to accounts.I want to update that new field with account's type field. I ...
0
votes
0answers
137 views

Package Retrival is not working

We are trying to retrieve the package from Salesforce Developer org While performing the retrieve we are getting errors for the below components. [sf:retrieve] package.xml - Metadata API received ...
0
votes
1answer
47 views

Design Pattern Help: Extended Interfaces with methods that shared the same functionality/code

I'm trying to figure out the best pattern for the code below (example: not actual code). IOpportunitiesA and IOpportunitiesB are extending the base interface and they have a similar method, ...
4
votes
2answers
626 views

VS Code - Snippets Library?

Before I go through and recreate all my most commonly used snippets in VS Code, does anyone know if these have been created for apex already? ..and if so where I can find them? I have checked in the ...
1
vote
1answer
724 views

Prettier formatting tabSize and printWidth

In VS Code preference, I set the Tab Width = 4 and Print Width = 120, but when I format, I can still see the tabSize being 2. Is there any other configuration that I need to do? Thanks.
0
votes
1answer
120 views

AMPscript in HTML - check c

I'm writing a code for personalize an email with product name , image, price (all in the same lines, three "boxes) The current layout include a visualization of up to 4 products and a structure like ...
0
votes
1answer
58 views

Apex trigger To throw an error if case is updated with ContactId Which is associated with Account

I have requirement where on Case Update if ContactId in same of accounts contact associated with that case then needs to throw an error. Example; Case 1 AccountId 1 and contactId 1 If case 1(...
0
votes
0answers
64 views

new instance of object creation for updating a record

Requirement-I have custom object request__C where i am storing sourceAccount ID and TargetAccountID. My requirement is to update the field in request object with max contact in any of the account. ...
0
votes
2answers
38 views

Not able to get max amount and update the status in Apex

i have requirement where i need to get all orders from account and need to check max amount from that order and need to update the status of order to InProgress. then from account1 ==>order4 needs to ...
0
votes
1answer
15 views

not able to update contact based on the requirement-seems bulkification issue

i have requirement where i am passing list of accountuuids to method 1.If contact with same accountname not present then create new contat call as shadow contact 2.if contact with same accountname ...
0
votes
1answer
37 views

Access audit trail data outside of salesforce

I need to pass audit trail data to informatica. Can anyone suggest how informatica extract the data. is there any way to query audit trail or any standard api to fetch data
0
votes
1answer
24 views

Apex class on Lead needs to review

Requirement-- I have one custom Object(Lead_map__c) where values are stored Like leadSource={'Web','Email','Phone'} and respective userIds in userId_assignee__c column Whenever lead is updated with ...
0
votes
1answer
29 views

Difficulties to retrieve values from Junction object in apex

Requirement I have 2 objects(sale_product,sales_Product_parts) one product can have many parts and one part can be assign to many product) i have created juntion object to achieve this. My ...
0
votes
2answers
38 views

facing issue to build a trigger on Opportunity to create a task

Requirement- I need to create a task on the opportunity when stage changes to Need analysis. but if a task with description already presents with 'Need analysis' for this opportunity then no need to ...
0
votes
0answers
947 views

System.JSONException: Invalid numeric value: Leading zeroes not allowed at input location [1,2]

I am getting the error mentioned in title of this question when I am calling one of my class method from a test class which is there to send the email with an attachment. Inside that method which is ...

1
2 3 4 5 6