• Raghu Nani
  • NEWBIE
  • 183 Points
  • Member since 2016
  • Senior Developer


  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 82
    Replies
global class OTFAutomationReport implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        //String query = 'select Id,OTF_Total_Hours__c,OTFClient__c, OTF_Date__c, (select Date__c, Duration_Hours__c from Time_Logs__r) from account where Name='+80 Acres Farms+';
       
        
        system.debug('==query==>' +[select Id,OTF_Total_Hours__c,OTFClient__c, OTF_Date__c, (select Date__c, Duration_Hours__c from Time_Logs__r) from account where Name='80 Acres Farms']);
        return Database.getQueryLocator([select Id,OTF_Total_Hours__c,OTFClient__c, OTF_Date__c, (select Date__c, Duration_Hours__c from Time_Logs__r) from account where Name='80 Acres Farms']);
       
    }
    global void execute(Database.BatchableContext bc, List<account> scope)
    {
        system.debug('==scope==>' +scope);
        //decimal TotalHours=0.0;
        list<account> accUpdate = new list<account>();
        for(account a: scope)
           
        {
            a.OTF_Total_Hours__c=0.0;
            system.debug('a===>1st loop' +a);
            for(Time_Log__c tl : a.Time_Logs__r)
            { system.debug('a===>2nd loop' +tl);
            
                //system.debug('a==a.OTF_Total_Hours__c=>2nd loop' +a.OTF_Total_Hours__c);
             system.debug('a=tl.Duration_Hours__c==>2nd loop' +tl.Duration_Hours__c);
            
                if(tl.Duration_Hours__c!=NUll && a.OTF_Total_Hours__c!=Null){
                a.OTF_Total_Hours__c +=tl.Duration_Hours__c;
                system.debug('==TotalHours==>' +a.OTF_Total_Hours__c);
                if(a.OTF_Total_Hours__c>=20 && a.OTFClient__c==false)
                {
                    a.OTFClient__c=true;
                    system.debug('==a.OTFClient__c==>' +a.OTFClient__c);
                    a.OTF_Date__c=tl.Date__c;
                    accUpdate.add(a);
                }
                }
            }
           
            
        }
        system.debug('==accUpdate > ' +accUpdate);
        update accUpdate;
       
    }
    global void finish(Database.BatchableContext BC)
    {}   
    
}
 
public class test5 {

  public list<string> lststatename{get;set;}
  public list<string> lstrating{get;set;}

 public test5(){
 
 
    string  jsonexample1 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "rating": 5.0 }, { "stateName": "Telangana",  "rating": 4.0 }, {"stateName": "Banglore",  "rating": 5.0 } , {"stateName": "Maharastra",  "rating": 4.5 }  ] } ';

   
     map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); 
     
      list<object>  values1= (list<object>)metadatamap.get('overalldata');
        
        
         lststatename= new list<string>();
         lstrating= new list<string>();
         
          for(object parsed : values1){
             
             
           map<string,object>  values = (map<string,object>)parsed;
             
             
            string statename = string.valueof(values.get('stateName'));
             string rating= string.valueof(values.get('rating'));
               
             lststatename.add(statename );
             lstrating.add(rating);
            
             }
       
 }
}
 
<apex:page controller="test5" >

 <apex:form >
 
 <table>
  <tr>
    <th>states</th>
    <th>rating</th>
  </tr>
  
  <apex:repeat value="{!lststatename}" var="a">
  <apex:repeat value="{!lstrating}" var="b">
  <tr>
   
   <td>{!a}</td>
  
    
    <td>{!b}</td>
  </tr>
   </apex:repeat>
   </apex:repeat>
</table>
    
 
 </apex:form>
 
</apex:page>

User-added image
 here to use the html table to display the values, but the data is getting iterated again , Any body have any idea to handle this. thanks in advance .. 

Additionally, if you update or delete a record in its before trigger, or delete a record in its after trigger, you will receive a runtime error. This includes both direct and indirect operations. For example, if you update account A, and the before update trigger of account A inserts contact B, and the after insert trigger of contact B queries for account A and updates it using the DML update statement or database method, then you are indirectly updating account A in its before trigger, and you will receive a runtime error.

can some one help me understan with an example pls
Hello, All.

I am trying to get information about users including IsActive and IsFrozen. IsActive is on the User object while IsFrozen is on the UserLogin object. The UserLogin object contains a User lookup field with an API name of UserId, (According to this documentation page: https://developer.salesforce.com/docs/atlas.en-us.sfFieldRef.meta/sfFieldRef/salesforce_field_reference_UserLogin.htm)

Queries to the UserLogin work fine:
/services/data/v45.0/query/?q=select+Id,IsFrozen,UserId+from+UserLogin

Queries to the User work fine:
/services/data/v45.0/query/?q=select+Id,IsActive+from+User

But combining the two into one query fails:
/services/data/v45.0/query/?q=select+Id,IsFrozen,UserId,UserId.IsActive+from+UserLogin

I am modeling my combined query after the another cross-object query that I have verified is working correctly:
/services/data/v45.0/query/?q=select+Id,Account.Name+from+Contact

What am I doing wrong here?



 
I am working on apex class which will fetch details from Campaign Member object, once it is fetched I am looking at map size, if it is greater than zero then I am creating a record in Staging_Event_Attendee__c object.
in Campaign Member if ContactId field is not null then I am populating Staging_Event_Attendee__c.Attendant = ContactId, now same like that if LeadId is not null then I need to populate Staging_Event_Attendee__c.Lead__c = LeadId
Can anyone help me out in this issue, on Campaign Member record I can have either leadId or ContactId at time.
I need to have a condition to check whether LeadId or ContactId is not null, if leadId is not null then I need to create a new record where Staging_Event_Attendee__c.Lead__c = CampaignMap.get(Con.Barcode__c).LeadId If ContactId is not null then I need to create a new record where Staging_Event_Attendee__c.Lead__c = CampaignMap.get(Con.Barcode__c).ContactId
 
Map<Id,CampaignMember> CampaignMap = new Map<Id,CampaignMember>([select ContactId,CampaignId from CampaignMember where Id in: barcodeSet]);
        for(Staging_Event_Attendee__c con : stagingEventAttendeeList) {
            if(CampaignMap.size()>0 ){
            con.Attendant__c = CampaignMap.get(con.Barcode__c).ContactId;
            con.Campaign_ID__c = CampaignMap.get(con.Barcode__c).CampaignId;
            con.Date_Attended__c = system.now();
        }
            else{
                con.Invalid_Barcode__c = true;
                con.Date_Attended__c = system.now();
            }
        }

 
Hi Team,

In my org omnichannel set up is done and every time client to trying to connect the omnichanne chat, i would like to display the average wait time for responce. Please suggest how to proceed on this.

Regards,
Raghu
is this possible to change the Price book in Quote object. I am unable to change, can any one please assist on this
Hi All,
I am getting below error while creating the Community User
Error: First exception on row 0; first error: UNKNOWN_EXCEPTION, portal account owner must have a role.

I verified the Account owner Role. It was selected the role also.

Later i found that Account Owner is inactive.

In this senario how to create community user. Is i need to change Account Owner? Please confirm or any best solution.
Hi,
scenario is I created a button ,
on click of button I need to open VF page along with parameters
if I hard code url in button for community users not working
bcz of  community name in not there URL
is this any way to form URL dynamically

I tried URLFOR in Formula
{!URLFOR($Page.ProcurementDetailsPage, null, [Id=SomeId])}
I am getting Error Page.ProcurementDetailsPage does not Exist
Can any one help on this


Thanks,
raghu
Hi friends,

Usually after Update trigger will gives the error saying maximum Trigger depth Exceeded.
How many times trigger will execute to reach this error Or in other words What is the depth of the trigger?



Thanks,
Raghu
Hi friends,

Can any one please conform is this possible in Salesforce Classic .
Requirement: is this Possible to get the SUB Tabs under Primary Tabs (because in my application too many tabs are there so for look and feel is this possible to set some tabs under Primary tabs)


Thanks,
Raghu
Hi friends,
I want to add meeting request in visualforce page can any one suggest the how to do, Or
suggest any app exchange app to suitable for meeting requests in salesforce
Hi Friends,
My client need a Meeting request and Schedular in Visualforce page is this any way to add that standard functionality using apex and VF 
OR can u please suggest any cloud schedulars,calenders which will do the same functionality..


Thanks
Raghu
HI friend,

I know normal standard user we can create from visualforce page also, but my requirement is to create Community and Community plus users need to create through VF page, i know usually we will create Community users from CONTACT , but i dont know is this any way to create community users through VF . this is bit urgent .

Thanks,
Raghu
What is the latest release for salesforce, and any one tel me when will be the next release
How to add Home Calender Section in Visualforce Page ,
If  calender not possible, Pls suggest How to do New Meeting Request from Visualforce page and along with i need to display( Scheduled Meetings & Requested Meetings ) in Visualforce Page

Pls Help me ASAP
Thanks 
Raghu
           <apex:repeat value="{!FormList}" var="f">
                        <apex:variable var="count" value="{!0}" />
                             <apex:repeat value="{!f.categories}" var="c">
                                 <apex:repeat value="{!c.tasks__r}" var="t" >
                                     <tr>
                                              <td>{!t.Task_Name__c}</td>
                                              <td><apex:inputField value="{!f.siteSelectionChilds[count].LQ_Owner_Responsible__c}"  /></td>
                                              <td><apex:inputField value="{!f.siteSelectionChilds[count].LQ_Date_Completed__c}"  /></td>
                                              <td><apex:inputField value="{!f.siteSelectionChilds[count].LQ_Comments__c}"/></td>
                                    <apex:variable var="count" value="{!count+1}" />
                                    </tr>
                                 </apex:repeat>
                             </apex:repeat>
                    </apex:repeat>
                              

hi above is my code in loop i am trying to insert the siteSelectionChilds data but i am unable to get the entered values to my apex class pls suggest any one
Hi friends the below code is VFpage code , I was created Homepage VF component and added in home Layout , but it is not redirecting to that specific link i dont know why, can any one help on yhis ... ASAP,actually the Href link is report link

<apex:page >
<script>
location.href="https://cs31.salesforce.com/00Op0000000GwfT";
 </script>
</apex:page>
Hi fiends,
               My requirement is simple, can any one help on this ...
     Requirement is i was created a Custom report ,when ever user logs into system by default we need to render that report,
 i thought it is possible by writing vf page and redirect to specific link but i coudnt ,cal any one help on this with code
I need to access the Salesforce files (External files integrated with File Connect) can any one help on this Some idea!!!!
Hi friends,
My requirement is I want to download the CSV file from Google drive and need to upload the CSV data in to Sobject automatically,
any body please help me on this...
Hi friends,

To day i thought is this possible to send message to my friend through salesforce app,
if any one know the steps please share with me
Hi Friends,
 I am facing issue , I Am Able to generate a Report along with Graphs using APEX code,But while saving Into PDF  the Graphs are not appearing in PDF ,pls help me
Hi friends,

    I am New to this ,I dont  know HOw to move Code From My developer org to Sandbox,Can U please Share ideas With Me.So,I can move forward,

Thanks,
Raghu
Hi i Need to ristrict the users to Delete The Activity History Records,
I am Trying to Set permission in UserProfile But I didnt Get
Can Any one help on this
 
Hi Team,

In my org omnichannel set up is done and every time client to trying to connect the omnichanne chat, i would like to display the average wait time for responce. Please suggest how to proceed on this.

Regards,
Raghu
We are doing Integration of sfdc and sap system with esb as middleware. Esb needs the endpoint url of salesforce. How to find the endpoint url of salesforce production environment.
 
hi i'm here

please can somebody help me in test class

this is my extension
 
public class addContactExtension {

 public List<Id> getFileId() {
        List<Id> ListOfImagesIds= new List<Id>();//store files/images Ids
        for(ContentDocumentLink CDL : [Select ContentDocument.LatestPublishedVersionId from ContentDocumentLink where LinkedEntityId IN(select Id from Campaign where Id=:camId.id) order by ContentDocument.CreatedDate ASC]){
            ListOfImagesIds.add(CDL.ContentDocument.LatestPublishedVersionId);
            //System.debug('Total Id'+ ListOfImagesIds);
        }
        return ListOfImagesIds;
    }//dynamically Images Fetching from Files Ends here.

}



How can I test this method
hi all,

I am facing error: You have uncommitted work pending. Please commit or rollback before calling out and i have used @future(callout = true) method it is not working can anyone help me with these

Apex Class:
 
public class Campaignbulk {
    public campaign camp;
    public integer cnt{get;set;}
    public string Text {get;set;}
    Public list<Campaignmember> camplist=new list<Campaignmember>();
    public list<Campaign> listcamp =new list<Campaign>();
    public Campaignbulk (ApexPages.StandardController stdController)
    {
        this.camp =(Campaign)stdController.getRecord(); 
        cnt=[ SELECT count() FROM Campaignmember WHERE CampaignId =:camp.Id];   
        camplist=[ SELECT phone FROM Campaignmember WHERE CampaignId =:camp.Id];  
    }
    
    public  void sendbulk(){
        
        List<SMS_Response__c> responseList= new List <SMS_Response__c>();
        for(Campaignmember Cpgmb: camplist ) {
            
            SMS_Response__c NewRec = new SMS_Response__c();
            NewRec.Mobile_Number__c =Cpgmb.Phone ;
            NewRec.Message__c = Text;
            NewRec.SMS_Type__c = 'OutGoing Message' ;
            NewRec.Service_Providers__c = 'Nexmo'; 
            NewRec.Campaign__c=camp.Id;
            NewRec.Status__c='Processing';
            responseList.add(NewRec);
        } 
        
        if (responseList.size()>0)
            insert(responseList);
        
        processCampaign(camp.Id, Text);
    } 
    @future(callout=true)
    public static void processCampaign(string campaignID, String smsText){
        
        configuration_setting__c conf = [select Name, Phone_Numbers__c,Lead_Phone_Number__c 
                                         FROM configuration_setting__c where Active__c =True  limit 1 ];                     
        
        List<String> lstAlpha = conf.Phone_Numbers__c.split(',');
        Integer currentPhone=0;
        
        List<Campaignmember> camplist=[ SELECT phone FROM Campaignmember WHERE CampaignId =:campaignID];
        
        for(Campaignmember Cpgmb: camplist ) {
            
            String newStatus= Nexmo.bulksms(  Cpgmb.Phone,  lstAlpha[currentPhone++],  smsText, 'sms');
            
           Campaignbulk.insertstatus(campaignID,Cpgmb.Phone,newStatus);
           
            if (currentPhone >= lstAlpha.size()){
                currentPhone=0;
            }
            
        } // end of all campaing memebers 
        
    } // end of method
    
    Public static void insertstatus(string campaignID,string Cpgmbphone,string newStatus){
         List<SMS_Response__c> smsRespList = [select id, status__c from SMS_Response__c where Campaign__c=:campaignID
                                                 and status__c='Processing' 
                                                 and Mobile_Number__c =:Cpgmbphone];
            
            if (smsRespList!= null && smsRespList.size()>0 ) {
                for(SMS_Response__c smsrp:smsRespList){
                    smsrp.status__c =newStatus;
                    
                }
                system.debug('My updated list'+smsRespList);
                 update smsRespList;
            }
    }
    
}

 
  • February 10, 2020
  • Like
  • 0
Hi Everyone,

I'm using @wire to pull back a fields value and then trying to pass it in an http callout. Unfortunately, the value is coming back undefined in the debugger and I used the salesforce documentation exactly. Does anyone see what I'm missing?
import { LightningElement, track, api, wire } from 'lwc';//api, wire 

import { getRecord, getFieldValue } from 'lightning/uiRecordApi';

//import field reference from schema
import SERIAL_FIELD from '@salesforce/schema/Asset.Serial_Test__c';

const field = [SERIAL_FIELD];

export default class TestCallout extends LightningElement {
  
    @track toDoData;
    @api recordId;
    @wire(getRecord, { recordId: '$recordId', field})
    asset;
   
    //return serial number field value
    get serial() {
        return getFieldValue(this.asset.data, SERIAL_FIELD);

    }

    //make callout using fetch
    connectedCallback() {

        fetch('https://jsonplaceholder.typicode.com/todos?id'+ this.serial, 
        //endpoint passes serial number from current sfdc record
        {
            // Request type
            method:"GET",
        
            headers:{
                // content type
                "Content-Type": "application/json",
                // adding your access token 
                //"Authorization": 'Basic ' + btoa(username + ":" + password),
                //"Authorization": "OAuth 00DB0000000EfVQ!AQwAQEiiynMU2EsBcS2PhXSQ6KQTTG.Zr0hlDHTFcGcAPqKQOBNDB0rwyASZK44fqIAVe6GrVNZPsAWJ6iqXLNBfSQ.dqvW1",
            }
        })
        .then((response) => {    
            return response.json(); // returning the response in the form of JSON
        })
        .then((jsonResponse) => {
                
                        let objData = {
                            title : '',
                            completed : '',
                        };
                        window.console.log('jsonResponse ===> '+JSON.stringify(jsonResponse));
                        // retriving the response data
                        let jsonData = jsonResponse[0];
            
                        // adding data object
                        objData.title = jsonData.title; 
                        objData.completed = jsonData.completed;
            
                        // adding data object to show in UI
                        this.toDoData = objData;
                    })
                    .catch(error => {
                        window.console.log('callout error ===> '+JSON.stringify(error));
                    })
                } 
            
            }

 
Greetings!

In Visual Studio Code, when I try to Create a Scratch Org, I receive the following error:

Cannot deserialize instance of boolean from VALUE_STRING value True or request may be missing a required field

I created a VFP and Apex Controller that will run a Flow. In the flow, the Case ID will be passed through and take the user back to the same Case record after clicking a custom button.

The only issue here is that the page does not refresh to display the changes after the flow was executed.

// Redirects user to the same Case record after flow executes and reloads the page

public with sharing class custom_caseJiraFlowRedirectController {
    public Object custom_caseJiraFlowRedirectController() {
            String unique_id = ApexPages.currentPage().getParameters().get('id');
            if(unique_id == null){
               // Return Home if no ID 
               String url = '/home/home.jsp';
               return new PageReference(url); 
        } // Get Case ID and set Redirect
          String caseId = [SELECT Id,
                              caseFlowUniqueId__c
                              FROM Case
                              WHERE caseFlowUniqueId__c = :unique_id
                              ORDER BY CreatedDate
                              DESC LIMIT 1].Id;
           // Did we find a Case?
           if (caseId == null) {
           // Return Home if no ID
           String url = '/home/home.jsp';
           return new PageReference(url);
           }
           // Redirect to Case
           String url = '/' + caseId;
          return new PageReference(url); 
      }
  }

Do I need to add this line somewhere?
System.PageReference setRedirect(Boolean redirect)

I'm trying to pinpoint an error with a test class using a static variable for a query on Report. Given below test class:

@IsTest
private with sharing class Example_Test_Class {
    private static String testReportName = 'My Test Report';
    private static Report testReport = [SELECT Id FROM Report WHERE Name=:testReportName LIMIT 1];

    @IsTest(SeeAllData=true)
    private static myTestMethod() {
        // Access testReport.Id here
    }
}
Is this valid? I'm not getting any compiler errors but this feels like a possible code smell.