• GYAN ANDRUS
  • NEWBIE
  • 90 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 69
    Questions
  • 111
    Replies
Apex page:

<apex:page controller="ReportController" >
    
    <apex:form >
        <apex:pageBlock title="Choose Report" id="out">
            <apex:pageBlockButtons >
                
                
                <apex:actionStatus id="actStatusId">
                    <apex:facet name="start">
                        <img src="/img/loading.gif" />
                    </apex:facet>
                </apex:actionStatus>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Choose Report Names">
                <apex:selectList value="{!selectedReport}" multiselect="false" size="1">
                    <apex:selectOptions value="{!reportsOptions}"/>
                    
                </apex:selectList>
              <apex:commandButton value="Show Reports" action="{!showReports}" reRender="out" status="actStatusId" /> 
                               <apex:commandButton value="Tab" action="{!URLFOR($Action.Account.Tab, $ObjectType.Account)}"/>

                <!--<apex:commandLink target="_blank" styleClass="btn" style="text-decoration:none;padding:4px;" action="{!showReports}" />-->
            </apex:pageBlockSection>
            
            
        </apex:pageBlock>
        <apex:pageBlock >
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

controller:

public with sharing class ReportController {
    
    public PageReference showReports() {
        try{
            Report objReport = [Select Id from Report where name=:selectedReport];
            PageReference report = new PageReference('/'+objReport.Id);
            report.setRedirect(true);
            return report;
        }catch(Exception e){
            return null;
        }
    }
    
    
    public String selectedReport{get;set;}
    public List<String> selectedCategories { get; set; }
    
    public List<SelectOption> getReportsOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        countryOptions.add(new SelectOption('','-None-'));
        countryOptions.add(new SelectOption('No Of Open Contracts','No Of Open Contracts'));
        countryOptions.add(new SelectOption('Number of Contracts','Number of Contracts'));
        System.debug('countryOptions: ' + countryOptions);
        return countryOptions;
    }
    
    
    public List<SelectOption> getCategories() {
    List<SelectOption> categories = new List<SelectOption>();
    System.debug('TCategories: ' + categories);   
    return categories;
        
    }
    
    
}

i tried command link,but its not wrorking in lightening
But the report showing in  inside the block,i want it in main report tab


public with sharing class ReportController {
    
    public PageReference showReports() {
        try{
            Report objReport = [Select Id from Report where name=:selectedReport];
            PageReference report = new PageReference('/'+objReport.Id);
            report.setRedirect(true);
            return report;
        }catch(Exception e){
            return null;
        }
    }
    
    
    public String selectedReport{get;set;}
    public List<String> selectedCategories { get; set; }
    
    public List<SelectOption> getReportsOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        countryOptions.add(new SelectOption('','-None-'));
        countryOptions.add(new SelectOption('No Of Open Contracts','No Of Open Contracts'));
        countryOptions.add(new SelectOption('Number of Contracts','Number of Contracts'));
        return countryOptions;
    }
    
    
    public List<SelectOption> getCategories() {
        
        List<SelectOption> categories = new List<SelectOption>();
        
        
        
        return categories;
        
    }
    
    
}

