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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 95
    Questions
  • 68
    Replies
Hi,
I need assistance with setting up delete access for sales managers in Salesforce.
Here are my requirements:
Edit Access: Sales managers should have the ability to edit all opportunities.
Record Types: Opportunities created by the Direct Sales team should use the "Direct Sales" record type, while those created by the Inside Sales team should use the "Inside Sales" record type.
View Access:
The Direct Sales team should be able to view all opportunities, regardless of the record type.
The Inside Sales team should only see opportunities belonging to their team.
Delete Access:
Both Direct Sales managers and Inside Sales managers should have the ability to delete all opportunities.
Here's what I've already done:
Created five profiles: Sales Manager, Direct Sales Manager, Inside Sales Manager, Direct Sales Rep, and Inside Sales Rep.
Set the Organization-Wide Default (OWD) to "Private."
Assigned record types based on profiles.
Used sharing rules with criteria to make Inside Sales team records accessible to that team.
Enabled the "View All" permission for the Direct Sales team.

Now, I need guidance on how to provide delete access exclusively to Direct and Inside Sales Managers.

Thanks 

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
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