• PC
  • NEWBIE
  • 70 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 30
    Replies
I am trying to insert the a Map of <Case,List<Case> as parents and their related child cases using apex. But once I insert the Map key set , the map values get null.
Map<Case,List<Case>> parentChildMap = new Map<Case,List<Case>>();
 List<Case> parentCases = new List<Case>();
        for(CaseWrapper wrap: caseWrapperList){
            parentChildMap.put(wrap.parentCase,wrap.childCases);
        }
        System.debug('map before insert==>'+parentChildMap);
        if(parentChildMap.keySet() !=null){
           parentCases.addAll(parentChildMap.keySet());
           insert parentCases ; 
           System.debug('map after insert==>'+parentChildMap);
        }


Debugs:
map before insert==> {Case:{Subject=1}=(Case:{Subject=1.1}), Case:{Subject=2}=(Case:{Subject=2.2})}

map after insert==> {Case:{Subject=1, Id=5000K00002cxQsWQAU}=null, Case:{Subject=2, Id=5000K00002cxQsXQAU}=null}

Why the values are geting set to null?
  • May 04, 2023
  • Like
  • 0
I need to insert key of map as parent objects and value of map as child object. 
Map<Case,List<Case>> parentChildMap = new Map<Case,List<Case>>();

How can we do this?
  • May 04, 2023
  • Like
  • 0
I have the below data containing list of roomtypes.Each room type can have multiple rates and I want to show it in a data table but I am only able to show the roomtypes values.

The table should have three colums ie. Room Type, Availability, Rate
Under the Rate column i want to create another datatable that can show Rate type, Availability,Price.

The no. of rates available for a particular roomtype is not static.Hence I need to create a dynamic table.The table should look like this.
LWC template:
       
 <div style="height: 125px;">
                <lightning-datatable
                        key-field="id"
                        data={roomTypeList}
                        show-row-number-column
                        row-number-offset={rowOffset}
                        hide-checkbox-column
                        columns={columnList}>
                </lightning-datatable>
            </div>

.js file:

const columnList = [
    {label: 'Room Type', fieldName: 'title'},
    {label: 'Availability', fieldName: 'availableroom'},
    {label: 'Rates', fieldName: 'rates'}
];

searchroom({hotelid:this.hotelid,cindate:this.checkindate,coutdate:this.checkoutdate})
            .then(result =>{
                console.log(result);
                console.log('============result '+JSON.stringify(result));
                this.roomTypeList = result;
            })

result value::::::

[
  {
    "amenities": "",
    "availableroom": "10",
    "basepax": "1",
    "code": "",
    "description": "",
    "id": "9NmOCdPNMaLNP3GfyPqvHjf9SKCN0hqQ-c7wbcxlEcw|",
    "imgs": "",
    "key": "dj9KhRF8",
    "maxpax": "4",
    "minRate": 20000,
    "minrooms": "1",
    "rates": [
      {
        "availableroom": 10,
        "bookingpolicy": {},
        "code": "WEBR",
        "description": "",
        "id": "NdUREH2JQTevHTZ9_ZW65GiExRg74f8apswzYjZhtxPbMBkS7OrVOFPn0fwHhIRAYQ3uohMBoXnuXeuUVr2UrjGT3lfAxzljWw5RUcRCp5iItBTe621xN1JzSwBOibRy",
        "key": "5HU05MyBuHGaeTy1cRo1nloSsVVqLHIzWN0fHDtP8mYGPUNz1QhwM6AdXoLUsmwwbp3zOJCUgk-ywG6A_5Vwhg||",
        "price": 20000,
        "tax": 0,
        "title": "Rack Rate"
      }
    ],
    "title": "Royal Suite"
  },
  {
    "amenities": "",
    "availableroom": "20",
    "basepax": "1",
    "code": "",
    "description": "",
    "id": "rc0JMoJXVfwRHMOi_ZQfxI48JldJw_6RAA7R7jQk1BM|",
    "imgs": "",
    "key": "dj9KhRF9",
    "maxpax": "3",
    "minRate": 16000,
    "minrooms": "1",
    "rates": [
      {
        "availableroom": 20,
        "bookingpolicy": {},
        "code": "WEBR",
        "description": "",
        "id": "NdUREH2JQTevHTZ9_ZW65GiExRg74f8apswzYjZhtxO-AFxNrM24ICxMqO0qvJqGNSrXWG9mU388E3sc4OHBKdI9hKXEbCOCha7Fzza48S-ZNuqpqRaw4vR6Z0bYvWLC",
        "key": "pQrtjHQe5E4YQ_oeQpNjx1svxl49CdAPEqKWMu-DVfcv597rkMU8rM2lppwyuflkoUYtIEgoUAOYTfnLB68B7g||",
        "price": 16000,
        "tax": 0,
        "title": "Rack Rate"
      }
    ],
    "title": "Orchid Suites"
  },
  {
    "amenities": "",
    "availableroom": "30",
    "basepax": "1",
    "code": "",
    "description": "",
    "id": "TMP70hSIljPEpF2-jb8X9HqS-O2fh5UVYujncCzbuJk|",
    "imgs": "",
    "key": "dj9KhRF-",
    "maxpax": "3",
    "minRate": 18000,
    "minrooms": "1",
    "rates": [
      {
        "availableroom": 30,
        "bookingpolicy": {},
        "code": "WEBR",
        "description": "",
        "id": "NdUREH2JQTevHTZ9_ZW65GiExRg74f8apswzYjZhtxOwpZAi2vw-pja70Y_xfbt_pCbHTVwB-5fFymmgGn8QHFc5ntLIGKBiK4kkFl03n7i24p-jc5bhzDMuvkGZns3f",
        "key": "GZ43Mq5wilimC2MzFwLVGzOzqH-jMaUdhpxc5AMgmcZ2fbUty0TjojyookC_ekLS9tLdKfVp1dtF5AolbVjHJg||",
        "price": 18000,
        "tax": 0,
        "title": "Rack Rate"
      }
    ],
    "title": "Royal Club"
  },
  {
    "amenities": "",
    "availableroom": "40",
    "basepax": "1",
    "code": "",
    "description": "",
    "id": "-scpOnCRpziNx3qJB7UUfu2u_gk35CKkEmv01KA3E7Q|",
    "imgs": "",
    "key": "dj9KhRF_",
    "maxpax": "3",
    "minRate": 14000,
    "minrooms": "1",
    "rates": [
      {
        "availableroom": 40,
        "bookingpolicy": {},
        "code": "WEBR",
        "description": "",
        "id": "NdUREH2JQTevHTZ9_ZW65GiExRg74f8apswzYjZhtxNo_zQyD7fjREJLqAkvBVs2VNSNwZX-Ul0S7LT9YT7i-M1sSFGijTqwVjfE1X4TAhMu43Rsquc0WvuM43Wvwqdg",
        "key": "HLUcuJUxG7VvJeTcJJLCMtpaUqWyryMRxKkDqevIdJJ4QXCqKtiqU1e9glle8uHB3cgfJrUIF6O3fCiNr6n5-Q||",
        "price": 14000,
        "tax": 0,
        "title": "Rack Rate"
      }
    ],
    "title": "Luxury"
  }
]

 
  • November 19, 2019
  • Like
  • 0
Below is the json data i am recieving.I want to get the value of datetime,accesskey and accesssecret in apex
{"hotelogix":{"version":"1.0","datetime":"2019-11-13T05:40:14","response":{"status":{"code":0,"message":"success"},"accesskey":"0vi1yR7ssx4IMrw","accesssecret":"rbgTdw6kfpE8ZQV"},"request":{"method":"wsauth","key":"5151BE0BE4A9B667C07"}}}
  • November 13, 2019
  • Like
  • 0
I have used the online Hmac generator and tested an API. Now I want to do the same thing using apex code.

I am not getting the success method by using the mac code generated using the method "Crypto.generateMac()".

I am generating the mac code using the method generateHmacSHA1Signature and calling the endpoint url using the mac generated earlier.

Getting the response as invalid signature.
public class HMACGenearatorHandler {
     public void createJson(){
         String jsonString; // create json here
         String json = '{"hotel":{"version":"1.0","datetime":"2019-11-12T08:09:59","request":{"method":"wsauth","key":"5151BE0BE4A9B667C07C727602C2EF4589658741"}}}';
         String sText= json.replaceAll( '\\s+', '');
         String strMd5= EncodingUtil.base64Encode (Crypto.generateDigest('MD5', Blob.valueOf(sText)));
         sendRequest(sText);
      generateHmacSHA1Signature(sText,'8B434FB19209EEE32002073C8680464785236985');
     } 
    