List <peer__Investment_Booking__c> TEMPInvestmentBookingList = new List<peer__Investment_Booking__c>();
            peer__Investment_Booking__c TEMPInvestmentBooking1;
            bookingOrderList = [SELECT Id, peer__Investor__c,Insured_Amount__c,Total_Insured_Amount__c FROM peer__Booking_Order__c WHERE peer__Investor__c =: account.Id];
          

          
          Map<String,List<peer__Investment_Booking__c>> mapBookingOrder = new Map<String,List<peer__Investment_Booking__c>>();
          
          for(peer__Investment_Booking__c peer : [SELECT peer__Investment_Amount__c,Insured_Percentage__c,Insured_Amount__c,Premium_Component__c,peer__Loan_Application__c
                                         FROM peer__Investment_Booking__c WHERE peer__Booking_Order__c in: bookingOrderList]) {
            if(!mapBookingOrder.containsKey(peer.peer__Booking_Order__c)) {
                List<peer__Investment_Booking__c> lstinvestBooking =  new List<peer__Investment_Booking__c>();
                mapBookingOrder.put(peer.peer__Booking_Order__c,lstinvestBooking);
            }
            mapBookingOrder.get(peer.peer__Booking_Order__c).add(peer);
          }
                
          for(i=0;i<bookingOrderList.size();i++)
            {
                bookingOrder = bookingOrderList.get(i);
                investmentBookingList = mapBookingOrder.get(bookingOrder.Id);//[SELECT peer__Investment_Amount__c,Insured_Percentage__c,Insured_Amount__c,Premium_Component__c,peer__Loan_Application__c
                                        // FROM peer__Investment_Booking__c WHERE peer__Booking_Order__c =: bookingOrder.Id];
                for(j=0;j<investmentBookingList.size();j++)
                {
                    investmentBooking = investmentBookingList.get(j);
                    TEMPInvestmentBookingList.add(investmentBooking);
                }
            }
            for(i=0;i<TEMPInvestmentBookingList.size();i++)
            {
                investmentBooking = TEMPInvestmentBookingList.get(i);
                j=i+1;
                while(j<TEMPInvestmentBookingList.size())
                {
                    TEMPInvestmentBooking1 = TEMPInvestmentBookingList.get(j);
                    if(investmentBooking.peer__Loan_Application__c == TEMPInvestmentBooking1.peer__Loan_Application__c)
                    {
                        investmentBooking.peer__Investment_Amount__c = investmentBooking.peer__Investment_Amount__c + TEMPInvestmentBooking1.peer__Investment_Amount__c;
                        TEMPInvestmentBookingList.remove(j);
                    }
                    else{
                        j++;
                    }
                }
                }
 List <peer__Investment_Booking__c> TEMPInvestmentBookingList = new List<peer__Investment_Booking__c>();
            peer__Investment_Booking__c TEMPInvestmentBooking1;
            bookingOrderList = [SELECT Id, peer__Investor__c,Insured_Amount__c,Total_Insured_Amount__c FROM peer__Booking_Order__c WHERE peer__Investor__c =: account.Id];
              /*List<Id> bookingId = new List<Id>();
            for(peer__Booking_Order__c tempbookingOrder:bookingOrderList){
                 bookingId.add(tempbookingOrder.Id);               
            }
            investmentBookingList = [SELECT peer__Investment_Amount__c,Insured_Percentage__c,Insured_Amount__c,Premium_Component__c,peer__Loan_Application__c
                                         FROM peer__Investment_Booking__c WHERE peer__Booking_Order__c IN :bookingId];
            for(j=0;j<investmentBookingList.size();j++)
                {
                    investmentBooking = investmentBookingList.get(j);
                    TEMPInvestmentBookingList.add(investmentBooking);
                }*/
          for(i=0;i<bookingOrderList.size();i++)
            {
                bookingOrder = bookingOrderList.get(i);
                investmentBookingList = [SELECT peer__Investment_Amount__c,Insured_Percentage__c,Insured_Amount__c,Premium_Component__c,peer__Loan_Application__c
                                         FROM peer__Investment_Booking__c WHERE peer__Booking_Order__c =: bookingOrder.Id];
                for(j=0;j<investmentBookingList.size();j++)
                {
                    investmentBooking = investmentBookingList.get(j);
                    TEMPInvestmentBookingList.add(investmentBooking);
                }
            }
            for(i=0;i<TEMPInvestmentBookingList.size();i++)
            {
                investmentBooking = TEMPInvestmentBookingList.get(i);
                j=i+1;
                while(j<TEMPInvestmentBookingList.size())
                {
                    TEMPInvestmentBooking1 = TEMPInvestmentBookingList.get(j);
                    if(investmentBooking.peer__Loan_Application__c == TEMPInvestmentBooking1.peer__Loan_Application__c)
                    {
                        investmentBooking.peer__Investment_Amount__c = investmentBooking.peer__Investment_Amount__c + TEMPInvestmentBooking1.peer__Investment_Amount__c;
                        TEMPInvestmentBookingList.remove(j);
                    }
                    else{
                        j++;
                    }
                }
            }

