• suji srinivasan
  • NEWBIE
  • 475 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 94
    Questions
  • 68
    Replies

Hi , I need to create custom calendar LWC Component . which fullcalendarjs version can i use for this  component.
 I tried with  version  3 and 5,6 . 
HTML:
<template>
 
    <!-- Spinner to show on waiting screens -->
    <template if:true={openSpinner}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </template>
 
   <div class="slds-grid slds-wrap slds-theme_default">
        <div class="slds-col slds-size_3-of-12">
            <!-- To display list of events or any parent records  
                TODO: add drag items in this div to drop on fullcalendar.
            -->
            <div class=" slds-p-around_medium slds-border_right slds-scrollable_y" style="height:800px">
                <div class="slds-clearfix">
                    <div class="slds-float_right">
                        <lightning-button icon-name="utility:add" slot="actions"
                                        alternative-text="add" title="Add" size="small"
                                        class="slds-p-around_medium"
                                        label="Add Event"
                                        onclick={addEvent}>
                        </lightning-button>
                    </div>
                  </div>
                 
                <template for:each={events} for:item="eachevent">
                    <lightning-card key={eachevent.id}
                                    class="slds-p-left_medium slds-p-right_small">
                        <h3 slot="title">
                            <span class="slds-p-right_small">
                                <lightning-icon icon-name="standard:event" size="small">
 
                                </lightning-icon>
                            </span>
                            {eachevent.title}
                        </h3>
                        <lightning-button-icon icon-name="action:remove" slot="actions"
                                                alternative-text="remove" title="Remove"
                                                value={eachevent.id} size="small"
                                                onclick={removeEvent}>
 
                        </lightning-button-icon>
                         
                        <p class="slds-p-horizontal_small"> Start: <lightning-formatted-date-time value={eachevent.start} year="numeric" month="numeric" day="numeric" hour="2-digit"
                            minute="2-digit" time-zone="GMT" time-zone-name="short" hour12="true"></lightning-formatted-date-time></p>
 
                        <p class="slds-p-horizontal_small">End <lightning-formatted-date-time value={eachevent.end} year="numeric" month="numeric" day="numeric" hour="2-digit"
                            minute="2-digit" time-zone="GMT" time-zone-name="short" hour12="true"></lightning-formatted-date-time></p>
                         
                    </lightning-card>
                </template>
            </div>
        </div>
        <div class="slds-col slds-size_9-of-12">
                <!-- fullcalendar sits in this div -->
                <div id="calendar" class="fullcalendarjs"></div>
        </div>
   </div>
 

JS:


import { LightningElement, track, wire } from 'lwc';
import { loadScript,loadStyle } from 'lightning/platformResourceLoader';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import FullCalendarJS from '@salesforce/resourceUrl/FullCalendarJS';
import fetchEvents from '@salesforce/apex/FullCalendarController.fetchEvents';
import createEvent from '@salesforce/apex/FullCalendarController.createEvent';
import deleteEvent from '@salesforce/apex/FullCalendarController.deleteEvent';
import { refreshApex } from '@salesforce/apex';
/**
 * @description: FullcalendarJs class with all the dependencies
 */
export default class FullCalendarJs extends LightningElement {
    //static renderMode ='light';
    //To avoid the recursion from renderedcallback
    fullCalendarJsInitialised = false;
 
    //Fields to store the event data -- add all other fields you want to add
    title;
    startDate;
    endDate;
 
    eventsRendered = false;//To render initial events only once
    openSpinner = false; //To open the spinner in waiting screens
    openModal = false; //To open form
 
    @track
    events = []; //all calendar events are stored in this field
 
    //To store the orignal wire object to use in refreshApex method
    eventOriginalData = [];
 
    //Get data from server - in this example, it fetches from the event object
    @wire(fetchEvents)
    eventObj(value){
        this.eventOriginalData = value; //To use in refresh cache
 
        const {data, error} = value;
        if(data){
            //format as fullcalendar event object
            console.log(data);
            let events = data.map(event => {
                return { id : event.Id,
                        title : event.Subject,
                        start : event.StartDateTime,
                        end : event.EndDateTime,
                        allDay : event.IsAllDayEvent};
            });
            this.events = JSON.parse(JSON.stringify(events));
            console.log(this.events);
            this.error = undefined;
 
            //load only on first wire call -
            // if events are not rendered, try to remove this 'if' condition and add directly
            if(! this.eventsRendered){
                //Add events to calendar
                const $ele = this.template.querySelector("div.fullcalendarjs");
                $ele.fullCalendar('renderEvents', this.events, true);
                this.eventsRendered = true;
            }
        }else if(error){
            this.events = [];
            this.error = 'No events are found';
        }
   }
 
   /**
    * Load the fullcalendar.io in this lifecycle hook method
    */
  renderedCallback() {
   // loadScript(this, jQuery ),
      // Performs this operation only on first render
      if (this.fullCalendarJsInitialised) {
         return;
      }
      this.fullCalendarJsInitialised = true;
      console.log('InsidefullCalendarJsInitialised');
      console.log(FullCalendarJS);
      console.log(jQuery);
     
      // Executes all loadScript and loadStyle promises
      // and only resolves them once all promises are done
        Promise.all([
            loadScript(this, FullCalendarJS + "/fullcalendarjquerymoment/jquery.min.js"),
            loadScript(this, FullCalendarJS + "/fullcalendarjquerymoment/moment.min.js"),
            loadScript(this, FullCalendarJS + "/fullcalendarminjs/fullcalendar.min.js"),
            loadStyle(this, FullCalendarJS + "/fullcalendarprintmincss/fullcalendar.min.css"),
        ])
        .then(() => {
            //initialize the full calendar
        this.initialiseFullCalendarJs();
        })
        .catch((error) => {
        console.error({
            message: "Error occured on FullCalendarJS",
            error,
        });
        });
   }
 
    initialiseFullCalendarJs() {
       const  $ele = this.template.querySelector("div.fullcalendarjs");
        //const modal = this.template.querySelector('div.modalclass');
        console.log($ele);
 
        let self = this;
 
        //To open the form with predefined fields
        //TODO: to be moved outside this function
        function openActivityForm(startDate, endDate){
            self.startDate = startDate;
            self.endDate = endDate;
            self.openModal = true;
        }
        //Actual fullcalendar renders here - https://fullcalendar.io/docs/v3/view-specific-options
        $ele.fullCalendar({
            header: {
                left: "prev,next today",
                center: "title",
                right: "month,agendaWeek,agendaDay",
            },
            defaultDate: new Date(), // default day is today - to show the current date
            defaultView : 'agendaWeek', //To display the default view - as of now it is set to week view
            navLinks: true, // can click day/week names to navigate views
            // editable: true, // To move the events on calendar - TODO
            selectable: true, //To select the period of time
 
            //To select the time period : https://fullcalendar.io/docs/v3/select-method
            select: function (startDate, endDate) {
                let stDate = startDate.format();
                let edDate = endDate.format();
                 
                openActivityForm(stDate, edDate);
            },
            eventLimit: true, // allow "more" link when too many events
            events: this.events, // all the events that are to be rendered - can be a duplicate statement here
        });
    }
 
    //TODO: add the logic to support multiple input texts
    handleKeyup(event) {
        this.title = event.target.value;
    }
     
    //To close the modal form
    handleCancel(event) {
      let ev = event.target.value;
      if(ev){
        this.openModal = false;
      }
       
    }
 
   //To save the event
    handleSave(event) {
      let ev = event.target.value;
      if(ev){
        //let events = this.events;
        this.openSpinner = true;
 
        //get all the field values - as of now they all are mandatory to create a standard event
        //TODO- you need to add your logic here.
        this.template.querySelectorAll('lightning-input').forEach(ele => {
            if(ele.name === 'title'){
               this.title = ele.value;
           }
           if(ele.name === 'start'){
                this.startDate = ele.value.includes('.000Z') ? ele.value : ele.value + '.000Z';
            }
            if(ele.name === 'end'){
                this.endDate = ele.value.includes('.000Z') ? ele.value : ele.value + '.000Z';
            }
        });
       
        //format as per fullcalendar event object to create and render
        let newevent = {title : this.title, start : this.startDate, end: this.endDate};
        console.log(this.events);
 
        //Close the modal
        this.openModal = false;
        //Server call to create the event
        createEvent({'event' : JSON.stringify(newevent)})
        .then( result => {
            const $ele = this.template.querySelector("div.fullcalendarjs");
 
            //To populate the event on fullcalendar object
            //Id should be unique and useful to remove the event from UI - calendar
            newevent.id = result;
             
            //renderEvent is a fullcalendar method to add the event to calendar on UI
            //Documentation: https://fullcalendar.io/docs/v3/renderEvent
            //$.noConflict();
            //jQuery( document ).ready(function( $ ){
            $ele.fullCalendar( 'renderEvent', newevent, true );//});
             
            //To display on UI with id from server
            this.events.push(newevent);
 
            //To close spinner and modal
            this.openSpinner = false;
 
            //show toast message
            this.showNotification('Success!!', 'Your event has been logged', 'success');
 
        })
        .catch( error => {
            console.log(error);
            this.openSpinner = false;
 
            //show toast message - TODO
            this.showNotification('Oops', 'Something went wrong, please review console', 'error');
        })
   }
  }
   
   /**
    * @description: remove the event with id
    * @documentation: https://fullcalendar.io/docs/v3/removeEvents
    */
   removeEvent(event) {
        //open the spinner
        this.openSpinner = true;
 
        //delete the event from server and then remove from UI
        let eventid = event.target.value;
        deleteEvent({'eventid' : eventid})
        .then( result => {
            console.log(result);
            const $ele = this.template.querySelector("div.fullcalendarjs");
            console.log(eventid);
            $ele.fullCalendar( 'removeEvents', [eventid] );
 
            this.openSpinner = false;
             
            //refresh the grid
            return refreshApex(this.eventOriginalData);
 
        })
        .catch( error => {
            console.log(error);
            this.openSpinner = false;
        });
   }
 
   /**
    *  @description open the modal by nullifying the inputs
    */
    addEvent(event) {
      let ev = event.target.value;
      if(ev){
        this.startDate = null;
        this.endDate = null;
        this.title = null;
        this.openModal = true;
    }
  }
 
    /**
     * @description method to show toast events
     */
    showNotification(title, message, variant) {
        console.log('enter');
        const evt = new ShowToastEvent({
            title: title,
            message: message,
            variant: variant,
        });
        this.dispatchEvent(evt);
    }
}

Apex class:
public with sharing class FullCalendarController {
    public class EventException extends Exception {}
   
    /**
     * @description: To retrieve the most recent events
     */
    @AuraEnabled(cacheable=true)
    public static List<Event> fetchEvents() {
        return [SELECT Id, Subject, StartDateTime, IsAllDayEvent, EndDateTime
                FROM Event
                ORDER BY CreatedDate DESC
                LIMIT 100];
    }
    /**
     * @description To create an event from web component
     * @param event - json string with event details - title, start and end for now
     */
    @AuraEnabled
    public static Id createEvent(String event){
        //The following logic to be replaced with your respective event object
        if(String.isBlank(event)){
            return null;
        }
        Map<String, Object> eventMap = (Map<String, Object>) JSON.deserializeUntyped(event);
       
        Event newEvent = new Event();
        newEvent.Subject = eventMap.get('title') != null ? (String)eventMap.get('title') : null;
        String startdate = eventMap.get('start') != null ?
                            ((String)eventMap.get('start')).replace('T', ' ').replace('.000Z', '') :
                            null;
        String endDate = eventMap.get('end') != null ?
                            ((String)eventMap.get('end')).replace('T', ' ').replace('.000Z', '') :
                            null;
        newEvent.StartDateTime = startdate != null ? Datetime.valueOfGmt(startdate) : null;
        newEvent.EndDateTime = endDate != null ? Datetime.valueOfGmt(endDate) : null;
        // newEvent.IsAllDayEvent = eventMap.get('start') != null ? eventMap.get('start') : null;
        insert newEvent;
        return newEvent.Id;
    }
    /**
     * @description To delete an event from web component
     * @param eventid - event id to delete from the component
     */
    @AuraEnabled
    public static void deleteEvent(Id eventid) {
       
        if(eventid != null){
            delete [SELECT Id FROM Event Where Id=:eventid];
        }else{
            throw new EventException('Event id is not passed');
        }
    }
}
 

Hi,I had created custom campaign  calendar .I would like to display each campaigns as different colour.   can we achieve this in apex?
how to create filter for this requirement  in calendar view ?

Thanks in Advance.
Hi , I created a campaign calendar in calendar object   through new calendar option .  I would like to share this calendar to all the users in the org .How to achieve this?  

thanks in advance
Hi, 
I need to update
1.account rating as client customer if opportunity = last 2 years & closed opportunity
2.account rating as prospect if  opportunity  = last 3 to 5 years & open opportunity.
3.  for last 2 years if  account have two opportunity and both are open it should get update as prospect.

4.some accounts have two opportunities one as open and another as closed and  its updating it as  prospect   if it has open opportunity for recent year it should get update as client customer 
can anyone guide me .

global class AccountOptyBatchclass implements  Database.Batchable<sObject>  {

global  Database.QueryLocator start(Database.BatchableContext bc) {
   list<Id> accopty = new list<Id>();
      string query='select ID,Name,Rating,(select Id,AccountId,stageName,CloseDate From Opportunities) from Account';
      return Database.getQueryLocator(query);
   }
global Void execute(Database.BatchableContext bc, List<Account> Scope){
       list<Account> accopty = new list<account>();
   
        system.debug('query'+scope);
        for(Account a :Scope){
            for(Opportunity o: a.Opportunities){
                date dt = system.today().adddays(-1825);
                date ty = system.today().adddays(-730);
               
                system.debug ('dt'+dt);
                system.debug ('ty'+ty);
                  if((o.CloseDate >=ty) && (o.StageName =='Won-Work In Progress' || o.StageName =='Closed Won' || o.StageName =='Delivered')) {
                   
                     a.rating='Client - Customer';
                      accopty.add(a) ;
                    system.debug(' Last2yearsCloseDate'+a.rating) ;
                
                }

               else if( (o.CloseDate >=ty) && (o.StageName =='Shaping' || o.StageName =='Proposal Submitted' || o.StageName =='Decision' || o.StageName =='Engagement' )){
                   //if ((o.StageName !='Won-Work In Progress' || o.StageName !='Closed Won' || o.StageName !='Delivered' )&&(o.CloseDate < ty)){
                     a.rating='prospect';
                     accopty.add(a) ;
                       system.debug(' Last3to5yearsCloseDate'+a.rating) ; //}
                
                
                    } 
                
        }}
  
    update accopty ;
   
}
        global void finish(Database.BatchableContext bc){
   }
}
 

