• hiteshwar marni
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 9
    Replies
When default sharing is set to Without sharing ,why salesforce has explictly provided without sharing keyword.

Thanks,
Hitesh
Im not able to deploy lightning web component from VS Code to Source Org. 
Please find the below screen shot for the error detils.
User-added imageThanks,
Hitesh
Hi below is my class and wrapper class

public class manageProductsController {
    
    @AuraEnabled
    public static string insertOpportunityLineItems(String oppId,list<Prodsearch> selctdProdList){
        system.debug('####SELTDPRODlIST####'+selctdProdList);
        system.debug('*****oppId*****'+oppId);
        
        system.debug('=====BEFORE FOR LOOP====');
        for(Prodsearch ps:selctdProdList){
            system.debug('=====IN FOR LOOP====');
            string [] prodPricBookIds = ps.issueCode.split('-');
            system.debug('IDIDIDIDIDIDID'+prodPricBookIds);
           opportunityLineItem oli = new opportunityLineItem();
            oli.OpportunityId = oppId;
            oli.Product2Id = prodPricBookIds[0];
            oli.Quantity=1;
            oli.UnitPrice=10;
            insert oli;
        }
        return null;
    }
    
    public class Prodsearch{
        @AuraEnabled
        public list<string> prodFamily{get;set;}
        @AuraEnabled
        public string subProd{get;set;}
        @AuraEnabled
        public  string issueCode{get;set;}
        
    
    }
   
}

I'm getting the following data in the debug
|####SELTDPRODlIST####({prodFamily=LDP-V, subProd=LDP-V BASIC, issueCode=01t28000000fLaDAAU-01u28000001Dx58AAC})
|*****oppId*****0060K00000TxL2g

but execution is getting fauiled before FOR LOOP with exception

FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1026148476-352 (-230392578) (-230392578)

Please help me on this,

Thanks
Hitesh
Hi,
I'm not able to display my parsed json response on VF page...pls help me on this.

VF CODE
<apex:page controller="Googlebooks_Controller" showHeader="false">
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection >
              <apex:inputText value="{!searchText}" label="Enter Name"/>
              <apex:selectList label="Select Account" multiselect="false" size="1" value="{!selectedCtriteria}">
              
                  <apex:selectOptions value="{!lstOptions}"></apex:selectOptions>
              </apex:selectList>
          </apex:pageBlockSection>
          <apex:commandButton value="Search" action="{!getBookDetails}" reRender="pb,pbt"/>
          <apex:pageBlockSection id="pb">
          {!searchText}
          {!selectedCtriteria}<br/>
              {!jsonresponse}
          </apex:pageBlockSection>
      <apex:pageBlockTable value="{!prsr}" var="i" id="pbt">
              
          <apex:column headerValue="TTTTT" value="{!i.kind}"/>
          <apex:pageBlockTable value="{!i.items}" var="pt">
              <apex:column value="{!pt.etag}" headerValue="sss"/>
          </apex:pageBlockTable>
          </apex:pageBlockTable>
      
      </apex:pageBlock>
      <apex:pageBlock id="pb">
      {!ss}
          
      </apex:pageBlock>
      
     
  </apex:form>
</apex:page>


APEX CLASS

