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


  • Chatter
    Feed
  • 52
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 339
    Replies

<apex:page standardController="account" extensions="SalaryRewards" showheader="false" sidebar="false">
    <apex:pagemessages ></apex:pagemessages>  
    <apex:pageblock >
        <apex:pageBlocktable value="{!lsalaryInfo}" var="sinfo">
            <apex:column value="{!sinfo.month}" headervalue="Month"/>
            <apex:column value="{!Round(sinfo.Basic_Allowance,0)}" headervalue="BasicAllowance"/>                              
      <apex:page standardController="account" extensions="SalaryRewards" showheader="false" sidebar="false">
    <apex:pagemessages ></apex:pagemessages>  
    <apex:pageblock >
        <apex:pageBlocktable value="{!lsalaryInfo}" var="sinfo">
            <apex:column value="{!sinfo.month}" headervalue="Month"/>
            <apex:column value="{!Round(sinfo.Basic_Allowance,0)}" headervalue="BasicAllowance"/>                              
               </apex:pageBlocktable>
    </apex:pageblock>
</apex:page>

I am getting error as : Syntax error. Missing ')'
can anyone guide me what i am missing ?

Thanks in Advance
 
I have rows of data to display on a VF form and on some rows I want to hide the button based on a field value for that row. Everything I try hides the entire column, e.g.

<apex:dataTable value="data" var="c">
    <apex:column>
        <apex:outputText value="{!c.field}/>
        <apex:outputPanel rendered="{!c.rowBoolean}">
            <button type="button">process...</button>
        </apex:outputPanel>
    </apex:column>
</apex:dataTable>
 
There are three objects .
Quote line group is Master-Detail with Quote.
Quote line is related to Quote Line group.

I need to query in SOQL fields of Quote Line group and Quote line based on Quote object .

How to Achieve 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>
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 ?
 
  • March 01, 2016
  • Like
  • 0
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;
        }
    }
}


 

<apex:page standardController="account" extensions="SalaryRewards" showheader="false" sidebar="false">
    <apex:pagemessages ></apex:pagemessages>  
    <apex:pageblock >
        <apex:pageBlocktable value="{!lsalaryInfo}" var="sinfo">
            <apex:column value="{!sinfo.month}" headervalue="Month"/>
            <apex:column value="{!Round(sinfo.Basic_Allowance,0)}" headervalue="BasicAllowance"/>                              
      <apex:page standardController="account" extensions="SalaryRewards" showheader="false" sidebar="false">
    <apex:pagemessages ></apex:pagemessages>  
    <apex:pageblock >
        <apex:pageBlocktable value="{!lsalaryInfo}" var="sinfo">
            <apex:column value="{!sinfo.month}" headervalue="Month"/>
            <apex:column value="{!Round(sinfo.Basic_Allowance,0)}" headervalue="BasicAllowance"/>                              
               </apex:pageBlocktable>
    </apex:pageblock>
</apex:page>

I am getting error as : Syntax error. Missing ')'
can anyone guide me what i am missing ?

Thanks in Advance
 

While creating Case record using Flows..

i am using screen component that hepls to user to select multiple Accounts (Multi-picklist) who are having the same record type and stores those ids in the text datatype field in Case object.

For now that text datatype field displaying the total selected Account ids with comma seperated values.

but my question is

how to display those respective account names despite Account ids.

  • September 28, 2022
  • Like
  • 0
public class SalaryRewards {

 public List <salaryInfo> lsalaryInfo{get;set;}
        public List <Salary_Detail__c> salarydetail{get;set;}
          
 public SalaryRewards(ApexPages.StandardController controller) 
    {
        lsalaryInfo = new list <salaryInfo>();
        salarydetail = new list<Salary_Detail__c>();
        salarydetail =[SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ];
  
        for(integer i=0;i<System.now().month();i++)
        {
            salaryInfo  sinfo = new salaryInfo ();
            sinfo.month = datetime.newinstance(2013,1,1).addmonths(i).format('MMM');
            sinfo.count = 0;
           lsalaryInfo.add(sinfo);
             system.debug('salary-month===>'+lsalaryInfo);
        }
      
            // lsalaryInfo = new List <salaryInfo>();
     list<Salary_Detail__c> sallist =new list<Salary_Detail__c>();
                  list<Salary_Detail__c> salmainlist =new list<Salary_Detail__c>([SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ]);
            for(Salary_Detail__c sal :salmainlist){
                                     lsalaryInfo.add(new Salary_Detail__c(sal,BasicAllowance__c));
// how to mention value here
//error:Type requires name=value pair construction: Salary_Detail__c

                      system.debug('salary-month===>'+ lsalaryInfo);}
    }}

      
    
            
      
     

        
 

       
        
    
  
