Questions tagged [hashcode]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
178 views

base64 hash using HMAC SHA256

I am trying to compute the Apex equivalent of the following - var shaBodyContent = CryptoJS.HmacSHA256(stringToSign, postman.getEnvironmentVariable("HMAC_SS")); var b64BodyContent = shaBodyContent....
2
votes
1answer
42 views

hashCode and equals implementation not working

I am not getting a match when using the containsKey method on a Map of this custom object type: Custom Apex Type public class StateTransition { final ProcessState CurrentState; final Command ...
0
votes
1answer
27 views

Prevent Duplicates using unique key

We want to prevent duplicate records of a custom object. The key is built from 20 fields of the record, for example: Let's say a record has Name = "Test", Date="01/01/2018", Number="5" the key would ...
0
votes
1answer
25 views

How do i get parameter values in decrypted format where the URL parameters are in encrypted format [closed]

Ex : https://www.abc.com/home?firstname=C1SA8WkuxUncg4SLsHeirA==&lastname=23O5jzhBJUGA9f9KwDre2A== Actually the above first name should display as suneel and last name as test. I have tried with ...
11
votes
1answer
166 views

Unexpected results when using a custom class as key in Map

I thought I understood how maps are supposed to work. So, I thought I would try to be clever and use a custom class as the key in a map in Apex. The results, however have been unexpected. It's so ...
7
votes
2answers
398 views

How can I check if an sObject is contained by a Set after changing a field value?

This is probably best summed up with an example and quote from the documentation. The following anonymous Apex will pass the given assertion. Account a1 = new Account(name='a'); Account a2 = new ...
2
votes
0answers
61 views

Build Duplicate matching rule for long text fields using a custom hashCode

To find duplicates of a custom object I planned using Salesforce.com's native Duplicate Management functionality. I was a bit disappointed to see that matching rules are not able to compare Long text ...
2
votes
1answer
249 views

Methods equals() and hashCode() misbehaving in Map.containsKey()

Can you see why this returns true: Map<IObject, XYZ> records1Map = getRecords(1); // returns Map<MyObject, XYZ> Map<IObject, XYZ> records2Map = getRecords(2); // returns Map<...
5
votes
1answer
174 views

HashCode Deduplication?

Background: Ever since I found out you can Use Custom Types in Map Keys and Sets, I wondered if you can map data by the hashCode value. I suspect it's a bad idea. I understand the basics of how hash ...
5
votes
3answers
87 views

Why is record object with different id not used as key in Map?

I don't quite understand this situation and I wonder, if somebody knows where is the problem. I' assigning in loop object as a key and simple number as his value: Map<QuoteLineItem, Integer> ...
0
votes
1answer
90 views

Hash Code Used In Map Keys

How is hash code generated when we use sobject as map keys in salesforce? As per the documentation, the hash code uses sobject field values to generate hash key but what if there are more than 200 ...
0
votes
1answer
392 views

Apex equivalent of PHP sha1() and some more encoding methods

I got a PHP script to generate an encoded URL. I need to translate this script into Apex code to generate the same URL. However, the PHP encode functions seem to work differently from Apex. The ...
9
votes
2answers
600 views

System.hashCode broken on Id properties of SObjects?

Just wasted some time trying to get a big business logic unit test to pass and tracked it down to this. Here is a failing test demonstrating just the problem of using System.hashCode for Id values: @...
20
votes
2answers
539 views

hashCode() is never called when adding to Maps and Sets

Given the following Apex class, which implements equals() and hashCode() as per the Using Custom Types in Map Keys and Sets documentation: public class Foo { private Integer x; public Foo(...
10
votes
4answers
2k views

Is there a way to generate a unique hashcode for an in memory SObject that does not yet have an Id?

When SObjects are used as Map keys they are compared by field values, so for example: Account a = new Account(); Account b = new Account(); System.debug(a == b); // Prints true Map<SObject, ...