public class Googlebooks_Controller {
 public JSON2Apex1 prsr{get;set;}
 public list<JSON2Apex1>ss{get;set;}
//public googlebooksparser wrapper {get;set;}
public string searchText{get;set;}
public string selectedCtriteria{get;set;}
public List<Selectoption> lstOptions {get;set;}
public string jsonresponse{get;set;}
public Googlebooks_Controller (){
    lstOptions  = new List<Selectoption>();
    //lstoptions.Add(new selectOption('','====None===='));
    lstoptions.Add(new selectOption('Author','Author'));
    lstoptions.Add(new selectOption('Title','title'));
    lstoptions.Add(new selectOption('ISBN','ISBN'));
    }

public void getBookDetails(){
    Http p = new Http();
    HttpRequest request = new HttpRequest();
    request.setMethod('GET');
    //AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA
    String sText = searchText;
    sText= sText.replaceAll( '\\s+', '');
    string endpoint;
    if(selectedCtriteria == 'author'){
        endpoint = 'https://www.googleapis.com/books/v1/volumes?q='+sText+'+inauthor:keyes&key=AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA';
    }
   /* if(selectedCtriteria == 'Title'){
    
        endpoint = 'https://www.googleapis.com/books/v1/volumes?q='+sText+'&key=AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA';
    }
    if(selectedCtriteria == 'ISBN'){
        endpoint = 'https://www.googleapis.com/books/v1/volumes?q=AnnaKeyes+inauthor:keyes&key=AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA';
    }*/
    system.debug('ENDPOINT '+endpoint);
    request.setEndPoint(endpoint);
    HttpResponse response = p.send(request);
    jsonresponse = response.getbody();
    
   JSON2Apex1  prsr= (JSON2Apex1)JSON.deserialize(jsonresponse, JSON2Apex1.class);
   
   system.debug('===='+prsr.items);
   
 
}
}

PARSERCLASS

public class JSON2Apex1 {
    public String kind{get;set;}
    public Integer totalItems{get;set;}
   public  List<Items> items{get;set;} //Your existing class.
    
    
    
    public class Items {
        public String kind {get;set;} 
        public String id {get;set;} 
        public String etag {get;set;} 
        public String selfLink {get;set;} 
        public VolumeInfo volumeInfo {get;set;} 
        //public SaleInfo saleInfo {get;set;} 
        //public AccessInfo accessInfo {get;set;} 
        //public SearchInfo searchInfo {get;set;} 
        public Items( String kind,String id,String etag,String selfLink,VolumeInfo VolumeInfo ){  
                        
              this.kind=kind;
              this.id=id;
              this.etag=etag;
              this.selfLink=selfLink;
              this.VolumeInfo =VolumeInfo;
        }
    }
     public class VolumeInfo {
        public String title {get;set;} 
        public String subtitle {get;set;} 
        public List<String> authors {get;set;} 

        public VolumeInfo(String title,String subtitle,List<String> authors) {
        this.title=title;
        this.subtitle=subtitle;
        this.authors=authors;
            
        }
    }
}
How to parse this JSON


