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
1 answer
29 views

What is the meaning of double percentage signs with square brackets?

I am currently working inside a Marketing Cloud Landing Page. The page has code inside an HTML block. Some of the code is within a script tag like this <script type="text/javascript">...
user avatar
  • 3
0 votes
2 answers
30 views

How to rewrite that ternary operator code to if-else?

I can't understand that part of the code - how to rewrite this to if-s and else? Especially the partthis.map1?.containsKey(custom_object__c?.workflow_status__c) List<custom_object_2__c> ...
user avatar
  • 1
0 votes
0 answers
14 views

Evergage.DisplayUtils.pageInactive seen several times into event stream

I put this code into the sitemap, but in the event stream I see this action repeated several times, without stopping until the page exit. How could I modify the code to display the action only once in ...
user avatar
  • 1
0 votes
1 answer
26 views

Test class for covering running user current application info

I have a class where I am using a method that returns the application label of the current logged in user. I am using that class method in another class method and based on the returned app name, I am ...
user avatar
0 votes
1 answer
34 views

Update Custom Metadata Type Record

I have a controller that updates/creates metadata type records. It works fine for the creation of new records, but when I try to update existing records, I get this error duplicate value found: ...
user avatar
  • 1
2 votes
2 answers
53 views

Does SOQL query on Attachment Object needs to be done asynchronously?

Problem statement: External system is creating a custom object record and placing an attachment to the same record via composite REST API. After Insert trigger code that runs immediately for further ...
user avatar
  • 4,677
0 votes
1 answer
65 views

Visualforce Page Quote Template, Display jpg from Rich Text Field or Rich Text

In our quote templates, some sites have very specific site terms where logos have to be displayed in the Quote. Currently, the Site terms are in a Text field (Site_Information__C) that gets pulled ...
user avatar
0 votes
0 answers
24 views

Split throught % of Open Rate

I have a journey where I send a 1st email and after that email I have to evaluate the opening % of that 1st email. In one way I will send another email to everyone who has an open rate > 20% and ...
user avatar
  • 1
0 votes
1 answer
30 views

Will Method called in for loop with Update statement(dml) will have governerLimit Issue

I have below requirement ,i have called method in for loop ,i want to know 1.Will this cause an Dml governer limit issue? 2.how we can optimize the below code Requirements - Update Primary contact on ...
user avatar
  • 3
0 votes
1 answer
50 views

Not able to check map condition in trigger

I have a requirement where on Update of account I need to check case if contactId is present and if that contacts Account is same as Case accountId then need to update one field. I have written some ...
user avatar
  • 5
0 votes
2 answers
46 views

Better way of searching for values in apex list

I have a list of unique strings say 'one' to 'ten' as below: List<String> values = {'one', 'two', 'three','four','five','six','seven','eight','nine','ten'}; I have a requirement to check if the ...
user avatar
  • 169
0 votes
0 answers
204 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 ...
user avatar
  • 1
0 votes
1 answer
89 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 ...
user avatar
-3 votes
1 answer
72 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 ...
user avatar
-1 votes
1 answer
19 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 ...
user avatar
  • 7
0 votes
1 answer
28 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?
user avatar
0 votes
1 answer
87 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 ...
user avatar
0 votes
1 answer
67 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 ...
user avatar
0 votes
0 answers
36 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> ...
user avatar
  • 1
0 votes
0 answers
52 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 ...
user avatar
0 votes
1 answer
216 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-...
user avatar
  • 7
-2 votes
3 answers
684 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: ...
user avatar
  • 21
1 vote
1 answer
124 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.......
user avatar
0 votes
0 answers
73 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 ...
user avatar
0 votes
1 answer
64 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<...
user avatar
  • 7
-2 votes
1 answer
276 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 ...
user avatar
  • 3
0 votes
1 answer
295 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 ...
user avatar
  • 1
0 votes
0 answers
59 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 ...
user avatar
1 vote
2 answers
2k 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 ...
user avatar
0 votes
1 answer
394 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 ...
user avatar
1 vote
1 answer
94 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 ...
user avatar
  • 31
1 vote
0 answers
258 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 ...
user avatar
0 votes
1 answer
482 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 ...
user avatar
0 votes
1 answer
598 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 ...
user avatar
  • 1
0 votes
1 answer
173 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 ...
user avatar
0 votes
1 answer
362 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 ...
user avatar
  • 1
0 votes
0 answers
37 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 ...
user avatar
0 votes
1 answer
120 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 ...
user avatar
0 votes
0 answers
42 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{ @...
user avatar
0 votes
2 answers
60 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) { ...
user avatar
  • 3
0 votes
1 answer
336 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 ...
user avatar
  • 3
0 votes
0 answers
89 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<...
user avatar
0 votes
2 answers
277 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 ...
user avatar
  • 13
0 votes
0 answers
178 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 ...
user avatar
  • 31
0 votes
1 answer
70 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, ...
user avatar
  • 765
4 votes
2 answers
820 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 ...
user avatar
  • 616
1 vote
1 answer
914 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.
user avatar
  • 1,155
0 votes
1 answer
153 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 ...
user avatar
0 votes
1 answer
77 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(...
user avatar
  • 1
0 votes
0 answers
106 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. ...
user avatar
  • 1

1
2 3 4 5 6