Has anyone done parsing of JSON response in the client controller of the lightning component?
In my scenario, I have the below code -
else if(response.getState()==="ERROR"){
console.log('Problem saving record, error: ' + JSON.stringify(response.getError()));
var errMsg = "";
---------------
}
The output of response.getError is -> [{"fieldErrors":{"PricebookEntryId":[{"statusCode":"FIELD_INTEGRITY_EXCEPTION","message":"field integrity exception: PricebookEntryId (pricebook entry is inactive)"}]},"pageErrors":[],"index":null,"duplicateResults":[]}]
I need to parse the above output to get the message information which I can display on the UI. Any help is appreciated!
Hi Rahul,
Thanks for this code but is there a way to make this code more generalized? I may not know what validation error/ exception is going to come upon clicking on the save button thus I am looking for a generic parser.
The code that you shared is throwing exceptions. Let me work through that and will share the updates.