{
    "results": [
        {
            "address_components": [
                {
                    "long_name": "111",
                    "short_name": "111",
                    "types": [
                        "street_number"
                    ]
                },
                {
                    "long_name": "Main Street",
                    "short_name": "Main St",
                    "types": [
                        "route"
                    ]
                },
                {
                    "long_name": "Old East Dallas",
                    "short_name": "Old East Dallas",
                    "types": [
                        "neighborhood",
                        "political"
                    ]
                },
                {
                    "long_name": "Dallas",
                    "short_name": "Dallas",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "Dallas County",
                    "short_name": "Dallas County",
                    "types": [
                        "administrative_area_level_2",
                        "political"
                    ]
                },
                {
                    "long_name": "Texas",
                    "short_name": "TX",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "United States",
                    "short_name": "US",
                    "types": [
                        "country",
                        "political"
                    ]
                },
                {
                    "long_name": "75226",
                    "short_name": "75226",
                    "types": [
                        "postal_code"
                    ]
                }
            ],
            "formatted_address": "111 Main St, Dallas, TX 75226, USA",
            "geometry": {
                "location": {
                    "lat": 32.7856754,
                    "lng": -96.7732783
                },
                "location_type": "RANGE_INTERPOLATED",
                "viewport": {
                    "northeast": {
                        "lat": 32.7870243802915,
                        "lng": -96.77192931970849
                    },
                    "southwest": {
                        "lat": 32.7843264197085,
                        "lng": -96.77462728029151
                    }
                }
            },
            "partial_match": true,
            "place_id": "EiIxMTEgTWFpbiBTdCwgRGFsbGFzLCBUWCA3NTIyNiwgVVNBIhoSGAoUChIJdcuXU8CYToYRqT7JZFXIPrEQbw",
            "types": [
                "street_address"
            ]
        },
        {
            "address_components": [
                {
                    "long_name": "602",
                    "short_name": "602",
                    "types": [
                        "street_number"
                    ]
                },
                {
                    "long_name": "Main Street",
                    "short_name": "Main St",
                    "types": [
                        "route"
                    ]
                },
                {
                    "long_name": "West End",
                    "short_name": "West End",
                    "types": [
                        "neighborhood",
                        "political"
                    ]
                },
                {
                    "long_name": "Dallas",
                    "short_name": "Dallas",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "Dallas County",
                    "short_name": "Dallas County",
                    "types": [
                        "administrative_area_level_2",
                        "political"
                    ]
                },
                {
                    "long_name": "Texas",
                    "short_name": "TX",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "United States",
                    "short_name": "US",
                    "types": [
                        "country",
                        "political"
                    ]
                },
                {
                    "long_name": "75202",
                    "short_name": "75202",
                    "types": [
                        "postal_code"
                    ]
                }
            ],
            "formatted_address": "602 Main St, Dallas, TX 75202, USA",
            "geometry": {
                "location": {
                    "lat": 32.7791016,
                    "lng": -96.8065259
                },
                "location_type": "RANGE_INTERPOLATED",
                "viewport": {
                    "northeast": {
                        "lat": 32.78045058029149,
                        "lng": -96.8051769197085
                    },
                    "southwest": {
                        "lat": 32.7777526197085,
                        "lng": -96.80787488029151
                    }
                }
            },
            "partial_match": true,
            "place_id": "EiI2MDIgTWFpbiBTdCwgRGFsbGFzLCBUWCA3NTIwMiwgVVNBIhsSGQoUChIJ_yeoUBaZToYRaoXTXGzpnc0Q2gQ",
            "types": [
                "street_address"
            ]
        }
    ],
    "status": "OK"
}


I want to access DALLAS COUNTY
it's urgent 


Thank you
Is ther any way to extract data from Complex PDF and insert into salesforce objects.


Thanks
public class caseReportGenerator{
    public static void caseReport(){
    
        list<user> u=[select id,name,email,isactive from user where id in (select userorgroupid from groupmember where group.name = 'HR - HR Tech Ops') and isActive=true];
    map<string,integer>userList= new  map<string,integer>();
    map<string,integer>usersInQueue= new  map<string,integer>();
    list<AggregateResult>caseCount=[select owner.name userName,count(id) Total from case group by owner.name ];
for(AggregateResult aggResult : caseCount)
{
  userList.put((String)aggResult.get('userName'), (integer)aggResult.get('total'));
}
    
    for(user uu:u)
    {
       if(userList.containsKey(uu.id))
       {
           
           usersInQueue.put(uu.name,userList.get(uu.name));
       }
    }
    
    string csvHeader = 'User Name,Count \n';

   string mainContent = csvHeader;

for (string  s: usersInQueue.keySet()) {

   
    string recordString = s+','+usersInQueue.get(s) +'\n';
     mainContent += recordString;
system.debug('rrrrrrrr'+recordString );
system.debug('mmmmmmmmmm'+mainContent );
}
Messaging.EmailFileAttachment csvAttcmnt = new Messaging.EmailFileAttachment ();

//Create CSV file using Blob

blob csvBlob = Blob.valueOf (mainContent);

string csvname= 'Case Report.csv';

csvAttcmnt.setFileName (csvname);

csvAttcmnt.setBody (csvBlob);

Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();

String [] toAddresses = new list<string> {'hiteshwar_mani@intuit.com'};

//Set recipient list

singEmail.setToAddresses (toAddresses);

String subject ='Case Reportcsv';

singEmail.setSubject (subject);

singEmail.setPlainTextBody ('Case Report csv');

//Set blob as CSV file attachment

singEmail.setFileAttachments (new Messaging.EmailFileAttachment []{csvAttcmnt});

Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});










    }
}

