Skip to main content
22 votes

Salesforce Metadata Api/ Tooling Api to build changesets

It turns out you can directly retrieve and update changesets directly with the Metadata API. Via Sean Harrison‏: Pro tip: U can retrieve the contents of a change set incl. manifest with the ...
Daniel Ballinger's user avatar
9 votes

Functional programming utilities in apex

Apex is a very static language. For example, you cannot reliably determine the class name of an object at run time (Can I determine the class name of an object instance at run-time?). Generics were ...
ipavlic's user avatar
  • 3,736
8 votes
Accepted

Create an Apex class that calls a REST endpoint and write a test class - Trailhead

This is the step by step approach for this implementation. Animal public class Animal { public Integer id; public String name; public String eats; public String says; } AnimalResult ...
Santanu Boral's user avatar
8 votes

How to add many values at once in Apex?

You can initialize list with your items: List<String> l = new List<String>{'a', 'b', 'c', 'etc'};
flameless's user avatar
7 votes
Accepted

ErrorCode 180008 - Unable to queue Triggered Send request. There are no valid subscribers

Make sure you checked the option Add subscribers to this list under Subscriber Management when creating your triggered send. To verify this option, go to Email Studio > Interactions > Triggered ...
Markus Dang - formerly Slabina's user avatar
7 votes
Accepted

can i pass variable values from ampscript to javascript?

I think what you are missing here is that Salesforce Marketing Cloud Server Side JavaScript is not the same as JavaScript that runs on the browser. Adding runat="server" to the script block causes ...
ncv's user avatar
  • 418
7 votes
Accepted

Does Crypto.generateMac method work exactly the same as Mac and SecretKeySpec java classes

