• Deepak Geriani
  • NEWBIE
  • 90 Points
  • Member since 2018
  • Sr. Software Developer


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 25
    Replies
Hi there. I have an VF page which is refernced to an apex class which basically references another VF page. Need help with a test class for this.

Visual Force Page where Apex Class is referenced:
<apex:page sidebar="false" lightningStylesheets="true">
<apex:form id="theForm">
 <div align="center">
  <apex:page controller="T_Dashboards">
<b><apex:commandbutton action="{!tradersummary}" value="Trader Summary"></apex:commandbutton></b>
<b><apex:commandbutton action="{!traderbook}" value="Trader Book"></apex:commandbutton></b>
<b><apex:commandbutton action="{!creditutilizationtrader}" value="Credit Utilization - Trader"></apex:commandbutton></b>
</apex:page>

Apex Class:
public class T_Dashboards {
public PageReference tradersummary() {

        PageReference pgref = new PageReference('/apex/TraderSummary');
        pgref.setRedirect(true);
        return pgref;
    }

public PageReference traderbook() {
        PageReference pgref = new PageReference('/apex/TraderBook');
        pgref.setRedirect(true);
        return pgref;
    }

public PageReference creditutilizationtrader() {
        PageReference pgref = new PageReference('/apex/CreditUtilizationTrader');
        pgref.setRedirect(true);
        return pgref;
    }
}

Test Class:
@isTest 
public class TestTDashboards{
public static testmethod void myunitTest(){    
Test.startTest();    
PageReference pageRef = Page.T_Dashboards;  
Test.setCurrentPage(pageRef);
T_Dashboards acontroller = new T_Dashboards();
PageReference pageRef1=acontroller.tradersummary();
Test.stopTest(); 
}
}
Considering the attached Picture, i want to copy the A Delivery with all its related list to Container and Related List.  I mean,  The Value of Delivey will be a new record in the object Container and the Item Distributed of the object Delivery will become Arcticle Container for the object Container. 
The Code below saved well but it fires with the following error :
caused by: System.ListException: Before Insert or Upsert list must not have two identically equal elements. Line 51
trigger PostToAfficliateInventory on Delivery__c (after update) {

list <Container__c> con = new List <Container__c>();
list <Articles_Containers__c> contenairItems = new list <Articles_Containers__c>();

    for (Delivery__c d : Trigger.New){
         if (d.Is_Posted_To_Affiliate_Inventory__c){
             Container__c c = new  Container__c();
             c.Name = d.Automatic_Code__c;
             c.FFP_Centers__c = d.Affiliate_Center__c ;
             c.RecordTypeId = '0126A000000nMlU';
             c.Distribution_Center__c = d.AffiliateCenterId__c;
             c.Is_Owner_Shipper__c = 'No';
             c.Provenance__c = 'FFP PAP';
             c.Type__c = 'Food';
             c.Shipment_Status__c = 'A - AWAITING ARRIVAL';
             c.Is_Automatic_Creation__c = TRUE;
             
             con.add(c);  
             insert con;
          
             Articles_Containers__c ac = new Articles_Containers__c();
             list<Item_Distributed__c> itemList = new  list<Item_Distributed__c>();
             
             
             itemList = [SELECT id,Name, Product__r.Expiration_Date__c,Product__r.Unit_Cost__c,   
                                 Product__r.Lot_Number__c,  Product__r.Unit_Weight__c ,
                                 Product__r.UM__c, Product__r.Product__r.Id , Quantity__c 
                         FROM Item_Distributed__c  
                         WHERE Delivery__c =: d.Id];
          
             for (Item_Distributed__c OrderItems: itemList){

                 for(Integer i = 0; i<itemList.Size(); i++){
                     ac.FFP_Centers__c = d.Affiliate_Center__c ;
                    ac.RecordTypeId = '0126A0000019jRJ'; 
                     ac.Container__c =c.Id;
                     ac.Product__c = OrderItems.Product__r.Product__r.Id;
                     ac.Number__c= 0;
                     ac.Quantity__c = OrderItems.Quantity__c;
                     ac.Unit_Of_Measure_Paking__c= OrderItems.Product__r.UM__c;
                     ac.UM__c = OrderItems.Product__r.UM__c;
                     ac.Expiration_Date__c = OrderItems.Product__r.Expiration_Date__c;
                     ac.Lot_Number__c = OrderItems.Product__r.Lot_Number__c;
                     ac.Unit_Cost__c = OrderItems.Product__r.Unit_Cost__c;
                     ac.Unit_Weight__c =OrderItems.Product__r.Unit_Weight__c;
                     
                     contenairItems.add(ac);
                     Insert contenairItems;
                }
             }          
         }
    } 
}

User-added image
public class jsontest {

  public  loandetails loandetails{get;set;}
  
