New answers tagged

0

Additional case that it can happen- if you lots of classes/trigger and you use the button 'Compile All', then this process might take few minutes (and you cannot stop it). During this time the organization is locked for changes and you just have to wait few minutes.


-3

public void beforeUpdate(SObject oldSo, SObject so){ Contract__c oldCon = (Contract__c) oldSo; Contract__c newCon = (Contract__c) so; if(newCon.AttributedTo__c != oldCon.AttributedTo__c){ if(newCon.AttributedToManager__c == oldCon.AttributedToManager__c){ contractAttributeListChanged.add(newCon); system.debug(...


1

Inspired by this code, fixed up by Daniel Ballinger, I wrote this version, which returns a list of Maps. It turns out that in order to have decent performance, you have to write it in a really complicated way. I actually wrote four or five different iterations to try and get decent performance, and the best one I came up with was still at least twice as slow ...


0

Please fix the Validate__c field on SOQL query in your code and use that field to identify the duplicate records. List<child_object__c> deleteList = new List<child_object__c>(); //To find duplicate child records use Validate__c field in WHERE condition deleteList = [SELECT Id, Name, Contact.validate__c FROM child_object__c WHERE Contact....


1

+1 for Sachin's answer. Looking at the code here, do remember that one benefit of Apex is that the compiler is aware of SOQL syntax. That means you can add line breaks to make your code easier to read: for (Applicable_Model__c model : [ select Id, Knowledge__c, Product__c, Product__r.Model_Code__c from Applicable_Model__c where Product__r....


2

conModelcodeMap.values() would actually be a list of list. And you can not bind a list of list in the SOQL. You would need to flatten it to an list first then you can bind it & get the list of records. SObject [] allRecords = new SObject []{}; for(SObject[] records: conModelcodeMap.values()) allRecords.addAll(records); for(Applicable_Model__c ...


0

You can check the lightning:recordForm component (https://developer.salesforce.com/docs/component-library/bundle/lightning:recordForm/documentation). The component allows you to display the details of a particular record based on the Page Layout that you configured when the "Full" value for the layoutType parameter is used: Full - The full layout ...


1

The explanation for the page to not ignoring your permission when seeing it, is likely what Adrian Larson states in the first comment. However, the explanation for you DMLs resulting in errors when you are not enforcing CUD (note that you are still missing checking the FLS, which should be done) is probably just because of the fact that you are using ...


2

Just for the record, consensus is an Apex static variable that the InstallHandler implementation sets and other code tests i.e.: /** * Referenced by triggers. */ public inherited sharing class Triggers { /** * Want to special case logic related to install handlers: the InstallHandler * implementation can set this and other code e.g. ...


2

Whenever you do a series of translations, you must invert them. Original operations: EncodingUtil.URLencode(EncodingUtil.base64Encode(bbEncryptedParam),'UTF-8'); Inverted operations: EncodingUtil.base64decode(EncodingUtil.URLdecode(bbEncryptedParam,'UTF-8'));


0

I think you may be out-thinking yourself here. Documentation is almost always a good starting place to look. Starting with checking the header The HttpResponse class has a getHeader(key) method. So String nextIndex = httpResponse.getHeader('Next-Page-Index'); is all you need. It'll be null if the header doesn't exist. Updating the callout endpoint Just store ...


0

After more scrutiny of Docusign's WSDLfile and the WSDL2Apex tool, I was able to change FontSize using the SOAP API in Salesforce as follows: Edit your WSDL2Apex generated class inner Tab class to include the FontSize_type_info array and update the field_order_type_info array to include FontSize. public class Tab { public String FontSize; ... ...


0

When you say "relaod page" I'm assuming you mean when the page refreshes due to action method updateSelectedTemplate (the return null). Normally, one simply makes the action method void if you are not causing a new Page to be displayed (wizard-style or redirect) I would suggest you make the selectOptions a lazyload and move the docusign call into ...


0

This can be done using Postman client app. For instance, to upload a file as attachment to Salesforce, use the following: POST to the standard REST endpoint. Eg: <base_url>/services/data/v52.0/sobjects/Attachment Under Headers, leave content-type header auto (do not set a value) Under form-body, provide first entry (select 'text' for KEY) with json ...


6

The decimal class has the setScale() method. It's usually used to set the number of decimal places to be used, but you can pass it a negative number to round to the nearest 10, 100, 1000, etc... Decimal d = 1234.56; system.debug(d.setScale(-3)); // 1000 system.debug(d.setScale(-3, RoundingMode.CEILING)); // 2000


2

To get the nearest thousand, divide by 1000, round, and then multiply by 1000: Decimal y = (x/1000).round()*1000; To get the next highest thousand (towards positive infinity), you can round up: Decimal y = (x/1000).round(RoundingMode.CEILING)*1000; You can also read more about RoundingMode for other options, such as rounding away from zero.


4

The approach we take is to: Ensure that the queueable state can be represented easily using simple types or collections of simple types. Add a counter as queueable state. When the queueable is constructed set the counter to 1. Each time the queueable is about to chain, at the end of execute, check the counter. If it is less than 5 then increment it and ...


6

This limitation is specifically only enforced in Sandboxes and Developer Edition orgs. In production orgs, you are allowed to chain indefinitely (but, be aware of the backoff mechanism as described in this answer). If you want to avoid this problem, consider using Batchable instead. See this question of mine where I wanted to implement a way to get a ...


0

Triggers cannot show warnings. A trigger may execute in a wide variety of contexts, including API interactions, that don't have a UI context attached to them; a warning would not be meaningful there. A trigger can only do addError() to block a record from being inserted entirely. If you need interactive warnings and page messages using ApexPages.addMessage(),...


0

Yes, that's how lookup fields work. To get the name, you'd have to use the relationship to get it, such as: con.Partner_Manager__c=accRelmap.get(acc.Id).Partner_Manager__r.Name; Where __r means you want to use a relationship, and .Name is the field you want to access. Note that you need to also update your query to include this field, or you'll get an ...


0

There are several problems with the code: You are queueing one batch per record inserted which I don't think is what you want to achieve (also a bad practice). I assume that you want to enqueue a single batch that will process all the records that have been inserted Your start() method of the Batch Class has no filtering. It is always querying for all the ...


0

You can use Layout Tooling API : SELECT TableEnumOrId, count(Id) FROM Layout WHERE ManageableState='unmanaged' group by TableEnumOrId


0

First of all, if it's a minor 1:1 creation, you probably don't need Batchable. That's for mass updates. Secondly, you've written your query without a filter, so naturally, it will create one child record for every parent in the database each time you create one parent. Further, you're creating one batch per record in the trigger context, so you could end up ...


0

The getBody method returns the CSV data as a UTF-8 string. No additional parsing necessary. String csvString = response.getBody(); If you wanted a blob, use getBodyAsBlob. Blob csvBlob = response.getBodyAsBlob(); Regardless, if your file has non-UTF-8 characters, you won't be able to read it as UTF-8. You'll need to check the data you're receiving to make ...


1

One way to achieve this just by using Salesforce administration would be the following one: Create a new text field and set it as unique Create a Flow and update the field that you just created with something like (OwnerId + Multipicklist Value) By doing this, you ensure that you can't have in the System two records with the same Owner Id and same values ...


1

Please check below code <apex:page controller="CheckboxValueC"> <apex:form > <apex:inputCheckbox id="checkboxShowP" value="{!isChecked}"> <apex:actionSupport event="onchange" action="{!click}"/> </apex:inputCheckbox> </apex:form> </...


0

Lightning data-table easily helps us to show large data in tabular format, with a flexible selection approach. When pagination applies with the LWC: Datatable pre-selected-rows, it does not work straightforward way. Because apply pagination helps to display only selected page information and hide the rest of the records actually they are not populated yet. ...


1

I'd rather let the trigger framework loop my records and have it call something like for (SObject so : Trigger.old) { handler.beforeUpdate(so, Trigger.newMap.get(so.Id)); } Then in beforeUpdate you only alter the value on the single opp. Nonetheless you should be able to look them up in Trigger.new at this point. If the opp is in trigger context you don'...


5

This has nothing to do with polymorphism. Polymorphism deals with situations where you have multiple classes that share a common ancestor. What you're dealing with are called "overloaded methods." This is not supported with @AuraEnabled. Each method you want to call must have a unique name. This is because of how the underlying API is designed. ...


1

You can use the ui-api (a REST API) to Get Values for All Picklist Fields of a Record Type, or describe the object and use the validFor property of each picklist.


1

As per the documentation, CONTAINS only compares strings so cannot be used to compare collections. Take a look at (and perhaps vote for) this idea and note the references to unofficialsf.com where you will find pre-build List actions for Flows that you can incorporate into your solution instead of writing the code yourself.


0

One of the permissions de check is "Read" and "Write" access to the lookup field (parent object) on the child object.


5

Resolved this question by finding the sObject "TwoFactorMethodInfo" and the field "HasUserVerifiedMobileNumber". https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_twofactormethodsinfo.htm


1

Thanks for Asking What you are doing you are adding Id in null which is not initialized yet.so before adding id to List you have initialized it Like below. newOutput.userIdsListOutput = new List<string>{id}; Also i don't think you need wrapper to return user Id's you can also return List which contain user Id's you can take reference from code which ...


0

In your code, you're receiving a List of FlowInput objects, and while you're technically returning a list of FlowOutput objects, the outputList will always have a single FlowOutput object in it. i.e. you're getting all userIds for all accounts referenced in all FlowInputs, and putting them into a single FlowOutput. You need to update your code to have one ...


1

When you do contractsWithGroups.put(conNumber,groupIdset); you are adding a reference to the collection groupIdset to the Map, not a copy of it. This means that later loop iterations mutate the collection you've already added to the Map under a different conNumber, and when you call clear() on that Set, you're actually clearing the one and only one Set that ...


0

The SObject get/put methods operate on a direct field, not a field path. To handle this you must split the path at the "." characters and process these a step at a time. For example (this code assumes "toField" is not a path for simplicity): void copyValue(SObject context, String fromPath, String toField) { String[] fromSteps = ...


0

To retrieve references you will need to use getSObject(fieldName) instead of get(fieldName). Something around these lines (a simplified version that needs to be enhanced if more than one level is desired): SObject parentConfig = [you query including csordtelcoa__Replaced_Product_Configuration__r.cscfga__originating_offer__c]; for(...


3

What if you use MD5Hash(token).toUpperCase(). toUpperCase is a method in String which converts your string value to upper case.


0

For some strange reason in LWC, Name field from PermissionSetTabSetting returns either standard object name or custom tab id, while in Classic, it returns the tab name. Workaround here is to use Tooling API with Classic Session Id. Create Visualforce Page 'Api'. <apex:page controller="ApiCont" showHeader="false" sidebar="false&...


0

For some strange reason in LWC, Name field from PermissionSetTabSetting returns either standard object name or custom tab id, while in Classic, it returns the tab name. Workaround here is to use Tooling API with Classic Session Id. Create Visualforce Page 'Api'. <apex:page controller="ApiCont" showHeader="false" sidebar="false&...


1

DML operations only work on the object directly referenced in the sObject variable or list. To update parents or children, you must perform a separate DML on them. If you don't already have the child records in your variable, you'll need to do the appropriate queries. You'll also need to update the relationship fields manually.


0

The record(s) you get from a StandardController or StandardSetController only contain the fields that are rendered in your Visualforce page (as I recall, adding something like html-style="visibility:hidden" or rendered="{![something that evaluates to false here]}" causes Salesforce to not automatically pull in that field). The general ...


5

localhost means "the computer the program is running on." In Apex, this means you're trying to access the Salesforce server. Postman is running from your computer, so you can access servers running your own computer. Salesforce is not your computer, so you cannot access your server with localhost. You will need to set up a public DNS with your ...


2

The Apex code is executing in a data centre out on the Internet but the URL you are supplying isn't accessible from there. Setup your test API on an Internet facing server (or use an existing REST service). Postman is running inside your local network so can access http://localhost:8080.


0

You use the standard Aggregate Query Update Pattern for this. You'll also want a trigger handler to avoid unnecessary recursion. trigger updateNotes on Demo__c (before insert, after insert, before update, after update) { DemoTriggerHandler.execute(Trigger.new); } ---- public class DemoTriggerHandler { static Boolean isRecursive = false; public ...


3

The error is here: Decimal amount = trans.Balance__c * ir; You're trying to multiply a record against a number. This is not allowed. You probably meant: Decimal amount = trans.Balance__c * ir.Interest_rate__c;


2

The class CreateQuotePDFController_Test contains no unit test methods. It contains only a test data setup method, data_setup(), which appears to also contain the start of a unit test but no assertions to validate behavior. You need to write at least one actual unit test method. Please review How do I write an Apex unit test? for introductory resources. Every ...


0

In order to discard the duplicate values for external field, we need select the "Unique" option which will not allow duplicate values to be stored in system by Treat "ABC" and "abc" as duplicate values (case insensitive).


1

I'm the author of the apex-lambda library that you mentioned. I believe it's the closest thing to what you looking for on the platform. As Apex is a very static language, you have to reify (i.e. "make into classes") all the type-related things that would be avoided through generics. If 3,000,000 characters are a risk, a library that provides many ...


Top 50 recent answers are included