• AmanSharma06
  • NEWBIE
  • 35 Points
  • Member since 2017
  • Salesforce Developer


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi All,

I am getting the error when I run the test class.
System.JSONException: Unexpected character ('C' (code 67)): was expecting comma to separate OBJECT entries

I have created the mock class, in that I am sending the body as below.
 
res.setBody('{"value": [{'+
        '"groupid": 1,'+
       '"group_name": "Test",'+
        '"sub_customer": "[{\"CustomerId\":\"9488491\",\"CustomerName\":\"Test\",\"Street\":\"Test\",\"City\":\"PENRITH\",\"PostalCode\":\"275\",\"Country\":\"Test\",\"Assetcnt\":\"6\"}]"}]}');

I am getting the error in Apex class
SearchResult obj=(SearchResult)JSON.deserialize(resp.getBody(), SearchResult.class);

Wrapper class :
 
Public class value{
        
        @AuraEnabled
        public Integer groupid {get; set;}
        @AuraEnabled
        public string group_name {get; set;}
        @AuraEnabled
        public String sub_customer {get; set;}
        
        
    }
    
    public class SearchResult {
        @AuraEnabled
        public List<value> value;
        
        public SearchResult(List<value> liList) {
            value = liList.clone();
        }
    } 
    
    Public class Value_out{
        @AuraEnabled
        public string group_name;
        @AuraEnabled
        public string groupid;
        //srini-added for parent level sum of assets
         @AuraEnabled
        public String sumofAssets;
        @AuraEnabled
        public list<sub_customer> children;
    }
    public class sub_customer{
        @AuraEnabled
        public string CustomerName;
        @AuraEnabled
        public string CustomerId;
        @AuraEnabled
        public string Street;
        @AuraEnabled
        public string City;
        @AuraEnabled
        public string PostalCode;
        @AuraEnabled
        public string Country;
        @AuraEnabled
        public string Assetcnt;
    }

Regards,
VSK98​​​​​​​
 
  • December 12, 2018
  • Like
  • 0
I've got a requirement where I want to encrypt standard Name field on a custom object. First of all is it really possible to achieve this. If so , then how to do that.
 
I am trying to create lightning component consisting draggable cards for each field available in the fieldset.A user can drag and drop available cards and change the sequence of fields on the page. As soon as he clicks on 'Save' button we want to remember his choice and when next time he login we want to display fields in a fieldset in the same sequence. I am flexible with my approach if anybody thinks that it can be achievable through any other ways. If above problem is unclear please drop a note.
I have created custom buttons which I would only make available based on the Contact.Type field value selected. Is it possible to create a custom component where I can group these buttons?
Hi All,

I want to know the basic resons for below point:

1.can we call future method into batch apex,if not why??
2.can we call futute method into anothrt future method??
Hi All,

I am getting the error when I run the test class.
System.JSONException: Unexpected character ('C' (code 67)): was expecting comma to separate OBJECT entries

I have created the mock class, in that I am sending the body as below.
 
res.setBody('{"value": [{'+
        '"groupid": 1,'+
       '"group_name": "Test",'+
        '"sub_customer": "[{\"CustomerId\":\"9488491\",\"CustomerName\":\"Test\",\"Street\":\"Test\",\"City\":\"PENRITH\",\"PostalCode\":\"275\",\"Country\":\"Test\",\"Assetcnt\":\"6\"}]"}]}');

I am getting the error in Apex class
SearchResult obj=(SearchResult)JSON.deserialize(resp.getBody(), SearchResult.class);

Wrapper class :
 
Public class value{
        
        @AuraEnabled
        public Integer groupid {get; set;}
        @AuraEnabled
        public string group_name {get; set;}
        @AuraEnabled
        public String sub_customer {get; set;}
        
        
    }
    
    public class SearchResult {
        @AuraEnabled
        public List<value> value;
        
        public SearchResult(List<value> liList) {
            value = liList.clone();
        }
    } 
    
    Public class Value_out{
        @AuraEnabled
        public string group_name;
        @AuraEnabled
        public string groupid;
        //srini-added for parent level sum of assets
         @AuraEnabled
        public String sumofAssets;
        @AuraEnabled
        public list<sub_customer> children;
    }
    public class sub_customer{
        @AuraEnabled
        public string CustomerName;
        @AuraEnabled
        public string CustomerId;
        @AuraEnabled
        public string Street;
        @AuraEnabled
        public string City;
        @AuraEnabled
        public string PostalCode;
        @AuraEnabled
        public string Country;
        @AuraEnabled
        public string Assetcnt;
    }

Regards,
VSK98​​​​​​​
 
  • December 12, 2018
  • Like
  • 0
Good morning folks,

I was wondering if its is possible to have a trigger on attachment whereas it would check if the record already has an attached file, and if so it would give an error and would not allow anymore files to be attached on said record.

And if the latter is indeed possible what should the trigger be counting? Attachments or Contentdocument?

Thanks in advanced for the help.
I have created custom buttons which I would only make available based on the Contact.Type field value selected. Is it possible to create a custom component where I can group these buttons?
I have a lightning-datatable web component which is happily displaying data.  I have written an onsort function which is performing the sort correctly in the controller but is not rerendering the display of the table so nothing appears to change.

I know the rows are being sorted because the rows have view and edit actions and clicking these performs the action against the correctly sorted row, even if it doesn't match what's being displayed.  It's as if I need to manually trigger some kind of refresh to cause the data on the screen to be updated to match the data in the controller, but the data is @api decorated so it should be doing it automatically, as I understand it.

There's not much out there about lightning web components, wondered if someone on here could offer a suggestion?
 
<template>
    <lightning-datatable data={tblData}
                         columns={columns}
                         hide-checkbox-column={hideCheckboxColumn}
                         sorted-by={sortedBy}
                         sorted-direction={sortedDirection}
                         key-field={keyField}
                         onsort={updateColumnSorting}
                         onrowaction={handleRowAction}
    >
    </lightning-datatable>
</template>
import { LightningElement, api, track} from 'lwc';
import { CurrentPageReference, NavigationMixin } from 'lightning/navigation';

export default class DatatableSortableWeb extends NavigationMixin(LightningElement) {
    @api tblData = [];
    @api columns;
    @api hideCheckboxColumn;
    @api sortedBy;
    @api sortedDirection;
    @api keyField;

    /*
    If user clicks a column header, sort using event params
    */
    updateColumnSorting(event) {
        var fieldName = event.detail.fieldName;
        var sortDirection = event.detail.sortDirection;

        // assign the latest attribute with the sorted column fieldName and sorted direction
        this.sortedBy = fieldName;
        this.sortedDirection = sortDirection;
        this.tblData = this.sortData(fieldName, sortDirection);
    }

    /*
    Sort table, ignoring case and treating empty cells as "zzz" so they come last when sorting ASC
    */
    sortData(fieldName, sortDirection) {
        var dataToSort = this.tblData;
        var reverse = sortDirection !== 'asc';
        //sorts the rows based on the column header that's clicked
        dataToSort.sort(this.sortBy(fieldName, reverse));
        return dataToSort;
    }

    sortBy(field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'zzz'};

        //checks if the two rows should switch places
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }