• Virendra Chouhan
  • SMARTIE
  • 1646 Points
  • Member since 2014


  • Chatter
    Feed
  • 49
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 329
    Replies
<apex:page >
<script type="text/javascript">
function validate()
{
document.getElementById('demo').innerhtml='hello js'
}
</script>

  <html>
  <body>
  <h1>Congratulations</h1>
  <p id="demo">This is your new Page: js1</p>
  <apex:form >
       <apex:commandButton value="Insert" onclick="validate();"/>
       </apex:form>
  </body>
  </html>
  
</apex:page>
Hello, 
I am writing code to create calender records. I am facing this error.

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [MTP]: [MTP]
Error is in expression '{!createdtp}' in component <apex:page> in page createdtp: Class.Calender.createdtp: line 40, column 1
An unexpected error has occurred. Your development organization has been notified.

Can anyone please help me to sort it out. MTP is master detail field

My code is:

Controller:
public with sharing class Calender {

    public Calender(ApexPages.StandardController controller)
     {
          tid = ApexPages.currentPage().getParameters().get('id');
         System.debug('***************dtp added*******************'+tid); 

     }

 public Decimal dy;
 public  id tid{get;set;}
    public PageReference createdtp() {
     
      System.debug('***************tid tid*******************'+tid);
    List<MTP__c> obj = [Select  Id, Month__c, Year__c,  February__c, NumberOfDays__c from MTP__c];
 
    for(MTP__c mt:obj)
    {
    if(mt.Month__c=='February')
    {
    String str=mt.February__c;
    dy=Decimal.ValueOf(str);
    }
    else
    {
     Decimal str= mt.NumberOfDays__c;
      dy=str;
    }
    }
  List<DTP__c> newdtp= new List<DTP__c>();
    for(Integer i = 1; i<=dy; i++)
    {
       DTP__c  dt = new DTP__c();
       dt.MTP__c=tid;
       newdtp.add(dt);
       System.debug('***************dtp added*******************'+tid);
       //insert newdtp;
       
    }
    insert newdtp;
    return null;
    }
        
    public List<DTP__c> getMydtpList(){
mydtpList =[select Name, Expenses__c, MTP__c, Food_Expenses__c, Date__c, Visit_type__c from DTP__c where id=:tid];

    return mydtpList ;
}
    List<DTP__c>  mydtpList = [select Expenses__c, Name, MTP__c, Food_Expenses__c, Visit_type__c from DTP__c where id=:tid];

    }

VF Page:

<apex:page standardController="MTP__c"  extensions="Calender" action="{!createdtp}">
 <apex:pageBlock title="All Dtp">
 <apex:pageblockTable value="{!mydtpList}" var="item">
 <apex:column value="{!item.Name}"/> 
 <apex:column value="{!item.Date__c}"/> 
 <apex:column value="{!item.Visit_type__c}"/> 
 <apex:column value="{!item.Food_Expenses__c}"/> 
</apex:pageblockTable>
 </apex:pageBlock> 
</apex:page>

Thanks & Regards,
Satakshi
Hi All, 

I found something crazy in opportunity object that is Partner Account field which is standard Lookup(account), I see 2 lookup(account) standard fields in opportunity object. I heard in few other orgs people are not able to find this field on their side. Can anyone explain me about this particular field, Why is it visible for few orgs and what is the related list name on account object. 

Thank you.
Hi ,

Iam completely new to implemnt the boot starp .Actually i have created the static resource by uploading the bootstrap in zip formate. Please suggest me how to use the  CSS classes of  of the bootstrap in VF pgae.  And the ZIP file name is  sfdcboot. 

Regards,
Siva  Reddy.
 
Hi

Iam attempting to reduce the number of SOQL's being triggered to avoid the limits.

I currently have two queiries. The first brings back the mailout items and the second brings back the attachements for the mailout items

Get the mailout items
objMailout = [SELECT Id, contact__c, contact__r.Name, recipient_first_name__c, recipient_last_name__c, caps__r.AccountID__c, file_password__c, email_address__c FROM ci_mailout__c WHERE Sent__c = FALSE AND Mailout_name__c = :strTemplate_Initial ORDER BY Policy_count__C Desc LIMIT 50];
Get the attachments for the above mailout items
objAttachment = [SELECT ID, Name, ContentType, body FROM attachment WHERE ParentId = :thisMailOut.Id];
So ... the above works but gets close to the limit for SOQL