Here I'm geting records into each and every debug statement.but i'm not getting records into csv attachment.please help me 

thanks
How to query all the users in a particualr queue

thanks
@RestResource(urlMapping='/mhc/*')

global  class CaseManager {

 

    @HttpGet

    global static void getCaseById() {

      

        // grab the caseId from the end of the URL
        String jsonResponse = '';
       RestRequest request = RestContext.request;
        RestResponse res = RestContext.response;
        string caseId= request.params.get('caseId');
          
            
        try{
        if(caseId!=null  ){
            
       Case result =  [SELECT CaseNumber,Subject,Status,Origin,Priority

                        FROM Case

                        WHERE Id = :caseId];
                     
             res.responseBody = Blob.valueOf(JSON.serialize(result));
            res.statusCode = 200;
            }
             else{
                
            throw new caserestexception(400,'aaaa');
            }
            }
           
            
        catch(caserestexception ex)
        {
             caserestexception aa;
             res.statusCode = 400;
            jsonResponse = '{"response": {"status": "Failure", "message": "' + ex + '"}}';
            res.responseBody = blob.valueOf(jsonResponse);
            return;
        }
                 
            
            
             
            
               


    }
    
}

I want to get my own error but i'm getting salesforce standard error.how to override standard error

 
In rest api i'm setting status code as 400.but it is always throwing error as bad request which is standard error message.but I need to send error message as no page.
Is it possible to override the error messages of standard http codes.
Thanks
Can we set custom http error codes  and meessages in salesforce
Thanks&Regards
Hiteshwar
what are the best practises for Exception handling in salesforce.I have gone through SF Document but didn't find any where.
Thanks
global class accountamountupdate1 implements Database.Batchable<sObject>
{
    global Database.queryLocator start(Database.BatchableContext bc)
    {
        string query='select id,AnnualRevenue from account';
        return database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext bc,list<sObject> acclist)
    {
    system.debug('11111'+acclist);
        list<account>updatelist= new list<account>();
        for(sObject acc:acclist)
            
            {
                Account a = (Account)acc;
                if(a.AnnualRevenue!=null){
                a.AnnualRevenue+=a.AnnualRevenue;
                system.debug('2222'+a);
                updatelist.add(a);
                }
            }
            update updatelist;
            system.debug('33333'+updatelist);
    }
    global void finish(database.batchablecontext bc)
    {
        
    }
}

and test class for this is

@isTest
    public class accountamountupdatetest
    {
        static testmethod void mhcmethodd()
        {
            list<account> acc = new list<account>();
            account a;
            for(integer i=0; i<10;i++)
            {
                a= new account();
                a.name='name'+i;
                acc.add(a);
            }
            insert acc;
            Test.startTest();
            accountamountupdate1 s = new accountamountupdate1();
        database.executebatch(s);
        Test.stopTest();
        }
        


    }

while I'm executing the class i'm getting following error .


Methods defined as TestMethod do not support Web service callouts
but I didn't used any webservice callouts in my batch.
thanks
 
{"Message":"Number of Post office(s) found: 21","Status":"Success","PostOffice":[{"Name":"Baroda House","Description":"","BranchType":"Sub Post Office","DeliveryStatus":"Non-Delivery","Taluk":"New Delhi","Circle":"New Delhi","District":"Central Delhi","Division":"New Delhi Central","Region":"Delhi","State":"Delhi","Country":"India"}]}

The above is my json string.
I have written the following code deserialize it

global class wrapper{
global class parserr
    {
       global string Message{get;set;}
       global string Status{get;set;} 
       global list<postoffice>po{get;set;}
    }
    global class postoffice
    {
        global string name{get;set;}
        global string Description{get;set;}
        global string BranchType{get;set;}
        global string DeliveryStatus{get;set;}
        global string Taluk{get;set;}
        global string Circle{get;set;}
        global string District{get;set;}
        global string Division{get;set;}
        global string Region{get;set;}
        global string state{get;set;}
        global string country{get;set;}
    }
}

 p= (wrapper.paresrr)JSON.deserialize(JSONresponse, wrapper.parserr.class);