public static void createInvestmentBooking(String investorId, String bookingOrderId, String loanApplicationId, Decimal investmentAmount,
                                               Decimal certificateRate, Decimal serviceRate, String Authorization)
    {
        System.debug('Inside createInvestmentBooking method.');
        JSONGenerator generator = JSON.createGenerator(true);
        generator.writeStartObject();
        generator.writeStringField('investorId', investorId);
        generator.writeStringField('bookingOrderId', bookingOrderId);
        generator.writeStringField('loanApplication', loanApplicationId);
        generator.writeNumberField('investmentAmount', investmentAmount);
        generator.writeNumberField('certificateRate', certificateRate);
        generator.writeNumberField('serviceRate', serviceRate);
        generator.writeEndObject();
        String jsonString = generator.getAsString();
        System.debug('jsonString = '+jsonString);
        HttpRequest request = new HttpRequest();
        request.setMethod('POST');
        String urlName = URL.getSalesforceBaseUrl().toExternalForm()+'/services/apexrest/peer/v/inves';
        System.debug('Booking URL = '+urlName);
        
        request.setEndpoint(urlName);
        request.setHeader('Authorization', Authorization);
        request.setHeader('Content-Type', 'application/json');
        request.setBody(jsonString);    
        Http http = new Http();
        response = http.send(request);
        System.debug('response.getStatus() in createInvestmentBooking = '+response.getStatus());
        System.debug('Fulfillment service returned in createInvestmentBooking'+ response.getBody());
I have the 3 profile in sandbox
Profile A,profile B, super admin profile,profile A should nt see the profile B records where as profile B should not see the profile A..super admin can able to see the profile A and profile B records..can anyone please how to achieve this scenario 
I am reading csv file using apex class ,,I am getting error as Invalid Decimal

 Amount  = csvRecordData[0];
             System.debug('The Amount value is : '+Amount );
             
             Decimal decVal = Decimal.ValueOf(Amount);
             accObj.Transaction_Amount__c = decVal;
             
            System.debug('The value issssssssssssssssss: ' +decVal);
                         
             acclist.add(accObj);  
The Transaction_Amount__c is not updating in the Investor_Banking_Info_Entries__c object,iam retrieving the value in Amount variable,Can anyone please tell how to assign this varible to Transaction_Amount__c field

public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public string Amount;



public List<Investor_Banking_Info_Entries__c> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Investor_Banking_Info_Entries__c>();
       
  }
 
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++){
           
               Investor_Banking_Info_Entries__c accObj = new Investor_Banking_Info_Entries__c() ;
                 
               
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.Investor_Name__c = csvRecordData[0] ;
               accObj.Account_Number__c  = csvRecordData[1];  
               Amount  = csvRecordData[2];
              System.debug('The value isSSSSSSSSSSSSSSSSSSSSSSSSSS: ' +Amount );
                           
              Amount = string.valueof(accObj.Transaction_Amount__c);
               
               System.debug('The value is: ' +Amount );
                           
               acclist.add(accObj);   
           }
        insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}

I have a object called Investor_Banking_Info_Entries__c ,I am uploading  bank account number,Transaction Amount the CSV file using VF page and apex classes,
I am uploading the bank account number in Investor_Banking_Info_Entries__c,
I have a another object called Bank_Account__c ,i have to check if the

bank account number = Bank_Account__c.Account_number,

If both account number is  same,i want to update the tranaction amount in another object called  loan__Investor_Fund_Transaction__c object.

trigger AutoPostingEntries on Investor_Banking_Info_Entries__c (after delete, after undelete,after update) {
     set<Id> accIds = new set<Id>();
     if(trigger.isinsert || trigger.isUpdate || trigger.Isundelete)
    {
        for(Investor_Banking_Info_Entries__c con: Trigger.new)
        {
            accIds.add(con.Account_Name__c);            
        }
    }
    
  List<Account> accList = [select  id,Bank_Account__c ( Select Id,name,loan__Bank_Name__c,Name_as_per_Bank__c,loan__Bank_Account_Number__c from Bank_Account__r ) from Account Where ID IN :accIds ] ;
}

 
Apex Class:
@RestResource(urlMapping='/WSItemMasterProductFacilities/*')
global class  WSItemMasterProductFacilities {
   
   @HttpPost
    global static Response ItemMasterProductFacilities() {
    
        RestRequest req = RestContext.request;
        RestResponse restRes = RestContext.response;
        Response res = new Response('ItemMasterProductFacilities');
 
         PBSI__PBSI_Item__c  ItemMaster = new PBSI__PBSI_Item__c();
         List <PBSI__PBSI_Item__c> itemMasterList = new List<PBSI__PBSI_Item__c>();
        
         WrapperItemMasterparticipatedList  ItemTrans = new WrapperItemMasterparticipatedList();
         List<WrapperItemMasterparticipatedList> ItemTransData = new List<WrapperItemMasterparticipatedList>();
        

        String ItemMasterId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        ItemMasterId = ItemMaster.Id;
        System.debug('ItemMasterId  in WSItemMasterProductFacilities = '+ItemMasterId);
        if(ItemMasterId!= null)
        {
            res.errorCode ='INVALID_INPUT';
            res.status = 'ERROR';
            res.message = 'ID_NOT_PRESENT_IN_HEADER';
            res.statuscode = 'HTTP_BAD_REQUEST';
            return res;
        }
     try
        {
        integer j;
        Integer  status ;
        Integer  backorders;
        Integer enable_qty_increments;
        Integer is_in_stock;
        Integer is_qty_decimal;
        Integer manage_stock;
        Integer max_sale_qty;
        Integer  min_qty;
        Integer  min_sale_qtynotify_stock_qty;
        Integer qty ;                   
        Integer use_config_manage_stock;
        Integer use_config_min_qty;
        Integer use_config_min_sale_qty;
        Integer use_config_max_sale_qty;
        Integer use_config_backorders;
        Integer use_config_enable_qty_inc;
        Integer use_config_notify_stock_qty;
        Integer tax_class_id;
        String type_id;
        Integer pageLayout = 2;
        Integer use_config_gift_message_available;
        Integer   visibility;
            
            
         PBSI__PBSI_Item__c  ItemMasterProdList;
         itemMasterList  = [Select id,Name,PBSI__Item_Code__c,PBSI__Item_Description_Long__c,Color__c,Series__c,Color_Family__c,Grade__c,
                            Default_Country_of_Origin__c,Additional_SO_Description__c,PBSI__description__c,
                            Datasheet__c,LeadTime__c,Default_UM__c,Finish__c,Finish_Family__c,PBSI__Item_Group__r.name,Installation_Material_Groups__c,
                            PBSI__salesprice__c,Recycled_Content__c,Shade_Variation__c,Size__c,PBSI__netweight__c,Installation_Material_Code__c,
                            Weight_UM__c,Color_Code__c,Available_for_Sale__c,Type__c,Subtype__c,Application__c,Material_Codes__c,
                            Stock_Item__c,COF_Dry__c,Sell_on_Website__c,Materials_Group__c,COF_Wet__c,Size_Code__c,type_subtype_codes__c,Finish_Code__c,Commercial_grade_codes__c,Application_Code__c,DCOF__c FROM PBSI__PBSI_Item__c where Sell_on_Website__c = true OR Show_on_Website__c = true];
            
         for(j=0;j<itemMasterList.size();j++)
                {
                ItemTrans = new WrapperItemMasterparticipatedList();
                ItemMasterProdList = itemMasterList.get(j);
                system.debug('ItemMasterProdList  LIST ------->'+ItemMasterProdList);
                ItemTrans.PBSI_salesprice = ItemMasterProdList.PBSI__salesprice__c;
                ItemTrans.entity_id  = ItemMasterProdList.name;
                ItemTrans.application = ItemMasterProdList.Application__c;
                ItemTrans.description = ItemMasterProdList.PBSI__description__c;
                ItemTrans.sku = ItemMasterProdList.PBSI__Item_Code__c;
                ItemTrans.item_code = ItemMasterProdList.PBSI__Item_Code__c;
                ItemTrans.qty = ItemMasterProdList.Available_for_Sale__c;  
                ItemTrans.cofDry = ItemMasterProdList.COF_Dry__c;
                ItemTrans.color_Code = ItemMasterProdList.Color_Code__c;
                ItemTrans.finishCode  = ItemMasterProdList.Finish_Code__c;                
                ItemTrans.type_Subtype = ItemMasterProdList.type_subtype_codes__c;
                ItemTrans.commercial_grade = ItemMasterProdList.Commercial_grade_codes__c;
                ItemTrans.Size = ItemMasterProdList.Size__c;
                ItemTrans.materialCodes = ItemMasterProdList.Material_Codes__c;
                ItemTrans.installationMaterialCode = ItemMasterProdList.Installation_Material_Code__c;
                ItemTrans.applicationCodes = ItemMasterProdList.Application_Code__c;
                ItemTrans.types = ItemMasterProdList.Type__c;
                ItemTrans.subtype = ItemMasterProdList.Subtype__c;
                ItemTrans.stockItem = ItemMasterProdList.Stock_Item__c;
                ItemTrans.cofWet =   ItemMasterProdList.COF_Wet__c;  
                ItemTrans.dCof = ItemMasterProdList.DCOF__c;  
                ItemTrans.color = ItemMasterProdList.Color__c;
                ItemTrans.series =  ItemMasterProdList.Series__c;  
                ItemTrans.colorFamily =  ItemMasterProdList.Color_Family__c;
                ItemTrans.grade = ItemMasterProdList.Grade__c;
                ItemTrans.countryOrigin = ItemMasterProdList.Default_Country_of_Origin__c;
                ItemTrans.dataSheet = ItemMasterProdList.Datasheet__c;  
                ItemTrans.leadTime = ItemMasterProdList.LeadTime__c;
                ItemTrans.finish = ItemMasterProdList.Finish__c;
                ItemTrans.finishFamily = ItemMasterProdList.Finish_Family__c;
                ItemTrans.itemGroup = ItemMasterProdList.PBSI__Item_Group__r.name;   
                ItemTrans.installationMaterialgroup = ItemMasterProdList.Installation_Material_Groups__c;
                ItemTrans.recyledContent = ItemMasterProdList.Recycled_Content__c;
                ItemTrans.shadeVariation = ItemMasterProdList.Shade_Variation__c;
               // ItemTrans.Size = ItemMasterProdList.Size__c;
                ItemTrans.pbsiNetWeight = ItemMasterProdList.PBSI__netweight__c;
                ItemTrans.weightUm = ItemMasterProdList.Weight_UM__c;
                ItemTrans.salesum =  ItemMasterProdList.Default_UM__c  ;
                ItemTransData.add(ItemTrans);
                system.debug('ItemTransDataLIST ------->'+ItemTransData);  
             }
          //Sending Response
          res.ItemTransData  = ItemTransData;
          res.statuscode = 'HTTP_OK';
          res.status = 'SUCCESS';
          return res;
            }
         catch (Exception e) {
            System.debug('Exception e is ='+e);
            res.errorCode = 'Line number= '+e.getLineNumber()+' Message is= ' +e.getmessage();
            res.status = 'ERROR';
            res.message = 'Internal Exeption Occurred';
            res.statuscode = 'HTTP_INTERNAL_ERROR';
            return res;
        
    }
}
}