 public jsontest (){

 string teststring ='{"status":1,"data":[{"$id":"1","type":"A","InterestAmount":"2.90","TotalAmount":"198000.00","year":2018,"Name":"Axis BANK"},{"$id":"2","type":"B","InterestAmount":"3.90","TotalAmount":"158000.00","year":2019,"Name":"ICICI BANK"},{"$id":"3","type":"A","InterestAmount":"2.90","TotalAmount":"258000.00","year":2018,"Name":"HDFC BANK"}]}';
 
           Map<String, Object> mapobj= (Map<String, Object>)JSON.deserializeUntyped(teststring);
           system.debug('the Mapped and deserialized values are:'+ mapobj);
           
            list<Object> objj = (list<Object>)mapobj.get('data');
            system.debug('the data value is :::'+objj);
           
            string SerilizeEmpdata = system.json.serialize(objj);
           system.debug('After Serilization:::'+ SerilizeEmpdata);
           
            loandetails =(loandetails)system.json.deserialize(SerilizeEmpdata,loandetails.class);
             system.debug(loandetails);
             system.debug('binded to loan information is:::'+loandetails.name);     
 
 }
 
  //wrapperclass
 
  public class loandetails{
  
    public string type{get;set;}
    public string InterestAmount{get;set;}
    public string TotalAmount{get;set;}
    public integer year{get;set;}
    public string name{get;set;}
  } 
}

Getting an error: 
System.JSONException: Malformed JSON: Expected '{' at the beginning of object
Hi Team,

Anyone was have idea about how write a test class for below code.if knows please help me out.

public with sharing class ParentexampleController {    
    public Example Example{get;set;}
    public ActivityData activityData{get;set;}
    public Device deviceInfo{get;set;}
    public MGCDeviceInf MGCDeviceInfo{get;set;}

        List<Example> lstExample = [Select ID from Example where parentid__c=:parentid];
            if (lstExample != null && lstExample.size() > 0) {
                delete lstExample;
            }
            
            List<Activity_Tracker_Information__c> lstActivityTrackerInfo = [Select ID from Activity_Tracker_Information__c where parentid__c=:parentid];
            if (lstActivityTrackerInfo != null && lstActivityTrackerInfo.size() > 0) {
                delete lstActivityTrackerInfo;
            }
            
            Example Example = new Example();
            Example.parentid__c = parentid;
            Example.ReadingLatestDate__c = Example.ReadingLatestDate;
            Example.ReadingLatestDate__c = Example.ReadingLatestDate;
            insert Example;
            
            if (obj.activityTrackerData != null && obj.activityTrackerData.Name != null) {
                List<Activity_Tracker_Information__c> lstActivityTracker = new List<Activity_Tracker_Information__c>();
                Activity_Tracker_Information__c activity = new Activity_Tracker_Information__c();
                activity.parentid__c = parentid;
                activity.Name__c = activityTrackerData.Name;
                activity.Last_Sync_Date__c = activityTrackerData.CreatedDateTime;
                lstActivityTracker.add(activity);
                insert lstActivityTracker;
            }
            
            if (obj.MGCDeviceInfo != null && obj.MGCDeviceInfo.Status != null) {
                if (obj.MGCDeviceInfo.Status == 1) {
                    MGCDeviceInfo.StatusDescription = 'Active';
                }
                else if (obj.MGCDeviceInfo.Status == 2) {
                    MGCDeviceInfo.StatusDescription = 'InActive';
                }
            }
}catch (System.NullPointerException e){
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
    }
    
    public class ParentRequestData{
        public String StarID {get;set;}
        public String parentid {get;set;}
    }


Thanks inadvance,
Raju.
global with sharing class PriceAdjustmentHookImpl implements vlocity_cmt.VlocityOpenInterface
{
    global Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)  
    {
        try
        {
            System.debug('____ PriceAdjustmentHookImpl' + methodName);
            
            if (methodName.equalsIgnoreCase('calculate.PreInvoke'))
            {
                system.debug('invoked pre');
                List<OrderItem> itemList = (List<OrderItem>)vlocity_cmt.PricingPlanService.getFromPricingContext('LineItemList'); 
                system.debug(LoggingLevel.ERROR, 'itemList' + itemList);
                String  itemList1= '';//(String)itemMap.get('vlocity_cmt__Action__c');
                
                if(itemList[0].vlocity_cmt__Action__c=='Existing')  
                {   
                  System.debug('--- calculate.PreInvoke input: ' + JSON.serialize(input));
                  Map<String, Object> pricingVariableCodeToValueMap = (Map<String, Object>)input.get('pricingVariableMap');
                  Decimal REC_MNTH_STD_PRC = (Decimal)pricingVariableCodeToValueMap.get('REC_MNTH_STD_PRC');
                  system.debug('REC_MNTH_STD_PRC'+REC_MNTH_STD_PRC);
                  pricingVariableCodeToValueMap.put('REC_MNTH_STD_PRC', 0.0); 
               }
            else if (methodName.equalsIgnoreCase('calculate.PostInvoke'))
            {                
              system.debug('invoked post');
 
            }
           }
            return true;
        }
        catch (Exception ex)
        {
            System.debug('--- Exception: ' + ex.getMessage());
            System.debug('--- Stack Trace: ' + ex.getStackTraceString());
            throw ex;
        }
    }
}
Whenever a Campaign member of type lead is inserted, check the RSVP field on campaign member, if it is blank and if the Lead RSVP field has value we would need to update that value on the Campaign member RSVP field.
Hi,
I am sending the Email with Email template via apex. But The letterhead like header and footer are not visible Can anyone help. Its urgent.