Thanks in Advance
can anyone guide me?

Thanks in Advance.
i would like to display my  content as table in helptext. can anyone guide me ? 


Thanks in advance
I am gettinf the output of month as number . but i need to convert that as string. can anyone help me?

​​​​​​​public with sharing class PieDemoController {  
    public Campaign camp {get;set;}
    
    public PieDemoController(ApexPages.StandardController std){
        camp = (Campaign)std.getRecord();
        
    }
    
    public List<PieWedgeData> getPieData() {
        List<PieWedgeData>PieWedgeData = new List<PieWedgeData>();
        List<AggregateResult> opps = [SELECT SUM(Amount) monthlyRevenue, COUNT(Name) numOppsClosedWon,
                  CALENDAR_MONTH(CloseDate) theMonth
             FROM Opportunity
             WHERE CampaignId =: camp.id 
             GROUP BY CALENDAR_MONTH(CloseDate)];
        
        for(AggregateResult ar : opps){
            String month = String.valueOf(ar.get('theMonth')); //this comes out as a number, not a word value
            Integer revenue = Integer.valueOf(ar.get('monthlyRevenue'));
           PieWedgeData.add(new PieWedgeData(month, revenue));
        }
        return PieWedgeData;
    }
    
    public class PieWedgeData {
       
        public PieWedgeData(String name, Integer count) {
            this.name = name;
            this.count = count;
        }
         public String name { get; set; }
        public Integer count { get; set; }

    }
}