Test Class:

@isTest(SeeAllData=true)
public class TestWsItemMasterProductFacilities {
    
    
    

  private Static testMethod void testFunction()
     {
        System.RestContext.request = new RestRequest();
        System.RestContext.response = new RestResponse();
        RestContext.request.requestBody = Blob.valueOf('{}');
        
        
      WSItemMasterProductFacilities.ItemMasterProductFacilities();
         
        RestContext.request.addHeader('Account-ID', 'temp');
        WSItemMasterProductFacilities.ItemMasterProductFacilities();
     }
    
    private Static testMethod void testFunction1()
     {
        System.RestContext.request = new RestRequest();
        System.RestContext.response = new RestResponse();
        RestContext.request.requestBody = Blob.valueOf('{}');
         
     
        PBSI__PBSI_Item__c  ItemMaster = new PBSI__PBSI_Item__c();
        insert  ItemMaster;
         
      RestContext.request.addHeader('Account-ID', ItemMaster.id);
       WSItemMasterProductFacilities.ItemMasterProductFacilities();
     }
}

 
         
             Decimal total_amt = 0.0;
             Base_live_funded_amount__c  obj1 = Base_live_funded_amount__c.getInstance('Base_Live_Amount_funded_so_far__c');
            for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where  status__c =' Funded' AND  peer__Amount_Funded__c!=NULL) from Account Where Type='Borrower'])
            {
                       for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r)
                      {
                        
                         total_amt = total_amt + temp.peer__Amount_Funded__c;
                        
                            if( total_amt != null &&  total_amt >0)
                            {
                               total_amt  +=obj1.Base_Live_Amount_funded_so_far__c+total_amt;
                               total_amt =  obj1.Base_Live_Amount_funded_so_far__c ;
                                system.debug('TTTTTTTTTTTTTTTTTTTTTTT -----------:'+total_amt);
                            
                             }

                       }

              
    
        
           }

 
