New answers tagged

1

You can loop over the "selected" list in javascript and get the CRId of all the accounts in a list and then you can pass that list as an argument to the apex method. See the below example- In js file: let ids = []; selected.forEach(account => { ids.push(account.CRId); }); // call apex method del({ deleteIds : ids ...


0

You can use RestContext to set request and response , Use addHeader(name, value), addParameter(name, value) to set header and params of method. RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); req.requestURI = ''; //Request URL req.httpMethod = '';//HTTP Request Type req.requestBody = Blob.valueof(JsonMsg); ...


-1

About the other answers: is there any guarantee that the Save Results are always and will always be returned in the same order as the records we are trying to insert? Salesforce does not seem to have documented this, so can we really be sure it's going to work 100%? :)


1

entity type ContentDocumentLink does not support search also the query syntax is wrong correct the syntax to below and you'll get the correct error . FIND {a016g00000D57xKAAR} IN ALL FIELDS RETURNING Attachment(ParentId), ContentVersion(FirstPublishLocationId), ContentDocumentLink( ...


1

Bulkification is usually about making the number of query calls or update calls unrelated to the number of records involved (e.g. removing a query from inside a loop). If your calculateOcc method is only called once, then there is no need to bulkify. You are probably getting no records because of this: ... where Occurrence__c =: 'myOcc' Instead, you ...


0

ChangeEvent entities are events posted by Change Data Capture. They're not persisted records in the database and should not be searchable (just like Platform Events or Streaming API messages). While the error message isn't very clear here, I'd suspect it's ultimately stemming from the inclusion of such non-searchable entities.


1

