New answers tagged

2

You can't use reserved or illegal names with JSON.deserialize and a template class. You need to enable the use of "explicit parsing" in JSON2Apex, which generates a longer JSON parser in the form of a JSONParser script, which you then call as: Json2Apex equiMap = Json2APex.parse(response.getBody().toString()); In other words, JSON.deserialize(...


1

I build an app that does something similar - it passes in 200 records at at a time in a JSON array to be processed, and many of those records have long text descriptions as part of the data so are too big for a long text field. So we have a staging object with a fields on it like status, type, and then the inbound request comes to a custom Apex REST endpoint ...


2

You need to query just the existing notes that you care about before determining if the note already existed. In addition, if there are duplicates in the list, you need to check for that, too. Here's a corrected version based on my Aggregate-Query-Update pattern, which you may want to read about, as you'll be using it a lot if you write any significant ...


1

The draftValues attribute can be read at any time. You don't need an event to get the draft values. handleSaveClick() { let draftValueJSON = JSON.stringify( this.template.querySelector('lightning-datatable').draftValues ); // Do something with draftValueJSON // }


0

The clue is in the exception message. When using JSON.deserializeUntyped a JSON object, like {"property": "value"}, is converted to an Apex Map<String, Object>. However, a JSON array, like [1, 2, 3] or [{...}, {...}], is converted to an Apex List<Object>. Since your JSON is a JSON array at the outermost level parsing it will ...


4

You'll want to add a storage variable to keep track of the opportunity. Here's an example I wrote up real quick that demonstrates a starting point for how I'd approach this problem. It presumes that you don't know the account Id, Pricebook2 Id, or any Product2 Id values, but you do know the names and product codes. This code follows what I call the Aggregate-...


0

This relates to the syntax of Apex strings where \ is an escape character that turns off any special meaning of the following character. So to represent a literal \ you need to escape the special meaning of the second \ with an added first \, hence \\. I suggest modifying your local code to not put in the \ in the first place as Apex strings use ' as the ...


1

Packages are containers, so to speak, for package versions. Package versions are what you install. Their ids start with 04t, rather than the 0Ho of the containing package. You haven't uploaded a package version yet. You need to do so using the force:package:version:create command, which you can status-check using force:package:version:create:report. Once you ...


1

The error you're receiving is telling you that data.fields is undefined. Looking at your code, you have segmentId( data, error ) { which is essentially declaring two objects to be passed into your function. As per the docs (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.data_wire_service_about), you need a single object with ...


3

As with any other method you want to cover, you have to actually call it. @IsTest static void myTest() { // setup as is Test.startTest(); DynamicApi.DynamicApiPost(); Test.stopTest(); // query results // assert behavior }


3

Not sure I understand your question completely, are you serializing an instance of this class, and do not want the Number_Address__c in the JSON? If so, look at serialize(objectToSerialize, suppressApexObjectNulls)


1

Create a below Function --> public String generateRequest(object requestObj, Boolean suppressNull) { return System.JSON.serializePretty(requestObj, suppressNull); } Notice notice = new Notice (); // // Prefill Your notice DTO // // requestBody json contain eliminated null value, blank value are not eliminated String requestBody = generateRequest(...


2

What happened is you tried to get CLDate from the targetFields map, which was null, so no conversion from String to Date occurred (you basically went down a default when else path, since the described type was null). You need to change: switch on targetFields.get(key)?.getDescribe().getType() { To: switch on targetFields.get(sObjectFieldsMap.get(key))?....


Top 50 recent answers are included