Your Apex code just misses the base64 decoding step on your secret key. If you change the call to generateMac() to this: Blob mac = Crypto.generateMac(algorithmName, Blob.valueOf(input), EncodingUtil....
David Reed's user avatar
  • 93.2k
6 votes
Accepted

Getting salesforce instance URL from Java

When you call the Partner API login() method it will return a LoginResult. It will have the: serverUrl URL of the endpoint that will process subsequent API calls. Your client application needs to ...
Daniel Ballinger's user avatar
6 votes
Accepted

Is there a zero-downtime way to rotate the server credentials used by force-wsc?

A properly written force-wsc app (or any other SOAP-based application) won't immediately be affected by password change; this is because a session remains valid even if the username or password for ...
sfdcfox's user avatar
  • 495k
5 votes
Accepted

How to set TLS Version in Java SOAP API

The problem here is that although Java 7 and higher support TLS 1.1 and 1.2, they are not enabled by default. You can enable them by using: System.setProperty(“https.protocols”, “TLSv1,TLSv1.1,TLSv1....
Frederik Witte's user avatar
5 votes
Accepted

Cannot retrieve full class list from the org using tooling API?

You will need to change your strategy as including all the class names you have already queried is causing the query string to exceed the 20,000 character query limit. The Partner API includes the ...
Keith C's user avatar
  • 136k
5 votes
Accepted

JSONGenerator issue

To remove the backslash you have to write the blob value of the JSON String into the body directly in the RestContext. You will have to change the return type of your method from String to void. @...
Saroj Bera's user avatar
  • 14.8k
5 votes
Accepted

Convert code snipet from Java to Apex

Yep, Http basic auth uses base64. The Base64.encodeToString in the Java snippet should've also given that away. Given what you've shown so far, your Authorization header is incorrect. If you inspect ...
Derek F's user avatar
  • 62.3k
4 votes
Accepted

Java - Metadata Api readMetadata() not returning corrrect info

Based on the documentation on readMetadata(), it does not seem like wildcard selection is possible, since the limit on returned results is 10. Arguments Name fullNames Type string[] ...
Adrian Larson's user avatar
  • 150k
4 votes
Accepted

SOQL retrieve limited?

lead.setFirstName(sobj[j].getField("FirstName").toString()); The Lead FirstName field is not required. As such, it will return as null via the API if it is not defined. You will need to check if it ...
Daniel Ballinger's user avatar
4 votes
Accepted

java and apex output different crypto generateDigest SHA-512 method in apex and java logic not same

Both languages are working fine. You are decoding them with wrong base. Apex method is encoding blob as Base 64 and Java method is encoding it in Base 16. When you convert it in base 16 it output hex ...
Ashwani's user avatar
  • 22.6k
4 votes

ErrorCode 180008 - Unable to queue Triggered Send request. There are no valid subscribers

Maybe will be useful for anyone in future. I got this error in another case. The triggered send was configured only to Add Subscribers to All Subscribers, without Update checkbox. And the request ...
Polina Drobot's user avatar
4 votes

Need Help on Encryption and decryption logic

The Crypto class in Apex only supports CBC (Cipher Block Chaining) mode for AES, so based on that alone I'd say that it's not possible to port this exact code to Apex (unless you implement your own ...
Derek F's user avatar
  • 62.3k
4 votes

Lombok for Salesforce Apex

Illuminated Cloud (paid plugin for IntelliJ) has live templates for Apex and Lightning Web Components to help save time. Likewise, you can create your own live templates for IntelliJ if desired. There'...
Kris Goncalves's user avatar
4 votes

Get values from nested JSON dictionaries in Apex

I'm the author of the libshare JsonMapper is a utility class I wrote as part of libshare opensource package. This makes it easy to read raw json. For ex., new JsonMapper(jsonStr).getString('values[0]....
metasync's user avatar
  • 1,772
3 votes
Accepted

How to communicate with Salesforce without WSDL?

It sounds like you are using the Enterprise WSDL. This is a strongly typed WSDL that is bound to the Salesforce configuration/schema at the time it was generated. On the plus side, it gives you easy ...
Daniel Ballinger's user avatar
3 votes

How to convert "2016-11-08T13:04:16.5260175Z" this into apex datetime like "11/8/2016 1:04 PM"

I think that the most reliable method is to use the JSON.deserialize method. This accounts for time zones etc and is invoked like this: DateTime result = (DateTime)JSON.deserialize('"' + '2016-11-...
Aidan's user avatar
  • 13.7k
3 votes
Accepted

Apex callout - POST Method

I am thinking below is the equivalent .We can declare the content type to be form url encoded and then simply use strings HTTP auth = new HTTP(); String Body = 'userID=XXXX&password=YYYYY'; ...
Mohith Shrivastava's user avatar
3 votes
Accepted

How to setup Tooling Api in Java Application?

Only the Enterprise API is Org specific. The Tooling API will work with any org providing the user has API access. In addition to API access the user making the API calls may require additional ...
Daniel Ballinger's user avatar
3 votes
Accepted

Java Desktop App To Login Salesforce

Basically, you just pop up a WebView with the appropriate User-Agent Flow endpoint, and set an event hook for when the callback URL is triggered. Once that happens, you'll have an access token you can ...
sfdcfox's user avatar
  • 495k
3 votes
Accepted

Force IDE 2 BETA not working due to java.lang.NullPointerExceptions

This happens if you (like me) are not reading the instructions carefully ;-) As a prerequisite you need to download and install Salesforce CLI like stated here Salesforce CLI Each Force.com ...
Uwe Heim's user avatar
  • 28.4k
3 votes
Accepted

Is a Java SDK like JSforce available?

There is a Java WSC (webservice connector) https://github.com/forcedotcom/wsc I have used it in past , pretty much gives you all the methods that are available in SOAP api, but its not as verse as ...
Avidev9's user avatar
  • 5,659
3 votes
Accepted

run assignment rule from javascript button

Looks like AssignmentRuleHeader is case sensitive, Try changing it to assignmentRuleHeader. Your code would then be: sforce.connection.AssignmentRuleHeader = {} sforce.connection....
Raul's user avatar
  • 18.8k
3 votes
Accepted

null argument for JSONGenerator.writeStringField()

You can't write a null value with the writeStringField function; instead, if the field is null, you have to use the writeNullField function. That means your code needs to look more like: Map<...
sfdcfox's user avatar
  • 495k
3 votes

Edit Update Reminder Setup by API

Actually, as of Sept. 2021, it turns out you can. Salesforce's documentation isn't very clear on this. You can't edit the update reminder entries themselves, but you CAN turn update reminders on and ...
Fields-Era's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible