• GulshanRaj
  • 703 Points
  • Member since 2017

  • Chatter
  • 21
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 138
    Public static List<string> invokeWebServiceString ssnumber) {
        String [] arrayOfResponsestrings = new List<String>();

        for(String num : ssnumber.split(',')){          
            ResponseWrapper APIResponse = InvokeAPI.invokeRespAPI(num);
            arrayOfResponsestrings.add(JSON.serialize(APIResponse ));
            System.debug('arrayOfResponsestrings :'+arrayOfResponsestrings);
        for(Integer i=0 ;i<arrayOfResponsestrings.size() ; i++) {
        return arrayOfResponsestrings;
  • September 30, 2018
  • Like
  • 0
The recordEditForm and recordViewForm, while not supported in Lightning Out, do work apart from two errors, neither of which appear to affect the functionality.

Is there any way of preventing these error from displaying so that we can use these components?

The steps to reproduce this: https://github.com/paulroberttaylor/lightning-out-recordeditform
  • March 11, 2018
  • Like
  • 0

This should be pretty basic,
I have a vf page to display the value of the name field of a record in a custom object called 'Certification_Accredited_Centres__c'
I also have a controller that the vf page uses.

The URL passes a paramater 'centreId' which is the id of the record I am trying to get the name value of.

At the moment all I am getting on the vf page is "Assesments taken at      " <-- the string is blank

VF Page (not complete)
<apex:page controller="AddingAssessmentsController>
<apex:outputText value="Assesments taken at {!asscen}"/>
Controller (not complete)
public class AddingAssessmentsController {

    public Id centreId;
    public String asscen{get;set;}
    public AddingAssessmentsController(){
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        String asscen = [SELECT name from Certification_Accredited_Centres__c WHERE id =: centreId].name;

Please can someone tell me why the {!asscen} is blank in the vf page?

I am taking quantity of product in this field and storing number of quantity.its showing up down arrow..but on down arrow its going below 0 i.e -1,-2... so i dnt want values below 0.how do i restrict it????
public with sharing class expensesLineItem{
    public final Expense_Line_Item__c el;
    public expensesLineItem(ApexPages.StandardController stdController){
        this.el = (Expense_Line_Item__c)stdController.getRecord();
    public PageReference Dismiss(){
        update el;
        PageReference page = ApexPages.currentPage();
        return page;

Test class:

public class expensesLineItem_Test{
  static void setupTestData()
    Expense__c exp = new Expense__c();
    exp.Period_From__c = system.today();
    exp.Period_To__c =system.today();
    insert exp;
    System.assertNotEquals(null, exp.Id); 
    Expense_Line_Item__c expLine = new Expense_Line_Item__c();
    expLine.Name = exp.Id;
    expLine.Expense_Head__c='Food' ;
    expLine.Cost_Head__c= 'Campaign' ;
    expLine.Amount__c= 10000;
    System.assertNotEquals(null, expLine.Id);
    insert expLine;
  static void testCall()
    Expense_Line_Item__c expLine  =  [SELECT Id,Name,Amount__c,Bill_Available__c,Cost_Head__c,Expense_Head__c,Expense__c from Expense_Line_Item__c][0];
   // System.assertEquals(true,expense_line_item_Obj.size()>0);
   // List<Expense__c> expense_Obj  =  [SELECT Id from Expense__c];
    ApexPages.StandardController stdCon = new ApexPages.StandardController(expLine);
    expensesLineItem obj01 = new  expensesLineItem(stdCon);
    //expensesLineItem obj01 = new expensesLineItem(new ApexPages.StandardController(expense_line_item_Obj[0]));
I'm trying to create a validation rule that requires a custom opportunity field to be populated (look up field) before being able to add a specific discount product to the opportunity. Is this possible? 

  TEXT(Product2.ProductCode, 'REFDISCOUNT')

Error: Field Product2 does not exist. Check spelling.

i want to test a contoller class using Apex Message passed by the controller on the Vf page 

But i am not able to get any result as pageMessages comes null 

Any ideas how i can do it ?

static testMethod void test_Member(){
        //start the test process
        TransactionController obj = new TransactionController();
        ApexPages.Message[] pageMessages = ApexPages.getMessages();
        //List<Apexpages.Message> pageMessages = ApexPages.getMessages();  
        Boolean check=false;

        for(ApexPages.Message msg:pageMessages){
            if (msg.getDetail().contains('Username Or Password is not valid')) {
                check = true;
                check = false;

        //Stop the test process
Greetings all,
I have a visualforce page with an apex:inputfield for ownerid for the record to create a timesheet.  I would like to default the record owner name on the page to the current user (the current user will usually be creating a timesheet for themselves), but give them the ability to change the value in the owner field if they choose.  Currently the field is coming up blank, rather than with the current user.  Please advise.  My code is below.

I'm still pretty new to apex so any help is greatly appreciated. 

My VF page:
<apex:page standardController="Timesheet__c" extensions="PayPeriodExtension">
    <apex:form >
    <apex:pageBlock title="Select Pay Period">
      <apex:pageMessages /> <!-- this is where the error messages will appear -->

        <apex:pageBlockSection >
       	<apex:selectList size="1" required="true" value="{!PayPeriodID}">
          <apex:selectOptions value="{!ActivePayperiods}"></apex:selectOptions>
        <apex:inputfield value="{!Timesheet__c.ownerid}"/>	<br/>

            <apex:pageBlockButtons >
            <apex:commandButton action="{! save }" value="Save" />        
        	<apex:commandButton action="{! cancel }" value="Cancel" />        
My Controller Extension:
public class PayPeriodExtension {
    public ApexPages.StandardController stdCntrlr {get; set;}
    Public List  <Pay_Period__c> PPTemp = new List <Pay_Period__c>(); 
    Public String PayPeriodID {get; set;}
    // the contact record you are adding values to
  public Timesheet__c timesheet {
    get {
      if (timesheet == null)
        timesheet = new Timesheet__c ();
        timesheet.OwnerId = UserInfo.getUserId();
        return timesheet;
	public  PayPeriodExtension(ApexPages.StandardController controller) {
        stdCntrlr = controller;    

    public List<SelectOption> ActivePayperiods
            PPTemp = [Select Id, Name, Days_Since_Start_Date__c From Pay_Period__c 
                      Where (Days_Since_Start_Date__c <14 AND days_Since_Start_Date__c >-21) 
                      Order BY Days_Since_Start_Date__c desc ];
            ActivePayPeriods = new List<SelectOption>();
            for(Pay_Period__c temp : PPTemp)
                ActivePayPeriods.add(new SelectOption(temp.id, temp.Name));
            return ActivePayPeriods;
    public PageReference save() {
    try {
        timesheet.Pay_Period__c = PayPeriodID;
        upsert timesheet; // inserts the new record into the database
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new timesheet.'));
      return null;

    // if successfully inserted new survey, then displays the thank you page.
    return (new ApexPages.StandardController(timesheet)).view();



I want to insert a value in my case field on before insert trigger . I have a static variable in controller whose value Iam initializing in a method in controller and when I access that variable in trigger It is showing "NULL".
and if I initialize the value while declaring then trigger prints the value.
refer the code below:

//this is the class.
public with sharing class Demo{
  public static String test;

public void testMethod(){

   test  = 'hello';


//this is the trigger.

trigger TestTrigger on Case (before insert) {
    System.debug(Demo.test);  //prints null

I´m trying to put a google maps on my standard object "Account" , i´m using the billing adress for the location, the map works fine for a few seconds than it appears this message:
User-added image

The code i´m using for this is:

<apex:page standardController="Account">
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var myOptions={ zoom: 15,mapTypeId: google.maps.MapTypeId.ROADMAP,mapTypeControl: false };
var map;
var marker;
var geocoder = new google.maps.Geocoder();
var address ="{!Account.BillingStreet},{!Account.BillingPostalCode}{!Account.BillingCity}, {!Account.BillingState},{!Account.BillingCountry}";
var infowindow = new google.maps.InfoWindow({
content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}<br>{!Account.BillingState}<br>{!Account.BillingCountry}"
geocoder.geocode( { address: address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK&&results.length) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
//create map
map = new google.maps.Map(document.getElementById("map"), myOptions);
//center map
//create marker
marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: "{!Account.Name}"
//add listeners
google.maps.event.addListener(marker, 'click', function() {
google.maps.event.addListener(infowindow, 'closeclick', function() {
} else {
$('#map').css({'height' : '15px'});
$('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
function resizeIframe() {
var me = window.name;
if (me) {
var iframes = parent.document.getElementsByName(me);
if (iframes&&iframes.length == 1) {
height = document.body.offsetHeight;
iframes[0].style.height = height + "px";
#map {
font-family: Arial;
line-height:normal !important;
<div id="map"></div>
Suppose i opened visualforce page , That insert the data into the DataBase. Is it possible in VisualForce?
Hi experts,
I need your help to build a formula as I am stuck here and don't know how to achieve the result that I want.

This is my formula :
if(ISNULL(Benefit_End_Date__c),12,round((Benefit_End_Date__c - Expected_Impact_Date__c),2)/30)
This formula returns 0 when the difference between the 2 dates are less than 30 days, so when there is less than a month.
In that case I would like to return 1. How cvan I do that?
It blocks me to implement a method as each time the result is 0 I get an error from Apex ...
Many thanks in advance for the time you will spend on my issue :)
This formula does not work for entire 24 hour clock in Pacific Time Zone.

CASE(MID ( TEXT (CreatedDate), 12, 2),"01",1," 02",2,"03",3,"04",4,"05",5,"06",6,"07",7,"08",8,"09",09,"10",10,"11",11,"12",12,"13",13,"14",14,"15",15,"16",16,"17",17,"18",18,"19",19,"20",20,"21",21,"22",22,"23",23,"00",00,Null)-(7)

Im trying to display maps in a visualforce page but the method that builds the map doesnt seem to be called when i preview my page. I would appreciate some help please :)

Here's my map : 

public map<string,string> getMapFieldLabel(){
        //List<string> fieldsLabels = new List<string>();
        List<Custom_Object__c> defaultFields = [Select Name from Custom_Object__c where Default__c=True];
        Map<String, Schema.SObjectField> typeMap = Schema.SObjectType.A_second_Custom_Object__c.fields.getMap();
        //Get choosen default fields label    
        for(Custom_Object__c defaultField : defaultFields) {
            Schema.SObjectField field = typeMap.get(defaultField.Name);
            string fieldLabel =field.getDescribe().getLabel();
            mapFieldLabel.put(defaultField.Name, fieldLabel);
        return mapFieldLabel;

And my VF code : 

         <apex:pageBlockSection columns="3" collapsible="true">
            <apex:repeat value="{!MapFieldLabel}" var="item" >
                    <apex:repeat value="{!MapFieldLabel[item]}" var="itemvalue" >                    
                    <apex:outputText value="{!itemvalue}" />

This code doesnt display anything on screen !

Thank you for your help in advance :)

I need help on the following requirement as follows,

I have 2 fields called "Latest date" and "Latest date 1"

I have a formula which would convert a text to a formula text

for eg : March-2017 would be stored as 01/03/2017

it works fine but my issue issue

if "Latest date" which holds March -2017 values if its null

then the next field "latest period date 1" is having some incorrect format like 1/01 which should also be null

help me how tyo fix it

Thanks in Advance

"01/"+CASE(UPPER(LEFT(Latest_Period_Date__c, FIND("-", Latest_Period_Date__c)-1)),
"MARCH", "03",
"APRIL", "04",
"MAY", "05",

First Namearpitvikash 
Last Namevijaykumar 
Hi ,

I need help on the following requirement as follows,

I have a text field called "Latest date" which has values in "March -2017" format

I want another formula field to convert the above text to dd/mm/yyyy format

The date can be 1st of every month

I shouldnt make any changes to the existing field and need this functionality in  a new field

Help me how to acheive this

Thanks in Advance
I am creating a lightning component and I'm trying to style the data table using the example in the Lightning Design System documentation. I'm having trouble getting this to render correctly. Any ideas? 

Here is what the example looks like:
Lightning Example - Data Table
Link to example:

Here is how mine renders:

User-added image
Here is what I am doing in the Component:
<aura:component controller="AddPoliciesApexController" implements="force:LightningQuickAction,force:hasRecordId">
	<aura:attribute name="policies" type="Policy__c[]" />
	<aura:attribute name="addToOpp" type="Boolean" />
	<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
	<table class="slds-table slds-table_bordered slds-table_cell-buffer slds-table_striped">
		    <tr class="slds-text-title_caps">
		      <th scope="col">
		        <div class="slds-truncate" title="Policy Number">POLICY NUMBER</div>
		      <th scope="col">
		        <div class="slds-truncate" title="Effective Date">EFFECTIVE DATE</div>
		      <th scope="col">
		        <div class="slds-truncate" title="Expiration Date">EXPIRATION DATE</div>
		      <th scope="col">
		        <div class="slds-truncate" title="Coverage Code">COVERAGE</div>
		      <th scope="col">
		        <div class="slds-truncate" title="Add to Opp">ADD TO OPP?</div>

	<aura:iteration items="{!v.policies}" var="pol" >

      <th scope="row" data-label="Policy Number">
        <div class="slds-truncate" title="Policy Number">
          <a href="javascript:void(0);">{!pol.Name}</a>
      <td data-label="Effective Date">
        <div class="slds-truncate" title="Effective Date">{!pol.Effective_Date__c}</div>
      <td data-label="Expiration Date">
        <div class="slds-truncate" title="Expiration Date">{!pol.Expiration_Date__c}</div>
      <td data-label="Coverage Code">
        <div class="slds-truncate" title="Coverage Code">{!pol.Coverage_Code_Product_Code__c }</div>
      <td data-label="Add to Opp">
        <div class="slds-truncate" title="Add to Opp">
        	<ui:inputCheckbox class="slds-form-element" label="Add to Opp?"/>


Does anyone know of any way to use slds in visual force when rendering the page as a pdf?
It keeps the formatting but the sytle is not applied.

Any Ideas?
I am working on a REST WebService that takes in 2 objects. I was able to create the 2 classes (one for Account, one for Contact). The test for Account gets 100% but for Contact only gets 50% and I'm not sure what I'm missing.

global with sharing class ContactsManager {

    global static ID createContact(String contactOwner, String department, String contactEmail) {
        Contact thisContact = new Contact(OwnerId=contactOwner, Department=department, Email=contactEmail);
        insert thisContact;
        return thisContact.Id;
(My Test class)  ContactsManagerTest.apxc:
public class ContactsManagerTest {
    @isTest static void testCreateContact() {
        // Call the method to test
        ID thisContactId = ContactsManager.createContact(
            '1', 'CSIS', 'olmsted@cofc.edu');
        // Verify results
        System.assert(thisContactId != null);
        Contact thisContact = [SELECT Id,Department FROM Contact WHERE Id=:thisContactId];
        System.assert(thisContact != null);
        System.assertEquals(thisContact.Department, 'CSIS');
When I click on the test area for the 2 lines that are failing, it points to:
insert thisContact;
        return thisContact.Id;

Not sure what's wrong with these?

Case is always taking up from email address (generated from email-to-case ) even after I am selecting email action from feed action bar. Is that possible it takes logged in user email address instead of taking from email address of the case originaly created from email-to-case.

User-added image

Thanks in advance.
Gulshan Raj

Suddenly my developer profile is showing everything in Japanese. Any idea where you change language preference ?

Thanks in Advance.User-added image

I am getting owner id in the data table for lightning component, when using

{label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            {label: 'Created By', fieldName: 'Owner__c'},

and no value when I try to use :

{label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            {label: 'Created By', fieldName: 'Owner__r.Name'},

on lightning component screen.

Also , the records that get created on save are displayed in tabular form, but gets saved randomly in table ordrer, i want to arrange them in order of creation time, with the last created record to be on the top of table
trigger InventoryChangeTrigger on Inventory_Change__c (after update) {
  if(Trigger.isAfter && Trigger.isUpdate) {
    for (Inventory_Change__c oIC : Trigger.new){
      Product2  oP = [SELECT Id, In_Stock__c  FROM Product2 WHERE Id = :oIC.Product__c];
      Id Rid = Schema.SObjectType.Inventory_Change__c.getRecordTypeInfosByName().get('Reduction').getRecordTypeId();
      Id Aid = Schema.SObjectType.Inventory_Change__c.getRecordTypeInfosByName().get('Addition').getRecordTypeId();
      if(trigger.oldmap.get(oIC.id).RecordTypeid != trigger.newmap.get(oIC.id).RecordTypeid){
        if(oIC.RecordTypeid == Rid ){
          oP.In_Stock__c = oP.In_Stock__c - oIC.Quantity__c;
        if(oIC.RecordTypeid == Aid ){
          oP.In_Stock__c = oP.In_Stock__c + oIC.Quantity__c;
    update oP;

                                                                                           TEST CLASS

public class InventoryChangeTrigger_Test{
  static testMethod void test_Inventory_ChangeTrigger(){
    product2 product2_Obj  = new product2(Name = 'Name735', IsActive = true, In_Stock__c = 19, Out_of_Stock__c = false);
    insert product2_Obj;
    Inventory_Change__c inventory_change_Obj = new Inventory_Change__c(RecordTypeId = '01236000000STHgAAO',Quantity__c = 16,product__c = product2_Obj.id );
    Insert inventory_change_Obj;
    product2 product2_Obj1 = [select id,Name,In_Stock__c from product2 where Name = 'Name735'  LIMIT 1];
    product2_Obj1.name= 'xyz';
    product2_Obj1.In_Stock__c = 3;
    update product2_Obj1;
I have a HttpPost methods. And I really don't know how to test it correctly.
My methods:
public static App__c ParseRequest(RestRequest req) {
    App__c app = new App__c();
    String body = req.requestBody.toString();
    app = (App__c)JSON.deserialize(body, App__c.class);
    return app;  

global static Id doPost() {
    RestRequest req = RestContext.request;        
    App__c app = ParseRequest(req);
    insert app;
    return app.id;

My test (just basis):
public static String GenerateJSON(App__c a){
    Map<String, String> fieldMap = new Map<String, String>{'Title__c' => a.Name};       
    String serialized = JSON.serialize(fieldMap);         
    return serialized;

static void testPost() {
    App__c record = createTestRecord();
    RestRequest request = new RestRequest();
    request.requestUri = System.URL.getSalesforceBaseUrl().toExternalForm() + '/services/apexrest/App__c/' + record.Id;
    request.httpMethod = 'POST';
    RestContext.request = request;

    record = (App__c)JSON.deserialize(GenerateJSON(record), App__c.class);

    App__c j = Endpoint.ParseRequest(request);
    record = (App__c)JSON.deserialize(body, App__c.class);

static App__c createTestRecord() {
    App__c app = new App__c(
        Title__c = 'Title',
    insert app;
    return app;

In App__c j = Endpoint.ParseRequest(request); I become Argument cannot be null. without coverage of:
app = (App__c)JSON.deserialize(body, App__c.class);
    return app;  

global static Id doPost() {
    RestRequest req = RestContext.request;        
    App__c app = ParseRequest(req);
    insert app;
    return app.id;

I have created two icons which I'd like to use in Salesforce based on the value selected in a picklist... Can anyone point me in the right direction of how to do this?

I have seen some formula fields which use Salesforce fields (I'm asuming text formula) and work something like this...

LEAD( ISPICKVAL(Enquiry_Type__c) , 
"Business", IMAGE( "/servlet/servlet.FileDownload?file=01550000000N4NG", "Green"),
"Personal", IMAGE( "/servlet/servlet.FileDownload?file=01550000000N4NY", "Yellow"),

The first thing I need to do is get the formula working which I can' seem to do. The picklist is called Enquiry_Type__c and has the options Business and Personal. I'm happy to show the two images detailed above (or even Salesforce images for the time-being).

Onmce I have the formula field working, I'm assuming I can upload my images to Salesforce and reference them instead?
I have created a custom button on a custom object.  The button, when clicked, opens up a Visualforce Page, in which the Lightning Component is placed:
<apex:page docType="html-5.0" standardController="Business_Request__c" extensions="BusinessRequest_BRtoCaseController" showHeader="false" sidebar="false" standardStylesheets="false">
    <apex:stylesheet value="{!URLFOR($Resource.SLDS260, '/styles/salesforce-lightning-design-system.min.css')}"/>    
    <apex:includeScript value="{!$Resource.jQuery331}"/>
    <apex:includeLightning />    
    <apex:outputPanel layout="block">
        <div id="lightning"/>
    <!--Lightning Component--> 
        var base = location.protocol+"//"+location.hostname+(location.port && ":"+location.port);
        var brRecordId = "{!recordId}";
        $Lightning.use("c:BusinessRequest_BRtoCaseDependencyApp", function() {
                                           recordId : brRecordId,
                                           baseUrl : base
                                       function(component) {

The component (for which I cannot post the code, sorry) consists of a Lightning Design System modal, with a lightning:recordEditForm inside of it.  Once the form is filled out and saved, the Apex controller creates a related record and passes a success/fail boolean to the Lightning Helper.  

In the Helper I have the code written to show a Toast and automatically close the window after a timeout:
action.setCallback(this, function(response){
            var state = response.getState();  
            var caseCreated = Object.keys(response.getReturnValue())[0];
            var caseComCreated = Object.values(response.getReturnValue())[0];
            if(state === "SUCCESS" && caseCreated === "true" && caseComCreated === "true") {
                this.showToastHp(component, true);

(later in the code...)

    showToastHp : function (component, success){
        var $j = jQuery.noConflict();


Now, the window itself closes just fine.  However, I need something else to happen as well.  I need the record on which the button was pushed to refresh/reload.  I've tried many different Javascript methods, but the one I think may work is prohibited by lightning (uses the "opener" syntax).

Is there any way to do this?
Hi All, 

I am getting following error message: 

Challenge not yet complete... here's what's wrong:
A field with an API Name 'Match_Billing_Address__c' does not exist on the Account object

my code is as follows:

trigger AccountAddressTrigger on Account (before insert, before update) {
     for(Account a : Trigger.New) {

 Thanks in Advance
Hi All,

I want to prepopulate the stage name in Opportunity sales stage with "Prospecting" at the time of new opportunity creation. Can you please suggest me where I can configure the default value sales stage?
User-added image
    Public static List<string> invokeWebServiceString ssnumber) {
        String [] arrayOfResponsestrings = new List<String>();

        for(String num : ssnumber.split(',')){          
            ResponseWrapper APIResponse = InvokeAPI.invokeRespAPI(num);
            arrayOfResponsestrings.add(JSON.serialize(APIResponse ));
            System.debug('arrayOfResponsestrings :'+arrayOfResponsestrings);
        for(Integer i=0 ;i<arrayOfResponsestrings.size() ; i++) {
        return arrayOfResponsestrings;
  • September 30, 2018
  • Like
  • 0
I tried several times to get the code coverage for the below test class now I need someone's help to get code coverage for red color coding in the Image How can I ???
Here the below image shows the code coverage.​

code coverage problem

My trigger
trigger customsolinsert on Price_Study__c (after update, after insert) {
// Find the existing (0 or 1) Custom_solution__c that reference Price_Study__c 
    Map<Id, Custom_solution__c> m = new Map<Id, Custom_solution__c>();
   list<Custom_solution__c> oblist=[ select id, Price_Study__c from Custom_solution__c where Price_Study__c in :Trigger.newMap.keySet() ];
    for (Custom_solution__c ob : oblist) {
        m.put(ob.Price_Study__c, ob);
// Insert or update the Custom_solution__c
List<Custom_solution__c> csol= new List<Custom_solution__c>();

for (Price_Study__c b : trigger.new) {
    // Get record to update
    Custom_solution__c ob = m.get(b.id);

 if (ob == null) {
        // If no record to update, add a record to be inserted
        ob = new Custom_solution__c(Price_Study__c = b.id);

upsert csol;

Test class
  public class Testcustomsolinsert{
  @istest Static void Testcustomsol1(){

    Profile prof = [select id from profile where name='system Administrator'];
    List<User> lstUser = [Select u.Profile.Name, u.ProfileId, u.IsActive, u.Id From User u Where IsActive = true AND Profile.Name = 'System Administrator'];

   Account acc=new account(Name='NicoTestacc',BillingCountry='India');
    insert acc;

    Opportunity op1= new opportunity(Name='NicoTestOpp',CloseDate=date.today(),StageName='Qualification',Product_Type__c='DPI',Accountid=acc.Id);
    insert op1;
    Price_Study__c ps=new Price_Study__c(Country_of_Treatment__c='India',Series_Row_nbr__c=3,

    Insert Ps;

        Map<Id, Custom_solution__c> m = new Map<Id, Custom_solution__c>();             

        Custom_solution__c cs1=new Custom_solution__c(Price_Study__c=PS.Id,Country__c=Ps.Country_of_Treatment__c);

        Insert cs1;

        delete cs1;

     Custom_solution__c cs=new Custom_solution__c();


  Insert cs;


  Update cs;

HI All

I am confusing why VF PAge not working in Production which is working fine in sandbox .In Sandbox its showing all list which is not showing Pro.User-added image
User-added image
<apex:page standardController="Quotation_Line_Item__c" extensions="ctrl_addproduct" showHeader="true" sidebar="false">
<apex:slds /> 
<div class="slds-scope">
<apex:form >

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
            $(document).ready(function() {
                $("input:checkbox").click(function() {
                    var decision = $(this).prop("checked")
                    var group = "input:checkbox[class='" + $(this).attr("class") + "']";
                    var n = group.indexOf("Common");
                    if (n >= 0) {} else {
                        if (decision) {
                            $(group).prop("checked", false);
                            $(this).prop("checked", true);

        <apex:pageMessages />
       <apex:pageBlock mode="Edit">
        <div style="text-align:right;">

            <apex:pageBlockButtons >
            <apex:inputText value="{!searchstring}" label="Input"/>   
  <apex:commandButton value="SEARCH PRODUCT" action="{!search}" styleClass="slds-button slds-button_success"/> 
                <apex:commandButton value="ADD PRODUCT" action="{!Csave}" styleClass="slds-button slds-button_success"/>
                <apex:commandButton value="CANCEL" action="{!Cancel}" styleClass="slds-button slds-button_destructive"/>
                <apex:pageBlockTable value="{!pitem}" var="pi">
                    <apex:column headerValue="Select" headerClass="slds-text-title--caps">
                        <apex:inputField value="{!pi.Applicable__c}" />
                    <apex:column value="{!pi.Name}" headerClass="slds-text-title--caps" />   
                     <apex:column headerValue="Basic Unit Price" headerClass="slds-text-title--caps">
                        <apex:outputField value="{!pi.Basic_Unit_Price__c}" />
                     <apex:column headerValue="Size" headerClass="slds-text-title--caps">
                        <apex:inputField value="{!pi.Size__c}" />
                    <apex:column headerValue="Quantity" headerClass="slds-text-title--caps">
                        <apex:inputField value="{!pi.Quantity__c}" />
Public with sharing class ctrl_addproduct{

     public List<Product__c> pitem{get;set;} 
     public List<Quotation_Line_Item__c> qitem{get;set;}
     public List<Quote_Product_Line_Item__c> opitem{get;set;}   
     public ID oppid {get; set;}
     public string searchstring {get;set;}  
     public boolean refpage{get;set;}
     public string searchText {get;set;}
     public String message {get;set;}
     public ctrl_addproduct(ApexPages.StandardController controller){
         pitem = new List<Product__c>();
         qitem = new List<Quotation_Line_Item__c>();
         opitem = new List<Quote_Product_Line_Item__c>();
         oppid = ApexPages.currentPage().getParameters().get('qid');
         pitem = [SELECT Applicable__c,Quantity__c,Account_Name__c, Basic_Unit_Price__c, CreatedById, CreatedDate, IsDeleted, Description__c, LastActivityDate, LastModifiedById, LastModifiedDate, 
         OwnerId, Name, Id, RecordTypeId, Size__c, Category__C, SystemModstamp,Type__c, Discount__c FROM Product__c where RecordTypeId=:'0120l0000000gGxAAI'];
         qitem = [SELECT id,Name FROM Quotation_Line_Item__c];
     public void search(){  
     string searchquery='select name,id,Applicable__c,Quantity__c,Account_Name__c,size__c, Basic_Unit_Price__c from Product__c where name like \'%'+searchstring+'%\' Limit 20';  
     pitem = Database.query(searchquery);  
    Public  PageReference csave()
       oppid = ApexPages.currentPage().getParameters().get('Id');
          for(Product__c op:pitem)
              Quote_Product_Line_Item__c p = new Quote_Product_Line_Item__c();
                   p.Quotation_Line_Item__c =oppid;
                   p.Product__c =op.id;
                   p.Quantity__c =op.Quantity__c; 
                   p.Size__c =op.Size__c;
                   p.Type__c =op.Category__C;
                   p.Discount__c =op.Discount__c;
           Insert opitem; message = 'updated records Sucessfully';
        Catch (Exception e) 
            return null;
        PageReference nextpage= new PageReference('/'+oppid);
        //return new PageReference('javascript:self.close()');
        return nextpage;
   public PageReference cancel() 
    oppid = ApexPages.currentPage().getParameters().get('Id');
     PageReference returnPage = new PageReference('/'+oppid);
     return returnPage;

Hi Everyone,

I need a help from anyone to clarify my doubts on the events for partner user. I have coded a visualforce page for displaying events on calender for a particular partner user. But it is displaying well as expected in internal sfdc org. I couldn't see the events for the partner user on the community portal.
I hope someone would help me to achieve this ASAP.

Hi All,

 I have requirement need connect Salesforce to Oracle when any update in Salesforce object like Account or Opportunity (Name,Stage ..etc) that values need to update in Oracle system.Please guide me Steps and Sample code .How to write Web services class for this integration? Please its very urgent help needded.
The recordEditForm and recordViewForm, while not supported in Lightning Out, do work apart from two errors, neither of which appear to affect the functionality.

Is there any way of preventing these error from displaying so that we can use these components?

The steps to reproduce this: https://github.com/paulroberttaylor/lightning-out-recordeditform
  • March 11, 2018
  • Like
  • 0