I need to sum all the value of peer_amount_funded__c .
And i have created the custom field in custom Setting Base_value__c..I  want to sum all the value of peer_amount__c and add it to base_value__C..Please help me  on this

for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where  status__c =' Funded' ) from Account Where Type='Borrower'])
            {
                      Decimal total_amt = 0.0;
                      for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r){
                       total_amt = total_amt + temp.peer__Amount_Funded__c;
                       }
           obj.Total_Amount_Funded__c =  total_amt;
           system.debug('LOAN DISBURSED SO FAR -----------:'+total_amt);  
           }
Now i want to apply this trigger and formula field values for existing records also,Can you pleas any one tell how to update this

I want to update the custom field - Finish_Code__c from PBSI__PBSI_Item__c object..please help me anyone
trigger ColorCodes on PBSI__PBSI_Item__c (after insert,after update) {
    
 Set<string> aliasscope = new Set<String>();  
   
 List<Item_Master_Color__c> mo = Item_Master_Color__c.getall().values();
 system.debug('ItemTransDataLIST ------->'+mo);
    
    for (PBSI__PBSI_Item__c  itemCod : Trigger.new) {
    aliasscope.add(itemCod.Color__c);

    }
    
    
}

I have created the custom Settings(list) called Item_Master_Color__c,I have name and Color Code fileds in Item_Master_Color__c(Custom settings).I want to update the the custom Setting color code dynamically in (-Item_Color_Code__c)Custom field in  PBSI__PBSI_Item__c object,If i insering and updating the record in PBSI__PBSI_Item__c object,I want to automatically update the  custom Setting COlor Code

In Custom Setting i have a  name -PINK
                                        color_Code-789
 
I am not giving any color code in record,I need to  get   the color  code dynamically .Please tell me how to acheive tiz
if Color__c = Pink
Color Code =780,

Like this i have  50 Color,How to acheive this
@RestResource(urlMapping='/WSItemMasterProductFacilities')
global class  WSItemMasterProductFacilities {
    
   @HttpPost
    global static Response ItemMasterProductFacilities() {
    
        RestRequest req = RestContext.request;
        RestResponse restRes = RestContext.response;
        Response res = new Response('ItemMasterProductFacilities');
 
        //Headers from request
        String accountId = req.headers.get('Account-ID');
        System.debug('accountId in WSBorrowerReports = '+accountId);
        if(accountId == null)
        {
            //res.errorCode = peer.Constants.INVALID_INPUT;
            res.status = peer.Constants.ERROR;
           res.message = 'ACCOUNT_ID_NOT_PRESENT_IN_HEADER';
            restRes.statuscode = peer.Constants.HTTP_BAD_REQUEST;
            return res;
        }
     try
        {
          String j;
         //String NameValue = req.params.get('name');
         List <PBSI__PBSI_Item__c> itemMasterList = new List<PBSI__PBSI_Item__c>();
         PBSI__PBSI_Item__c  loanDisbursalTrans;
         WrapperItemMasterparticipatedList  ItemTrans = new WrapperItemMasterparticipatedList();
         List<WrapperItemMasterparticipatedList> ItemTransData = new List<WrapperItemMasterparticipatedList>();

        
         itemMasterList  = [Select id,Name from PBSI__PBSI_Item__c];
         for(j=0;j<itemMasterList.size();j++)
                {
                ItemTrans = new WrapperItemMasterparticipatedList();
                loanDisbursalTrans = itemMasterList.get(j);
                ItemTrans.entity_id  = loanDisbursalTrans.name;
                ItemTransData.add(ItemTrans);
                
            }
        
        //Sending Response
          res.ItemTransData  = ItemTransData;
         // restRes.statuscode = peer.Constants.HTTP_OK;
           res.status = peer.Constants.SUCCESS;
            return res;
            }
         catch (Exception e) {
            System.debug('Exception e is ='+e);
            res.errorCode = 'Line number= '+e.getLineNumber()+' Message is= ' +e.getmessage();
            res.status = peer.Constants.ERROR;
            res.message = 'Internal Exeption Occurred';
            restRes.statuscode = peer.Constants.HTTP_INTERNAL_ERROR;
            return res;
        
    }
}
}



ERROR:Variable does not exist: peer.Constants.INVALID_INPUT
if any records created in Custom object,I hve written code,I have added the URL in Remote site settings,But in POSTMAN is not working
MY POSTMAN URL:https://aci--uat.cs23.my.salesforce.com/services/apexrest/WSItemMasterProductFacilities
REMOTE SITE SETTING URL:https://aci--uat.cs23.my.salesforce.com

@RestResource(urlMapping='/WSItemMasterProductFacilities')
global class  WSItemMasterProductFacilities {
    
     @HttpGet
    global static List<PBSI__PBSI_Item__c> getWidgets() {
        List<PBSI__PBSI_Item__c> widgets = [SELECT Name from PBSI__PBSI_Item__c];
        return widgets;
    }
    @HttpPost
    global static List<PBSI__PBSI_Item__c> ItemMasterProductFacilities()
    {
       List<PBSI__PBSI_Item__c> itemMaster;
       
        try
        {
         RestRequest req = RestContext.request;
         String NameValue = req.params.get('name');   
         itemMaster = [Select id,Name from PBSI__PBSI_Item__c];   
         return itemMaster;  
            }
        catch(Exception e)
        {
        System.debug('Line Number is = '+e.getLineNumber()+' Message is = ' +e.getMessage());
         }
        return itemMaster;  
        
    }
}
@RestResource(urlMapping='/WSItemMasterProductFacilities')
global class  WSItemMasterProductFacilities {
    @HttpPost
    global static List<PBSI__PBSI_Item__c> ItemMasterProductFacilities()
    {
       List<PBSI__PBSI_Item__c> itemMaster;
       
        try
        {
         RestRequest req = RestContext.request;
         String NameValue = req.params.get('name');   
         itemMaster = [Select id,Name from PBSI__PBSI_Item__c];   
         return itemMaster;  
            }
        catch(Exception e)
        {
        System.debug('Line Number is = '+e.getLineNumber()+' Message is = ' +e.getMessage());
         }
        return itemMaster;  
        
    }
}



The URL which i have added in remoteSite Setting:https://aci--uat.cs23.my.salesforce.com
The records to be inserted in Salesforce,I want to give the Rest API(POST) to magento,Whenever i insert or update any record i need to give that data  as a json format,Please help me ,How to do that?


Thanks in Advance,
Gyan....
 
Now i want to apply this trigger and formula field values for existing records also,Can you pleas any one tell how to update this

I want to update the custom field - Finish_Code__c from PBSI__PBSI_Item__c object..please help me anyone
hi,

        I want to update the picklist option dynamically  in picklist field while i selecting the  picklist option in another picklist field ,for example 

  1.state(picklist field)--india,america,if i chose the picklist option as america and clicks any button,it (america)will update in another pickist field.and also have to open the two text fields also.

thanks,
 List <peer__Investment_Booking__c> TEMPInvestmentBookingList = new List<peer__Investment_Booking__c>();
            peer__Investment_Booking__c TEMPInvestmentBooking1;
            bookingOrderList = [SELECT Id, peer__Investor__c,Insured_Amount__c,Total_Insured_Amount__c FROM peer__Booking_Order__c WHERE peer__Investor__c =: account.Id];
              /*List<Id> bookingId = new List<Id>();
            for(peer__Booking_Order__c tempbookingOrder:bookingOrderList){
                 bookingId.add(tempbookingOrder.Id);               
            }
            investmentBookingList = [SELECT peer__Investment_Amount__c,Insured_Percentage__c,Insured_Amount__c,Premium_Component__c,peer__Loan_Application__c
                                         FROM peer__Investment_Booking__c WHERE peer__Booking_Order__c IN :bookingId];
            for(j=0;j<investmentBookingList.size();j++)
                {
                    investmentBooking = investmentBookingList.get(j);
                    TEMPInvestmentBookingList.add(investmentBooking);
                }*/
          for(i=0;i<bookingOrderList.size();i++)
            {
                bookingOrder = bookingOrderList.get(i);
                investmentBookingList = [SELECT peer__Investment_Amount__c,Insured_Percentage__c,Insured_Amount__c,Premium_Component__c,peer__Loan_Application__c
                                         FROM peer__Investment_Booking__c WHERE peer__Booking_Order__c =: bookingOrder.Id];
                for(j=0;j<investmentBookingList.size();j++)
                {
                    investmentBooking = investmentBookingList.get(j);
                    TEMPInvestmentBookingList.add(investmentBooking);
                }
            }
            for(i=0;i<TEMPInvestmentBookingList.size();i++)
            {
                investmentBooking = TEMPInvestmentBookingList.get(i);
                j=i+1;
                while(j<TEMPInvestmentBookingList.size())
                {
                    TEMPInvestmentBooking1 = TEMPInvestmentBookingList.get(j);
                    if(investmentBooking.peer__Loan_Application__c == TEMPInvestmentBooking1.peer__Loan_Application__c)
                    {
                        investmentBooking.peer__Investment_Amount__c = investmentBooking.peer__Investment_Amount__c + TEMPInvestmentBooking1.peer__Investment_Amount__c;
                        TEMPInvestmentBookingList.remove(j);
                    }
                    else{
                        j++;
                    }
                }
            }
