Hot answers tagged

4

This is not a valid JSON, you might want to format it like this { "header": { "worker count": "2" }, "Worker": [{ "name": "emp1" }, { "name": "emp2" }, { "name": "emp3" } ] } array of worker Objects you put as value of "Worker" attribute.


4

This JSON is mangled: you have a single outer key, Account, whose value is not more JSON but a string value containing escaped JSON. It would be best to fix this at the source of this JSON by correcting its logic. However, assuming this value is stored in a Map<String, Object> inputJSON, you can just deserialize the value of the Account property: Map&...


4

Sure, but let's get the trigger bulkified first. I'd strongly recommend completing Bulk Apex Triggers on Trailhead. The quick summary is that here we need those SOQL queries out of the loop, and you can combine them into a single parent-child SOQL query at the top. You don't need to query the records in Trigger.new at all (you get their data for free), but ...


3

I believe that something like this should work trigger ActiveOrder on Order (after insert, after update) { public class JSONOrderInfo { private String ordAccountId; private String ordBillingStreet; ... public JSONOrderInfo(Order newOrder) { this.ordAccountId = newOrder.AccountId; this....


3

Judging from your comments, I am going to assume that Content is returned in an array: [{ "ip": "176.114.240.35", "location": { "country": "CZ", "region": "Hlavní město Praha", "city": "Malá Strana", "lat": 50.0877, "lng": 14.4045, "postalCode": "", "timezone": "+01:00", "geonameId": ...


3

You are serializing variable x into variable y ,and still priting variable x which is unchanged. fix: Print variable y Map<String, Object> m = new Map<String, Object>(); m.put('property', 'name'); m.put('value', 'mike'); Map<String, Object> m2 = new Map<String, Object>(); m2.put('property', 'age'); m2.put('value', 47); List<...


2

You should make use of callback parameter in the call to recommend.json - you can easily append it if you have existing parameters in your querystring: https://{MID}.recs.igodigital.com/a/v2/{MID}>/category/recommend.json?category={CATEGORY}&item={CONTENT_ID}&callback=foobar This will wrap the response in a function call with the name passed in ...


1

My personal preference is to use the JSONParser.readValueAs This will avoid the headache of parsing a JSON node by node. 1/ First thing you need to do is to create an Apex POJO class with the same structure of the JSON. Different tools you can use: JSON2Apex / jsonschema2pojo (This will generate a JAVA class but the code is very similar to Apex) 2/ ...


1

Yes, the third-party would use https://domain.my.salesforce.com/services/apexrest/Cases/. To authenticate, they would use OAuth or the SOAP login() command, and set the Authorization header to Authorization: Bearer <session-id-or-access-token>. See the Web Server OAuth Flow, the User-Agent Flow, and SOAP login(). You can also use the Canvas API to log ...


1

This is actually surprisingly easy to achieve using standard JavaScript functionality that is supported by the Salesforce Locker Service; the XMLHttpRequest. You can check what is supported by opening the Locker API Viewer then searching for the feature of interest. Static resources can be referenced by special imports in LWC using their base name (without ...


1

You have to build the map in JS as an object: let jsMap = { '0017F00000gqDetQAE': { 'ACCOUNTNUMBER': 'CD451796 -- new', 'PHONE': '(512) 757-6000 --' }, '0017F00000gqDevQAE': { 'NAME': 'Pyramid Construction Inc. --' } }; let stringForSendingToAPEX = JSON.stringify(jsMap); Then you will be able to deserialize this ...


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