    @future (callout=true)
	public static void sendRequest(String jsonString){
        HttpRequest req = new HttpRequest();
        req.setEndpoint(System.Label.EndPoint);
        req.setMethod('POST');
        req.setHeader('X-HAPI-Signature','b7ua89TY1m6hHawC8v+ETX/SK7o=');
        req.setHeader('Content-Type', System.label.Content_Type); 
        req.setBody(jsonString);
        Http http = new Http();
        if(!test.isRunningTest()){
            HTTPResponse res = http.send(req);
            System.debug(res);
            System.debug('resp body+++'+res.getBody());
        } 
    } 
     
    public static Blob generateHmacSHA1Signature(String canonical_str, String secreteKey){ 
             Blob mac = Crypto.generateMac('HMacSHA1', Blob.valueof(canonical_str), Blob.valueof(secreteKey));
        	 String strSignature = EncodingUtil.base64Encode(mac);
             System.debug('strSignature11++'+strSignature);
             return mac;
         }
 }


 
  • November 12, 2019
  • Like
  • 0
I have a custom object called Incentive_Management__c.This custom object has a lookup to the User object.

I  have a lookup relationship incentive__c  in the lead object with Incentive_Management__c.
I want to auto populate the incentive__c field in the lead if the Lead Owner and the User in the custom object Incentive_Management__c matches.
  • January 12, 2018
  • Like
  • 0
Hi,
I hava a custom object Feedback__c and a visualforce page "feedbackpage ". Whenever a case is "closed" a link having the feedbackpage address goes to the customer for giving feedback.

The feedbackpage consists of radio buttons and smiley images .
But i want to incorporate the smiley and the radio button in the email template itself.
How can i do this??
<apex:form >
        <apex:pageBlock >
              <div class="vertical-center">
                  <div class="container">
                      <div class="row">
                          <div class="col-sm-8 col-sm-offset-2">  
                            <center><apex:image url="{!URLFOR($Resource.smiley,'smiley/pb.PNG')}" style="width:300px;height:60px;" /></center>

                                       
                              <div class="panel panel-primary"> 
                                  
                                  <div class="panel-body"> 
                                        <div class="alert-danger">
                                        <apex:messages />
                                        </div> 
                                                                    
                                        <table border="0">
                                            <tr>
                                               <apex:image url="{!URLFOR($Resource.smiley,'smiley/excellent.png')}" style="padding-left:66px;" />
                                                        
                                                <apex:image url="{!URLFOR($Resource.smiley,'smiley/good.png')}" style="padding-left:135px;"/>
                                                        
                                                <apex:image url="{!URLFOR($Resource.smiley,'smiley/poor.png')}" style="padding-left:133px;"/> 
                                                      <td class="center">
                                                         <p>
                                                         <apex:selectRadio value="{!feedback.PB_Survey_Result__c}" styleClass="radioinput" style="width:456px;">
                                                           <apex:selectOptions value="{!types}"></apex:selectOptions>
                                                         </apex:selectRadio>
                                                         </p>
                                                     </td> 
                                             </tr>
                                        </table>
                                  </div><!-- panel- body-->
                               </div> <!-- panel primary -->     
                                    
                                
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-5">
                                     <apex:commandButton styleClass="btn btn-success" value="Save" action="{!save}" />&nbsp;&nbsp;
                                     <apex:commandButton styleClass="btn btn-danger" value="Cancel" immediate="true" action="{!Cancel}" /> 
                                    </div>
                                </div> 
                            </div> 
                          
                          </div>                  
                      </div>
                  </div>
             
        
       
     </apex:pageBlock>   
    </apex:form>

want the same thing in email template.
  • December 04, 2017
  • Like
  • 0
Hi,
I have a apex checkbox field in the vf page called "ONLY VEG". When I first click on the check box it selects only veg item from menu object and shows in the vf page. But if i want to uncheck it again so thai it will again show all the veg and non veg items,,,,,But I am not able to uncheck it again.
Checkbox in vf page:
<apex:inputCheckbox value="{!myCheckbox}"> <apex:actionSupport event="onchange" action="{!onlyveg}" /> </apex:inputCheckbox>
Controller:
 public boolean myCheckbox {get; set;}

  public PageReference onlyveg(){
                if(myCheckbox=TRUE){
                system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
                menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Veg'];
                }else{
                system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
                menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Non-veg'];
                }
                
                return null;
         
    }
  • October 18, 2017
  • Like
  • 0
hi,
I have a favourite button which fetches the items which has been ordered more than twice.
This is my controller

    Public List<Menu__c> favmenu {get;set;}
     favmenu = [select id, name,Category__c,Description__c,Image__c,ImageURL__c,Dish_Name__c,Price__c,
                 Special_Dish__c,Status__c,SubCategory__c,veg_non_veg__c,remarks__c from Menu__c where id IN : menuIdList]; 
           
           if(favmenu.size()>0)
               nofavourites = 'Choose from your favourites';
           else
                nofavourites='No favourites yet';

When i m testing for favmenu.size()>0 ..... it is working fine....but for the else part, when the soql query is not fetching any item, it is showing the error
Attempt to de-reference a null object 
An unexpected error has occurred. Your development organization has been notified.
  • September 21, 2017
  • Like
  • 1
Hi, 
I have a custom site in salesforce. I have created it like when you enter your mobile number it will check the number in contact object and if the number is not existing one, it will get saved.
But now i want to give login through  facebook and google in the page ...
Can anyone please help me in this.
  • August 22, 2017
  • Like
  • 0
Hi,
I have a custom object calle OLI__c
I m trying to fetch  the order line items from OLI__c  that are repeated against a particular customer in the Order__c Object.

But I am getting the error 
List has no rows for assignment to SObject 
An unexpected error has occurred. Your development organization has been notified.

I have tested the soql query in developer console and it is giving the desired result.
favourites = [select Menu__r.id menuid from OLI__c  where Order__c in(SELECT id FROM Order__c where Customer__c=:c.id and Status__c='Completed') group By Order__r.Customer__r.name,Menu__r.Dish_Name__c,Menu__r.id having count(id)>1 ];
          
 for(AggregateResult ar : favourites){
                 
                 mid = String.Valueof(ar.get('menuid'));
                
            }

            if(mid!='')    
                favmenu = [select id, name,Category__c,Description__c,Image__c,ImageURL__c,Dish_Name__c,Price__c,
                 Special_Dish__c,Status__c,SubCategory__c,veg_non_veg__c,remarks__c from Menu__c where id=:mid];

 
  • August 21, 2017
  • Like
  • 0
I have a variable 'd' that captures the current date time.
In the same page i have a button inside jquery which is redirecting to a new page in new window.
I want to pass the variable d  in the url.
Code:
var d = new Date();
The url is :   '<a href="/apex/vfp_KOT?oid=" class="js-newWindow" data-popup="width=500,height=600"><button type="button" class="btn btn-primary">Print KOT</button></a>&nbsp;&nbsp;&nbsp;&nbsp;'+

New Window :  
$(document).ready(function(){
            $('.js-newWindow').click(function (event) {
                event.preventDefault();
                var $this = $(this);
                var url = $this.attr("href");
                var windowName = "popUp";
                var windowSize = $this.data("popup");
                //alert($.session.get('sessionoid'));
                var noid = $.session.get('sessionoid');
                var urlnew = url+noid;
                window.open(urlnew, windowName, windowSize);
            });
        });
  • August 09, 2017
  • Like
  • 0
I have a jquery popup window which has image , Dish name,quantity and price for various rows. I am able to fetch the data for each row and save in the back end. Now I want to add one text box in each row , showing the remarks .But I am not able to save the remark data from frontend to backend.