The Transaction_Amount__c is not updating in the Investor_Banking_Info_Entries__c object,iam retrieving the value in Amount variable,Can anyone please tell how to assign this varible to Transaction_Amount__c field

public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public string Amount;



public List<Investor_Banking_Info_Entries__c> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Investor_Banking_Info_Entries__c>();
       
  }
 
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++){
           
               Investor_Banking_Info_Entries__c accObj = new Investor_Banking_Info_Entries__c() ;
                 
               
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.Investor_Name__c = csvRecordData[0] ;
               accObj.Account_Number__c  = csvRecordData[1];  
               Amount  = csvRecordData[2];
              System.debug('The value isSSSSSSSSSSSSSSSSSSSSSSSSSS: ' +Amount );
                           
              Amount = string.valueof(accObj.Transaction_Amount__c);
               
               System.debug('The value is: ' +Amount );
                           
               acclist.add(accObj);   
           }
        insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}
         
             Decimal total_amt = 0.0;
             Base_live_funded_amount__c  obj1 = Base_live_funded_amount__c.getInstance('Base_Live_Amount_funded_so_far__c');
            for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where  status__c =' Funded' AND  peer__Amount_Funded__c!=NULL) from Account Where Type='Borrower'])
            {
                       for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r)
                      {
                        
                         total_amt = total_amt + temp.peer__Amount_Funded__c;
                        
                            if( total_amt != null &&  total_amt >0)
                            {
                               total_amt  +=obj1.Base_Live_Amount_funded_so_far__c+total_amt;
                               total_amt =  obj1.Base_Live_Amount_funded_so_far__c ;
                                system.debug('TTTTTTTTTTTTTTTTTTTTTTT -----------:'+total_amt);
                            
                             }

                       }

              
    
        
           }

 
I need to sum all the value of peer_amount_funded__c .
And i have created the custom field in custom Setting Base_value__c..I  want to sum all the value of peer_amount__c and add it to base_value__C..Please help me  on this

for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where  status__c =' Funded' ) from Account Where Type='Borrower'])
            {
                      Decimal total_amt = 0.0;
                      for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r){
                       total_amt = total_amt + temp.peer__Amount_Funded__c;
                       }
           obj.Total_Amount_Funded__c =  total_amt;
           system.debug('LOAN DISBURSED SO FAR -----------:'+total_amt);  
           }
Now i want to apply this trigger and formula field values for existing records also,Can you pleas any one tell how to update this

I want to update the custom field - Finish_Code__c from PBSI__PBSI_Item__c object..please help me anyone
trigger ColorCodes on PBSI__PBSI_Item__c (after insert,after update) {
    
 Set<string> aliasscope = new Set<String>();  
   
 List<Item_Master_Color__c> mo = Item_Master_Color__c.getall().values();
 system.debug('ItemTransDataLIST ------->'+mo);
    
    for (PBSI__PBSI_Item__c  itemCod : Trigger.new) {
    aliasscope.add(itemCod.Color__c);

    }
    
    
}

I have created the custom Settings(list) called Item_Master_Color__c,I have name and Color Code fileds in Item_Master_Color__c(Custom settings).I want to update the the custom Setting color code dynamically in (-Item_Color_Code__c)Custom field in  PBSI__PBSI_Item__c object,If i insering and updating the record in PBSI__PBSI_Item__c object,I want to automatically update the  custom Setting COlor Code

In Custom Setting i have a  name -PINK
                                        color_Code-789
 
I am not giving any color code in record,I need to  get   the color  code dynamically .Please tell me how to acheive tiz
if Color__c = Pink
Color Code =780,

Like this i have  50 Color,How to acheive this