• Jim Field
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hello,

I am trying to parse the following JSON into a List of a custom Apex class, but I am getting this error:  1:55:17.0 (5766922)|USER_DEBUG|[210]|DEBUG|ERROR: System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set.

The JSON is:

{
    "DCLPricing" : [ {
        "PriceListNumber" : "C1000004",
        "Currency" : "USD",
        "CustomerNumber" : "C1000004",
        "ValidFrom" : 20200101,
        "ValidTo" : 20211231,
        "Name" : "3M CORPORATION"
    }, {
        "PriceListNumber" : "C1000011",
        "Currency" : "EUR",
        "CustomerNumber" : "C1000011",
        "ValidFrom" : 20200101,
        "ValidTo" : 20211231,
        "Name" : "A SCHULMAN PLAS"
    }, {
        "PriceListNumber" : "C1000022",
        "Currency" : "USD",
        "CustomerNumber" : "C1000022",
        "ValidFrom" : 20200101,
        "ValidTo" : 20211231,
        "Name" : "A. SCHULMAN CO."
    } ]
}

The code to parse the JSON is:
List<DCLPricing> priceLists = (List<DCLPricing>)JSON.deserialize(request.requestBody.tostring(), List<DCLPricing>.class);

The custom class is:

public class DCLPricing {
        public String PriceListNumber;
        public String CurrencyCode;
        public String CustomerNumber;
        public Date ValidFrom;
        public Date ValidTo;
        public String Name;
        
        public DCLPricing(String priceListNumber, String currencyCode, String customerNumber, String validFrom, String validTo, String name ){
            this.PriceListNumber = priceListNumber;
            this.CurrencyCode = currencyCode;
            this.CustomerNumber = customerNumber;
            String year = validFrom.substring(0, 4);
            String month = validFrom.substring(4,6);
            String day = validFrom.substring(6, 8);
            System.debug('year: ' + year + ' / ' + 'month: ' + month + ' / ' + 'day: ' + day);
            this.ValidFrom = Date.parse(day + '/' + month + '/' + year);
            
            year = validTo.substring(0, 4);
            month = validTo.substring(4,6);
            day = validTo.substring(6, 8);
            System.debug('year: ' + year + ' / ' + 'month: ' + month + ' / ' + 'day: ' + day);
            this.ValidTo = Date.parse(day + '/' + month + '/' + year);
            
            this.Name = name;
        }
    }

Can anyone help me successfully parse this JSON into a list?
 
I am sending Salesforce accounts to Infor M3 via an api call to ION.  After the M3 customer number is returned to Salesforce and written to the record, I need to send any related contacts to M3.  I have tried numerous ways of doing this, but I always end up with an error on the contact send.   The errors range from "you have uncommitted work pending, please commit or rollback before calling out" to "you can't call a future method from a future method."  I even tried using a business process flow to call apex to send the contacts after the account has been updated with the M3 customer number, but that also results in an "uncommitted work" error.  What is the best practice for sending a Salesforce record to an outside system and then sending any related records to the outside system?  How can I send the contacts after the account M3 customer number has been written to the Salesforce account record?
I have created an Apex REST service, but I am having trouble connecting to it from outside of Salesforce.  I have created a connected app to facilitate the connection, but when I try to get an authorization token from Postman or curl, I get an authentication failure error.  It seems I have my connected app configured incorrectly or my request is set up incorrectly, but I do not know which or if there is another step I have missed.  Any help would be greatly appreciated.
I need to send XML bods to ION IMS from Apex, but I cannot find any examples of how to send a multipart message from Apex.  I need the body to send two parameters:  

1. ParameterRequest - a JSON based list of parameters
2. MessagePayload - the actual XML containing the Salesforce data.

Does anyone know how to do this?
I am new to Saleforce development, and I am trying to embed an svg file in a Lightning Web Component, but I am having trouble.  I am following the example in the documentation (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_svg_in_component).

I have uploaded the svg file as a static resource called TestSVG.

My javascript file is as follows:

import { LightningElement } from 'lwc'; 
import SVG_URL from '@salesforce/resourceUrl/TestSVG'; 
export default class myComponent extends LightningElement { 
get svgURL () { return SVG_URL; } 
}

My html file is as follows:
<template>
    <svg xmlns="http://www.w3.org/2000/svg">
        <use xlink:href={svgURL}></use>
    </svg>
</template>

The web component deploys successfully, but when I load the page the svg area is blank.  If I open the svg from the static resource, it shows the floorplan of a building.  Does anyone have any ideas why it isn't rendering in the web component?
I have created an Apex REST service, but I am having trouble connecting to it from outside of Salesforce.  I have created a connected app to facilitate the connection, but when I try to get an authorization token from Postman or curl, I get an authentication failure error.  It seems I have my connected app configured incorrectly or my request is set up incorrectly, but I do not know which or if there is another step I have missed.  Any help would be greatly appreciated.
I am new to Saleforce development, and I am trying to embed an svg file in a Lightning Web Component, but I am having trouble.  I am following the example in the documentation (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_svg_in_component).

I have uploaded the svg file as a static resource called TestSVG.

My javascript file is as follows:

import { LightningElement } from 'lwc'; 
import SVG_URL from '@salesforce/resourceUrl/TestSVG'; 
export default class myComponent extends LightningElement { 
get svgURL () { return SVG_URL; } 
}

My html file is as follows:
<template>
    <svg xmlns="http://www.w3.org/2000/svg">
        <use xlink:href={svgURL}></use>
    </svg>
</template>

The web component deploys successfully, but when I load the page the svg area is blank.  If I open the svg from the static resource, it shows the floorplan of a building.  Does anyone have any ideas why it isn't rendering in the web component?