Code:
var products = ProductManager.getAllProducts();
      $.each(products, function(){
        var total = this.quantity * this.price;
        $cartTable.append(
          '<tr title="' + this.summary + '" data-id="' + this.id + '" data-price="' + this.price + '">' +
          '<td class="text-center" style="width: 30px;"><img width="30px" height="30px" src="' + this.image + '"/></td>' +
          '<td>' + this.name + '</td>' +
          '<td title="Unit Price">Rs ' + this.price + '</td>' +
          '<td title="Quantity"><input type="number" min="1" style="width: 70px;" class="' + classProductQuantity + '" value="' + this.quantity + '"/></td>' +
          '<td title="Total Amount" class="' + classProductTotal + '"> Rs ' + total + '</td>' +
          '<td title="remark">  <input type="text" id="txtREMARKS" placeholder="Enter your remarks" /> </td>' +
          '<td title="Remove from Cart" class="text-center" style="width: 30px;"><a href="javascript:void(0);" class="btn btn-xs btn-danger ' + classProductRemove + '">X</a></td>' +
          '</tr>'
        );

 
  • August 07, 2017
  • Like
  • 0
Hi, I have a cart form which is a pop up.I want to add extra editable rows in the form  on click of a button.

 var products = ProductManager.getAllProducts();
      $.each(products, function(){
        var total = this.quantity * this.price;
        $cartTable.append(
          '<tr title="' + this.summary + '" data-id="' + this.id + '" data-price="' + this.price + '">' +
          '<td class="text-center" style="width: 30px;"><img width="30px" height="30px" src="' + this.image + '"/></td>' +
          '<td name="name<? $i ?>">' + this.name + '</td>' +
          '<td title="Unit Price" name="unitprice<? $i ?>">Rs ' + this.price + '</td>' +
          '<td title="Quantity" name="quantity<? $i ?>"><input type="number" min="1" style="width: 70px;" class="' + classProductQuantity + '" value="' + this.quantity + '"/></td>' +
          '<td title="Total" class="' + classProductTotal + '"> Rs ' + total + '</td>' +
          '<td title="Remove from Cart" class="text-center" style="width: 30px;"><a href="javascript:void(0);" class="btn btn-xs btn-danger ' + classProductRemove + '">X</a></td>' +
          '</tr>'
        );


User-added image
  • August 01, 2017
  • Like
  • 1
Hi, I am creating a visualforce feedbackform with smiley , I have a custom object Feedback__c and Response__c . So I am fetching the questions from Feedback__c using repeat .
For smiley I am using radio buttons inside repeat function.
I want to select one radio button from each group.But the problem is the radio button is working for first row but when i am clicking on any other row again the respected radio button from the first row get selected.
My code is:-

<apex:page standardController="Feedback__c" extensions="ctr_feedbackform" applyHtmlTag="true" sidebar="false" showHeader="false" language="{!langu}" standardStylesheets="false"  doctype="HTML-5.0">
   <html>
    
    <head>
    <!--js and css files-->
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />        
       
        <script src="https://code.jquery.com/jquery-1.11.3.min.js"/>
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/> 
        <link href="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/css/bootstrap.css')}" rel="stylesheet" />
        <link href="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/dist/jquery.bootgrid.css')}" rel="stylesheet" />        
        <script src="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/js/modernizr-2.8.1.js')}"></script>
        <script src="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/js/bootstrap.min.js')}"></script>
        <script src="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/js/star-rating.js')}"></script> 
        <apex:stylesheet value="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/css/star-rating.css')}"/> 
        <apex:includeScript value="{!URLFOR($Resource.asset, 'asset/js/jquery.min.js')}"/>
        <apex:stylesheet value="{!URLFOR($Resource.asset, 'asset/css/bootstrap.min.css')}"/>
        
        <title>Citi Residency</title>
     <style>            
            .msgpanel{
                color: #3c763d;
                background-color: #dff0d8;
                border-color: #d6e9c6;
                margin-top: 250px;
                margin-left: 300px;
            }     
            .panel-primary> .panel-heading {
                font-weight: bold;
            }
            .list{
                width: 20%;
                margin-left: 430px;
            }
            .pick{
                margin-left: 150px;
            }
            .menu{
                text-align: center;
                cursor: pointer;
                color: #428bca;
                font-weight: normal;
            }
            .pull-left {
                margin-top: 10px;
            }
            .btn-danger {
                margin-left: 10px;
            }
            .fontcolor{
                background-color: #eee;
                color: #428bca;
            }
            .vertical-center {
              min-height: 100%;
              min-height: 100vh;
              display: flex;
              align-items: center;
              justify-content: center;
              flex-direction: column;
              display: -webkit-flex; /* For Safari */
              -webkit-justify-content: center; /* For Safari */
              -webkit-align-items: center; /* For Safari */
            }
        </style>
          <style>

.lookupInput img
{
    background-repeat: no-repeat;
    margin-center: .25em;
    vertical-align: right;
}
.lookupInput .disabled
{
    background-color: #ccc;
}
.lookupInput .emptyDependentLookup
{
    font-style: italic;
}
.lookupInput input[readonly]
{
    background-color: #e6e6e6;
    border: 2px solid #e6e6e6;
    color: #333;
    cursor: default;
}
.lookupInput a.readOnly
{
    float: right;
}
.lookupInput span.readOnly
{
    display: block;
    white-space: normal;
}
.lookupInput span.totalSummary
{
    font-weight: bold;
}
.inlineEditRequiredDiv .lookupInput img,.inlineEditDiv .lookupInput img
{
    vertical-align: middle;
}
.quickCreateModule .lookupInput input {
    max-width: 155px
}
.lookupIcon {
    background-image: url(/img/func_icons/util/lookup20.gif);
    background-position: 0 0;
    width: 20px;
    height: 20px;
    background-position: top left
}
.lookupIconOn {
    background-image: url(/img/func_icons/util/lookup20.gif);
    background-position: 0 0;
    width: 20px;
    height: 20px;
    background-position: top right

</style>

<style>
/* lookup field override */


.lookupInput img {
  float:center;
}
.span.lookupInput {
  position: relative;
  display: inherit;
}
.lookupInput a, .lookupInput a {
  border: none !important;
  background: none !important;
}

.radioinput input[type="radio"]{float:top;}

.radioinput label{display:block;}

    lor:#f2f2f2;
    font-family:Arial, sans-serif;
}

 .left   {text-align:left;}
 .center {text-align:center;}
 .right  {text-align:right;}
 .my_text{
     font-family:  Arial, Helvetica, sans-serif
     font-size:  60px;
     font-weight: bold;
     color: #337AB7;
}
</style> 

<style>

/* =============================================
* RADIO BUTTONS
=============================================== */

#radios label {
    cursor: pointer;
    position: relative;
}

#radios label + label {
    margin-left: 15px;
}

input[type="radio"] {
    opacity: 0; /* hidden but still tabable */
    position: absolute;
}

input[type="radio"] + span {
    font-family: 'Material Icons';
    //color: #B3CEFB;
    border-radius: 50%;
    padding: 20px;
    transition: all 0.4s;
    -webkit-transition: all 0.4s;
}

input[type="radio"]:checked + span {
    color: #D9E7FD;
  background-color: #4285F4;
}

input[type="radio"]:focus + span {
    color: #fff;
}

/* ================ TOOLTIPS ================= */

#radios label:hover::before {
    content: attr(for);
    font-family: Roboto, -apple-system, sans-serif;
    text-transform: capitalize;
    font-size: 11px;
    position: absolute;
    top: 170%;
    left: 0;
    right: 0;
    opacity: 0.75;
    background-color: #323232;
    color: #fff;    
    padding: 4px;
    border-radius: 3px;
  display: block;
}

</style>
     
    </head>
    
    <apex:form >
        <apex:pageBlock >
            <apex:actionFunction name="setEng" action="{!changeToEnglish}" immediate="true"/>
            <!--<apex:actionFunction name="setBen" action="{!changeToBengali}" immediate="true"/>-->
            <!--<apex:actionFunction name="setHindi" action="{!changeToHindi}" immediate="true"/>-->
            
            <div class="vertical-center">
            <div class="container">
                
                <div class="row">
                    <div class="col-sm-8 col-sm-offset-2">                                         
                        <div class="panel panel-primary"> 
                            <div class="panel-heading">                                        
                                <div class="pull-left">
                                    <h3 class="panel-title">{!$label.FBTitle}</h3>
                                </div>
                                <div class="pull-right">
                                    <ul class="nav nav-tabs"> 
                                      
                                    </ul>
                                </div>
                                <div class="clearfix"></div>
                            </div> 
                           
                            <div class="panel-body"> 
                                <div class="alert-danger">
                                    <apex:messages />
                                </div> 
                                
                                <div class="form-group"> 
                                    <label for="desc">{!$ObjectType.Response__c.fields.Email__c.Label}:</label>
                                    <apex:inputField value="{!re.Email__c}" styleClass="form-control" html-placeholder="xyz@abc.com"  required="true"/>   
                                </div> 
                                <div class="form-group"> 
                                    <label for="desc">{!$ObjectType.Response__c.fields.Mobile__c.Label}:</label>
                                    <apex:inputField type="tel" value="{!re.Mobile__c}" styleClass="form-control" html-placeholder="10 digit Mobile No. " required="true"/>   
                                </div>
                               
                                <div class="form-group"> 
                                    <label for="desc">{!$ObjectType.Response__c.fields.Room__c.Label}:</label>
                                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                                    <apex:inputField value="{!re.Room__c}"/>   
                                </div> 
                                
                                <apex:variable value="{!1}" var="rowNum"/>  
                                <apex:repeat value="{!fb}" var="f">
                                 <apex:outputPanel rendered="{!if(f.Category__c='Restaurant',TRUE,FALSE)}">
                                    <div class="row form-group">
                                        <div class="col-md-12 col-sm-12 col-xs-12"> 
                                            <div class="my_text">
                                            
                                                ({!rowNum}) {!f.Question__c} 
                                            </div> 
                                        </div>
                                        <br/><br/>
                                        <div class="col-md-6 col-sm-6 col-xs-12 "> 
                                       
                                                <div id="{!rowNum}">
                                                    <label for="excellent" class="material-icons">
                                                        <input type="radio" name="{!rowNum}" id="excellent" value="excellent"/>
                                                        <span>&#xE815;</span>
                                                    </label>                                
                                                    <label for="good" class="material-icons">
                                                        <input type="radio" name="{!rowNum}" id="good" value="good" />
                                                        <span>&#xE812;</span>
                                                    </label>
                                                    <label for="poor" class="material-icons">
                                                        <input type="radio" name="{!rowNum}" id="poor" value="poor" />
                                                        <span>&#xE814;</span>
                                                    </label>
                                                </div>
                                            
                                                                                     
                                        </div>
                                      
                                        
                                    </div>      
                                    <apex:variable var="rowNum" value="{!rowNum + 1}"/>
                                    </apex:outputPanel>
                                    <br/>
                                </apex:repeat>
                                
                                
                                
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-5">
                                     <apex:commandButton styleClass="btn btn-success" value="{!$Label.FBSave}" action="{!save}" />&nbsp;&nbsp;
                                     <apex:commandButton styleClass="btn btn-danger" value="{!$Label.FBCancel}" immediate="true" action="{!Cancel}" /> 
                                    </div>
                                </div> 
                            </div> 
                          
                          </div>                  
                      </div>
                  </div>
              </div>
          </div>
          
        </apex:pageBlock>
        
        
    </apex:form>
    </html>
</apex:page>
 
  • July 06, 2017
  • Like
  • 0
Hi, 
I am writing a test class for my ctr_searchController

public with sharing class ctr_searchcontroller {

    Public Menu__c menu { get; set;}
    Public String mid {get;set;}
    Public String cid { get; set;}
    public String lang { get; set; }
    Public String tout { get; set;}
    Public String tablen{get;set;}
    Public Contact c { get; set;}
    Public String cmessage { get; set;}
     Public Room__c room {get;set;}
     Public id existingorderid { get; set;}    
    // Public String Closelaterorderid{get; set;}
     // Public Boolean closelater{get; set;}
      Public List<Order__c> order { get; set;}
      
     public ctr_searchcontroller(){
        lang = ApexPages.currentPage().getParameters().get('lang');
        mid = ApexPages.currentPage().getParameters().get('mid');
        cid = ApexPages.currentPage().getParameters().get('cid');
           cmessage = Label.Order_Submissions;
        existingorderid = null;
       room = new Room__c();
        tout = System.currentPageReference().getParameters().get('tout');
        tablen = ApexPages.currentPage().getParameters().get('tablen');
         if(cid!=null & cid!=''){
        c = [select id,name,Last_Login_Reff_Id__c,Mobilephone from contact where id=:cid limit 1];
        //order = [select id, Name,status__c from Order__c where Customer__c=:c.id and Session_id__c=:c.Last_Login_Reff_Id__c limit 1];
         order = [select id, Name,status__c from Order__c where Customer__c=:c.id and Tables__c=:tablen and Status__c='In Progress'  limit 1];
        if(order.size()>0)
                existingorderid = order[0].id;
            else
                existingorderid = null;
            
        }
        else{
            pagereference ref = new pagereference('/apex/vfp_firstpage');
            ref.setredirect(true);
        } 
         menu = [select id, name,Category__c,Description__c,Dish_Name__c,ImageURL__c,
        Price__c,Special_Dish__c,Status__c from Menu__c where id=:mid];
        
  }
}


My test class is:

@isTest
public class ctr_searchControllerTest {
    @isTest
    static void searchController(){
    
       
       // Menu__c menu = new Menu__c();
        
         
        ctr_searchController search = new ctr_searchController();
        Contact c = new Contact();
        ApexPages.currentPage().getParameters().put('cid', c.Id);
        search.menu = new Menu__c(Description__c='this is sample');
        insert search.menu;

        search.lang ='eng';
        search.tablen='1';
        search.tout ='out';
        search.order = new List<Order__c>();
        search.c = new contact(lastname='ram');
        search.room = new room__c();
       // search.c = [select id,name,Last_Login_Reff_Id__c,Mobilephone from contact where id=:'cid' limit 1];
        
        
        //search.closelater = false;
        //search.Closelaterorderid ='55888888';
        search.existingorderid ='85255558888';
      //  search.existingorderid ='';        
    }
}


I m getting the error System Exception: List has no rows for assignment to SObject
 
  • June 30, 2017
  • Like
  • 0
I am using a jquey incrementor and decrementor button in add to cart vf page for increasing and decreasing quantity.Initially i was using a number field 

and the code below is working fine to increment the cart value
 $(document).on("input", "." + classProductQuantity, function () {
      var price = $(this).closest("tr").data("price");
      var id = $(this).closest("tr").data("id");
      var quantity = $(this).val();
      alert(quantity);
      alert(price);
      $(this).parent("td").next("." + classProductTotal).text("Rs " + price * quantity);
      ProductManager.updatePoduct(id, quantity);

      $cartBadge.text(ProductManager.getTotalQuantity());
      showGrandTotal();
      showDiscountPrice();
    });

As number field is not working in tablet, I am using jquery to replace the number field.

var drawTable = function(){
      var $cartTable = $("#" + idCartTable);
      $cartTable.empty();

      var products = ProductManager.getAllProducts();
      $.each(products, function(){
        var total = this.quantity * this.price;
        $cartTable.append(
          '<tr title="' + this.summary + '" data-id="' + this.id + '" data-price="' + this.price + '">' +
          '<td class="text-center" style="width: 30px;"><img width="30px" height="30px" src="' + this.image + '"/></td>' +
          '<td>' + this.name + '</td>' +
          '<td title="Unit Price">Rs ' + this.price + '</td>' +
          '<td title="Quantity">'+      
          '<div class="center">'+
          '<div class="input-group">'+
          '<span class="input-group-btn">'+
              '<button type="button" class="btn btn-default btn-number" data-type="minus" data-field="' + this.id + '">'+
                  '<span class="glyphicon glyphicon-minus"></span>'+
              '</button>'+
          '</span>'+
          '<input type="text" name="' + this.id + '"  class="' + classProductQuantity + ' form-control input-number" value="' + this.quantity + '" min="1" max="20">'+
          '<span class="input-group-btn">'+
              '<button type="button" class="btn btn-default btn-number" data-type="plus" data-field="' + this.id + '">'+
                  '<span class="glyphicon glyphicon-plus"></span>'+
              '</button>'+
          '</span>'+
          '</div>'+
          '</div>'+
          '</td>' + 
            '<td title="Total" class="' + classProductTotal + '"> Rs ' + total + '</td>' +
          
          '<td title="Remove from Cart" class="text-center" style="width: 30px;"><a href="javascript:void(0);" class="btn btn-xs btn-danger ' + classProductRemove + '">X</a></td>' +
          '</tr>'
        );
       
    $(document).ready(function(){     
        $('.btn-number').click(function(e){
        e.preventDefault();
        var fieldName = $(this).attr('data-field');
        var type = $(this).attr('data-type');
        var input = $("input[name='"+fieldName+"']");
        var currentVal = parseInt(input.val());
        var price = $(this).closest("tr").data("price");
        var id = $(this).closest("tr").data("id");
        alert(price);
        alert(id);
        alert(currentVal)
        if (!isNaN(currentVal)) 
        {
            if(type == 'minus') 
            {
            
                if(currentVal > input.attr('min')) 
                {
                  
                    input.val(currentVal - 1).change();
                } 
                if(parseInt(input.val()) == input.attr('min')) {
                    $(this).attr('disabled', true);
                }
              
               $(this).parent("td").next("." + classProductTotal).text("Rs " + price * quantity);
               ProductManager.updatePoduct(id, quantity);
               alert("ok");
      $cartBadge.text(ProductManager.getTotalQuantity());
      showGrandTotal();

        } else if(type == 'plus') 
        {

            if(currentVal < input.attr('max')) {
                input.val(currentVal + 1).change();
            }
            if(parseInt(input.val()) == input.attr('max')) {
                $(this).attr('disabled', true);
            }

        }
        
    } 
    else 
    {
        input.val(0);
    }
     
});




$('.input-number').focusin(function(){
  $(this).data('oldValue', $(this).val());
});
$('.input-number').change(function() {
    
    minValue =  parseInt($(this).attr('min'));
    maxValue =  parseInt($(this).attr('max'));
    valueCurrent = parseInt($(this).val());
    name = $(this).attr('name');
    if(valueCurrent >= minValue) {
        $(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
    } else {
        alert('Sorry, the minimum value was reached');
        $(this).val($(this).data('oldValue'));
    }
    if(valueCurrent <= maxValue) {
        $(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled')
    } else {
        alert('Sorry, the maximum value was reached');
        $(this).val($(this).data('oldValue'));
    }
    
    
});
$(".input-number").keydown(function (e) {
        // Allow: backspace, delete, tab, escape, enter and .
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
             // Allow: Ctrl+A
            (e.keyCode == 65 && e.ctrlKey === true) || 
             // Allow: home, end, left, right
            (e.keyCode >= 35 && e.keyCode <= 39)) {
                 // let it happen, don't do anything
                 return;
        }
        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    });
   });
});

So, the problem is the value is increasing and decreasing properly.But when i am closing the cart ....the value is getting reset to the initial value...ie it is not holding the value.
User-added image
and also the quantity and price is not getting multiplied.
  • June 22, 2017
  • Like
  • 0
Hi, I want to write a test class for this....I am not able to get what i should write for the fetching cookies method and for the go method i am not able to cover all the lines.

public with sharing class ctr_validation {
     // Varaible Declaration
    Public String lang {get;set;}
    Public Contact con { get; set;}
    Public String tout { get; set;}
    Public String tablen{get;set;}
    //Public String existingorderid { get; set;}
    List<String> errorMessages = new List<String>();
    
    /* Constructor Starts here */      
    public ctr_validation(){
        lang = ApexPages.currentPage().getParameters().get('lang');
        tout = System.currentPageReference().getParameters().get('tout');
        tablen = ApexPages.currentPage().getParameters().get('tablen');
        languageCookiValue(lang);
        con = new Contact();
       }
    //Fetch cookie's language
    private string fetchLanguageCook(){
        string data='';
        Cookie cook = ApexPages.currentPage().getCookies().get('language');
        if(cook != null){
            data = cook.getvalue();
        }
        return data;
    }
    
     /* Go method Starts here */  
    public PageReference go() {
        try{
             if(con.MobilleNumber__c.length() < 10 || con.MobilleNumber__c.startsWith('00') || con.MobilleNumber__c.length() > 10)
              {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please enter 10 Digit for Mobile Number EX: XXXXXXXXXX'));  
              }
              
              else if (con.MobilleNumber__c!= null && con.MobilleNumber__c!= '')
              {
                  List<Contact> checkcon = new List<Contact>();
                  checkcon  = [select id, name, phone, MobilleNumber__c from contact where MobilleNumber__c=:con.MobilleNumber__c limit 1];
                  system.debug('&&&&'+con);
                  if(checkcon.size()>0){
                      Contact conupdate = new Contact();
                      conupdate.Last_Login_Reff_Id__c = string.valueof(system.now());
                      conupdate.id =checkcon[0].id;
                      update conupdate;
                      PageReference conpg = new PageReference('/apex/vfp_main?cid='+checkcon[0].id+'&lang='+lang+'&tout='+tout+'&tablen='+tablen);
                      conpg.setRedirect(TRUE);
                      return conpg;
                  }
                  else{
                      
                      PageReference connewpg = new PageReference('/apex/vfp_contactInfo?lang='+lang+'&mob='+con.MobilleNumber__c+'&tout='+tout+'&tablen='+tablen);
                      connewpg.setRedirect(TRUE);
                      return connewpg;
                  }
             }
             else
             {
              ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter the mobile number'));
              return null;
             }
           
           }
           Catch(Exception e){
              ApexPages.addmessages(e);
              return null;
           }
            return null;
   }
   /* Go method ends here */      
    
    /* home method Starts here */      
    public PageReference home() {
        PageReference homepg= new PageReference('/apex/vfp_home');
        homepg.setRedirect(TRUE);
        return homepg;
    }
   /* home method ends here */   
           
             
}
  • June 21, 2017
  • Like
  • 0
I want to write test class for my ctr_homepage class.
public with sharing class ctr_homepage {
     // Varaible Declaration
    Public String tablen{get;set;}
    Public String tout { get; set;}
    
     /* Constructor Starts here */ 
    Public ctr_homepage(){
        tout = System.currentPageReference().getParameters().get('tout');
        tablen = ApexPages.currentPage().getParameters().get('tablen');
    }
      /* Constructor ends here */ 
 
    // To redirect to english Language
    public PageReference english() {
        PageReference engpg = new PageReference('/apex/vfp_validation?lang=en&tout='+tout+'&tablen='+tablen);
        engpg.setRedirect(TRUE);
        return engpg ;
    }

   // To redirect to hindi Language
    public PageReference hindi() {
        PageReference hinpg = new PageReference('/apex/vfp_validation?lang=hi');
        hinpg.setRedirect(TRUE);
        return hinpg ;
    }
    
    // To redirect to bengali Language
    public PageReference bengali() {
       PageReference benpg = new PageReference('/apex/vfp_validation?lang=bn');
        benpg.setRedirect(TRUE);
        return benpg ;
    }

}

I am not able to understand what i should write for the PageReference.
  • June 21, 2017
  • Like
  • 0
I have a custom object Order__c with fields Tables__c(Table No) and Status__c(Picklist-In Progress/Completed). 
Another object Table__c having table no.
In the first page i have a lookup saying enter table number.....once i select a table no. and click next then from Order__c object i want to check if there is a record in custom order object with the table no. which i selected and status is equal to "In Progress".
if yes I want to store the existing order id in a variable 'existingorderid' and pass it in URL.
if no then set the existing order id as null.
Code-:
public with sharing class ctr_firstController {
 
       Public String tout { get; set;}
       Public String tablen{get;set;}
       Public  Tables__c  Table{get;set;}
       Public  Tables__c  Table1{get;set;}
       
       Public List<Order__c> eoid{get;set;}
       Public String exoid {get;set;}
       public String existingorderid {get;set;}
       
    public  ctr_firstController(){        
       Table = new Tables__c();
             
   }
   
   public Tables__c getTables() {
        return Table1;
    }

    public PageReference go() {
        
        String tableno =Table.TablesLU__c; 
       Table1 =  [select id, Name, Reserved__c from Tables__c where id=:tableno limit 1];
       Table1.Reserved__c= True;
       update Table1;
       
       eoid = [select id, name, Tables__c ,Status__c from Order__c where Tables__c=:Table1.Name and Status__c=:'In Progress' limit 1];
       if(eoid.size()>0)
           existingorderid = eoid[0].id;
       else
           existingorderid = null;

        pagereference ref = new pagereference('/apex/vfp_Home?exoid='+existingorderid+'&tablen='+tableno+'&tout=false');
        ref.setredirect(true);
        return ref;
        
        
    }




WHEN I AM USING THIS CODE ,THE NEXT PAGE URL IS SHOWING(exoid=null) instead of showing the id
https://c.cs58.visual.force.com/apex/vfp_Home?exoid=null&tablen=a050l000000FyRAAA0&tout=false
  • June 20, 2017
  • Like
  • 0
hi,
I have a favourite button which fetches the items which has been ordered more than twice.
This is my controller

    Public List<Menu__c> favmenu {get;set;}
     favmenu = [select id, name,Category__c,Description__c,Image__c,ImageURL__c,Dish_Name__c,Price__c,
                 Special_Dish__c,Status__c,SubCategory__c,veg_non_veg__c,remarks__c from Menu__c where id IN : menuIdList]; 
           
           if(favmenu.size()>0)
               nofavourites = 'Choose from your favourites';
           else
                nofavourites='No favourites yet';

When i m testing for favmenu.size()>0 ..... it is working fine....but for the else part, when the soql query is not fetching any item, it is showing the error
Attempt to de-reference a null object 
An unexpected error has occurred. Your development organization has been notified.
  • September 21, 2017
  • Like
  • 1
Hi, I have a cart form which is a pop up.I want to add extra editable rows in the form  on click of a button.

 var products = ProductManager.getAllProducts();
      $.each(products, function(){
        var total = this.quantity * this.price;
        $cartTable.append(
          '<tr title="' + this.summary + '" data-id="' + this.id + '" data-price="' + this.price + '">' +
          '<td class="text-center" style="width: 30px;"><img width="30px" height="30px" src="' + this.image + '"/></td>' +
          '<td name="name<? $i ?>">' + this.name + '</td>' +
          '<td title="Unit Price" name="unitprice<? $i ?>">Rs ' + this.price + '</td>' +
          '<td title="Quantity" name="quantity<? $i ?>"><input type="number" min="1" style="width: 70px;" class="' + classProductQuantity + '" value="' + this.quantity + '"/></td>' +
          '<td title="Total" class="' + classProductTotal + '"> Rs ' + total + '</td>' +
          '<td title="Remove from Cart" class="text-center" style="width: 30px;"><a href="javascript:void(0);" class="btn btn-xs btn-danger ' + classProductRemove + '">X</a></td>' +
          '</tr>'
        );


User-added image
  • August 01, 2017
  • Like
  • 1
I have created a web to case form in html in which there is a date field.I want to save the data entered in the date field though pop up calendar into a date field that i have created in the case object.But it is not taking the value of the date field. 
  • January 03, 2017
  • Like
  • 1
I am trying to insert the a Map of <Case,List<Case> as parents and their related child cases using apex. But once I insert the Map key set , the map values get null.
Map<Case,List<Case>> parentChildMap = new Map<Case,List<Case>>();
 List<Case> parentCases = new List<Case>();
        for(CaseWrapper wrap: caseWrapperList){
            parentChildMap.put(wrap.parentCase,wrap.childCases);
        }
        System.debug('map before insert==>'+parentChildMap);
        if(parentChildMap.keySet() !=null){
           parentCases.addAll(parentChildMap.keySet());
           insert parentCases ; 
           System.debug('map after insert==>'+parentChildMap);
        }


Debugs:
map before insert==> {Case:{Subject=1}=(Case:{Subject=1.1}), Case:{Subject=2}=(Case:{Subject=2.2})}

map after insert==> {Case:{Subject=1, Id=5000K00002cxQsWQAU}=null, Case:{Subject=2, Id=5000K00002cxQsXQAU}=null}

Why the values are geting set to null?
  • May 04, 2023
  • Like
  • 0
I have used the online Hmac generator and tested an API. Now I want to do the same thing using apex code.

I am not getting the success method by using the mac code generated using the method "Crypto.generateMac()".

I am generating the mac code using the method generateHmacSHA1Signature and calling the endpoint url using the mac generated earlier.

Getting the response as invalid signature.
public class HMACGenearatorHandler {
     public void createJson(){
         String jsonString; // create json here
         String json = '{"hotel":{"version":"1.0","datetime":"2019-11-12T08:09:59","request":{"method":"wsauth","key":"5151BE0BE4A9B667C07C727602C2EF4589658741"}}}';
         String sText= json.replaceAll( '\\s+', '');
         String strMd5= EncodingUtil.base64Encode (Crypto.generateDigest('MD5', Blob.valueOf(sText)));
         sendRequest(sText);
      generateHmacSHA1Signature(sText,'8B434FB19209EEE32002073C8680464785236985');
     } 
    
    @future (callout=true)
	public static void sendRequest(String jsonString){
        HttpRequest req = new HttpRequest();
        req.setEndpoint(System.Label.EndPoint);
        req.setMethod('POST');
        req.setHeader('X-HAPI-Signature','b7ua89TY1m6hHawC8v+ETX/SK7o=');
        req.setHeader('Content-Type', System.label.Content_Type); 
        req.setBody(jsonString);
        Http http = new Http();
        if(!test.isRunningTest()){
            HTTPResponse res = http.send(req);
            System.debug(res);
            System.debug('resp body+++'+res.getBody());
        } 
    } 
     
    public static Blob generateHmacSHA1Signature(String canonical_str, String secreteKey){ 
             Blob mac = Crypto.generateMac('HMacSHA1', Blob.valueof(canonical_str), Blob.valueof(secreteKey));
        	 String strSignature = EncodingUtil.base64Encode(mac);
             System.debug('strSignature11++'+strSignature);
             return mac;
         }
 }


 
  • November 12, 2019
  • Like
  • 0
Hi,
I have a apex checkbox field in the vf page called "ONLY VEG". When I first click on the check box it selects only veg item from menu object and shows in the vf page. But if i want to uncheck it again so thai it will again show all the veg and non veg items,,,,,But I am not able to uncheck it again.
Checkbox in vf page:
<apex:inputCheckbox value="{!myCheckbox}"> <apex:actionSupport event="onchange" action="{!onlyveg}" /> </apex:inputCheckbox>
Controller:
 public boolean myCheckbox {get; set;}

  public PageReference onlyveg(){
                if(myCheckbox=TRUE){
                system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
                menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Veg'];
                }else{
                system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
                menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Non-veg'];
                }
                
                return null;
         
    }
  • October 18, 2017
  • Like
  • 0
hi,
I have a favourite button which fetches the items which has been ordered more than twice.
This is my controller

    Public List<Menu__c> favmenu {get;set;}
     favmenu = [select id, name,Category__c,Description__c,Image__c,ImageURL__c,Dish_Name__c,Price__c,
                 Special_Dish__c,Status__c,SubCategory__c,veg_non_veg__c,remarks__c from Menu__c where id IN : menuIdList]; 
           
           if(favmenu.size()>0)
               nofavourites = 'Choose from your favourites';
           else
                nofavourites='No favourites yet';

When i m testing for favmenu.size()>0 ..... it is working fine....but for the else part, when the soql query is not fetching any item, it is showing the error
Attempt to de-reference a null object 
An unexpected error has occurred. Your development organization has been notified.
  • September 21, 2017
  • Like
  • 1
Hi, 
I have a custom site in salesforce. I have created it like when you enter your mobile number it will check the number in contact object and if the number is not existing one, it will get saved.
But now i want to give login through  facebook and google in the page ...
Can anyone please help me in this.
  • August 22, 2017
  • Like
  • 0
Hi,
I have a custom object calle OLI__c
I m trying to fetch  the order line items from OLI__c  that are repeated against a particular customer in the Order__c Object.

But I am getting the error 
List has no rows for assignment to SObject 
An unexpected error has occurred. Your development organization has been notified.

I have tested the soql query in developer console and it is giving the desired result.
favourites = [select Menu__r.id menuid from OLI__c  where Order__c in(SELECT id FROM Order__c where Customer__c=:c.id and Status__c='Completed') group By Order__r.Customer__r.name,Menu__r.Dish_Name__c,Menu__r.id having count(id)>1 ];
          
 for(AggregateResult ar : favourites){
                 
                 mid = String.Valueof(ar.get('menuid'));
                
            }

            if(mid!='')    
                favmenu = [select id, name,Category__c,Description__c,Image__c,ImageURL__c,Dish_Name__c,Price__c,
                 Special_Dish__c,Status__c,SubCategory__c,veg_non_veg__c,remarks__c from Menu__c where id=:mid];

 
  • August 21, 2017
  • Like
  • 0
I have a variable 'd' that captures the current date time.
In the same page i have a button inside jquery which is redirecting to a new page in new window.
I want to pass the variable d  in the url.
Code:
var d = new Date();
The url is :   '<a href="/apex/vfp_KOT?oid=" class="js-newWindow" data-popup="width=500,height=600"><button type="button" class="btn btn-primary">Print KOT</button></a>&nbsp;&nbsp;&nbsp;&nbsp;'+

New Window :  
$(document).ready(function(){
            $('.js-newWindow').click(function (event) {
                event.preventDefault();
                var $this = $(this);
                var url = $this.attr("href");
                var windowName = "popUp";
                var windowSize = $this.data("popup");
                //alert($.session.get('sessionoid'));
                var noid = $.session.get('sessionoid');
                var urlnew = url+noid;
                window.open(urlnew, windowName, windowSize);
            });
        });
  • August 09, 2017
  • Like
  • 0
I have a jquery popup window which has image , Dish name,quantity and price for various rows. I am able to fetch the data for each row and save in the back end. Now I want to add one text box in each row , showing the remarks .But I am not able to save the remark data from frontend to backend.

Code:
var products = ProductManager.getAllProducts();
      $.each(products, function(){
        var total = this.quantity * this.price;
        $cartTable.append(
          '<tr title="' + this.summary + '" data-id="' + this.id + '" data-price="' + this.price + '">' +
          '<td class="text-center" style="width: 30px;"><img width="30px" height="30px" src="' + this.image + '"/></td>' +
          '<td>' + this.name + '</td>' +
          '<td title="Unit Price">Rs ' + this.price + '</td>' +
          '<td title="Quantity"><input type="number" min="1" style="width: 70px;" class="' + classProductQuantity + '" value="' + this.quantity + '"/></td>' +
          '<td title="Total Amount" class="' + classProductTotal + '"> Rs ' + total + '</td>' +
          '<td title="remark">  <input type="text" id="txtREMARKS" placeholder="Enter your remarks" /> </td>' +
          '<td title="Remove from Cart" class="text-center" style="width: 30px;"><a href="javascript:void(0);" class="btn btn-xs btn-danger ' + classProductRemove + '">X</a></td>' +
          '</tr>'
        );

 
  • August 07, 2017
  • Like
  • 0
Hi, I am creating a visualforce feedbackform with smiley , I have a custom object Feedback__c and Response__c . So I am fetching the questions from Feedback__c using repeat .
For smiley I am using radio buttons inside repeat function.
I want to select one radio button from each group.But the problem is the radio button is working for first row but when i am clicking on any other row again the respected radio button from the first row get selected.
My code is:-

<apex:page standardController="Feedback__c" extensions="ctr_feedbackform" applyHtmlTag="true" sidebar="false" showHeader="false" language="{!langu}" standardStylesheets="false"  doctype="HTML-5.0">
   <html>
    
    <head>
    <!--js and css files-->
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />        
       
        <script src="https://code.jquery.com/jquery-1.11.3.min.js"/>
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/> 
        <link href="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/css/bootstrap.css')}" rel="stylesheet" />
        <link href="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/dist/jquery.bootgrid.css')}" rel="stylesheet" />        
        <script src="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/js/modernizr-2.8.1.js')}"></script>
        <script src="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/js/bootstrap.min.js')}"></script>
        <script src="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/js/star-rating.js')}"></script> 
        <apex:stylesheet value="{!URLFOR($Resource.bootstrap,'bootstrap/bootstrap/css/star-rating.css')}"/> 
        <apex:includeScript value="{!URLFOR($Resource.asset, 'asset/js/jquery.min.js')}"/>
        <apex:stylesheet value="{!URLFOR($Resource.asset, 'asset/css/bootstrap.min.css')}"/>
        
        <title>Citi Residency</title>
     <style>            
            .msgpanel{
                color: #3c763d;
                background-color: #dff0d8;
                border-color: #d6e9c6;
                margin-top: 250px;
                margin-left: 300px;
            }     
            .panel-primary> .panel-heading {
                font-weight: bold;
            }
            .list{
                width: 20%;
                margin-left: 430px;
            }
            .pick{
                margin-left: 150px;
            }
            .menu{
                text-align: center;
                cursor: pointer;
                color: #428bca;
                font-weight: normal;
            }
            .pull-left {
                margin-top: 10px;
            }
            .btn-danger {
                margin-left: 10px;
            }
            .fontcolor{
                background-color: #eee;
                color: #428bca;
            }
            .vertical-center {
              min-height: 100%;
              min-height: 100vh;
              display: flex;
              align-items: center;
              justify-content: center;
              flex-direction: column;
              display: -webkit-flex; /* For Safari */
              -webkit-justify-content: center; /* For Safari */
              -webkit-align-items: center; /* For Safari */
            }
        </style>
          <style>

.lookupInput img
{
    background-repeat: no-repeat;
    margin-center: .25em;
    vertical-align: right;
}
.lookupInput .disabled
{
    background-color: #ccc;
}
.lookupInput .emptyDependentLookup
{
    font-style: italic;
}
.lookupInput input[readonly]
{
    background-color: #e6e6e6;
    border: 2px solid #e6e6e6;
    color: #333;
    cursor: default;
}
.lookupInput a.readOnly
{
    float: right;
}
.lookupInput span.readOnly
{
    display: block;
    white-space: normal;
}
.lookupInput span.totalSummary
{
    font-weight: bold;
}
.inlineEditRequiredDiv .lookupInput img,.inlineEditDiv .lookupInput img
{
    vertical-align: middle;
}
.quickCreateModule .lookupInput input {
    max-width: 155px
}
.lookupIcon {
    background-image: url(/img/func_icons/util/lookup20.gif);
    background-position: 0 0;
    width: 20px;
    height: 20px;
    background-position: top left
}
.lookupIconOn {
    background-image: url(/img/func_icons/util/lookup20.gif);
    background-position: 0 0;
    width: 20px;
    height: 20px;
    background-position: top right

</style>

<style>
/* lookup field override */


.lookupInput img {
  float:center;
}
.span.lookupInput {
  position: relative;
  display: inherit;
}
.lookupInput a, .lookupInput a {
  border: none !important;
  background: none !important;
}

.radioinput input[type="radio"]{float:top;}

.radioinput label{display:block;}

    lor:#f2f2f2;
    font-family:Arial, sans-serif;
}

 .left   {text-align:left;}
 .center {text-align:center;}
 .right  {text-align:right;}
 .my_text{
     font-family:  Arial, Helvetica, sans-serif
     font-size:  60px;
     font-weight: bold;
     color: #337AB7;
}
</style> 

<style>

/* =============================================
* RADIO BUTTONS
=============================================== */

#radios label {
    cursor: pointer;
    position: relative;
}

#radios label + label {
    margin-left: 15px;
}

input[type="radio"] {
    opacity: 0; /* hidden but still tabable */
    position: absolute;
}

input[type="radio"] + span {
    font-family: 'Material Icons';
    //color: #B3CEFB;
    border-radius: 50%;
    padding: 20px;
    transition: all 0.4s;
    -webkit-transition: all 0.4s;
}

input[type="radio"]:checked + span {
    color: #D9E7FD;
  background-color: #4285F4;
}

input[type="radio"]:focus + span {
    color: #fff;
}

/* ================ TOOLTIPS ================= */

#radios label:hover::before {
    content: attr(for);
    font-family: Roboto, -apple-system, sans-serif;
    text-transform: capitalize;
    font-size: 11px;
    position: absolute;
    top: 170%;
    left: 0;
    right: 0;
    opacity: 0.75;
    background-color: #323232;
    color: #fff;    
    padding: 4px;
    border-radius: 3px;
  display: block;
}

</style>
     
    </head>
    
    <apex:form >
        <apex:pageBlock >
            <apex:actionFunction name="setEng" action="{!changeToEnglish}" immediate="true"/>
            <!--<apex:actionFunction name="setBen" action="{!changeToBengali}" immediate="true"/>-->
            <!--<apex:actionFunction name="setHindi" action="{!changeToHindi}" immediate="true"/>-->
            
            <div class="vertical-center">
            <div class="container">
                
                <div class="row">
                    <div class="col-sm-8 col-sm-offset-2">                                         
                        <div class="panel panel-primary"> 
                            <div class="panel-heading">                                        
                                <div class="pull-left">
                                    <h3 class="panel-title">{!$label.FBTitle}</h3>
                                </div>
                                <div class="pull-right">
                                    <ul class="nav nav-tabs"> 
                                      
                                    </ul>
                                </div>
                                <div class="clearfix"></div>
                            </div> 
                           
                            <div class="panel-body"> 
                                <div class="alert-danger">
                                    <apex:messages />
                                </div> 
                                
                                <div class="form-group"> 
                                    <label for="desc">{!$ObjectType.Response__c.fields.Email__c.Label}:</label>
                                    <apex:inputField value="{!re.Email__c}" styleClass="form-control" html-placeholder="xyz@abc.com"  required="true"/>   
                                </div> 
                                <div class="form-group"> 
                                    <label for="desc">{!$ObjectType.Response__c.fields.Mobile__c.Label}:</label>
                                    <apex:inputField type="tel" value="{!re.Mobile__c}" styleClass="form-control" html-placeholder="10 digit Mobile No. " required="true"/>   
                                </div>
                               
                                <div class="form-group"> 
                                    <label for="desc">{!$ObjectType.Response__c.fields.Room__c.Label}:</label>
                                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                                    <apex:inputField value="{!re.Room__c}"/>   
                                </div> 
                                
                                <apex:variable value="{!1}" var="rowNum"/>  
                                <apex:repeat value="{!fb}" var="f">
                                 <apex:outputPanel rendered="{!if(f.Category__c='Restaurant',TRUE,FALSE)}">
                                    <div class="row form-group">
                                        <div class="col-md-12 col-sm-12 col-xs-12"> 
                                            <div class="my_text">
                                            
                                                ({!rowNum}) {!f.Question__c} 
                                            </div> 
                                        </div>
                                        <br/><br/>
                                        <div class="col-md-6 col-sm-6 col-xs-12 "> 
                                       
                                                <div id="{!rowNum}">
                                                    <label for="excellent" class="material-icons">
                                                        <input type="radio" name="{!rowNum}" id="excellent" value="excellent"/>
                                                        <span>&#xE815;</span>
                                                    </label>                                
                                                    <label for="good" class="material-icons">
                                                        <input type="radio" name="{!rowNum}" id="good" value="good" />
                                                        <span>&#xE812;</span>
                                                    </label>
                                                    <label for="poor" class="material-icons">
                                                        <input type="radio" name="{!rowNum}" id="poor" value="poor" />
                                                        <span>&#xE814;</span>
                                                    </label>
                                                </div>
                                            
                                                                                     
                                        </div>
                                      
                                        
                                    </div>      
                                    <apex:variable var="rowNum" value="{!rowNum + 1}"/>
                                    </apex:outputPanel>
                                    <br/>
                                </apex:repeat>
                                
                                
                                
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-5">
                                     <apex:commandButton styleClass="btn btn-success" value="{!$Label.FBSave}" action="{!save}" />&nbsp;&nbsp;
                                     <apex:commandButton styleClass="btn btn-danger" value="{!$Label.FBCancel}" immediate="true" action="{!Cancel}" /> 
                                    </div>
                                </div> 
                            </div> 
                          
                          </div>                  
                      </div>
                  </div>
              </div>
          </div>
          
        </apex:pageBlock>
        
        
    </apex:form>
    </html>
</apex:page>
 
  • July 06, 2017
  • Like
  • 0
I am using a jquey incrementor and decrementor button in add to cart vf page for increasing and decreasing quantity.Initially i was using a number field 

and the code below is working fine to increment the cart value
 $(document).on("input", "." + classProductQuantity, function () {
      var price = $(this).closest("tr").data("price");
      var id = $(this).closest("tr").data("id");
      var quantity = $(this).val();
      alert(quantity);
      alert(price);
      $(this).parent("td").next("." + classProductTotal).text("Rs " + price * quantity);
      ProductManager.updatePoduct(id, quantity);

      $cartBadge.text(ProductManager.getTotalQuantity());
      showGrandTotal();
      showDiscountPrice();
    });

As number field is not working in tablet, I am using jquery to replace the number field.

var drawTable = function(){
      var $cartTable = $("#" + idCartTable);
      $cartTable.empty();

      var products = ProductManager.getAllProducts();
      $.each(products, function(){
        var total = this.quantity * this.price;
        $cartTable.append(
          '<tr title="' + this.summary + '" data-id="' + this.id + '" data-price="' + this.price + '">' +
          '<td class="text-center" style="width: 30px;"><img width="30px" height="30px" src="' + this.image + '"/></td>' +
          '<td>' + this.name + '</td>' +
          '<td title="Unit Price">Rs ' + this.price + '</td>' +
          '<td title="Quantity">'+      
          '<div class="center">'+
          '<div class="input-group">'+
          '<span class="input-group-btn">'+
              '<button type="button" class="btn btn-default btn-number" data-type="minus" data-field="' + this.id + '">'+
                  '<span class="glyphicon glyphicon-minus"></span>'+
              '</button>'+
          '</span>'+
          '<input type="text" name="' + this.id + '"  class="' + classProductQuantity + ' form-control input-number" value="' + this.quantity + '" min="1" max="20">'+
          '<span class="input-group-btn">'+
              '<button type="button" class="btn btn-default btn-number" data-type="plus" data-field="' + this.id + '">'+
                  '<span class="glyphicon glyphicon-plus"></span>'+
              '</button>'+
          '</span>'+
          '</div>'+
          '</div>'+
          '</td>' + 
            '<td title="Total" class="' + classProductTotal + '"> Rs ' + total + '</td>' +
          
          '<td title="Remove from Cart" class="text-center" style="width: 30px;"><a href="javascript:void(0);" class="btn btn-xs btn-danger ' + classProductRemove + '">X</a></td>' +
          '</tr>'
        );
       
    $(document).ready(function(){     
        $('.btn-number').click(function(e){
        e.preventDefault();
        var fieldName = $(this).attr('data-field');
        var type = $(this).attr('data-type');
        var input = $("input[name='"+fieldName+"']");
        var currentVal = parseInt(input.val());
        var price = $(this).closest("tr").data("price");
        var id = $(this).closest("tr").data("id");
        alert(price);
        alert(id);
        alert(currentVal)
        if (!isNaN(currentVal)) 
        {
            if(type == 'minus') 
            {
            
                if(currentVal > input.attr('min')) 
                {
                  
                    input.val(currentVal - 1).change();
                } 
                if(parseInt(input.val()) == input.attr('min')) {
                    $(this).attr('disabled', true);
                }
              
               $(this).parent("td").next("." + classProductTotal).text("Rs " + price * quantity);
               ProductManager.updatePoduct(id, quantity);
               alert("ok");
      $cartBadge.text(ProductManager.getTotalQuantity());
      showGrandTotal();

        } else if(type == 'plus') 
        {

            if(currentVal < input.attr('max')) {
                input.val(currentVal + 1).change();
            }
            if(parseInt(input.val()) == input.attr('max')) {
                $(this).attr('disabled', true);
            }

        }
        
    } 
    else 
    {
        input.val(0);
    }
     
});




$('.input-number').focusin(function(){
  $(this).data('oldValue', $(this).val());
});
$('.input-number').change(function() {
    
    minValue =  parseInt($(this).attr('min'));
    maxValue =  parseInt($(this).attr('max'));
    valueCurrent = parseInt($(this).val());
    name = $(this).attr('name');
    if(valueCurrent >= minValue) {
        $(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
    } else {
        alert('Sorry, the minimum value was reached');
        $(this).val($(this).data('oldValue'));
    }
    if(valueCurrent <= maxValue) {
        $(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled')
    } else {
        alert('Sorry, the maximum value was reached');
        $(this).val($(this).data('oldValue'));
    }
    
    
});
$(".input-number").keydown(function (e) {
        // Allow: backspace, delete, tab, escape, enter and .
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
             // Allow: Ctrl+A
            (e.keyCode == 65 && e.ctrlKey === true) || 
             // Allow: home, end, left, right
            (e.keyCode >= 35 && e.keyCode <= 39)) {
                 // let it happen, don't do anything
                 return;
        }
        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    });
   });
});

So, the problem is the value is increasing and decreasing properly.But when i am closing the cart ....the value is getting reset to the initial value...ie it is not holding the value.
User-added image
and also the quantity and price is not getting multiplied.
  • June 22, 2017
  • Like
  • 0