Thanks in advance
I need move variables to a file and use it in apex classes. How do this?
Hi All,

I have an object with a start date and an end date. I am trying to create insert weekly dates in one object and a list of dates between the start date and end date in another object.
Object A
start Date    End Date
10/01/2020  10/31/2020
Object B
start date      end date          Object A ID
10/01/2020     10/07/2020
10/07/2020     10/14/2020
10/14/2020     10/21/2020
10/21/2020     10/27/2020
10/27/2020       11/03/2020

Object C
Date              Object BID   Object A ID
10/01/2020
10/02/2020
10/03/2020
---
--
10/31/2020

I have created lookup from Object B to Object A and Object C to Object B and Object C to Object B.
Is it possible to map Object B and Object C. How can I populate Object B Id in Object C? Can anyone send a sample code?

Thanks,
Sirisha
Hi, we are doing site migration from our old e-commerce website platform into a salesforce environment, as a part of it, we are finding a way to do the dynamic mapping from our old product pages to new product pages in salesforce.
Since we couldn’t find a proper pattern in our old product page URL, it’s making complex to do redirection with dynamic mapping rule. Here I’m mentioning our old URL path and new URL structure in SFCC. Could anyone please help what dynamic mapping rule would match this?


Old structure: domain.com/nike-airmax-270-shoe-N-6574-06

New Salesforce URL structure: domain.com/ nike-airmax-270-shoe/N-6574-06.html

Nike – brand name
airmax-270-shoe – Product name

N-6574-06 - ID

Since we have more than 50,000 product URLs, static mapping is a really time-consuming and big effort. So kindly help me if any other better ways or ideas with dynamic mapping for common redirection.
 

Hi, I am a newbie to Salesforce (literally a newbie) but I do have experience in SPA Web Development with Angular & React.  As a newbie in SF, I am struggling with not knowing what schema or directive to import when working on the Lightning Web Component in VS Code.

I have already installed the Salesforce Extension Pack but it does not appear to have the "auto-import" feature.  With Angular, I can select the yellow lightbulb and the VS Code will insert the correct import schema or directive.  I am curious if there is something like that with Salesforce LWC development?

Hello,

I am looking to do the following:
When a new case is created with a custom field (Unique ID) populated i want SFDC to find the matching unique ID in an account record and then autopopulate the Account name on the case object.

I appreciate any help i can get!

Thank you,
Leonie
Hi there. I have an VF page which is refernced to an apex class which basically references another VF page. Need help with a test class for this.

Visual Force Page where Apex Class is referenced:
<apex:page sidebar="false" lightningStylesheets="true">
<apex:form id="theForm">
 <div align="center">
  <apex:page controller="T_Dashboards">
<b><apex:commandbutton action="{!tradersummary}" value="Trader Summary"></apex:commandbutton></b>
<b><apex:commandbutton action="{!traderbook}" value="Trader Book"></apex:commandbutton></b>
<b><apex:commandbutton action="{!creditutilizationtrader}" value="Credit Utilization - Trader"></apex:commandbutton></b>
</apex:page>

Apex Class:
public class T_Dashboards {
public PageReference tradersummary() {

        PageReference pgref = new PageReference('/apex/TraderSummary');
        pgref.setRedirect(true);
        return pgref;
    }

public PageReference traderbook() {
        PageReference pgref = new PageReference('/apex/TraderBook');
        pgref.setRedirect(true);
        return pgref;
    }

public PageReference creditutilizationtrader() {
        PageReference pgref = new PageReference('/apex/CreditUtilizationTrader');
        pgref.setRedirect(true);
        return pgref;
    }
}