Thanks in advance
Hi, background colour is not changing only text colour is getting changed for my lightning data table
.css:
tabletitle{
    color: var(--light-theme-text-color,#e06000);
    font-weight: bold;
}
.
.tablecss {
 background-color: var(--light-theme-backgroud-color, lightcyan);
    color: var(--light-theme-text-color, darkblue);
 
    font-weight: bold;
}
html:
<template>
    <template if:true={isSpinner}>
        <div class="spinner">
            <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
        </div>
    </template>
   
    <lightning-card title="My Rewards" class="tabletitle">
        <div class="tablecss">
        <lightning-datatable data={salaryList} columns={cols} key-field="Id" >
       
        </lightning-datatable> </div>
    </lightning-card>
</template>

thanks in advance
I would like to display month as a column in datatable based on created date & I need to roundoff number for customfields .
How to achieve this?


js:

import { LightningElement, wire, track } from 'lwc';
import getsalarylist from '@salesforce/apex/salarylist.getsalarylist';
const COLS = [
    { label: 'Month', fieldName: 'createddate', type: 'date', typeAttributes:{
        month: "long"
    } },

    { label: 'BasicAllowance', fieldName: 'BasicAllowance__c', type: 'Decimal' },
    { label: 'HouseRentAllowance', fieldName: 'HouseRentAllowance__c', type: 'Number' },
    { label: 'SpecialAllowance', fieldName: 'SpecialAllowance__c', type: 'Number',typeAttributes:{maximumFractionDigits:0} },
    { label: 'PF', fieldName: 'PF__c', type: 'Number' },.....................

Thanks in advance
Hi,
this are my formula  used in decision 
1.PriorValueNeworWorking
ISCHANGED({!$Record.Status}) &&
(TEXT(PRIORVALUE({!$Record.Status})) = “New” || TEXT(PRIORVALUE({!$Record.Status})) = “Working” )


2.NeworWorkingCase
(ISNEW() && TEXT({!$Record.Status}) = “New”) ||
(ISCHANGED({!$Record.Status}) && TEXT({!$Record.Status}) = “Working”)

condition in decision
PriorValueNeworWorking = true
NeworWorkingCase=true

output:
Skipped this outcome because its conditions weren't met: case1
Outcome conditions
{!Newcaseworking} (false) Equals true
All conditions must be true (AND)
Skipped this outcome because its conditions weren't met: prior
Outcome conditions
{!priorworking} (false) Equals true
All conditions must be true (AND)
Default outcome executed.

can anyone guide me what went wrong ? I created case record status as new . later modified its status as working.
 I have two records in same recordtype =compensation  .in salary_detail__c object.

1.first record record_status__c = Active
2.Second record  record_status__c =Inprogress


by updating second  record recordstatus as active  .it should  update first record record status  as inactive

trigger salarycredit on Salary_Detail__c (before update) {

   Set<id> revisedid = new Set<id>();
 Id c= Schema.SObjectType.Salary_Detail__c.getRecordTypeInfosByName().get('Compensation').getRecordTypeId();
   List<Salary_Detail__c>tobeinactive =[select id, name ,Employee_Id__c,Employee_Information__c, record_status__c from Salary_Detail__c where record_status__c ='Active' AND RecordTypeId =:c AND ID NOT IN: revisedid ];
  if (Trigger.isbefore && Trigger.isupdate) {  
          for (Salary_Detail__c s :trigger.new){
           
              Salary_Detail__c oldsalary= Trigger.oldMap.get(s.ID);
              //Salary_Detail__c newsalary= Trigger.newMap.get(s.ID);
              if(oldsalary.Record_Status__c =='Inprogress' && oldsalary.Record_Status__c!=s.Record_Status__c && s.RecordTypeId == c){
                 revisedid.add(s.id);
                   system.debug('revisedid.........>'+revisedid);
                 for (Salary_Detail__c si :tobeinactive){ 
                   si.Record_Status__c ='Inactive';
                 
              }
          }
          
      } 
      }        

Thanks in Advance
public class Update_salary_Recordstatus_as_Inactive {
    @InvocableMethod(label='Update salary  Recordstatus as Inactive' description='Returns the list of salary active records' )
    Public static List<Salary_Detail__c> getsalary(List<id> Ids){
   // Set<String> EmployeeId = new Set<String>();
    Id auRecordTypeId = Schema.SObjectType.Salary_Detail__c.getRecordTypeInfosByName().get('Compensation').getRecordTypeId();
    //for(Employee_Information__c e :[select id,Employee_Id__c from Employee_Information__c where Tax_Regime__c!=null AND Employee_Id__c != Null ] ){
          //  EmployeeId.add(e.Employee_Id__c);}
    List<Salary_Detail__c>sallist =[select id,Employee_First_Name__c,Employee_Last_Name__c,Employee_Information__c,RecordTypeId,Employee_ID__c,Confirmed_CTC__c,Record_Status__c,Date_of_Joining__c from Salary_Detail__c WHERE RecordTypeId =:auRecordTypeId AND Record_Status__c='Active' AND ID =:IDs  ];
    List<Salary_Detail__c>tobeinactive = [select id,Employee_First_Name__c,Employee_Last_Name__c,Employee_Information__c,RecordTypeId,Employee_ID__c,Confirmed_CTC__c,Record_Status__c,Date_of_Joining__c from Salary_Detail__c WHERE RecordTypeId =:auRecordTypeId AND Record_Status__c='Active' AND ID NOT IN :IDs  ];

        List<Salary_Detail__c>Inactivesallist = new  List<Salary_Detail__c> ();
        
    for (Salary_Detail__c s :tobeinactive){
       
            s.Record_Status__c ='Inactive';  
            Inactivesallist.add(s);  
        system.debug(' Inactivesallist......'+ Inactivesallist);
           }
   update Inactivesallist;
  return Inactivesallist;                                

 }

Inputs: $record.id

I need to update record other than this input . can anyone guide me. Thanks in advance
if picklist record_status__c is changed from 'inprogress' to 'active ' in new salary record 

I want to update record_status__c as inactive in old salary record

public class Update_salary_Recordstatus_as_Inactive {
    @InvocableMethod(label='Update salary  Recordstatus as Inactive' description='Returns the list of salary active records' )
    Public static List<Salary_Detail__c> getsalary(){
  
    Set<String> EmployeeId = new Set<String>();
    Id auRecordTypeId = Schema.SObjectType.Salary_Detail__c.getRecordTypeInfosByName().get('Compensation').getRecordTypeId();
    for(Employee_Information__c e :[select id,Employee_Id__c from Employee_Information__c where Tax_Regime__c!=null AND Employee_Id__c != Null ] ){
            EmployeeId.add(e.Employee_Id__c);}
    List<Salary_Detail__c>sallist =[select id,Employee_First_Name__c,Employee_Last_Name__c,Employee_Information__c,RecordTypeId,Employee_ID__c,Confirmed_CTC__c,Record_Status__c from Salary_Detail__c WHERE RecordTypeId=:auRecordTypeId AND Employee_Id__c IN :EmployeeId];
    List<Salary_Detail__c>Inactivesallist = new  List<Salary_Detail__c> ();
   
   
    for (Salary_Detail__c s :sallist){
          s.Record_Status__c ='Inactive'; 
          //s.oldRecordstatus= trigger.oldmap.get
          Inactivesallist.add(s);
    }
   
  return Inactivesallist;                                
} }

how to mention oldvalue is inprogress in this apex class?

Thanks in advance


 

sourceorg:
public class LeadInfoRestAPI {
    public static void getLeadInfo(){
        HttpRequest req = new  HttpRequest();
        req.setEndpoint('https://abccom703-dev-ed.my.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9fe4g9fhX0E6mT.C7abEpUyc09UVggmNHPjPmuN6B93fDcKaryyx5Ro5MvBzm.XrNRa7un0kxRV0Xo2.S&client_secret=74A03DB8307235BDC86113B9130E9F6CBBE0C3B24D60A91B7D169EDBE07BD277&username=test@abc.com&password=Test3@');
        req.setMethod('POST');
        Http http = new Http();
        HttpResponse res = new HttpResponse();
        res = http.send(req);
        system.debug('response--------'+res.getBody());
        Oauth objAuthInfo = (Oauth)JSON.deserialize(res.getBody(),Oauth.class);
        system.debug('objAuthInfo--------'+objAuthInfo);
        if(objAuthInfo.access_token !=null){
             HttpRequest req1= new  HttpRequest();
             req1.setEndpoint('https://abccom703-dev-ed.my.salesforce.com/services/apexrest/LeadInfo/00Q5g000008TNrGEAW?Content-Type=application/json&Authorization=Bearer 00D5g00000DguX0!ARkAQE3pNrJvOeLrIVw7ym0QDquIRUuHtnZ8.WEujlQ1iF.PRwrrZO_8PeWKxB7wNKi3M9YVGGe2SsvxHH6ra6KpWWmMevzK');
             req1.setMethod('GET');
             req1.setHeader('Content-Type', 'application/json');
             req1.setHeader('Authorization','Bearer '+objAuthInfo.access_token);
             Http http1 = new Http();
             HttpResponse res1= new HttpResponse();
             res1 = http.send(req1);
             
             system.debug('LeadInfo--------'+res1.getBody());
        }}
    
    public class Oauth{
         public string access_token{get;set;}
         public string instance_url{get;set;}
         public string id{get;set;}
         public string token_type{get;set;}
         public string issued_at{get;set;}
         public string signature{get;set;}
    }

ERROR:


|DEBUG|LeadInfo--------<h1>Bad Message 400</h1><pre>reason: Illegal character SPACE=' '</pre>

can anyone guide me where i missed out ?

Thanks in advance.

Hi,
I need to create a record   in salary__c object
if 1) date _of_joing of the employees > year
or
2) salary revision date of the employees (last year) > year

can anyone guide me?
Thanks in advance
Hi , i need to keep cc as respective users personal email id in visualforce email template . how to keep cc dynamically in visualforce email template ?

Thanks in advance
 
Hi , if salarystatus  picklist is credited in salary object .i need to send email  to the respective employees  official mail id and add cc to the personal mail id of employees .  can anyone guide me?

if (trigger.isafter && trigger.isupdate) { 
    for(Salary_Detail__c Sa:trigger.new){
        if( sa.salary_status__c=='Credited'){
            //public PageReference sendPdf(){                
     PageReference pdf = Page.payslip;//mail_pdf is the name of vf page
     pdf.getParameters().put('email',email);
     // goToNextPage('email');
     Blob body;                
     try{
        body = pdf.getContent();
     }catch(VisualforceException e){
            body=Blob.valueOf('Some text');
     }            
      Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
      attach.setContentType('application/pdf');
      attach.setFileName('payslip.pdf');
      attach.setInline(false);
      attach.Body = body;
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      mail.setUseSignature(false);
      mail.setToAddresses(new String[] { email });
      mail.setSubject('Payslip');
      mail.setHtmlBody('Please Find the payslip for the month');
      mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
      // Send the email    
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Email with PDF sent to '+email));
      return null;
    //}
}
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sa.userinfo.getuseremail());
                mail.setToAddresses(sendTo); 
                //mail.setReplyTo('test@gmail.com');
                mail.setSenderDisplayName('HR Team');
                List<String> ccTo = new List<String>();
                ccTo.add();
                mail.setSubject('Payslip for the month');
                String body = '<html><body>Dear ' + sa.Name + 'Please find the salary slip for the month of :  Thanks ,HR Team</body> </html>

Thanks in advance
 
I  am capturing images of employees regulary for attendance tracking through vf page in salesforce .My images are stored in files .I need to display it in Custom object record of respective  employees  dynamically . can anyone guide me ?
Hi , I need to take picture from camera using vf page in salesforce .but , i need to restrict picture from gallery. 
by default gallery is available  along with camera .can anyone guide me?

[sourcecode language=”java”]
<apex:page controller=”CreateSnap” standardStylesheets=”false” showHeader=”false”>
<apex:includeScript value=”{!$Resource.ExifJavaScript}”/>
<script> function getGPSdata(e) {
EXIF.getData(e.files[0], function() {
var obj = {};
obj.Latitude = EXIF.getTag(this, “GPSLatitude”);
obj.Longitude = EXIF.getTag(this, “GPSLongitude”);
obj.CreatedDate = EXIF.getTag(this,”DateTime”);
document.querySelectorAll(‘[id$=”desc”]’)[0].value = JSON.stringify(obj); });}
</script>
<div class=”container” style=”background-color:#E6E6FA”>
<div class=”row clearfix”>
<div class=”col-md-12 column”>
<div class=”jumbotron”>
<h1> Camera Access in Visualforce using HTML 5</h1>
</div>
<div class=”panel panel-warning”>
<div class=”panel-heading”>
<apex:form >
<apex:inputFile value=”{!cont.VersionData}” accept=”image/*;capture=camera” filename=”{!cont.Title}” onchange=”getGPSdata(this)”/>
<apex:inputTextarea value=”{!cont.description}” id=”desc” rows=”7″ cols=”25″ disabled=”true” >
<apex:commandButton StyleClass=”btn btn-danger” action=”{!saveFile}” value=”Save File” >
</apex:form></div>
</div>
</div>
</div>
</div>
</apex:page>
[/sourcecode]
APEX CLASS:
[sourcecode language=”java”]
public class CreateSnap{
public ContentVersion cont {get;set;}
public CreateSnap() {
cont = new ContentVersion();
}
public PageReference saveFile()
{
//PathOnClient is Mandatory
cont.PathOnClient = cont.title;
cont.Description = cont.Description;
//By default Origin value is “C” that means Content must be enabled in Org, so we need to explicitly set Origin as H
cont.Origin = ‘H’;
insert cont;
//redirect to path where file is saved
return new PageReference(‘/’+cont.id);
}
}

thanks in advance
I installed node .confirmed it by node-v command in command prompt.
I didnt install python .  can anyone guide me ?  

I got the following error :

PS C:\Users\Sujis\Desktop\VScode\Hello world> sfdx plugins:install @salesforce/lwc-dev-server
Polling for new version(s) to become available on npm... done
Successfully validated digital signature for @salesforce/lwc-dev-server.
Finished digital signature check.
warning @salesforce/lwc-dev-server > @lwc/engine@1.2.2: Use @lwc/engine-dom instead
warning @salesforce/lwc-dev-server > request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
warning @salesforce/lwc-dev-server > jsdom > request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
warning @salesforce/lwc-dev-server > cpx > chokidar@1.7.0: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning @salesforce/lwc-dev-server > @communities-webruntime/extensions > csurf@1.11.0: Please use another csrf package
warning @salesforce/lwc-dev-server > @salesforce/command > cli-ux@4.9.3: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning @salesforce/lwc-dev-server > cpx > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning @salesforce/lwc-dev-server > jsdom > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @salesforce/lwc-dev-server > @salesforce/core > jsforce > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @salesforce/lwc-dev-server > @webruntime/compiler > babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. 
This package will no longer receive updates.
warning @salesforce/lwc-dev-server > @webruntime/compiler > rollup-plugin-commonjs@9.3.4: This package has been deprecated 
and is no longer maintained. Please use @rollup/plugin-commonjs.
warning @salesforce/lwc-dev-server > @webruntime/compiler > rollup-plugin-node-resolve@4.2.4: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-node-resolve.
warning @salesforce/lwc-dev-server > @webruntime/compiler > rollup-plugin-replace@2.2.0: This module has moved and is now available at @rollup/plugin-replace. Please update your dependencies. This version is no longer maintained.
warning @salesforce/lwc-dev-server > @webruntime/api > @lwc/compiler > rollup-plugin-replace@2.2.0: This module has moved and is now available at @rollup/plugin-replace. Please update your dependencies. This version is no longer maintained.      
warning @salesforce/lwc-dev-server > uuidv4 > uuid@3.3.3: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details. 
warning @salesforce/lwc-dev-server > @webruntime/server > uuidv4 > uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
warning @salesforce/lwc-dev-server > jsdom > request > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions 
may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for 
details.
warning @salesforce/lwc-dev-server > jsdom > request > har-validator@5.1.5: this library is no longer supported
warning @salesforce/lwc-dev-server > cpx > babel-runtime > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not 
recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @salesforce/lwc-dev-server > cpx > chokidar > readdirp > micromatch > snapdragon > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
warning @salesforce/lwc-dev-server > cpx > chokidar > readdirp > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning @salesforce/lwc-dev-server > cpx > chokidar > readdirp > micromatch > snapdragon > source-map-resolve > source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
warning @salesforce/lwc-dev-server > cpx > chokidar > readdirp > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning @salesforce/lwc-dev-server > @webruntime/api > @lwc/compiler > @lwc/style-compiler > cssnano-preset-default > postcss-svgo > svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
warning @salesforce/lwc-dev-server > @webruntime/api > @lwc/compiler > @lwc/style-compiler > cssnano-preset-default > postcss-svgo > svgo > stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
warning "@salesforce/lwc-dev-server > @rollup/plugin-alias@3.1.9" has unmet peer dependency "rollup@^1.20.0||^2.0.0".
warning "@salesforce/lwc-dev-server > request-promise-native@1.0.9" has unmet peer dependency "request@^2.34".       
warning "@salesforce/lwc-dev-server > request-promise-native > request-promise-core@1.1.4" has unmet peer dependency "request@^2.34".
error C:\Users\Sujis\AppData\Local\sfdx\node_modules\fibers: Command failed.
Exit code: 1
Command: node build.js || nodejs build.js
Arguments:
Directory: C:\Users\Sujis\AppData\Local\sfdx\node_modules\fibers
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@9.1.0
gyp info using node@16.17.0 | win32 | x64
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python39\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python39\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python39\python.exe
gyp ERR! find Python - "C:\Program Files\Python39\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python39-32\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python39-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python39-32\python.exe
gyp ERR! find Python - "C:\Program Files\Python39-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python39-32\python.exe
gyp ERR! find Python - "C:\Program Files (x86)\Python39-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python38\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python38\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python38\python.exe
gyp ERR! find Python - "C:\Program Files\Python38\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python38-32\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python38-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python38-32\python.exe
gyp ERR! find Python - "C:\Program Files\Python38-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python38-32\python.exe
gyp ERR! find Python - "C:\Program Files (x86)\Python38-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python37\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python37\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python37\python.exe
gyp ERR! find Python - "C:\Program Files\Python37\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python37-32\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python37-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python37-32\python.exe
gyp ERR! find Python - "C:\Program Files\Python37-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python37-32\python.exe
gyp ERR! find Python - "C:\Program Files (x86)\Python37-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python36\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python36\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python36\python.exe
gyp ERR! find Python - "C:\Program Files\Python36\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Users\Sujis\AppData\Local\Programs\Python\Python36-32\python.exe
gyp ERR! find Python - "C:\Users\Sujis\AppData\Local\Programs\Python\Python36-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files\Python36-32\python.exe
gyp ERR! find Python - "C:\Program Files\Python36-32\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python36-32\python.exe
gyp ERR! find Python - "C:\Program Files (x86)\Python36-32\python.exe" could not be run
gyp ERR! find Python checking if the py launcher can be used to find Python 3
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (C:\Users\Sujis\AppData\Roaming\npm\node_modules\node-gyp\lib\find-python.js:330:47)
gyp ERR! stack     at PythonFinder.runChecks (C:\Users\Sujis\AppData\Roaming\npm\node_modules\node-gyp\lib\find-python.js:159:21)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\Sujis\AppData\Roaming\npm\node_modules\node-gyp\lib\find-python.js:228:18)
gyp ERR! stack     at PythonFinder.execFileCallback (C:\Users\Sujis\AppData\Roaming\npm\node_modules\node-gyp\lib\find-python.js:294:16)
gyp ERR! stack     at exithandler (node:child_process:408:5)
gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:420:5)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
gyp ERR! stack     at onErrorNT (node:internal/child_process:478:16)
gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Users\\Sujis\\AppData\\Local\\sfdx\\client\\7.170.0-bd51991\\bin\\node.exe" "C:\\Users\\Sujis\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd C:\Users\Sujis\AppData\Local\sfdx\node_modules\fibers
gyp ERR! node -v v16.17.0
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
RHEL users please run: `yum install gcc-c++` and `yum groupinstall 'Development Tools'`
Alpine users please run: `sudo apk add python make g++`
'nodejs' is not recognized as an internal or external command,
operable program or batch file.
Installing plugin @salesforce/lwc-dev-server... failed
    Error: yarn add @salesforce/lwc-dev-server@latest --non-interactive 
    --mutex=file:C:\Users\Sujis\AppData\Local\sfdx\yarn.lock
    --preferred-cache-folder=C:\Users\Sujis\AppData\Local\sfdx\yarn --check-files exited with code 1


Thanks in advance
Hi,I had created custom campaign  calendar .I would like to display each campaigns as different colour.   can we achieve this in apex?
how to create filter for this requirement  in calendar view ?

Thanks in Advance.
Hi , I created a campaign calendar in calendar object   through new calendar option .  I would like to share this calendar to all the users in the org .How to achieve this?  

thanks in advance
Hi, 
I need to update
1.account rating as client customer if opportunity = last 2 years & closed opportunity
2.account rating as prospect if  opportunity  = last 3 to 5 years & open opportunity.
3.  for last 2 years if  account have two opportunity and both are open it should get update as prospect.

4.some accounts have two opportunities one as open and another as closed and  its updating it as  prospect   if it has open opportunity for recent year it should get update as client customer 
can anyone guide me .

global class AccountOptyBatchclass implements  Database.Batchable<sObject>  {

global  Database.QueryLocator start(Database.BatchableContext bc) {
   list<Id> accopty = new list<Id>();
      string query='select ID,Name,Rating,(select Id,AccountId,stageName,CloseDate From Opportunities) from Account';
      return Database.getQueryLocator(query);
   }
global Void execute(Database.BatchableContext bc, List<Account> Scope){
       list<Account> accopty = new list<account>();
   
        system.debug('query'+scope);
        for(Account a :Scope){
            for(Opportunity o: a.Opportunities){
                date dt = system.today().adddays(-1825);
                date ty = system.today().adddays(-730);
               
                system.debug ('dt'+dt);
                system.debug ('ty'+ty);
                  if((o.CloseDate >=ty) && (o.StageName =='Won-Work In Progress' || o.StageName =='Closed Won' || o.StageName =='Delivered')) {
                   
                     a.rating='Client - Customer';
                      accopty.add(a) ;
                    system.debug(' Last2yearsCloseDate'+a.rating) ;
                
                }

               else if( (o.CloseDate >=ty) && (o.StageName =='Shaping' || o.StageName =='Proposal Submitted' || o.StageName =='Decision' || o.StageName =='Engagement' )){
                   //if ((o.StageName !='Won-Work In Progress' || o.StageName !='Closed Won' || o.StageName !='Delivered' )&&(o.CloseDate < ty)){
                     a.rating='prospect';
                     accopty.add(a) ;
                       system.debug(' Last3to5yearsCloseDate'+a.rating) ; //}
                
                
                    } 
                
        }}
  
    update accopty ;
   
}
        global void finish(Database.BatchableContext bc){
   }
}
 

Thanks in Advance
I am gettinf the output of month as number . but i need to convert that as string. can anyone help me?

​​​​​​​public with sharing class PieDemoController {  
    public Campaign camp {get;set;}
    
    public PieDemoController(ApexPages.StandardController std){
        camp = (Campaign)std.getRecord();
        
    }
    
    public List<PieWedgeData> getPieData() {
        List<PieWedgeData>PieWedgeData = new List<PieWedgeData>();
        List<AggregateResult> opps = [SELECT SUM(Amount) monthlyRevenue, COUNT(Name) numOppsClosedWon,
                  CALENDAR_MONTH(CloseDate) theMonth
             FROM Opportunity
             WHERE CampaignId =: camp.id 
             GROUP BY CALENDAR_MONTH(CloseDate)];
        
        for(AggregateResult ar : opps){
            String month = String.valueOf(ar.get('theMonth')); //this comes out as a number, not a word value
            Integer revenue = Integer.valueOf(ar.get('monthlyRevenue'));
           PieWedgeData.add(new PieWedgeData(month, revenue));
        }
        return PieWedgeData;
    }
    
    public class PieWedgeData {
       
        public PieWedgeData(String name, Integer count) {
            this.name = name;
            this.count = count;
        }
         public String name { get; set; }
        public Integer count { get; set; }

    }
}

Thanks in advance
Hi,
this are my formula  used in decision 
1.PriorValueNeworWorking
ISCHANGED({!$Record.Status}) &&
(TEXT(PRIORVALUE({!$Record.Status})) = “New” || TEXT(PRIORVALUE({!$Record.Status})) = “Working” )


2.NeworWorkingCase
(ISNEW() && TEXT({!$Record.Status}) = “New”) ||
(ISCHANGED({!$Record.Status}) && TEXT({!$Record.Status}) = “Working”)

condition in decision
PriorValueNeworWorking = true
NeworWorkingCase=true

output:
Skipped this outcome because its conditions weren't met: case1
Outcome conditions
{!Newcaseworking} (false) Equals true
All conditions must be true (AND)
Skipped this outcome because its conditions weren't met: prior
Outcome conditions
{!priorworking} (false) Equals true
All conditions must be true (AND)
Default outcome executed.

can anyone guide me what went wrong ? I created case record status as new . later modified its status as working.

sourceorg:
public class LeadInfoRestAPI {
    public static void getLeadInfo(){
        HttpRequest req = new  HttpRequest();
        req.setEndpoint('https://abccom703-dev-ed.my.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9fe4g9fhX0E6mT.C7abEpUyc09UVggmNHPjPmuN6B93fDcKaryyx5Ro5MvBzm.XrNRa7un0kxRV0Xo2.S&client_secret=74A03DB8307235BDC86113B9130E9F6CBBE0C3B24D60A91B7D169EDBE07BD277&username=test@abc.com&password=Test3@');
        req.setMethod('POST');
        Http http = new Http();
        HttpResponse res = new HttpResponse();
        res = http.send(req);
        system.debug('response--------'+res.getBody());
        Oauth objAuthInfo = (Oauth)JSON.deserialize(res.getBody(),Oauth.class);
        system.debug('objAuthInfo--------'+objAuthInfo);
        if(objAuthInfo.access_token !=null){
             HttpRequest req1= new  HttpRequest();
             req1.setEndpoint('https://abccom703-dev-ed.my.salesforce.com/services/apexrest/LeadInfo/00Q5g000008TNrGEAW?Content-Type=application/json&Authorization=Bearer 00D5g00000DguX0!ARkAQE3pNrJvOeLrIVw7ym0QDquIRUuHtnZ8.WEujlQ1iF.PRwrrZO_8PeWKxB7wNKi3M9YVGGe2SsvxHH6ra6KpWWmMevzK');
             req1.setMethod('GET');
             req1.setHeader('Content-Type', 'application/json');
             req1.setHeader('Authorization','Bearer '+objAuthInfo.access_token);
             Http http1 = new Http();
             HttpResponse res1= new HttpResponse();
             res1 = http.send(req1);
             
             system.debug('LeadInfo--------'+res1.getBody());
        }}
    
    public class Oauth{
         public string access_token{get;set;}
         public string instance_url{get;set;}
         public string id{get;set;}
         public string token_type{get;set;}
         public string issued_at{get;set;}
         public string signature{get;set;}
    }

ERROR:


|DEBUG|LeadInfo--------<h1>Bad Message 400</h1><pre>reason: Illegal character SPACE=' '</pre>

can anyone guide me where i missed out ?

Thanks in advance.


<apex:page standardController="account" extensions="SalaryRewards" showheader="false" sidebar="false">
    <apex:pagemessages ></apex:pagemessages>  
    <apex:pageblock >
        <apex:pageBlocktable value="{!lsalaryInfo}" var="sinfo">
            <apex:column value="{!sinfo.month}" headervalue="Month"/>
            <apex:column value="{!Round(sinfo.Basic_Allowance,0)}" headervalue="BasicAllowance"/>                              
      <apex:page standardController="account" extensions="SalaryRewards" showheader="false" sidebar="false">
    <apex:pagemessages ></apex:pagemessages>  
    <apex:pageblock >
        <apex:pageBlocktable value="{!lsalaryInfo}" var="sinfo">
            <apex:column value="{!sinfo.month}" headervalue="Month"/>
            <apex:column value="{!Round(sinfo.Basic_Allowance,0)}" headervalue="BasicAllowance"/>                              
               </apex:pageBlocktable>
    </apex:pageblock>
</apex:page>

I am getting error as : Syntax error. Missing ')'
can anyone guide me what i am missing ?

Thanks in Advance
 
public class SalaryRewards {
 public List <salaryInfo> lsalaryInfo{get;set;}
 public List <Salary_Detail__c> salarydetail{get;set;}
          
 public SalaryRewards(ApexPages.StandardController controller) 
    {
        lsalaryInfo = new list <salaryInfo>();
        salarydetail = new list<Salary_Detail__c>();
        salarydetail =[SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ];
  
        for(integer i=0;i<System.now().month();i++)
        {
            salaryInfo  sinfo = new salaryInfo ();
            sinfo.month = datetime.newinstance(2013,1,1).addmonths(i).format('MMM');
            sinfo.count = 0;
           lsalaryInfo.add(sinfo);
             system.debug('salary-month===>'+lsalaryInfo);
        }}
      
            // lsalaryInfo = new List <salaryInfo>();
    public getsalary(){                  
for( Salary_Detail__c sal :[SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ]){                
            //Integer Basic_Allowance  = integer.valueof(sal.get(''));
            
                       lsalaryInfo.add(new salaryInfo(Salary_Detail__c= salarydetail.BasicAllowance__c));
    system.debug('salary-month===>'+lsalaryInfo);}}
            
       
     
        }
        
 
I got invalid constructor error for the highlighted code
       
      Thanks in advance  .
Hi, how to write test class for vf component Apex class?  
can anyone guide me?
Apex class:
public class salarydetail{
   public static list<Salary_Detail__c>salary; 
    //salary = new list<Salary_Detail__c>();
   public String salaryId {
        get{
            if(salaryId == null && ApexPages.currentPage().getParameters().get('id') != null){
                salaryId = ApexPages.currentPage().getParameters().get('id');
            }
            return salaryId;
        }
        set;
    }
      
    public Salary_Detail__c sd {
       
        get{
            return [SELECT Id, Employee_ID__c,Date_of_Joining__c,Department__c,Designation__c,
                    Gender__c,Location__c,Pan_Number__c,Professional_Tax__c,UAN_No__c,BasicAllowance__c,HouseRentAllowance__c,MonthDays__c,Number_of_Days_present__c, Account_No__c,
                    Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c,
                    NetPay__c,In_Words__c FROM Salary_Detail__c WHERE Id = :salaryId LIMIT 1];
        }
        set;
      
    }
}

Test class:
@ IsTest
public class salarydetailtest {
    public static Testmethod void Salary(){
       Test.startTest(); 
       Employee_Information__c E = new Employee_Information__c();
        
        E.Name='Test';
        E.Employee_Last_Name__c ='s';
        E.Employee_ID__c = 'E-1234';
        E.Date_of_Join__c= system.today();
        E.Tax_Regime__c='Old Regime';
        E.Confirmed_CTC__c=1500000;
        insert E;
        
        Employee_Information__c E1 = new Employee_Information__c();
        
        E1.Name='Test1';
        E1.Employee_Last_Name__c ='s';
        E1.Employee_ID__c = 'E-12345';
        E1.Date_of_Join__c= system.today();
        E1.Tax_Regime__c='New Regime';
        E1.Confirmed_CTC__c=1500000;
        insert E1;
        
     List< Salary_Detail__c>lis=    [SELECT Id, Employee_ID__c,Date_of_Joining__c,Department__c,Designation__c,
                    Gender__c,Location__c,Pan_Number__c,Professional_Tax__c,UAN_No__c,BasicAllowance__c,HouseRentAllowance__c,MonthDays__c,Number_of_Days_present__c, Account_No__c,
                    Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c,
                    NetPay__c,In_Words__c FROM Salary_Detail__c ];
       Salary_Detail__c s = new Salary_Detail__c();
       
       // s.Employee_Names__c='Tests';
        s.Employee_First_Name__c='Test';
        s.Employee_Last_Name__c ='s';
        s.RecordTypeId = '0123K0000009lfpQAA';
        s.Record_Status__c='Active';  
        s.Date_of_Joining__c=system.today();
        s.Employee_ID__c = 'E-1234';
        s.Employee_Information__c=E.id;
        s.MonthDays__c=31;
        S.LastMonthLeaves__c=1;
        S.LastMonthLops__c=1;
        s.Worked_days__c=30;
        s.Confirmed_CTC__c=1500000;
        s.Basic_Annual__c=450000;
         s.HRA_Annual__c=180000;
         s.Special_Allowance_Annual__c=809250;
        s.Tax_Regime__c='Old Regime'; 
        s.standard_deduction_monthly__c=4167;
        s.Professional_Tax__c=200;
        s.Medical_Reimbursement_Annual__c=0;
            s.Skill_up_Allowance__c =0;
            s.Company_Medical_Insurance_Contribution__c =0; 
          s.zeroto2_5__c=250000;
           s.X2_5to5__c=250000;
           s.X5to7_5__c=250000;
           s.X7_5to10__c=250000;
            s.X10to12_5__c=250000;
           s.X12_5to15__c=250000;
           s.X15Great__c=0;
            s.TaxExempt__c=0;
        s.TotalDeductions__c=0;
        s.TotalEarnings__c=0;
        s.NetPay__c=0;
        lis.add (s);
        upsert lis;
        
         Salary_Detail__c s1 = new Salary_Detail__c();
       
       // s.Employee_Names__c='Tests';
        s1.Employee_First_Name__c='Test';
        s1.Employee_Last_Name__c ='s';
        s1.RecordTypeId = '0123K0000009lfpQAA';
        s1.Record_Status__c='Active';  
        s1.Date_of_Joining__c=system.today();
        s1.Employee_ID__c = 'E-12345';
        s1.Employee_Information__c=E1.id;
        s1.MonthDays__c=31;
        S1.LastMonthLeaves__c=1;
        S1.LastMonthLops__c=1;
        s1.Worked_days__c=30;
        s1.Confirmed_CTC__c=-1;
        s1.Basic_Annual__c=450000;
        s1.HRA_Annual__c=180000;
         s1.Special_Allowance_Annual__c=809250;
        s1.Tax_Regime__c='Old Regime'; 
        s1.standard_deduction_monthly__c=4167;
        s1.Professional_Tax__c=200;
        s1.Medical_Reimbursement_Annual__c=0;
            s1.Skill_up_Allowance__c =0;
            s1.Company_Medical_Insurance_Contribution__c =0; 
          s1.zeroto2_5__c=250000;
           s1.X2_5to5__c=250000;
           s1.X5to7_5__c=250000;
           s1.X7_5to10__c=250000;
            s1.X10to12_5__c=250000;
           s1.X12_5to15__c=250000;
           s1.X15Great__c=0;
            s1.TaxExempt__c=0;
        s1.TotalDeductions__c=0;
        s1.TotalEarnings__c=0;
        s1.NetPay__c=0;
        lis.add (s1);
        upsert lis;
        
        Leave_Request__c L = new Leave_Request__c();
        L.Approval_Status__c ='Approved';
        L.Employee_ID__c = 'E-1234';
        L.Employee_Name__c=E.id;
        L.Last_Month_LOPs__c=1;
        L.Last_Month_Leaves__c=1;
        insert L;

       
        //salarydetailtest t = new salarydetailtest();
         // salarydetailtest.Salary();
        Test.stopTest();
}

    }

Thanks in advance
how to write testclass for convert currency to word  Apex class?

Apex class:

public with sharing class ConvertCurrencyToWords {
 
     static String[] to_19 = new string[]{ 'zero', 'one',  'two', 'three', 'four',  'five',  'six',  
     'seven', 'eight', 'nine', 'ten',  'eleven', 'twelve', 'thirteen',  
      'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen' };  
    static String[] tens = new string[]{ 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'};  
    static String[] denom = new string[]{ '',  
     'thousand',   'million',     'billion',    'trillion',    'quadrillion',  
      'quintillion', 's!xtillion',   'septillion',  'octillion',   'nonillion',  
      'decillion',  'undecillion',   'duodecillion', 'tredecillion',  'quattuordecillion',  
      's!xdecillion', 'septendecillion', 'octodecillion', 'novemdecillion', 'vigintillion' };  
    // convert a value < 100 to English.    
   public static String convert_nn(integer val) {  
      if (val < 20)  
        return to_19[val];  
      if(val == 100)  
          return 'One Hundred';  
      for (integer v = 0; v < tens.size(); v++) {  
        String dcap = tens[v];  
        integer dval = 20 + 10 * v;  
        if (dval + 10 > val) {  
          if (Math.Mod(val,10) != 0)  
           return dcap + ' ' + to_19[Math.Mod(val,10)];  
         return dcap;  
        }      
      }  
      return 'Should never get here, less than 100 failure';  
    }  
    // convert a value < 1000 to english, special cased because it is the level that kicks   
    // off the < 100 special case. The rest are more general. This also allows you to  
   // get strings in the form of "forty-five hundred" if called directly.  
   public static String convert_nnn(integer val) {  
     String word = '';  
     integer rem = val / 100;  
     integer mod = Math.mod(val,100);  
      if (rem > 0) {  
        word = to_19[rem] + ' hundred';          if (mod > 0) {  
          word += ' ';  
        }  
      }  
      if (mod > 0) {  
        word += convert_nn(mod);  
      }        return word;  
    }  
   public static String english_number(long val) {  
     if (val < 100) {  
       return convert_nn(val.intValue());  
      }  
      if (val < 1000) {  
        return convert_nnn(val.intValue());  
      }  
      for (integer v = 0; v < denom.size(); v++) {  
        integer didx = v - 1;  
        integer dval = (integer)Math.pow(1000, v);  
        if (dval > val) {  
          integer mod = (integer)Math.pow(1000, didx);  
         integer l = (integer) val / mod;  
          integer r = (integer) val - (l * mod);  
          String ret = convert_nnn(l) + ' ' + denom[didx];  
          if (r > 0) {  
           ret += ', ' + english_number(r);  
         }  
          return ret;  
        }  
      }  
      return 'Should never get here, bottomed out in english_number';  
        }  
 
        
  }
I have LOP__c field in Leaverequest__c object .
I need to  count this field in  records.

Thanks in advance
 
how to perform the following action in formulas ? 

IF( AND(Cost_to_company_Annual__c >=250000 , Cost_to_company_Annual__c <500000),
"(Cost_to_company_Annual__c-250000)*5",'zero')

Thanks in advance
When i try to fetch data for a lookupfield .i got only id .can anyone suggest me what needs to be done to fetch values for the lookup fields.

Thanks in advance
I have two record types Standard Payment & custom payment . 
according to recordtypes i need to display my table values.

thanks in advance
User-added image
 
Task object have Master Detail Relationship with Phase , project objects
Project object  have Lookup relationship with program object .
API name for program lookup field in project object is inov8__Program__c
how to fetch program object values in this soql?

select name,inov8__Phase__r.inov8__Project__r.Name from inov8__PMT_Task__c 

Thanks in Advance.
I created subcontact__c object  and created lookup relationship  with contact .child relationship Name -subcontacts

1.I tried to query child to parent  
select Name, Account.Name from Contact  - got response
2.when i trield to query grand child to parent  getting error 
select Name, Contact.Account.Name from subcontact__c - got error

Can you clarify me, why i didnt get response?
Thanks in Advance. 


Task is the child of phase
when i try to query from child to parent,grand parent great grand parent.(App which i am trying is PMT)


i am getting error as
select Name,inov8__PMT_Phase__r.inov8__PMT_Project__r.name
            ^
ERROR at Row:1:Column:13
Didn't understand relationship 'inov8__PMT_Phase__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
select Name,inov8__PMT_Phase__r.Name from inov8__PMT_Task__c

Thanks in advance
I am able to fetch the standard fields in rest batch Apex. but unable to fetch the custom fields .

Thanks in advance