Hot answers tagged

6

The result from JSON.deserializeUntyped is either a List, Map, String, Boolean, or Decimal/Integer. You can detect these conditions dynamically, even recursively if you want to. Object source = JSON.deserializeUntyped(jsonString); if(source instanceOf Map<String, Object>) { Map<String, Object> values = (Map<String, Object>)source; ...


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-...


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)


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))?....


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 // }


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 ...


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(...


1

That could be simply accomplished with a replace using a regex This regex select a string in format 'XXXX-XX-XX' where X are numbers from 0 to 9 const regex = /'[0-9]{4}-[0-9]{2}-[0-9]{2}'/gm; const str = ` select Owner.Name, Owner.Id from custom_table where CreatedDate >= '2020-01-01'`; const result = str.replace(regex, subst); console.log('...


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