New answers tagged

0

can you give a try with this if(c.Email != null && userEmailMap.containsKey(c.Email) && (c.pse__Salesforce_User__c == userEmailMap.get(c.Email).ID) && (c.pse__Salesforce_User__r.isActive))


0

it worked after removing this "reqbody += '&scope=refresh_token full';


3

You can specify a version by invoking it via Tooling REST API /services/data/vXX.X/tooling/executeAnonymous/?anonymousBody=...


0

With Spring 19' update there is a new setting in the "App Permission -> Content -> Query All Files: Allows View All Data users to SOQL query all files in the org". This is not enabled by default for the admin user but you can at least enable it in a Profile/Permissions Set. Also, now documented in https://developer.salesforce.com/docs/atlas.en-us....


0

As per my experience the flex queue is the place where all the queued job stay. It keeps there till the time of any free resource found . Also the job queue can hold 100 after that count all the jobs send for the flex queue.


1

The Flex Queue is its own unique queue, separate from the asynchronous queue. Basically, until a Batchable process starts, it is in the Flex Queue, and can have its priority changed. Once the system has resources, it starts building up jobs to perform in the asynchronous queue. This includes start, execute, and finish methods of Schedulable, Queueable, and ...


0

From the AuthConfiguration.getSamlSsoUrl doc: Parameters communityUrl Type: String The URL for the community or My Domain subdomain. If not null and not specified as an empty string, you get the URL for a community. If null or specified as an empty string, you get the URL for a My Domain subdomain. You should be passing null ...


0

sorry that this is not an accurate response to your question but just a suggestion and a path if somebody looks at this. Open a case with Salesforce Support. Some months ago we had a similar issue on one of our managed packages, I can't recall the exact solution but we just needed some changes at the component level (something pretty strange and non ...


0

As I speculated on the comments, the best approaches might just be to either: Use the Test.isRunningTest method to check for the test context and thus bypass the .setClientCertificateName method in your code. Use a try/catch scope to catch the exception thrown when the platform tries to assign the missing certificate to the request. The first approach ...


3

Simpler way? well yes and no. We have Database.getUpdated method that returns Id of records updated in a particular time span. It takes sObject Type , start date and end date as arguments and returns ID of updated record. The tricky bit is not every object is supported, so you have add ignore list or some custom logic for objects not supported by ...


1

You just need to use the rendered parameter on the apex:commanButton element. e.g. <apex:commandButton rendered="{!Opportunity.Product_Family__c != 'Services'}" value="Add Item" action="{!addItemRow}" reRender="tableId" status="status" /> You don't need any apex code if all you want to do is control whether the buttons is displayed on page load.


0

Actually, this is how searches work. What you have implemented looks correct and is very easy to use for the end-user. However, If you want to optimize this, I can think of the following approaches: Let the user enter at least 2-3 characters before making the query. Add a delay and check if the user has stopped typing before querying. This will reduce your ...


0