I have rows of data to display on a VF form and on some rows I want to hide the button based on a field value for that row. Everything I try hides the entire column, e.g.

<apex:dataTable value="data" var="c">
    <apex:column>
        <apex:outputText value="{!c.field}/>
        <apex:outputPanel rendered="{!c.rowBoolean}">
            <button type="button">process...</button>
        </apex:outputPanel>
    </apex:column>
</apex:dataTable>
 
System.NullPointerException: Attempt to de-reference a null object
Class.OpportunityUpdateFromTicketHandler.emailNotificationFromIteroBackOffice: line 30, column 1
Class.OpportunityUpdateFromTicketHandlerTest.emailNotificationFromIteroBackOfficeTest: line 76, column 1

Apex class :
-----------------
ublic class OpportunityUpdateFromTicketHandler {
    
    Public static void sendEmail(List<String> toAddress,EmailTemplate et)
    {
       List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTemplateId(et.Id);
                mail.setToAddresses(toAddress);
                mail.setSubject(et.subject);
                mail.setHTMLBody(et.Body);
                allmsg.add(mail);
            Messaging.sendEmail(allmsg);
        
    }
    Public static EmailTemplate getQuery(String tempname)
    {
      EmailTemplate et = [select id,Subject,Body from EmailTemplate where DeveloperName =: tempname];
        return et; 
    }
    // created by Jayaramu for Technical Det story
    Public static void emailNotificationFromIteroBackOffice(List<case> ticketList,Map<Id,Case> oldMapCase)
    {
        EmailTemplate et = getQuery('iTero_back_office_Template');
        system.debug('@@@@@@@@@'+et);
        Map<ID, RecordType> recordTypeMap = New Map<ID, RecordType>([Select ID, Name From RecordType Where sObjectType = 'Case']);
        List<string> toAddress = new List<string>();    
        for(Case ticket :ticketList)
        {
        if(recordTypeMap!=null && ticket !=null && recordTypeMap.get(ticket.recordTypeID).name.containsIgnoreCase('iTero Contracts') && ticket.Ticket_Type__c =='New scanner sale' && ticket.Final_Status__c != oldMapCase.get(ticket.Id).Final_Status__c && ticket.Final_Status__c =='Processed/Assigned to Logistics' )
        {
            if(ticket.Region__c =='NA' || ticket.Region__c =='LATAM')
            {
              toAddress.add('test@gmail.com');
                system.debug('#######' + ticket.managerid__c);
                if(toAddress !=null && et!=null)
                {
                    sendEmail(toAddress, et);
                }
                
            }
        }
        
        }
   }

Test Class
------------------
@isTest
public class OpportunityUpdateFromTicketHandlerTest {
        public static Id eUiteroRecordTypeId  =  Schema.SObjectType.Case.getRecordTypeInfosByName().get('iTero Contracts').getRecordTypeId();
    public static Id eUiteroRecordTypeId1  =  Schema.SObjectType.Case.getRecordTypeInfosByName().get('Incentive Compensation Request').getRecordTypeId();
    //public static Id eUiteroRecordTypeId2  =  Schema.SObjectType.Case.getRecordTypeInfosByName().get('iTero Training').getRecordTypeId();
  @isTest static void emailNotificationFromIteroBackOfficeTest(){
      Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
      Userrole objr = [SELECT Id FROM UserRole WHERE Name = 'Global Administrator' LIMIT 1];
       User thisUser = new User(Alias = 'standt', Email='contractdesk@testorg.com', 
                                 EmailEncodingKey='UTF-8', LastName='contractdesk', LanguageLocaleKey='en_US', 
                                 LocaleSidKey='en_US', ProfileId = p.Id,UserRoleId = objr.Id,
                                 TimeZoneSidKey='America/Los_Angeles', UserName='contractdesk@testorg.com');
        TestDataBuilder testBuilder = new TestDataBuilder();
        //insert manager
        User usrManager             = new User();
        usrManager          = testBuilder.dummyUser(0);
        usrManager.UserRoleId = objr.Id;
        insert usrManager; 
        //Insert User
        User usr                = new User();
        usr             = testBuilder.dummyUser(1);
        usr.ManagerId   = usrManager.Id;
        usr.UserRoleId = objr.Id;
        
        insert usr;
      
      System.runAs(thisUser){
      List<case> caseList = new List<case>();
        //insert Case
        Case cse                    = new Case();
        cse.RecordTypeId    = eUiteroRecordTypeId;
        cse.Ticket_Type__c  = 'New scanner sale';
        cse.Origin          = 'Web';
        cse.Final_Status__c ='Processed/Assigned to Logistics';
        cse.Region__c = 'NA';
        //cse.Status='Approved';
        cse.Type_of_Credit__c='Internal';
        cse.Reason_for_Credit__c='Staff Discount Coupon';
        cse.Subject='Testing';
        cse.Invoice_Number__c='1234567891';
        cse.Amount_of_credit__c=10;
        cse.Order_type__c='webstore';
        cse.Sales_Order_Number__c='123456';
      caseList.add(cse);
      Case cse1                    = new Case();
        cse1.RecordTypeId    = eUiteroRecordTypeId;
        cse1.Ticket_Type__c  = 'New scanner sale';
        cse1.Origin          = 'Web';
        cse1.Final_Status__c ='Processed/Assigned to Logistics';
        cse1.Region__c = 'NA';
        //cse1.Status='Approved';
        cse1.Type_of_Credit__c='Internal';
        cse1.Reason_for_Credit__c='Staff Discount Coupon';
             cse1.Subject='Testing';
        cse1.Invoice_Number__c='1234567891';
        cse1.Amount_of_credit__c=10;
        cse1.Order_type__c='webstore';
        cse1.Sales_Order_Number__c='123456';
         caseList.add(cse1);
          EmailTemplate et = OpportunityUpdateFromTicketHandler.getQuery('iTero_back_office_Template');
            emailmessage em = new emailmessage();
                em.fromaddress = 'Test@test.com';
                em.toaddress = 'test1@test.com';
                em.subject = 'Test Email';
                em.textbody = 'testing';
                em.parentid = caseList[0].id;
                test.starttest();
                insert em;
      Map<Id,Case> oldMapCase = new Map<Id,Case>(); 
      insert caseList;
      oldMapCase.put(cse.Id, cse);
       System.assertEquals(0, Limits.getEmailInvocations(), 'No emails should be sent');

       OpportunityUpdateFromTicketHandler.emailNotificationFromIteroBackOffice(caseList,oldMapCase);

       System.assertEquals(1, Limits.getEmailInvocations(), 'Emails should be sent');
       Test.stopTest();
      }
  }
        
  }


Thanks!!
  • September 08, 2022
  • Like
  • 0
There are three objects .
Quote line group is Master-Detail with Quote.
Quote line is related to Quote Line group.

I need to query in SOQL fields of Quote Line group and Quote line based on Quote object .

How to Achieve this
Hi, 

Trying to run the test but for some reason my test code coverage shows None. Here is my code

Class:

public with sharing class emailHelper {
public Aspirant__c asp {get;set;}    
public User myUser { get;set;}

public emailHelper(ApexPages.StandardController stdController)

    asp = (Aspirant__c)stdController.getRecord(); 
}

User currentUser = [Select email from User where username = :UserInfo.getUserName() limit 1];

public  PageReference sendEmail() {
PageReference emailPage = new PageReference('/email/author/emailauthor.jsp');
Map<String, String> params = emailPage.getParameters();
params.put('p2_lkid',asp.Email__c);
params.put('p3_lkid',asp.ID); 
params.put('template_id','00X3K000000F91e'); 
params.put('rtype','003');
params.put('p24',currentUser.Email); 
params.put('new_template','1'); 
params.put('retURL',ApexPages.currentPage().getUrl()); 
     
return emailPage;     
}
}


Test:

@isTest 
public class emailHelperTest
{
 static testMethod void testMethod1() 
 {
 Aspirant__c testAsp = new Aspirant__c();
 testAsp.First_Name__c='Test' ;
 testAsp.Email__c ='tharanginigts@gmail.com';
 insert  testAsp;
 
 Test.startTest();
PageReference emailPage = new PageReference('/email/author/emailauthor.jsp');
Map<String, String> params = emailPage.getParameters();
params.put('p3_lkid',testAsp.ID); //email will be attached to the activity history of the account where the button was clicked using the acct.ID
params.put('template_id','00X3K000000F91e'); /// template ID of the email template to be shown goes here
params.put('rtype','003');
params.put('p24',testAsp.Email__c); //currentUser.Email showing in "Additional to" field
params.put('new_template','1'); 
params.put('retURL',ApexPages.currentPage().getUrl()); //after send button is clicked, go back to the account where the button was clicked
 Test.stopTest();
 }
}
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
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;           
        }
    }


}