Test Class:
@isTest 
public class TestTDashboards{
public static testmethod void myunitTest(){    
Test.startTest();    
PageReference pageRef = Page.T_Dashboards;  
Test.setCurrentPage(pageRef);
T_Dashboards acontroller = new T_Dashboards();
PageReference pageRef1=acontroller.tradersummary();
Test.stopTest(); 
}
}
Considering the attached Picture, i want to copy the A Delivery with all its related list to Container and Related List.  I mean,  The Value of Delivey will be a new record in the object Container and the Item Distributed of the object Delivery will become Arcticle Container for the object Container. 
The Code below saved well but it fires with the following error :
caused by: System.ListException: Before Insert or Upsert list must not have two identically equal elements. Line 51
trigger PostToAfficliateInventory on Delivery__c (after update) {

list <Container__c> con = new List <Container__c>();
list <Articles_Containers__c> contenairItems = new list <Articles_Containers__c>();

    for (Delivery__c d : Trigger.New){
         if (d.Is_Posted_To_Affiliate_Inventory__c){
             Container__c c = new  Container__c();
             c.Name = d.Automatic_Code__c;
             c.FFP_Centers__c = d.Affiliate_Center__c ;
             c.RecordTypeId = '0126A000000nMlU';
             c.Distribution_Center__c = d.AffiliateCenterId__c;
             c.Is_Owner_Shipper__c = 'No';
             c.Provenance__c = 'FFP PAP';
             c.Type__c = 'Food';
             c.Shipment_Status__c = 'A - AWAITING ARRIVAL';
             c.Is_Automatic_Creation__c = TRUE;
             
             con.add(c);  
             insert con;
          
             Articles_Containers__c ac = new Articles_Containers__c();
             list<Item_Distributed__c> itemList = new  list<Item_Distributed__c>();
             
             
             itemList = [SELECT id,Name, Product__r.Expiration_Date__c,Product__r.Unit_Cost__c,   
                                 Product__r.Lot_Number__c,  Product__r.Unit_Weight__c ,
                                 Product__r.UM__c, Product__r.Product__r.Id , Quantity__c 
                         FROM Item_Distributed__c  
                         WHERE Delivery__c =: d.Id];
          
             for (Item_Distributed__c OrderItems: itemList){

                 for(Integer i = 0; i<itemList.Size(); i++){
                     ac.FFP_Centers__c = d.Affiliate_Center__c ;
                    ac.RecordTypeId = '0126A0000019jRJ'; 
                     ac.Container__c =c.Id;
                     ac.Product__c = OrderItems.Product__r.Product__r.Id;
                     ac.Number__c= 0;
                     ac.Quantity__c = OrderItems.Quantity__c;
                     ac.Unit_Of_Measure_Paking__c= OrderItems.Product__r.UM__c;
                     ac.UM__c = OrderItems.Product__r.UM__c;
                     ac.Expiration_Date__c = OrderItems.Product__r.Expiration_Date__c;
                     ac.Lot_Number__c = OrderItems.Product__r.Lot_Number__c;
                     ac.Unit_Cost__c = OrderItems.Product__r.Unit_Cost__c;
                     ac.Unit_Weight__c =OrderItems.Product__r.Unit_Weight__c;
                     
                     contenairItems.add(ac);
                     Insert contenairItems;
                }
             }          
         }
    } 
}

User-added image

Hi there,
I'm trying to display my app on salesforce using canvas and if I see my app on my web browser it shows the app as it's supposed to, however, if I use exactly the same url on salesforce canvas, I get a completely different app.

My url is something like "https://aaa.aa.a.aa:aaaa/stuff/#1234/....." and I was wondering if my issue is being caused by the hashtag.
Can someone help please?

Thanks,
- Hugo Soares

Hi all,

We are working in our sandbox and creating a new custom Button type URL to redirect to a visualforce page I'm getting this error:
User-added image

Here's my button code:
 
window.location = '/apex/FinancialRequest_New'

Even I'm setting the button to use it as  URL '/apex/FinancialRequest_New' , the message is the page no longer exist, so still the same issue.

Thanks in advance.
I have a requirement to scrub a users photo when they leave the company.  Unfortunately, both of the fields that hold the photo are read only, and i get error "Field is not writeable" from APEX code when i  refer to them.
Also - i cannot clear them manually using APEX data loader as they do not appear in the field listing for the USER object.  
So - i cannot update these either programatically nor manually using dataloader.

Does anyone know of a way i can do this?  Users without a photo have a value in the url path of 005 which is what i want to update these to for leavers.

Hi,

I am trying to make HTTP POST request with multipart/form-data, the problem is that the request is sent but without the body part. I was trying the solution: http://enreeco.blogspot.it/2013/01/salesforce-apex-post-mutipartform-data.html, but it doesn't worked for me. I think it is the same problem as: http://boards.developerforce.com/t5/Apex-Code-Development/Image-upload-using-multipart-form-data/m-p/243335/highlight/true#M42610. Will this issue be solved? Is there any alternative to HttpRequest?