So when I try to join the SOQL into 1 I get the following error
A driving SObject type has already been set, all other entity types in the FROM clause must be relationships to the initial object.  The driving object is CI_Mailout__c.
This is the query that I am attempting to use
objMailout = [SELECT Id, contact__c, contact__r.Name, recipient_first_name__c, recipient_last_name__c, caps__r.AccountID__c, file_password__c, email_address__c FROM ci_mailout__c, attachment WHERE ID = :[SELECT PARENTID FROM ATTACHMENT] AND Sent__c = FALSE AND Mailout_name__c = :strTemplate_Initial ORDER BY Policy_count__C Desc LIMIT 50];

Any guidance would be greatly appreciated.

Thanks


 
Hi,
Good Morning.
can any one help me to solve the following.........
I have an object student__c. It has only one field name.i would like to add the records into object using VF page. Initiallay, In VF page I have Add button,Save button & a text box. When i click on add button i need to display one more textbox. Like this i can add any number of textboxes. But when i entered data into these textboxes and clicked on save. I would like to add all the names into object in the form of records. That means, each name will be added into object as a record. i need controller class also Can any one help me.
Hi Guys,
Need your help on the below situation.
I have a page which is showing "List of Cases" for my organisation.I have added a filter 'Status' so that it can refine the case list based on requirement.Status options are 'New' and 'Resolved' Cases and after choosing any one of the option if I hit the search button it will show the list of cases based on the status.If no option is selected by default it will show the all cases in the list.
Now the requirement is if I apply case filter status as 'new' and if it retuns 4 cases, after clciking any one of that case it should redirect to the case detail page and after clicking the 'back to cases' command link in case detail page it should redirect back to refined serach result (it should show all that 4 cases in the list not all the cases) .I am giving my code here .Please help .thanks!!!
<apex:page controller="testController100">
<apex:form >
<apex:outputPanel >
  <apex:pageBlock title="List Of Cases For My Test Organisation" >
    <apex:outputLabel ><b> Status : </b></apex:outputLabel>
       <apex:selectList value="{!caseStatus1}" size="1">
         <apex:selectOption itemvalue="NEW" />
         <apex:selectOption itemvalue="RESOLVED" />
       </apex:selectList>  
       <apex:commandButton value="search" action="{!search}" /> 
  </apex:pageBlock>
 </apex:outputPanel>    
 </apex:form>
 <!--show the List of Cases -->   
    <apex:form >
    <apex:outputPanel id="out1">
     <apex:pageBlock >
          <apex:pageBlockTable value="{!listofcases}" var="lstofcases">
           <apex:column >
             <apex:facet name="header" >
                <apex:commandLink value="Case" >   
            </apex:commandLink>             
          </apex:facet>  
        <apex:outputLink value="/apex/casedetail?id={!lstofCases.Id}" id="theLink0" >{!lstofcases.CaseNumber}</apex:outputLink> 
        </apex:column>
 
public with sharing class testController100 {
  
  public String caseStatus1{get;set;}
  
  public pagereference search(){ 
  return null;
  }
 
    // code to show list of cases
     public List<case> getlistofcases(){
      List<Case> listofcases=New List<Case>();
      if(caseStatus1=='NEW'){
      listofcases=[select casenumber,status,priority from case where status='New' order by status ASC];
     }
     else if(caseStatus1=='Resolved'){
     listofcases=[select casenumber,status,priority from case where status='Closed' order by status ASC];
     }
     else{
      listofcases=[select casenumber,status,priority from case where status='Closed' or status='New' order by status ASC];
     }
     return listofcases;
     }
    }
 
<!-- Case detail page-->
<apex:page standardController="case" extensions="testcontroller101">
<apex:form >
  <apex:outputpanel style="left-padding:600px" id="panelId">
            <apex:commandLink value="Back To Case" style="color:blue ;font-size:16px" action="{!backurl}" />
            <apex:pageBlock >
             <apex:pageBlockSection columns="2">
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Case #</apex:outputLabel>
                <apex:outputField value="{!CaseInfo.CaseNumber}" style="width:200px;"  id="BCname"/>
            </apex:pageBlockSectionItem>        
            <apex:pageBlockSectionItem >        
                <apex:outputLabel >Status</apex:outputLabel>
                <apex:outputField value="{!CaseInfo.Status}" style="width:200px;" id="CCategory"/>
            </apex:pageBlockSectionItem>
            </apex:pageblocksection>
            </apex:pageBlock>
  </apex:outputPanel>          
</apex:form>            
</apex:page>
 
public with sharing class testcontroller101 {

    public id caseId{get;set;}
    public Case CaseInfo { get; set; }
    
    public testcontroller101(ApexPages.StandardController stdController) 
    {
    caseId = stdController.getRecord().Id;
    if(caseId!=null)
        {
            CaseInfo=[ select casenumber,Id,status 
                  From Case where id=:caseId];
                  
            system.debug('--CaseInfo--'+CaseInfo);
}
}
   public pagereference backUrl()
    {
        pagereference pg=new pagereference('/apex/page10');
        return pg;
    }
}

 
Hi my requirement is, i want to fetdch the recors from Account object based on the name enter in the VFpage, (when i enter the name ram in VFpage  ,then total recordswith the Name ram have to be fetched ) for that i have written the belwo code, in this codewhen enter the name in the vfpage ima getting the error like bleow
"Attempt to de-reference a null object
Error is in expression '{!values}' in component <apex:commandButton> in page chennai: Class.chennai.values: line 18, column 1 "

andmy code is as follows,

vf code:

<apex:page controller="chennai">

<apex:form>

<apex:outputText>EnterName</apex:outputText>

<apex:inputField value="{!a.Name}"/>

<apex:commandButton value="Enter"  action="{!values}" reRender="one"/>


<apex:pageBlock id="one">
<apex:pageBlockSection >

<apex:pageBlockTable value="{!at}" var="b">

<apex:column value="{!b.Name}"/>


</apex:pageBlockTable>

</apex:pageBlockSection>
</apex:pageBlock>




  </apex:form>
</apex:page>


Apex Code:

Public class chennai
{

Public chennai()
{
List<Account> at=new List<Account>();

Account a=new Account();
}

Public List<Account> at{get;set;}

Public Account a{get;set;}

Public void values()
{

List<Account> at=[select Name from Account where Name=:a.Name];


}

}

Please suggest me

Regards,
siva.


 

I have a Vf page which display account object records. In this vf page each and every record have a button called Edit. If we click on Edit button it should be take us to detailed edit page respected record. For more clearance see my pictures which i uploded. 
User-added image
User-added image

To achive this process, I have developed following VF page.

<apex:page Controller="Redirect_Main2" action="{!Redirect_Main}">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accs}" var="a" >
                <apex:column value="{!a.Id}"/>
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Phone}"/>
                <apex:column value="{!a.Industry}"/>
                <apex:column id="two">
                    <apex:commandButton value=" Edit " onclick="window.open('/{!a.id}')" reRender="two"/>
<!--/e?retURL=%2F{!a.id}&_CONFIRMATIONTOKEN=VmpFPSxNakF4Tmkwd055MHlPVlF3T1Rvek5qb3dPQzQ0TnpaYSxvTFl3eklmdmNBcjl6RlVDeDRWUnBtLE9XWTJNbU01&common.udd.actions.ActionsUtilORIG_URI=%2F{!a.id}%2Fe')" reRender="two"/>
   -->             </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Controller:
public class Redirect_Main2 {

   public List<Account> accs { get; set; }
    public PageReference Redirect_Main(){
        accs = [select id,name,phone,Industry from account];       
        return null;
     }
}
 


But this is taking me to detailed page of the record but not edit page. Please tell me neccessary actions which i need to take.

Thanking you
KS Kumaar

Hi,

I am trying to copy one field value to another field through one button click.I have created one custom button and in java script is below.

{!requireScript("/soap/ajax/26.0/connection.js")} 
var emp=sforce.connection.query("Select Branch_Code__r.Name from Employee_Master__c where User__c='{!User.Id}' limit 1"); 
var recs = emp.getArray("records"); 
window.open("https://pfpdl--pdlpcsb.cs31.my.salesforce.com/a0v/e?ent=BDC-Transaction-Detail Edit&save_new_url=%2Fa0v%2Fo&retURL=&00Np0000000mvq0="+recs[0].Branch_Code__r.Name,"_self");