You can iterate the map and check the list to search like this: for (String key: getmap.keySet()) { if (getmap.get(key).contains('20')) { //20 found, do something } }


1

SOQL queries are inherently single-object. You are correct that there is no way to implement this requirement as written without using iteration. However, this requirement itself is rather suspect. If you have a need to perform the same query across multiple objects, you should at least evaluating using SOSL rather than SOQL. If you simply need to perform ...


1

My overlapping answer that converts to the list of map of string to object is very like Mariia's: String theJsonString = '[{"id":2, "name":"Abc_SS", "description":"Abc"}, {"id":100, "name":"sales", "description":"sales"}]'; Object theJsonObject = JSON.deserializeUntyped(theJsonString); List<Object> theJsonList = (List<Object>) theJsonObject; ...


5

It is impossible explicitly, however, you can deserialize you String into List< Object> and then cast your Object in for-loop to Map< String, Object>: String jsonString = '[{"id":2,"name":"Abc_SS","description":"Abc"},{"id":100,"name":"sales","description":"sales"}]'; List<Object> items = (List<Object>) JSON.deserializeUntyped(jsonString);...


3

To deploy: Your trigger must be exercised by a testmethod Your @future class need not be exercised by a testmethod in order to deploy provided that you have at least 75% coverage across all Apex You can specify which tests to run when you deploy. You do not need to run all tests That said, it is "developer negligence" to not write testmethods for each ...


0

For a test class, I like to simply upsert: CustSettings__c settings = new custSettings__c.getInstance(); settings.someField__c = 'Some Value'; upsert settings; The advantage being, is generally in a test class you don't care what the hierarchy is, you just care about what values your test class will be using. If you want to test with a profile instead, ...


5

24 hours as per docs for Org Cache. No mention for session cache, probably because the session can expire any time?


0

In the end the requirement was met by using the following code. I think what the problem is, is when you get a list of the Knowledge_kav object, there was a "wrapper" of attributes that the custom datatype did not take into account. (see picture) and here is the final code I used: @RestResource(urlMapping='/PublishedKBArticles/*') Global with Sharing ...


2

I'd use the rendered attribute to show either an input or output field: <apex:inputField rendered="{!isEditAllowed}" value="{!pro.Total_units_ordered__c}" style="width:50px" id="inputToDisable" /> <apex:outputField rendered="{!NOT(isEditAllowed)}" value="{!pro.Total_units_ordered__c}" style="width:50px" id="inputToDisable" /> This will work for ...


3

I would code that like this: public PageReference applyTarget() { String url; switch on selectedTarget { when 'COLLECTION TARGET' { url = '/apex/CollectionTargetSettingInit'; } when 'SIGNED REVENUE TARGET' { url = '/apex/SignedRevenueTargetPeriodSetting'; } when 'NETWORK TARGET' { ...


0

The problem here is recordTypeId in getPicklistValuesByRecordType is not available by default. To get current record's recordTypeId, you would need to make a getRecord call asking it to retrieve the recordTypeId. Psuedo example is as below: import { LightningElement, track, api, wire } from 'lwc'; import { getRecord } from 'lightning/uiRecordApi'; import ...


0

You create then use an external authentication provider, where you can call whatever you need using apex :) ( API, SOAP, HTTP .... it does not require to be OAuth ) https://help.salesforce.com/articleView?id=sso_authentication_providers_external.htm&type=5 https://help.salesforce.com/articleView?id=sso_provider_plugin_custom.htm&type=5


3

Change the class signature: public with sharing class APTS_UsageInput_InsertTempRecordsBatch implements Database.Batchable<APTS_UsageInputWrapper> Make sure you consistently apply "generics" in your Batchable implementation, as covered in the documentation: public Iterable<APTS_UsageInputWrapper> start(Database.BatchableContext context) and:...


1

I think I found the problem. I found that order has a Pricebook2Id field that need to be populate to create OrderItem records linked to it.


7

It seems that you want to remove elements "Closed Won" and "Closed Lost" from the list. You can do it by the below code. pickListValuesList.remove(pickListValuesList.indexOf('Closed Won')); pickListValuesList.remove(pickListValuesList.indexOf('Closed Lost')); Since "splice" is not a function for apex lists. You can find all the functions supported by apex ...


3

This is happening because you are using the Database.insert() method with DMLOptions. The DMLOptions object contains a property called optAllOrNone. By default which is set to false. According to documentation. If optAllOrNone is set to true, all changes are rolled back if any record causes errors. The default for this property is false and ...


0

You can make this work by including the BOM at the start of the VisualForce page. In the VF page on the first line I have (the strange use of outputText is something I've inherited from an existing implementation of a CSV export): <apex:outputText value="{!utf8Bom}"/><apex:outputText value="Organisation"/> <apex:outputText value="{!COMMA}"/&...


0

I found a way to insert ContentVersion and attach it to Record in one SOQL. <apex:page controller="ContentController"> <apex:form> <apex:inputFile value="{!file}" /> <apex:commandbutton action="{!upload}" value="Upload" /> </apex:form> </apex:page> Class: public class ContentController { ...


4

This is due to how Type Systems work. While your ActiveContactListController.ContactsWithRoles object contains an AccountContactRelation object, it (ContactsWithRoles) is not the same as an AccountContactRelation object. The declared return type in your method needs to match (or extend) the type of the variable (or statement) that you actually return. ...


0

By moving the <tr> tag to after <apex:repeat> seems to be working <apex:repeat value="{!transmittalDetailsList}" var="i"> <tr> <td><apex:outputText>{!i.Country__c}</apex:outputText></td> <td><apex:outputText>{!i.Media_Content__c}</apex:...


3

I created a very simple component: js controller: ({ doInit : function (component, event, helper){ var action = component.get("c.getAccountWithContacts"); action.setCallback(this, function(response){ console.log(response.getReturnValue()); }); $A.enqueueAction(action); } }) Apex Controller public class ...


11

I tested three basic boundaries: total payload size, size of an element, and number of items. Total Payload Size, Element Size First, I created a map with 9 keys, each key being a 3,000,000 character string. This weighs in at just over 27 MB of data. Aura rendered the page in a couple of seconds, all elements present and accounted for. Large Number of ...


0

I would recommend this post How to Update Leads or Contacts When Shared Activities Logged, which gives you a better approach to understand activities logs. Updated post How to Update Lead or Contact When Activity Logged In case you just want to use code: Note: seems there is an issue from (2016) for quering TaskWhoRelation records which only return Primary ...


0

Clearing a collection variable by setting the variable to null (or making it equal an empty collection variable of the same type) will terminate the loop, as there are no more records to process. I have never tested what happens if you end a flow without completing a loop. I assume that it would be handled gracefully, but it does seem best to terminate the ...


2

You can't utilize retURL in Lightning and I think the best answer would be to look at using a quick action on the account which can pre-populate the fields based on the current record and then displays a toast message with a link to click into the new record. You're on Lightning now so you should look at catering your customization/actions to fit the ...


0

That error message is part of a "gack". Gacks are salesforce internal errors that you can't usually fix on your own. Think of them as an unhandled salesforce error. Theres a lot of resources out there about gacks but at the end of the day they all say the same thing - only salesforce knows what this error means and only salesforce can fix it. What is a ...


3

To make a connection to production org, follow below steps:- Open command palette, search for sfdx: Authorize an Org and select it Now, You will get few options to authorise. You can select Production Org to authorise to a production org:- Then, VS Code will ask you for an alias name and once you press enter, it will open a browser window to authorise in ...


0

If files is undefined, you get an error in the template (you do so here when there's an error). Instead, just check to see if it has a value: <template if:true={files}> Also, arguably, you shouldn't return "null" when there's no records; that will show an error when no error actually occurred. Your error panel will probably give errors itself in that ...


0

This is what we use. Works with both, Permsets and Profiles. public static Boolean canCreateMetadata(Id thisUserId) { try { User thisUser = [ SELECT Profile.PermissionsModifyAllData, Profile.PermissionsModifyMetadata FROM User ...


0

This is a "feature" of System.debug of an sobject A way to verify: String[] debugLines = new List<String>(); for (ID recId : mapToMap.keySet() ) { GPMIR_obj_energyLead__c rec = mapToMap.get(recId); debugLines.add(rec + ' ' + rec.Community__r.Name__c + ' ' + ....); } System.debug(String.join(debugLines,'\n');


1

Timezones are the bane of my existence, so I usually try to rationalize what is happening. Here is my result. When you add your offset, apex will return a datetime record that will be identical to the time you have right now locally. However, as far as apex is concerned, that datetime will still be in GMT. Hence, when you do hourGMT, you will get the ...


8

I'll try to illustrate this. This is valid JSON. { "errors": [ { "params": { "password": "size must be between 4 and 30", "loginId": "must match \"^[a-zA-Z0-9_]*$\"" } } ] } This is not: String str = '{ "errors": [ { "params": { "password": "size must be between 4 and 30", "...


1

The thing is, sharing mode in Apex only really affects SOQL, DML, and other Apex methods that do query/DB-like work. So perhaps you could centralize these operations in a core class that can be explicitly called in with/out sharing mode. Then all of your dual-mode classes can default to with sharing, but when a sharing-sensitive operation is called you route ...


6

You only need to declare @AuraEnabled once per type, if you use the comma operator to define multiple variables. In your case, you could write it as: @AuraEnabled public String var1, var3, var4; @AuraEnabled public Decimal var2; You do not need to add explicit default getter-setter { get; set; } in order for the variables to be accessible (this is a ...


0

In your Apex, your getter method takes a parameter: public List<Integer> getScoreList(List<JobOffer__c> offerList){ Visualforce does not have a parameter to pass to this method. Visualforce getters are required to take no arguments. You will need to either expose the instance variable directly, as J.Dillinger suggested in another answer, by ...


0

Your trigger will never execute because your unit test never inserts a DATEV1__AccountingDocument__c. The three fundamental components of a unit test are Perform data setup. Execute code path under test. Validate results. This unit test currently does only (1). You must cause your code to execute, and you must write assertions to validate the results. ...


1

You might try creating a Map with key of record id and value of set string. So as you loop through the first set, you'd substring out the record id and check the map for that key. If it exists, you then substring out the timestamps and compare them. If the value from the set is newer than what's already in the map, replace it, else keep what's already in the ...


0

I guess you have to specify {get; set;}property for the scoreList


2

I have made slight change to your code. Check out this Playground LINK Use height : 90vh i.e - 90% of viewport


3

There is no way to load more than a total of 50K records in a given synchronous session/transaction (as per the documentation), and certainly no way to do this in a trigger. The only way to deal with this sort of thing is to use async processing such as in a Batchable as you mentioned. It is possible to execute certain types of aggregate query across more ...


-1

Your provided VF is working fine. You need to provide id of Account "/apex/VFpageName?id=accid". this will print all related self lookup records. Also if you have added related list on page layout then will print all related records. As per Nigam response you can find child relationship name then you can use inner SOQL query to fetch child records. ...


0

You don't need to have two queries on Task object, rather you can get them in a single query on account object. Account[] accounts = [SELECT id, (SELECT WhatId FROM Tasks where Subject = 'Sending' and Status != 'Completed') FROM Account WHERE Id IN :accounts]; Task[] taskList = new List<Task>(); for (Account acc : accounts){ for(Task taskObj: acc....


1

I suggest this sort of code if there is only ever one Task at most per Account: Map<Id, Task> whatIdToTasks = Map<Id, Task>(); for (Task t : [...]) { whatIdToTasks.put(t.whatId, t); } for (Account acc : [...]) { // Update existing Task or create new one Task gTask = whatIdToTasks.get(acc.Id); if (gTask == null) gTask = new Task(...


0

Here you will get a relationship name Here is query: Select Id, (Select Id FROM Accounts__r) FROM Account


Top 50 recent answers are included