This works perfectly fine, I have modified the logic where it appends '_x' to replace it with the metadata file. Changed from : for (String key : keys) { Object value = obj.get(key); objJSONGenerator.writeFieldName(key + '_x'); //<------- reserved word safety here if (value == null) { objJSONGenerator.writeNull(); ...


0

Arrgh, I was mapping the firstName datafield into the LastName field in the submittedContact. I fixed it and it works.


0

After diving deep, I was able to simulate test data. Thanks to @cropredy for making me think loud. Just to add to my actual test method from my post, Test.startTest(); MyControllerClass ctrl = new MyControllerClass(); MyControllerClass.InputWrapper lstInput = new MyControllerClass.InputWrapper(); ctrl.lstInput.typeValue = adjValue; //This is the way I ...


1

In addition to all the other great answers You should filter out converted leads in the top level loop The Utils.mergeLeadWithXXX has to be called with a list of items and at the end of the main loop - otherwise you will blow up DML statements in any batch operation. See Trailhead resources on bulkification Once you have matched against an account or ...


1

Your problem is most likely here: MyControllerClass ctrl = new MyControllerClass(); MyControllerClass.InputWrapper lstInput = new MyControllerClass.InputWrapper(); lstInput.typeValue = adjValue; this should be: MyControllerClass ctrl = new MyControllerClass(); ctrl.lstInput = new MyControllerClass.InputWrapper(); ctrl.lstInput.typeValue = adjValue; That ...


1

Outline of a solution: start() Query all Accounts execute() Do an aggregate query on Contact WHERE Contact.AccountId IN:scope. Group By accountId, Specialty and Count(Id) Examine aggregate results and compute Mode (per Account) Update Accounts


1

You can use $# to reference a capture group ($1 is the first, $2 is the second, etc.) For your case I ran this: System.debug('1a2'.replaceAll('(\\d)(\\D)(\\d)', 'first: $1; second: $2, third: $3')); System.debug('8o8'.replaceAll('(\\d)(\\D)(\\d)', 'first: $1; second: $2, third: $3')); And got this: first: 1; second: a, third: 2 first: 8; second: o, third:...


1

As the [doc states(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database.htm?search_text=getquerylocator), the argument to a Database.getQueryLocator can not be an Aggregate query You can't use getQueryLocator with any query that contains an aggregate function. There are two workarounds: If the number of ...


0

There's a couple of things not quite clear here, perhaps you forgot to add some of your code? In Apex controller, why "testMethod", that's probably there by mistake. Your method "getProducts" is good enough to get the product options, but the JS controller is not processing the results right. You're checking a string, but returning a list. See the docs ...


-1

Probably a late reply, but you don't need to convert it with the EncodingUtil class. As an example, this is the way to get a csv from a content version: final ContentVersion cv = [SELECT VersionData FROM ContentVersion WHERE ContentDocumentId = :docId AND IsLatest = true]; final String csvContents = cv.VersionData.toString(); final String[] csvLines = ...


1

Debugging a CPU time issue is probably one of the more frustrating things to try to track down and resolve. One thing to keep in mind here is that the line of code that your error points to isn't necessarily the problem, it's just where you happened to go over the CPU limit. Measuring CPU time usage is more of a pain than, say, Query Rows (since each ...


1

Added As its clear that there are 3 levels of strings, you can simple use JSON.deserialize : System.debug(JSON.deserialize('[[[1,2],[3,4],[5,6]]]',List<List<List<String>>>.Class)); OLD ANSWER I could have written a comment but I wanted to paste a screenshot and so writing Answer. This is not a valid JSON: "[[[1 2],[3 4],[5 6]]]" As ...


0

To add to @JanetKang's answer: You have nested for loops; these are pretty much a complete no-no in Apex, especially when there are a lot of items to iterate at both levels, as this is highly inefficient and rapidly uses up your CPU limit (as you are seeing). You should look to remove the loop nesting by "pre-processing" the details from the nested ...


1

Use Input Tag for Radio Button as shown below <td> <input name="isRadio" type="radio" value="{!rep.Id}" /><br/> </td> Click here to see Implementation of Radio Button


2

You should almost never use matches(), but instead typically prefer find(). My primary suggestion to you here is that you add some word boundaries to your patterns (\b). You can actually condense your whole search into just one pattern: ^(\b\D+\b)?\s*(\b.*?\d.*?\b)\s*(\b\D+\b)?$ The link above explains each component of the expression. There are two basic ...


1

There are a couple of possibilities that I can think of off the top of my head. The first is that your account and contact queries are returning a bunch of records and that's slowing it down. I also don't know what's happening in that Util class, so that may be running very inefficiently as well. My first suggestion would be to figure out what's causing the ...


1

HAVING COUNT(Name) > 0 AND CustomField__c = 'myValue' Only aggregated fields can be added in HAVING filter. CustomField__c is not being aggregated in query. In above given query, you are grouping on Account__c and you can add filter in HAVING clause only on this field. I don't your problem but a valid query similar to your query would be: SELECT ...


3

It seems like you're trying really hard to avoid untyped deserialization just because it's comfortable and easy to work with or because it feels "prettier". The best solution then would be to create constructors for your classes that you want to serialize the information into. The constructors should accept a Map<String, Object> and look through the ...


-2

It was returning always zero since i was running with @isTest so my test case was failing to see all the data, when i changed to @isTest(SeeAllData=true) it started working well and fine. thanks for all your response


-1

Try [...](select id, Name from Initial_Notification_Templates__r where Program__c ='+ programId+') [...] instead.


0

Recently had the same problem: when testing the scheduler that run batch - batch wasn't executed. Found the solution here: Does Test.stopTest() ensure a System.Schedule/Database.Batchable completes in a test? If you need to run batch in scheduler test, set the scheduler in @testsetup method and surround it with Test.start() Test.stop(); Then in any test ...


0

You will not get Trigger.new in after delete (Trigger context variables). So, you should consider using Trigger.old in delete context. Also, You can minimize the code as below: There is no need of tempOlisList as you can directly implement for logic for loading MapMonths Check below code: Account acc = new Account(Name='Test'); insert acc; This is same ...


2

If I understand your question correctly you want to know if the code in a certain class has been run recently. As far as I know there is no standard way to do that. You could try to collect and analyze the apex logs over some time. To find the code that is run you can look for lines with 'CODE_UNIT_STARTED'. You could probably automate the log collection ...


4

If you can wait a few months till WINTER 20, you can use MetadataComponentDependencyQueries. This will tell you where your APEX class is used, if it's just in test-class then it should be safe to delete along with the test class. Another option till then will be to try deleting them in the sandbox, it will give you why it cant be deleted due to dependency, ...


1

Use Input Tag for Radio Button as shown below and no need to use Script.. it can be done by Apex Controller itself <td> <input name="isRadio" type="radio" value="{!rep.ocr.Contact.Id}" /><br/> </td> public void updateRole() { List<OpportunityContactRole> roleUpdate = new List<OpportunityContactRole>(); ...


1

A batch's start method can only return a single SOQL query when using query locators. However, if you are wanting to query the same object type but with multiple different WHERE selection clauses, and you then want to just apply the same logic to them, this is a simple matter of appropriately parenthesizing and combining the clauses into a single WHERE. For ...


3

Added based on omments (for creating record): There is no need of Apex to create record as you have standard createRecord. However, I have provided sample code for both below. Get the record values from onload event of record-edit-form and create a record structure from that data. Filter the fields based on what fields are used in form. While processing ...


2

When you have a reverse relationship, such that you can use a nested select, that means you have a direct relationship between that child and the parent. In this case you have OpportunityLineItem and Opportunity related via a field on OpportunityLineItem itself - the field is called OpportunityId and the relationship field is called Opportunity. You can, ...


3

Well, software api architecture is built on contract, if the contract changes then you have to make changes to your implementation. Yes, its there, it's inevitable. SF too changes the contract, but the best thing it does it maintains backward compatibility(v40, v41 etc) Lets assume, the 3rd party API is on version 1, thus it cant change its contract on ...


2

If you're concerned about the source of the data changing on you (because you don't control it) then yes, you may have to use a wrapper to ensure that you control all the variable/property names. It is duplicated code, but if you plan to use the JSON payload in several places, it will pay off to abstract it. I have a lot of wrapper classes that look like ...


6

Per this document, you can use get the getTime() method for this. getTime() Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this DateTime object. In your case, DateTime utcDate3 = DateTime.newInstanceGMT(2019, 7, 19, 18, 20, 5); Long myMiliseconds = utcDate3.getTime();


2

You have not upgraded to Report Builder, and this user has Accessibility Mode enabled. You should go in to Setup > (Quick Find) > Reports and Dashboards Settings, and upgrade to the Report Builder. Please see this help topic. Also, the other differences in the UI are because of Accessibility Mode. The user can to go their Personal Setup screen and disable ...


1

1) Create a formula field FullName__c = FirstName + " "+ LastName 2) Then in your apex code create a third list: List<String> fullNameList = new List<String>(); for(Integer i=0;i<firstNameList.size();i++){ fullNameList.add(firstNameList[i] + ' '+ lastNameList[i]); } List<Contact> contactList = [SELECT Id, firstName, LastName ...


2

My favorite site to help with RegEx things like this is GSkinner's RegEx site where you can test these patterns and it also has a lot of help. What you're going to want to do with this is is create a group to capture the digits as optional followed by another optional group to catch the alpha character, again as optional, then a group to capture the street ...


1

If you want to show the radio button against each record in repeat tag, then you will have to use the html input tag with type as radio i.e. <input type="radio" name="namefield" value="{!value}" /> Where name attribute determines the group and having all the radio buttons with same name makes sure that only one record is selected from the list of ...


3

This is because, wired service always returns an object to property of function in the data structure {data:some_result,error:some_error}. But imperative method promise will resolve to exactlky whatever you are returning from Apex method. So, initially as you are referring to contactList.data, its loading but later when you are searching through ...


1

From your console log: So a wire response in JSON format looks something like { "data" : [Your response]} Now, imperative method response looks like [ {Your response} ,{Your response}] In your searchRecords() method you are just populating just this.contactList The markup template:for is expecting the data in data attribute. <template for:each={...


0

I came across a nice solution if you want to grab class variables dynamically along with their values (inspired by Daveed's answer here): public class MyWrapper { public static final String VAR_NAME = 'name'; public String name; public Integer count; public Account myAcct; public MyWrapper(){} // Returns Map<key, value> only on ...


Top 50 recent answers are included