I'm getting the values of Message and status correctly. But list<postoffice> po is getting as null although values are coming into response.And also I want the values in postoffice class also.
Thanks
list<KnowledgeArticleVersion> hrlist = new list<KnowledgeArticleVersion>();
String articleId = '';
hrlist=[SELECT ArticleType,Id,KnowledgeArticleId,Language,PublishStatus FROM KnowledgeArticleVersion WHERE ArticleType = 'How_To_HR__kav' AND Language = 'en_US' AND PublishStatus = 'Online'limit 100];

for(KnowledgeArticleVersion hr:hrlist)
{
    articleId = hr.KnowledgeArticleId;
    KbManagement.PublishingService.archiveOnlineArticle(articleId, null); 
    articleId = '';
}


I'm writing above code to mass Archive articles.Bu its throwing below error

System.HandledException: You can't perform this action. Be sure the action is valid for the current state of the article, and that you have permission to perform it.
 
@RestResource(urlMapping='/mhcknw/*')
global class knowledgeApi{
           @HttpGet
    global static list<wrapperclass> findrecords(){
    //string kmid='kA128000000XdZtCAK';
       list<wrapperclass> wrapperlist;

    RestRequest request = RestContext.request;
         RestResponse res = RestContext.response;
        string kmId = request.requestURI.substring(
          request.requestURI.lastIndexOf('/')+1);
          system.debug('######'+kmid);
    
    list<KnowledgeArticleVersion> ka=[SELECT Id,KnowledgeArticleId,Language,PublishStatus,Summary,Title FROM KnowledgeArticleVersion WHERE PublishStatus = 'online' AND Language = 'en_US' and KnowledgeArticleId =:kmid];
        system.debug('@@@@@@'+ka);

   list<hitesh31__Test_Art__kav> htak= [SELECT ArticleNumber,ArticleType,Id,KnowledgeArticleId,Language,PublishStatus,Summary FROM hitesh31__Test_Art__kav WHERE Language = 'en_US' AND PublishStatus = 'online' AND KnowledgeArticleId =:kmid];
     system.debug('*******'+htak);
     for(KnowledgeArticleVersion ka1:ka){
         for(hitesh31__Test_Art__kav htak1:htak){
             wrapperlist.add(new wrapperclass(Ka1,htak1));
    system.debug('&&&&&&&'+wrapperlist);


         }
     }

        return wrapperlist;
    
    
    } 
    
    global class wrapperclass{
    public KnowledgeArticleVersion kversion;
    public hitesh31__Test_Art__kav katype;
        public wrapperclass(KnowledgeArticleVersion kn,hitesh31__Test_Art__kav k ){
           kversion=kn;
            katype=k;
    }

}
}

In the above class i'm able to get records into the above two queries.but when i' calling this api from workbench it throwing nullpointer exception.I think there is some problem in wrapperlist.i'm not able to debug that, but records are getting into the query's.
I'm querying some fields in knowledgearticle version , but I need to qeury another field from articletype__kav also.how to do it?
As there is no relation between knowledgeArticleversion and articletype__kav.


Thanks
public class sampleclass{
        public list<rows> rows{get;set;}
        public list<String> origin_addresses{get;set;}
        public String status{get;set;}
        public list<String> destination_addresses{get;set;}
        }

I want to display the above variables i.e lists and strings in a single table in VF page.I have gone through wrapper class examples but I didn't got it.Please help me in this.
​Thanks
{ "destination_addresses" : [ "Bengaluru, Karnataka, India" ], "origin_addresses" : [ "Hyderabad, Telangana, India" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "576 km", "value" : 575574 }, "duration" : { "text" : "8 hours 33 mins", "value" : 30763 }, "status" : "OK" } ] } ], "status" : "OK" }


Thanks
 
In rest api i'm setting status code as 400.but it is always throwing error as bad request which is standard error message.but I need to send error message as no page.
Is it possible to override the error messages of standard http codes.
Thanks
@RestResource(urlMapping='/mhc/*')

