• Sunil Pal
  • NEWBIE
  • 80 Points
  • Member since 2013
  • Sr. Technology Associate

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 65
    Replies
I am trying to write a test class for my Wrapper Class, unfortunately my overall code coverage is 51%, so I need to get more then 75% in order to deploy.how i will do plz help me 
public with sharing class CRM_AddProducts
{

    public String message { get; set; }
 
  public String SelectedProduct{get;set;}
  public list<pProduct> lstproduct { get; set; }
  public list<cproduct> cartlstproduct {get;set;}
  
  public list<CProduct__c> lstselproduct { get; set; }
  public list<CQuote_Line_Item__c> lstaddquoteproduct { get; set; }
  public List<SelectOption> Product_Selectionoptions {get;set;} 
  public boolean selected {get;set;}
  public boolean display {get;set;}
  public CProduct__c pro {get;set;}
 // public CProduct__c cpro{get;set;}
 // public CProduct__c cess{get;set;}
  public map<Id,double> mapProductIdToQuantity { get; set; }
  public string strid;
  public boolean blnStatus1 ;
  
  
  
  

    public CRM_AddProducts()
      {
          lstproduct=new list<pProduct>();
          mapProductIdToQuantity = new map<Id,double>();
          cartlstproduct = new list<cproduct>();
          lstaddquoteproduct = new list<CQuote_Line_Item__c>();
          strid = apexpages.currentPage().getParameters().get('id');
         
        
                for(CProduct__c objproduct : [select id,
                                              Name,
                                              List_Price__c,
                                              Product_Code__c,
                                              Product_Description__c,
                                              Sales_Price__c,
                                              Product_Family__c
                                      from    CProduct__c])
          {
              lstproduct.add(new pProduct(objproduct));
              system.debug('---lstproduct---'+lstproduct);
          }
      }
      
      
       public pageReference check()
    {
      return null;
    }
        
         
  
    //builds a picklist of product names based on their product id
      public List<SelectOption>getProduct_Selection() 
    
     {
        List<SelectOption> Product_Selectionoptions = new List<SelectOption>();
  //new list for holding all of the picklist options
       
       for (CProduct__c Product_Selection : [SELECT Id, Name FROM CProduct__c]) 
       { 
  //query for Product records 
       Product_Selectionoptions.add(new selectOption(Product_Selection.Id,Product_Selection.Name));
      
  //for all records found - add them to the picklist options
       }
       system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
      return Product_Selectionoptions; //return the picklist options
       
   }
   
         
         public pageReference addtocart()
         {
            for(pProduct cProd : lstproduct)
        {
                
                system.debug('----cProd---'+cProd);
                system.debug('--SelectedProduct--'+SelectedProduct);
                system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
               //  system.debug('-Product_Selection-'+Product_Selectionoptions.Product_Selection);
                if(cProd.selected == true)
                {
                  system.debug('----cProd---'+cProd);
                  CProduct__c objproduct1 =  [  select id,  Name,
                                                    List_Price__c,
                                                    Product_Code__c,
                                                    Product_Description__c,
                                                    Sales_Price__c,
                                                    Product_Family__c
                                            from    CProduct__c  
                                            where   id =:SelectedProduct];
                        cartlstproduct.add(new cproduct(objproduct1))     ;             
                     system.debug('---cartlstproduct---'+cartlstproduct);                       
                } 
        }      
           return null ;
         }
         
         
         
         
          public pageReference processSelected()
         {
           list<CQuote_Line_Item__c> lstaddquoteproduct = new list<CQuote_Line_Item__c>();
        //   list<CProduct__c> lstselproduct = new list<CProduct__c>();
           system.debug(lstproduct+'===lstproduct====');
  
          for(cproduct cess:cartlstproduct)
             {
                  system.debug('-----cess---'+cess);
                  if(cess.Display== true)
      {
        
                
       if((cess.quantity!=null && cess.quantity!='' && cess.quantity!=string.valueof(0) )&& (cess.salesprice!=null && cess.salesprice!='' ) )
        {
                  
              //mapProductIdToQuantity.put(cPro.pro.id,double.valueof(cPro.quantity));
              //system.debug(mapProductIdToQuantity+'---map---');
                
                CQuote_Line_Item__c objQuoteli = new CQuote_Line_Item__c();
                system.debug('---cess.quantity---'+cess.quantity);
                objQuoteli.Name = cess.cpro.Name  ;
                objQuoteli.Quantity__c =double.valueOf(cess.quantity) ;
                objQuoteli.Unit_Price__c =cess.cpro.List_Price__c;
                objQuoteli.Quote__c = strid;
                objQuoteli.Total_Amount__c= double.valueof(cess.TotalAmount );
                //objQuoteli.Discount_Percent__c = double.valueOf(cess.discount) ;
                objQuoteli.Sales_Price__c = double.valueOf(cess.salesprice) ;
                system.debug('---objQuoteli---'+objQuoteli);
                lstaddquoteproduct.add(objQuoteli);
                system.debug(lstaddquoteproduct+'----lstaddquoteproduct----');
                  }
            else
                     {
                            system.debug('---else---');
                            ApexPages.Message errormessage = new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter all the values.');
                            ApexPages.addMessage(errormessage);
                     }
                          
                  }
      
   }//for loop
    if(lstaddquoteproduct.size()>0)
                {
                   insert lstaddquoteproduct;
                   system.debug('---strid--'+strid);
                   pageReference pageRef1 = new pageReference('/'+strid);
                   pageRef1.setredirect(true);
                   return pageRef1;
              }
           return null;
           }
              
              
                //product list wrapper class
    
      public class pProduct
        {
            public CProduct__c pro {get;set;}
            public boolean selected {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public integer TotalAmount {get;set;}
            public integer discount {get;set;}
             //public string discount {get;set;}
            public pProduct(CProduct__c p)
                {
                    pro = p;    
                    selected = false ;   
                    quantity='1';
                }
        
        
        }  
        
        //cart list wrapper class
        public class cproduct
        {
            public CProduct__c cpro{get;set;}
            public boolean selected {get;set;}
            public boolean Display {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public string TotalAmount {get;set;}
            public string discount {get;set;}
            public cProduct(CProduct__c c)
                {
                    cpro = c;  
                    selected = false ;  
                    quantity='1';
                   salesprice= string.valueof( cpro.List_Price__c );
                     TotalAmount = string.valueof( cpro.List_Price__c );
                    Display = false ;
                }
        
        
        }
        
       
  
  
    public pageReference cancelbutton()
        {
            pageReference pageRef1 = new pageReference('/'+strid);
            pageRef1.setredirect(true);
            return pageRef1;
        }
 }

 
Hello Eveyone,

I have to get the all the messages with the same converarstionhappening in chatter messgaes by using the ConnectAPI. Whenver we click on the messges under the recent message came it expands and display all the messges within that chain.  

Please provide me the method that is used for getting the messges realeted to that chain.
User-added imageUser-added image

When we click on the box written as 7:22 AM in screen 1, it expand and become screen 2. How to get the all the messages by using connectApi
Thanks,
Sunil
HI Everyone 

I have one requirement for uploading the files in BOX api using java(in Heroku). I have done some R&D its seems its possible. But I am new to the Java background. Please help it will be very usefull for me.

Thanks in advance
Hi All,

1 -Is there any limits governing for rest api callout while its transferring data to other service?
Like I have SF org and one is Heroku Web app. If I am sending request from Heroku to Sf so is there any limitation comes while sending data ?
2- If I am posting some data on SF from Heroku so is there any limitation hits like size of content etc.

Please let me know if anyone know this.

Thanks in advance
HI All,

I want to get the file content from box after uploading the file in Box. I am able to get the file content in zip and when I am making that file unzipp I am getting the SVG and Html content, But in place of SVG conetent I want PBN format. Please help me if any one had worked on this It will be very helpful to me. Thanks in advance. Please let me know if anyone need more information I will provide all.
Hi All

I have two remote action method on controller side say method1 and method2. I am creating a list in method1 and the return type  is void now form other action I am calling method2 where I need to return the list which I have created in method1. On the nutshell I need to that list which is created in method1 in method two. And method1 is not having retrun type.  If it is not possible then any alternate for this scenario. Please suggest If anyone have any idea, it will be very usefull.

HI All, 

 

I have used pageblock in which using inline editing, on click of inline editing the column is is extending(width) .

Trying to give fixed width but after giving fixed with its also not working please help..

<apex:outputField value="#" id="outputFieldIdInLineEdit" >
<apex:inlineEditSupport disabled="#" event="ondbClick" resetFunction="inLineEditSupport" changedStyleClass="myBoldClass" />
</apex:outputField>

This is my portion ..

 

 

Thanks

 

Hi,

I have a list as in debug it is showing:

====List======(StringComp:[value= 123, 456, 789, 222,])

I want to fetch 123, 456,789, 222

But not able to fetch, Can any one please help

Hi all,

 

Any ane done the integration of salesforce and google.I want to upload files from salsforce to google drive using apex code.

Please help.

 

Thanks

Hi All,

 

I am having a callout which giving me response as well i have to Decode the response data so that i will go further.

I am not getting how to decode xml data in US_ASCII 'http://coderstoolbox.net/string/#!encoding=xml&action=decode&charset=us_ascii' i have tried by this tool and it is giving me proper response.

I want this is by use of apex code. Is it possible.

Please provide some information or any example if you have 

 

 

Thanks.

 

How to generate the correct oauth_signature in apex.Here is the code for generating oauth_nonce, oauth_timestamp and oauth_signature. But not getting the correct oauth_signature.

// Generate a unique combination of numbers and alphabets for oauth-nonce
String nonce = String.valueOf(Crypto.getRandomLong());
Blob key = Blob.valueOf(nonce);
String Keyy = 'XXXXXXXXXXXXXXXX';
Long timee=DateTime.now().getTime();
Integer random = Crypto.getRandomInteger();
Integer time2 = integer.valueOf(timee) +random;
String str2= string.valueOf(time2);
Blob key2= Blob.valueOf(str2);
Blob keyHash = Crypto.generateDigest('MD5',key2);
String hexDigest = EncodingUtil.convertToHex(keyHash);

// Generate timestamp for current time
String timestamp = String.valueOf(DateTime.now().getTime()/1000);

// Create map for maintaining the parameters used to create signature
map<String, String> parameters = new Map<String, String>();
parameters.put('oauth_consumer_key','ZZZZZZZZZZZZ');
parameters.put('oauth_signature_method','HMAC-SHA1');
parameters.put('oauth_timestamp',timestamp);
parameters.put('oauth_nonce',hexDigest);
parameters.put('oauth_version','1.0');

// Form the gneral HttpRequest
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('https://YYYYYYYYYYY.com/people/1234567/identity');

String host = req.getEndpoint();
Integer n = host.indexOf('?');
List<String> keys = new List<String>();
keys.addAll(parameters.keySet());
keys.sort();
String str = keys.get(0)+'='+parameters.get(keys.get(0));

for(Integer i=1;i<keys.size();i++)
{
str = str +'&'+keys.get(i)+'='+parameters.get(keys.get(i));
}
String s = req.getMethod().toUpperCase()+ '&' +
EncodingUtil.urlEncode(host, 'UTF-8') +'&'+
EncodingUtil.urlEncode(str, 'UTF-8');
Blob sig = Crypto.generateMac('Hmac-SHA1', Blob.valueOf(s), Blob.valueOf(Keyy));
Blob signature1 = Blob.valueOf(EncodingUtil.convertToHex(sig));

String signature = EncodingUtil.base64encode(signature1);
req.setEndpoint('https://XXXXXXXXX.com/people/1234567/identity?oauth_version=1.0&oauth_nonce='+hexDigest+'&oauth_timestamp='+timestamp+'&oauth_consumer_key=ZZZZZZZZZZZZZ&oauth_signature_method=HMAC-SHA1&oauth_signature='+signature+'');
HttpResponse res = h.send(req);
System.debug('Response from request token request: ('+res.getStatusCode()+')'+res.getBody());

Please suggest the correct way.

Thanks.

Hi All,

 

 

I am able to get the oauth_nonce,oauth_timestamp and oauth_signature but after executing this, i am getting  (Status=Unauthorized, StatusCode=401) 401)Invalid OAuth Request. I am Coming. Why it is coming however i have crerated all these thing correctly,Please suggest or guide .Why it is giving this problem.

My endpoint is -

 

https://api.XXXXXXXX.com/rr/6125188/identity?oauth_version=1.0&oauth_nonce=2bbf03308a70eb4c8f99f8369b129416&oauth_timestamp=1378622233&oauth_consumer_key=YYYYYYYY&oauth_signature_method=HMAC-SHA1&oauth_signature=hteW%2Fl91NTP9S9RMG0He7TgGMyU%3D.

 

Thanks

Hi all,

 

How we can generate oauth_nonce,oauth_timestamp,oauth_signature dynamically for each request

Please advice

 

Thanks in advance.

Hi all,

 

How to get the request token and then use that token for access token for get satisafction.
please share any example if any one have.It will be very helpful.

 

Thanks in advance

 

 

Hi every one 

 

I want to attach a file in my  mail drive , i am able to atach in my mail only as inbox , is there any way from which i can send to my drive . I don't want salesforce google doc (Standard Way).

 

Please suggest some way..

 

Thanks

Hi everyone,

 

I am attaching file in  google docs , but not able to retrieve, that file.

I don't know where it is storing, in salesforce.How we can get this i.e in which object these files are storing???
Please suggest.....Thanks

 Hi 

I have a Vf page in which i am having one input text for user name and and for passowrd, on click of save button i want to generate a pdf in which only both user name and password is written , in tabular format ,. 

 

 

Please suggest some way , iam not getting how to approach

 

Thanks

How to get the roleId from group member if the group containing role.

 

 

 

Thanks

Hi 

I have to update multiselect picklist on contact on the basis of account picklist value. 

I have made formula field to contact  , but it is not working please give some suggestion so that it will work

IF ( INCLUDES (Account.Type , "Attorney" ), "Attorney; ",null )

 

Account Type is field and Attorney is value

  

Its showing Error: Field type is a picklist  fileds. Picklist fields are only supported in certain function

IF ( INCLUDES (Account.Type , "Attorney" ), "Attorney; ",null )

 

Thanks

 

Here is my page.

onclick of save button i am getting the following error
Error: j_id0:j_id4:PbId:init_items: Validation Error: Value is not valid

 Why it is coming i am not getting, please help.

 

=============================================================

<apex:page extensions="SL_createAListController" standardController="Company_List__c">
<apex:sectionHeader title="Create New Conatct List." subtitle="List"/>
<apex:includeScript value="{!URLFOR($Resource.jquery_js)}"/>
<script type="text/javascript">

$(document).ready(function(){

recheckSelectedList();

$('#add_sl_button').click(function() {
add_selected();
});

$('select.select1').dblclick(function() {
add_selected();
});

$('#remove_sl_button').click(function() {
remove_selected();
});

$('select.select2').dblclick(function() {
remove_selected();
});

});

function add_selected()
{
$('select.select1 option:selected').each(function(sIdx, el) {

if($('select.select2 option').length==1 && el.value!='0')
$("select.select2 option[value='0']").remove();

if(el.value!='0' && $('input[type="hidden"][name$="someHiddenKeys"]').val().indexOf(el.value)<0)
$(this).appendTo('select.select2');

if($('select.select1 option').length==0)
$("select.select1").append( $('<option value="0">--None--</option>'));
});

recheckSelectedList();
}

function remove_selected()
{
$('select.select2 option:selected').each(function(sIdx, el) {
if($('select.select1 option').length==1 && el.value!='0')
$("select.select1 option[value='0']").remove();

if(el.value !='0')
$(this).appendTo('select.select1');
if($('select.select2 option').length==0)
$("select.select2").append( $('<option value="0">--None--</option>'));
});

recheckSelectedList();
}

function recheckSelectedList()
{
var sTemp = '';
$('select.select2 option').each(function(sIdx, el) {
if(el.value != '0')
sTemp += (sTemp != '' ? ';' : '') + el.value;
});
$('input[type="hidden"][name$="someHiddenKeys"]').val(sTemp);
}


var isLeftAsc = 1;
function doLeftSort()
{
if(isLeftAsc == 1) {
doSortSelect('select1');
isLeftAsc = 0;
} else {
doSortDescSelect('select1');
isLeftAsc = 1;
}
}

var isRightAsc = 1;
function doRightSort()
{
if(isRightAsc == 1) {
doSortSelect('select2');
isRightAsc = 0;
} else {
doSortDescSelect('select2');
isRightAsc = 1;
}

recheckSelectedList();
}

function doSortSelect ( select_class )
{
var sortedVals = $.makeArray($('select.'+select_class+' option')).sort(function(a,b){
return $(a).text() > $(b).text() ? 1 : $(a).text() < $(b).text() ? -1 : 0 ;
});
$('select.'+select_class).empty().html(sortedVals);
}

function doSortDescSelect ( select_class )
{
var sortedVals = $.makeArray($('select.'+select_class+' option')).sort(function(a,b){
return $(a).text() > $(b).text() ? -1 : $(a).text() < $(b).text() ? 1 : 0 ;
});
$('select.'+select_class).empty().html(sortedVals);
}

function doMoveUp( select_class )
{

var i = 0;
$('select.'+select_class+' option').each(function(sIdx, el) {
val = el.value;
txt = el.text;

if(el.selected){
if(sIdx > 0) {
var oElem =$(this).prev();
//alert(oElem.selected);
//oElem.is(':selected')
//alert(oElem.is(':selected'));
if(oElem!=null && !oElem.is(':selected'))
$(this).remove().insertBefore(oElem);
}
}

i+=1;
});

recheckSelectedList();
}

function doMoveDown( select_class )
{

var i = 0;
$('select.'+select_class+' option').each(function(sIdx, el) {
val = el.value;
txt = el.text;

if(el.selected){
if(sIdx < $('select.'+select_class+' option').size()-1) {
var oElem =$(this).next();
if(oElem!=null && !oElem.is(':selected'))
$(this).remove().insertAfter(oElem);
}
}

i+=1;
});

recheckSelectedList();
}

</script>
<apex:form >
<apex:pageblock Id="PbId">
<apex:actionfunction name="funChangeUserOrGroup" action="{!fetchUserOrTGroupPicklistValues}" rerender="idLeftPicklist, idRightPicklist"/>
<apex:pageMessages id="ErrorMessageId"/>
<table align="center" border="" width="100%">
<tr>
<td align="left" width="20%">
<b>List Name:</b>
</td>
<td align="left" width="20%">
<apex:inputfield value="{!objList.Name}" />
</td>

<td width="20%" align="right">
<b>Share My List With:</b>
</td>
<td width="20%">
<apex:selectList id="idUserOrGroup" value="{!strUserOrGroup}" size="1" onchange="funChangeUserOrGroup();">
<apex:selectOption itemValue="None" itemLabel="--None--"/>
<apex:selectOption itemValue="Group" itemLabel="Group"/>
<apex:selectOption itemValue="User" itemLabel="User"/>
</apex:selectList>
<!-- <apex:Inputfield value="{!objList.Share_With__c}" /> -->
</td>
</tr>

<tr>
<td>
<b>Show In Quick Add:</b>
</td>
<td>
<apex:inputfield value="{!objList.Show_in_Quick_Add__c}" />
</td>
<td width="20%" align="right">
<b>Share With: </b>
</td>

<td width="20%">
<!-- <c:SL_LIB20_component_Multiselect in_list_opt="{!lstUserOrGroup_Input}" out_list_opt="{!lstUserOrGroup_Output}" out_str_ids="{!BaseParam}" /> -->
<apex:inputHidden value="{!sHiddenKeys}" id="someHiddenKeys" />

<table style="border:0">

<tr>
<td align="center">
<b>Available</b>
</td>
<td>
</td>
<td align="center">
<b>Selected</b>
</td>
<td>
</td&gt..
onclick of save button i am getting the following error
Error: j_id0:j_id4:PbId:init_items: Validation Error: Value is not valid

 Why it is coming i am not getting, please help.

Thanks

Hi All I am doing callout , for one request it is showing Status Ok , but for the other request same as first it is showing Bad request Invalid verb , Ihave checked all verb , nothing is in small letter. But i don't know why it is coming..

 

 

Thanks

 

I am trying to create a trigger that will update a field on a Job object every time when a field on Opportunity is changed.

The field on the Job object is an email field and is called "Account Manager email". It should be populated with the Opportunity Owner's email.
(I cannot use a simple formula field for the Account Manager email, because I want to use this field in a workflow)

Will appreciate it if someone can help me write the trigger.

Thanks!
  • August 07, 2015
  • Like
  • 0
Hai guys
When i create the visual force for sending massemailmessages.following error will coming 
System.NullPointerException: Attempt to de-reference a null object 
Class.MassEmailMessage_controller1.<init>: line 10, column 1
please help me any one

vf page
------------------------------
<apex:page standardcontroller="contact" extensions="MassEmailMessage_controller1">
  <apex:form >
  <apex:commandButton value="sendEmail" action="{!sendEmail}"/>
  
  </apex:form>
</apex:page>

controller
--------------------------------
public class MassEmailMessage_controller1 {

    private final list<Id> contactids;
    public list<contact> con;
    public MassEmailMessage_controller1(ApexPages.StandardController controller) {

    con = [select Id from contact limit 250];
        for(integer i = 0;i<250;i++)
        {
             contactids.add(con[i].Id);
         
        }
    }
    
    public void sendEmail()
    {
        Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
        mail.setTargetObjectIds(contactids);
        Messaging.sendEmail(new Messaging.MassEmailMessage[]{mail});
    
    }

}
Hi Guys


How to create calculation after insert trigger value

after firing the trigger ,how i will created calaculation on particalar value with the help of trigger
trigger realtime2 on BankBook__c (after insert){
List<BankBook__c> bnkBookListToUpdate=new List<BankBook__c>();
   for(BankBook__c bkObj:[SELECT Id,New_Closing_Bal__c,New_Related_Bank_Acc__c,Debit__c,Credit__c  FROM BankBook__c WHERE Id IN :Trigger.new])
   {
   
   double s = bkObj.New_Related_Bank_Acc__c; //copy the notes to a string object
   double s1 = bkObj.Debit__c;
   double s2 = bkObj.Credit__c;                
   
   bkObj.New_Closing_Bal__c=s-s1+s2  ;
       // bkObj.New_Closing_Bal__c= bkObj.New_Related_Bank_Acc__c;
        bnkBookListToUpdate.add(bkObj);
    }
    try{
     update  bnkBookListToUpdate;
    }catch(DMlException de ){
      System.debug(de );
    }
}

error

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger realtime2 caused an unexpected exception, contact your administrator: realtime2: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.realtime2: line 10, column 1
Hi,
i have been reading about action tags,it make sense to me that,in few ways both Actionsup and actionfunc works similarly,so far have not found any example other than Onclickevent on actionsup and popup message when used action function.

Can someone provide me with few example situations where we can use only ActionFuc but not Actionsup and similarly only ActionSup works but not ActionFunc




 
  • August 06, 2015
  • Like
  • 0
trigger productsQtyUpdate on IS__c (after insert) { 
Map<ID, PI__c> pqtyMap = new Map<ID,PI__c>();
Set<string> pid = new Set<string>();
Decimal soldQty;

for(IS__c pSoldqtyId:trigger.new){
soldQty = pSoldqtyId.Sold__c;
pid.add(pSoldqtyId.Name);
}

pqtyMap = new Map<ID,PI__c>([SELECT id,Quantity__c FROM PI__c where id In :pid]);
for(IS__c pSoldqty:trigger.new){
PI__c pqty = pqtyMap.get(pSoldqty.Name);
pqty.Quantity__c = pqty.Quantity__c - soldQty ;
}
update pqtyMap.values();
}


For the above trigger, i get the error while saving trigger.

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger productsQtyUpdate caused an unexpected exception, contact your administrator: productsQtyUpdate: execution of AfterInsert caused by: System.StringException: Invalid id: 1: External entry point
i have two apex:pageblock in visualforce page.   1st pageblock will displays always. 2nd pageblock should be display with if condition,  but it is not working ...  please help. I checked this - data coming to javascript and alert boxes are working. 
 
<apex:page controller="myleaddata" id="p1">	
  <apex:form id="f1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
      <script>
       $j = jQuery.noConflict();

      var a;
      function mydata()
      {
          a=document.getElementById('p1:f1:pb:my1').value;
          document.getElementById('p1:f1:pb:my2').value=a;
          
      if(a=='New Employee')
          {
alert('this is 1st alert');
              j$(document).ready(function() {
   j$('div#hidden').show();
});
      
         }
else
{
alert('this is 2nd alert');
              j$(document).ready(function() {
   j$('div#hidden').hide();
});
      
         }
 }
      
      
      </script>
 
       <apex:pageblock title="Basic lead info" id="pb">
           <apex:outputlabel value="company name" />
        <apex:inputtext value="{!companyname}" /><br/>
        <apex:outputlabel value="lead last name" />
        <apex:inputtext value="{!lastname}" /><br/>
          <apex:outputlabel value="phone number" />
        <apex:inputtext value="{!phone}" /><br/>
          <apex:outputlabel value="Email" />
        <apex:inputtext value="{!email}" /><br/>
          <apex:outputlabel value="Source" />
        <apex:inputtext value="{!source}" /><br/>
          <apex:outputlabel value="Referer" />
        
           <apex:inputfield value="{!le.Reffered__c}" id="my1" onchange="mydata()" /><br/>
           <apex:inputhidden id="my2" value="{!referer}" />
    
    </apex:pageblock>
      <div id="hidden" >
          
     
      <apex:pageblock title="address info"  >
      
          <apex:outputlabel value="street" />
          <apex:inputtext value="{!street1}" /><br/>
          <apex:outputlabel value="city" />
          <apex:inputtext value="{!city1}" /><br/>
          <apex:outputlabel value="state" />
          <apex:inputtext value="{!state1}" /><br/>
          <apex:outputlabel value="zip" />
          <apex:inputtext value="{!zip1}" /><br/>
          <apex:outputlabel value="country" />
          <apex:inputtext value="{!country1}" /><br/>
          
      
      </apex:pageblock></div>
      
      <apex:commandButton value="submit" action="{!myleaddata1}" />
           </apex:form>
    
</apex:page>

Apex:code

public class myleaddata {
    public string lastname{set;get;}
    public string companyname{set;get;}
    public string leadname{set;get;}
    public string phone{set;get;}
    public string email{set;get;}
    public string  source {set;get;}
    public string referer{set;get;}
    public string street1{set;get;}
    public string city1{set;get;}
    public string state1{set;get;}
    public string zip1{set;get;}
    public string country1{set;get;}
   
    
    public lead le{set;get;}
    
     
    public void myleaddata1()
    {
    if(referer == 'existing employee')
    {
      Opportunity opp=new Opportunity();
        opp.Name=lastname;
       opp.StageName='qualification';
        opp.LeadSource=source;
        opp.CloseDate=date.parse('8/10/2015');
        insert opp;
        
      }
      
      else
      {
       lead l1=new lead();
        l1.lastname=lastname;
        l1.Company=companyname;
        l1.Phone=phone;
        l1.email=Email;
        l1.LeadSource=source;
        l1.Reffered__c=referer;
        
        // address info part
       l1.PostalCode=zip1;
       l1.Street  =street1; 
       l1.City=city1;
        l1.state=state1;
        l1.PostalCode=zip1;
        l1.Country=country1;
        
        insert l1;
       }
    }
}

 
Hi all,

Registration__c is my custom object with 2 recordtypes Recordtype1 or RecordType2
Now i am fetching the records from recordtype1. 

List<Registration__c> reg=[Select id, name, RecordType.Name FROM Registration__c
WHERE recordtypeid in (Select Id From RecordType where sobjecttype = 'Registration__c' and DeveloperName IN ('Recordtype1'))];
for(Registration__c rg : reg)
System.debug(rg.Name);

Thanks in advance.
Monika.
I have two fields Occupation and Occupation codes with 580 values. When I select the Occupation (Developer), the Occupation code must be auto-populated as (0001). I am new to development and would be great if anyone can suggest a way or give references to do this using a trigger?
I am trying to write a test class for my Wrapper Class, unfortunately my overall code coverage is 51%, so I need to get more then 75% in order to deploy.how i will do plz help me 
public with sharing class CRM_AddProducts
{

    public String message { get; set; }
 
  public String SelectedProduct{get;set;}
  public list<pProduct> lstproduct { get; set; }
  public list<cproduct> cartlstproduct {get;set;}
  
  public list<CProduct__c> lstselproduct { get; set; }
  public list<CQuote_Line_Item__c> lstaddquoteproduct { get; set; }
  public List<SelectOption> Product_Selectionoptions {get;set;} 
  public boolean selected {get;set;}
  public boolean display {get;set;}
  public CProduct__c pro {get;set;}
 // public CProduct__c cpro{get;set;}
 // public CProduct__c cess{get;set;}
  public map<Id,double> mapProductIdToQuantity { get; set; }
  public string strid;
  public boolean blnStatus1 ;
  
  
  
  

    public CRM_AddProducts()
      {
          lstproduct=new list<pProduct>();
          mapProductIdToQuantity = new map<Id,double>();
          cartlstproduct = new list<cproduct>();
          lstaddquoteproduct = new list<CQuote_Line_Item__c>();
          strid = apexpages.currentPage().getParameters().get('id');
         
        
                for(CProduct__c objproduct : [select id,
                                              Name,
                                              List_Price__c,
                                              Product_Code__c,
                                              Product_Description__c,
                                              Sales_Price__c,
                                              Product_Family__c
                                      from    CProduct__c])
          {
              lstproduct.add(new pProduct(objproduct));
              system.debug('---lstproduct---'+lstproduct);
          }
      }
      
      
       public pageReference check()
    {
      return null;
    }
        
         
  
    //builds a picklist of product names based on their product id
      public List<SelectOption>getProduct_Selection() 
    
     {
        List<SelectOption> Product_Selectionoptions = new List<SelectOption>();
  //new list for holding all of the picklist options
       
       for (CProduct__c Product_Selection : [SELECT Id, Name FROM CProduct__c]) 
       { 
  //query for Product records 
       Product_Selectionoptions.add(new selectOption(Product_Selection.Id,Product_Selection.Name));
      
  //for all records found - add them to the picklist options
       }
       system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
      return Product_Selectionoptions; //return the picklist options
       
   }
   
         
         public pageReference addtocart()
         {
            for(pProduct cProd : lstproduct)
        {
                
                system.debug('----cProd---'+cProd);
                system.debug('--SelectedProduct--'+SelectedProduct);
                system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
               //  system.debug('-Product_Selection-'+Product_Selectionoptions.Product_Selection);
                if(cProd.selected == true)
                {
                  system.debug('----cProd---'+cProd);
                  CProduct__c objproduct1 =  [  select id,  Name,
                                                    List_Price__c,
                                                    Product_Code__c,
                                                    Product_Description__c,
                                                    Sales_Price__c,
                                                    Product_Family__c
                                            from    CProduct__c  
                                            where   id =:SelectedProduct];
                        cartlstproduct.add(new cproduct(objproduct1))     ;             
                     system.debug('---cartlstproduct---'+cartlstproduct);                       
                } 
        }      
           return null ;
         }
         
         
         
         
          public pageReference processSelected()
         {
           list<CQuote_Line_Item__c> lstaddquoteproduct = new list<CQuote_Line_Item__c>();
        //   list<CProduct__c> lstselproduct = new list<CProduct__c>();
           system.debug(lstproduct+'===lstproduct====');
  
          for(cproduct cess:cartlstproduct)
             {
                  system.debug('-----cess---'+cess);
                  if(cess.Display== true)
      {
        
                
       if((cess.quantity!=null && cess.quantity!='' && cess.quantity!=string.valueof(0) )&& (cess.salesprice!=null && cess.salesprice!='' ) )
        {
                  
              //mapProductIdToQuantity.put(cPro.pro.id,double.valueof(cPro.quantity));
              //system.debug(mapProductIdToQuantity+'---map---');
                
                CQuote_Line_Item__c objQuoteli = new CQuote_Line_Item__c();
                system.debug('---cess.quantity---'+cess.quantity);
                objQuoteli.Name = cess.cpro.Name  ;
                objQuoteli.Quantity__c =double.valueOf(cess.quantity) ;
                objQuoteli.Unit_Price__c =cess.cpro.List_Price__c;
                objQuoteli.Quote__c = strid;
                objQuoteli.Total_Amount__c= double.valueof(cess.TotalAmount );
                //objQuoteli.Discount_Percent__c = double.valueOf(cess.discount) ;
                objQuoteli.Sales_Price__c = double.valueOf(cess.salesprice) ;
                system.debug('---objQuoteli---'+objQuoteli);
                lstaddquoteproduct.add(objQuoteli);
                system.debug(lstaddquoteproduct+'----lstaddquoteproduct----');
                  }
            else
                     {
                            system.debug('---else---');
                            ApexPages.Message errormessage = new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter all the values.');
                            ApexPages.addMessage(errormessage);
                     }
                          
                  }
      
   }//for loop
    if(lstaddquoteproduct.size()>0)
                {
                   insert lstaddquoteproduct;
                   system.debug('---strid--'+strid);
                   pageReference pageRef1 = new pageReference('/'+strid);
                   pageRef1.setredirect(true);
                   return pageRef1;
              }
           return null;
           }
              
              
                //product list wrapper class
    
      public class pProduct
        {
            public CProduct__c pro {get;set;}
            public boolean selected {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public integer TotalAmount {get;set;}
            public integer discount {get;set;}
             //public string discount {get;set;}
            public pProduct(CProduct__c p)
                {
                    pro = p;    
                    selected = false ;   
                    quantity='1';
                }
        
        
        }  
        
        //cart list wrapper class
        public class cproduct
        {
            public CProduct__c cpro{get;set;}
            public boolean selected {get;set;}
            public boolean Display {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public string TotalAmount {get;set;}
            public string discount {get;set;}
            public cProduct(CProduct__c c)
                {
                    cpro = c;  
                    selected = false ;  
                    quantity='1';
                   salesprice= string.valueof( cpro.List_Price__c );
                     TotalAmount = string.valueof( cpro.List_Price__c );
                    Display = false ;
                }
        
        
        }
        
       
  
  
    public pageReference cancelbutton()
        {
            pageReference pageRef1 = new pageReference('/'+strid);
            pageRef1.setredirect(true);
            return pageRef1;
        }
 }

 
Hi,

I keep getting the error that there is no Visual Force page titled "SpeakerForm." I've checked everything multiple times. Anyone know what I'm doing wrong?
Hi all,

Any one can please give a sample code (Insert class and Test class ) from insert and update record into Lead Object. 


Thanks in advance 
I need to auto-populate a lookup field(Account) on the case object with reference to the text value(having Account Name) on custom text field in same object. How to do this ? any trigger code may help..
HI,

How to Display the Reports and Dashboards in Partner Community .Which permissions need to give if we want to access the reports and dashboards in Community ?


please advise .


Thanks,
Shiva