This script is copying the value in the url but not in that field.Anyone please help.
Hi All,
Having very small req but not able to find out its way to resolve.In the opportunity screen there is section Opportunity Team in which three buttons are there.User-added image
Now when i cheked at profile level the object has read/write access but i want to know this particular section's buttons that for which conditions they are enabling and disabling.means is it based on Role/Profile or opportunity owner.
 
Hi, 

I need add a button or link in report to navigate to a help page. 
Can any one help on this or give me other choice to achieve it?
Hello,

I am executing 672 lines of code in ananymous log, it gives me error saying ecexution failded.
What is reason and limitations for executing coe in Anonymous window ?
 
Hi, 

I have tried to use the trigger on user for make that action but when I choose Disabling a Portal User from the layout of the person account it doesn't seem to enter in the trigger, I think this is some kind of special update but I want to know if there is some way to update a field from another object when Disabling a Portal User. Thanks
I provided the screen capture of this error please tell me how to resove thisUser-added image
"IS Changed can not be used if the previously Met flag has been selected.."
what does it mean?
Hi all, 

Okay so I'm pretty weak at using sub query and usually avoid this. So I will need a little help on this. 
 
List<Job__c> jobs = [SELECT ID, Contact__c, Project_site_contact_name__c, (SELECT ID, Contact__c FROM Job_Contacts__r) FROM Job__c WHERE ID in :updateContactIds];
	for (Job__c job : jobs)
	{		

		for(Contact con : jobs.job_contacts__r)
		{

                }
        {
So here's the little code snippet. I the 2nd for loop is giving me error saying "Initial term of field expression must be a concrete SObject: LIST&lt;Job__c&gt;"

If I understand correctly the error is saying Job.job_contact__c is not a list. How do I check through the sub query? 
Dear all,
             i am writing a class to display contacts of standard objects(Contact). but while writing i got above problem. so could you pls rectify the problem? suggest me how to write program? what is the need of inner class? is it compulsory to write in every class.
this is my VF Page:
<apex:page standardController="Contact">
    <apex:form >
        <apex:pageBlock title="All Contacts">
            <apex:pageBlockSection >
                <apex:dataTable value="{!contact}" var="con" border="2" cellpadding="10">
                    <apex:column headerValue="Contact Name">
                        <apex:outputField value="{!con.lastname}"/></apex:column>
                    <apex:column headerValue="Account Name">
                        <apex:outputField value="{!con.name}"/></apex:column>
                    <apex:column headerValue="Lead Source">
                        <apex:outputField value="{!con.LeadSource}"/></apex:column>
                    <apex:column headerValue="Phone">
                        <apex:outputField value="{!con.Phone}"/></apex:column>
                    <apex:column headerValue="Fax">
                        <apex:outputField value="{!con.Fax}"/></apex:column>
                    </apex:dataTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
this is my controller:
public class Contact
{
    List<Contact> conlist = new List<Contact>();
    public List<Contact> displayContacts(){
        for(Contact c:[SELECT lastname,name,leadsource,phone,fax FROM Contact]){
            conlist.add(c);
        }
        return conlist;
    }
    
    public class contactwrapper
    {
        private Contact con{get;set;}
        public contactwrapper(Contact c){
            con = c;
        }
    }
}


 

Ther are 4 objects.
Route__c is a master
Route_outlet__c is Junction object for Route__c & Account.

And For Route__c there is one lookup for City__c

 

So My Requirment is,,,, While saving the Rout_outlet__c Record.
We must check the Account__r.BillingCity & route__r.City__r.name
if these two matches the rout_outlet__c record must save.

my Trigger is this

trigger AvoidCityNomatch on Route_Outlet__c (Before Insert, Before Update) {
for(Route_Outlet__c ro:Trigger.new){
if(ro.route__r.City__c!=ro.Account__r.BillingCity)
Ro.City__c.adderror('Account City & Rout City No Match');
}
}
in debug log ro.route__r.City__c showing null, pls guide me

Hi all,
I have created a visualforce page that allows multiple rows of the same fieldto be added on the page.

However when i try to save the record, the page refreshes but does not save. I am not sure if I have to create a custom save method or weather I can use the one provided with the standard controller.

My controller is:
public class IncidentLogPopup
{ 
    public List<Incident_Log__c> memberList {get;set;}
    public List<Incident_Log__c> memberAddList {get;set;}
    public String memberName {get;set;}  
    public IncidentLogPopup(ApexPages.StandardController controller) {
        String sql = 'SELECT Date_Time__c, Incident__c, Reported_to__c, Reported_By__c FROM Incident_Log__c';
        memberList = Database.Query(sql);
        memberAddList = new List<Incident_Log__c>();
        memberAddList.add(new Incident_Log__c());
    }

  
    public void AddRow()
    {
        memberAddList.add(new Incident_Log__c());
    } 
    
    
}

VF Page:
<apex:page sidebar="false" StandardController="Incident_Log__c" extensions="IncidentLogPopup">
<apex:form >
    <apex:pageBlock id="membAdd" >  
    <apex:pageBlockButtons location="Both">
                <apex:commandButton value="Save" Action="{!save}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/>
                </apex:pageBlockButtons>                
        <apex:pageblockSection >
            <apex:pageBlockTable value="{!memberAddList}" var="memb">
                <apex:column headerValue="Date/Time">
                    <apex:inputField value="{!memb.Date_Time__c}"/>
                </apex:column>
                <apex:column headerValue="Incident">
                    <apex:inputField value="{!memb.Incident__c}"/>
                </apex:column>
                <apex:column headerValue="Reported To">
                    <apex:inputField value="{!memb.Reported_To__c}"/>
                </apex:column>
                <apex:column headerValue="Reported By">
                    <apex:inputField value="{!memb.Reported_By__c}"/>
                </apex:column>
            </apex:pageBlockTable> 
            <br/><apex:commandLink value="Add Row" action="{!addRow}" />        
        </apex:pageblockSection>        
        <apex:pageblockSection columns="1" >
            <apex:pageblockSectionItem >
           
            </apex:pageblockSectionItem>        
        </apex:pageblockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Thanks
Hi all,
Scenaio : How to pass values from one VF page to another VF page.
I have 2 VF pages.   emp VF page and DetailVFpage
i have values firstname, lastname,email, phone in empVFPage and need to pass values to DetailVFpage.

 PageReference pageRef= new PageReference('/apex/DetailVFpage');

i can able to naviage to 2nd VF page(DetailVFPage) after click on link in empVFPage....But values are not passing
1stVFpage
when click on Verification page link, i can able to see Detail VF page..But the values not passing ..
see screenshot the Result page not showing values of VF page firstname, lastname....
2ndVFPage
Anyone have idea on htis
 
  • April 30, 2018
  • Like
  • 0
JavaScript Problem
    I have a problem with the following code:
    <apex:page >
        
        <apex:form >
            <apex:commandButton value="Click" onclick="document.getElementById('sp').innerHTML='Hello'" />
    <span id="sp"></span>
        </apex:form>

    </apex:page>

    When I click on the button the value I  am setting in the span tag ('Hello' in span)  appears for 1 second and again disappears, I want the text 'Hello' to remain in span after clicking on the button. Can anyone please help me with this?
<apex:page >
<script type="text/javascript">
function validate()
{
document.getElementById('demo').innerhtml='hello js'
}
</script>

  <html>
  <body>
  <h1>Congratulations</h1>
  <p id="demo">This is your new Page: js1</p>
  <apex:form >
       <apex:commandButton value="Insert" onclick="validate();"/>
       </apex:form>
  </body>
  </html>
  
</apex:page>
Friends, I have created a visual force page with cancel button. but when i click cancel button the page ask me to fill  required fields. How Can i Overcome this . My requirement is when i click cancel button it has to go list view page. 

Here My code
Apex:

Public Pagereference docancel(){      
    PageReference pageRef = new PageReference('/001/o');   
    pageRef.setRedirect(true);
    return pageRef;   
    }
I am putting together code for an update to a custom object (opportunity hierarchy) based on set fields (IDs) being provided in the opportunity object.
I am getting an error that my field Account_Name__c is not a variable the exists.  Any ideas?
 
trigger OpptyHierarchy on Opportunity_Hierarchy__c (before insert, before update) {
    Set<string> OpportunityID = new set<string>();
    for (Opportunity_Hierarchy__c tc : trigger.new) {
        if (tc.Account_Name__c != NULL) {OpportunityID.add(tc.Account_Name__c);
        }
    }
    Map<string, Opportunity> Opportunity = new Map <string, Opportunity>();
    for (Opportunity obj : [SELECT ID, AccountID, Main_Account__c, Enterprise_Account__c
                            from Opportunity
                            Where OpportunityID in: Opportunity]) {Opportunity.put(obj.Account_Name__c,obj);
    }
    for (Opportunity_Hierarchy__c t: trigger.new) {
        if (Opportunity.containsKey(tc.Account_Name__c)) tc.Account_Name__c = Opportunity.get(tc.Account_Name__c).ID;
        tc.Main_Account__c = Opportunity.get(tc.Account_Name__c).Main_Account__c;
        tc.Enterprise_Account__c = Opportunity.get(tc.Account_Name__c).Enterprise_Account__c;
    }
}

 
Hello, 

I am writing a code where when i will create record date should be automatically create into visualforce. i am getting error in this line        date myDate = date.newInstance(obj.Year__c, obj.Month__c, 1);
Can anyone please help me to solve this?

public with sharing class Calender {
    public List<DTP__c> mydtpList{get;set;}
    public  MTP__c obj{get;set;}
    public Calender(ApexPages.StandardController controller)
     {
          tid = ApexPages.currentPage().getParameters().get('id');
         System.debug('***************dtp added*******************'+tid); 

     }

public Decimal dy;
public date myDate;

public  id tid{get;set;}

    public PageReference createdtp() {
     
        System.debug('***************tid tid*******************'+tid);
        obj = [Select  Id, Month__c, Year__c,  February__c, NumberOfDays__c from MTP__c where id=:tid ];
        dy= obj.NumberOfDays__c;
        if(obj.February__c !=null)      
        {
         String str=obj.February__c;
         dy=Decimal.ValueOf(str);
        }  
           else 
           {
            Decimal str= obj.NumberOfDays__c;
         dy=str;
         }
        
       
        
/*
    for(MTP__c mt:obj)
    {
    if(mt.Month__c=='February')
    
    {
    String str=mt.February__c;
    dy=Decimal.ValueOf(s
      System.debug('***************in IF dy size******************'+dy);
    }
    else
    {
     Decimal str= mt.NumberOfDays__c;
      dy=str;
        System.debug('***************in  else dy size******************'+dy);
    }
    }*/
    
  List<DTP__c> newdtp= new List<DTP__c>();
   System.debug('***************dy size******************'+dy);
    for(Integer i = 1; i<=dy; i++)

    {
       DTP__c  dt = new DTP__c();
       dt.MTP__c=tid;
       date myDate = date.newInstance(obj.Year__c, obj.Month__c, 1);
       Integer day = myDate.dayOfYear();
       system.assertEquals(294, day);
       newdtp.add(dt);
       System.debug('****************dtp added********************'+tid);
       //insert newdtp;
     
   
    }
    insert newdtp;
    return null;
    }
   
    }


Thanks & Regards,
Satakshi
Hi,
I want functionality where according to month and year date will automatically added into record. How can we achive it?



public with sharing class Calender {
    public List<DTP__c> mydtpList{get;set;}
    public  MTP__c obj{get;set;}
    public Calender(ApexPages.StandardController controller)
     {
          tid = ApexPages.currentPage().getParameters().get('id');
         System.debug('***************dtp added*******************'+tid); 

     }

public Decimal dy;
public  id tid{get;set;}

    public PageReference createdtp() {
     
        System.debug('***************tid tid*******************'+tid);
        obj = [Select  Id, Month__c, Year__c,  February__c, NumberOfDays__c from MTP__c where id=:tid ];
        dy= obj.NumberOfDays__c;
        if(obj.February__c !=null)      
        {
         String str=obj.February__c;
         dy=Decimal.ValueOf(str);
        }  
           else 
           {
            Decimal str= obj.NumberOfDays__c;
         dy=str;
         }
        
       
        
/*
    for(MTP__c mt:obj)
    {
    if(mt.Month__c=='February')
    
    {
    String str=mt.February__c;
    dy=Decimal.ValueOf(s
      System.debug('***************in IF dy size******************'+dy);
    }
    else
    {
     Decimal str= mt.NumberOfDays__c;
      dy=str;
        System.debug('***************in  else dy size******************'+dy);
    }
    }*/
    
  List<DTP__c> newdtp= new List<DTP__c>();
   System.debug('***************dy size******************'+dy);
    for(Integer i = 1; i<=dy; i++)

    {
       DTP__c  dt = new DTP__c();
       dt.MTP__c=tid;
       newdtp.add(dt);
       System.debug('****************dtp added********************'+tid);
       //insert newdtp;
     
   
    }
    insert newdtp;
    return null;
    }
   
    }


Regards,
Satakshi
I am new to salesforce.  Trying to create a new user with System Administrator profile but not getting the options in the drop down list.

looking forward to your response  
Hello, 
I am writing code to create calender records. I am facing this error.

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [MTP]: [MTP]
Error is in expression '{!createdtp}' in component <apex:page> in page createdtp: Class.Calender.createdtp: line 40, column 1
An unexpected error has occurred. Your development organization has been notified.

Can anyone please help me to sort it out. MTP is master detail field

My code is:

Controller:
public with sharing class Calender {

    public Calender(ApexPages.StandardController controller)
     {
          tid = ApexPages.currentPage().getParameters().get('id');
         System.debug('***************dtp added*******************'+tid); 

     }

 public Decimal dy;
 public  id tid{get;set;}
    public PageReference createdtp() {
     
      System.debug('***************tid tid*******************'+tid);
    List<MTP__c> obj = [Select  Id, Month__c, Year__c,  February__c, NumberOfDays__c from MTP__c];
 
    for(MTP__c mt:obj)
    {
    if(mt.Month__c=='February')
    {
    String str=mt.February__c;
    dy=Decimal.ValueOf(str);
    }
    else
    {
     Decimal str= mt.NumberOfDays__c;
      dy=str;
    }
    }
  List<DTP__c> newdtp= new List<DTP__c>();
    for(Integer i = 1; i<=dy; i++)
    {
       DTP__c  dt = new DTP__c();
       dt.MTP__c=tid;
       newdtp.add(dt);
       System.debug('***************dtp added*******************'+tid);
       //insert newdtp;
       
    }
    insert newdtp;
    return null;
    }
        
    public List<DTP__c> getMydtpList(){
mydtpList =[select Name, Expenses__c, MTP__c, Food_Expenses__c, Date__c, Visit_type__c from DTP__c where id=:tid];

    return mydtpList ;
}
    List<DTP__c>  mydtpList = [select Expenses__c, Name, MTP__c, Food_Expenses__c, Visit_type__c from DTP__c where id=:tid];

    }

VF Page:

<apex:page standardController="MTP__c"  extensions="Calender" action="{!createdtp}">
 <apex:pageBlock title="All Dtp">
 <apex:pageblockTable value="{!mydtpList}" var="item">
 <apex:column value="{!item.Name}"/> 
 <apex:column value="{!item.Date__c}"/> 
 <apex:column value="{!item.Visit_type__c}"/> 
 <apex:column value="{!item.Food_Expenses__c}"/> 
</apex:pageblockTable>
 </apex:pageBlock> 
</apex:page>

Thanks & Regards,
Satakshi
<apex:page standardcontroller="Opportunity" extensions="myOpptyController" tabStyle="Opportunity">

          <apex:pageBlock title="opportunity product related list">

             <apex:pageBlockTable value="{!opptyList}" var="div">

               <apex:column >

                        <apex:pageBlockTable value="{!div.OpportunityLineItems}" var="custom">

                        <apex:column value="{!custom.Quantity}"/>

                        <apex:column value="{!custom.UnitPrice}"/>

                        <apex:column value="{!custom.TotalPrice}"/>

                        <apex:column value="{!custom.PricebookEntry.Name}"/>

                        <apex:column value="{!custom.PricebookEntry.Product2.Family}"/>

                    </apex:pageBlockTable>

            </apex:column>   

     </apex:pageBlockTable>

    </apex:pageBlock>

    </apex:page>

Class is as follows:
public class myOpptyController {

    public myOpptyController(ApexPages.StandardController controller) {

    }     

        public List<Opportunity> opptyList{get;set;}

       // public List<OpportunityListItems> opptyList1{get;set;}

        public myOpptyController() {
     

        opptyList = [SELECT Id,Name,

             (SELECT ID, Quantity, UnitPrice, TotalPrice,PricebookEntry.Name, PricebookEntry.Product2.Family FROM OpportunityLineItems)

                            FROM Opportunity WHERE Id =: ApexPages.currentPage().getParameters().get('ID')];

                  //   System.debug('opptyList ='+opptyList);

        }

         

      //  public List<Opportunity> getopptyList() {

      //      return opptyList;
    //    }
      

    }
This code is not displaying opportunitylineitem table
Hi all,

I have a requirement to indentify number of emails sent by each user (basically related to cases) for service cloud.I have pulled a report for the same which does not exactly gives the count.For instance,when the cases are assigned to specific owners, and some one else has sent email on a particular case,the email count against case owner ,but not against the sender of the email.

​Thanks!! 
Hi All, 

I found something crazy in opportunity object that is Partner Account field which is standard Lookup(account), I see 2 lookup(account) standard fields in opportunity object. I heard in few other orgs people are not able to find this field on their side. Can anyone explain me about this particular field, Why is it visible for few orgs and what is the related list name on account object. 

Thank you.
I am learing REST.... During developing code for calling PUT method I stuck at a point. I am loading a pick list at the load time depending on account name selected I am listing below the table for Status of cases available for that Account. Now I want to edit that Status and save it. But I am not able to use inlineEditSupport component as I am using DTO....anyonw know how to solve this issue??

I needed to create DTO as my REST methods do not let me to store response as a case list. 

my code is here:
(I am commenting some part)

VF page :
<apex:page standardController="Account" Extensions="demoExtension">
  
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Picklists" columns="2">
                <apex:selectList value="{!selectedAccounts}" size="1" label="Account" >
                    <!-- <apex:actionSupport event="onchange" action="{!getOpenCases}" status="assign-action-status" reRender="theForm, caseResults"/> -->
                    <apex:selectOptions value="{!items}"/>
                </apex:selectList>
            </apex:pageBlockSection>
        </apex:pageBlock>

        <apex:pageBlock mode="inlineEdit">
            <apex:pageBlockTable value="{!resDtolist}" var="val" >          
                <apex:column value="{!val.Status}" headerValue="Status"/>
                <apex:inlineEditSupport event="ondblClick" />
            </apex:pageBlockTable>
        </apex:pageBlock>
        
    </apex:form>
  
</apex:page>

APEX / Controller /class code :

public class demoExtension {
    // stores selected account option
    public String selectedAccounts { get; set; }
    public List<RestDTO> resDtolist{ get; set; }
    // stores accounts (used as drop down list)
    public List<Account> accountList { get; set; }
    
    // constructor
    public demoExtension(ApexPages.StandardController controller) {
        accountList = [SELECT name, id, OwnerId FROM Account WHERE OwnerId=:UserInfo.getUserId()];
    
        resDtolist = new List<RestDTO>();
        for(Case c : [SELECT ID, Subject , Status , Owner.Id , Owner.Name FROM case LIMIT 10]){
            resDtolist.add(new RestDTO(c));
        }
    }
    // creates drop down list of options (account ids and names)
    public List<SelectOption> getItems() 
    {
        List<SelectOption> options = new List<SelectOption>();
        for(Account actName : accountList ) //constructor
        {
            options.add(new SelectOption(actName.name, actName.name));
        }
        return options;
    }
    
    public class RestDTO{
        public String Id{ get; set; }
        public String Subject{ get; set; }
        public String Status{ get; set; }
        public String OwnerId{ get; set; }
        public String OwnerName{ get; set; }
        
        public RestDTO(Case c){
            this.Id = c.Id;          
            this.Subject = c.Subject;            
            this.Status = c.Status;          
            this.OwnerId = c.OwnerId;            
            this.OwnerName = c.Owner.Name;           
        }
    }


}