global  class CaseManager {

 

    @HttpGet

    global static void getCaseById() {

      

        // grab the caseId from the end of the URL
        String jsonResponse = '';
       RestRequest request = RestContext.request;
        RestResponse res = RestContext.response;
        string caseId= request.params.get('caseId');
          
            
        try{
        if(caseId!=null  ){
            
       Case result =  [SELECT CaseNumber,Subject,Status,Origin,Priority

                        FROM Case

                        WHERE Id = :caseId];
                     
             res.responseBody = Blob.valueOf(JSON.serialize(result));
            res.statusCode = 200;
            }
             else{
                
            throw new caserestexception(400,'aaaa');
            }
            }
           
            
        catch(caserestexception ex)
        {
             caserestexception aa;
             res.statusCode = 400;
            jsonResponse = '{"response": {"status": "Failure", "message": "' + ex + '"}}';
            res.responseBody = blob.valueOf(jsonResponse);
            return;
        }
                 
            
            
             
            
               


    }
    
}

I want to get my own error but i'm getting salesforce standard error.how to override standard error

 
{"Message":"Number of Post office(s) found: 21","Status":"Success","PostOffice":[{"Name":"Baroda House","Description":"","BranchType":"Sub Post Office","DeliveryStatus":"Non-Delivery","Taluk":"New Delhi","Circle":"New Delhi","District":"Central Delhi","Division":"New Delhi Central","Region":"Delhi","State":"Delhi","Country":"India"}]}

The above is my json string.
I have written the following code deserialize it

global class wrapper{
global class parserr
    {
       global string Message{get;set;}
       global string Status{get;set;} 
       global list<postoffice>po{get;set;}
    }
    global class postoffice
    {
        global string name{get;set;}
        global string Description{get;set;}
        global string BranchType{get;set;}
        global string DeliveryStatus{get;set;}
        global string Taluk{get;set;}
        global string Circle{get;set;}
        global string District{get;set;}
        global string Division{get;set;}
        global string Region{get;set;}
        global string state{get;set;}
        global string country{get;set;}
    }
}

 p= (wrapper.paresrr)JSON.deserialize(JSONresponse, wrapper.parserr.class);
I'm getting the values of Message and status correctly. But list<postoffice> po is getting as null although values are coming into response.And also I want the values in postoffice class also.
Thanks
I'm querying some fields in knowledgearticle version , but I need to qeury another field from articletype__kav also.how to do it?
As there is no relation between knowledgeArticleversion and articletype__kav.


Thanks
I'm trying to create feedpollchoice record in test class but it's throwing exception as fields not writable although i have pernission.pls help on this thanks
I'm writing below batch apex to transfer the accounts of particualr user to another user
bu it's throwing error as " EXCEPTION_THROWN [7]|System.QueryException: unexpected token: 'Eo3Z' ".
Thanks

global class accountownerhangebatch implements database.batchable<sobject>{
        
    global database.querylocator start(database.batchablecontext bc){
   string query = 'select Name,Ownerid from account where ownerid = 00528000001Eo3Z' ;
    return database.getquerylocator(query);
    }
    
    global void execute (database.batchablecontext bc, list<Account> scope){
    id oid = 'SELECT Id,name FROM User WHERE name = marni user1';
        for(account a : scope){
        
        a.Ownerid= oid;
        system.debug('---->'+a.Ownerid);
              
        }
          update scope;

    }
    
    global void finish(database.batchablecontext bc){
    
    }

}
I am not able to get a clarity on the Database.query() , Database.getQueryLocator and Database.QueryLocator.I have gone through many documents but no use.Could any one help me on this.
Thanks
I have scheduled my certification exam on 8-August-2016.But in the middle of the exam it has been suspended automatically without any prior information.I have raised a case,but they didn't respond till date.Could any one suggest me how to proceed further.

Should I again book the slot by paying total amount,or will they reschedule it with amount with which I have booked slot before.

Thanks
Hiteshwar