• hitesh90
  • PRO
  • 4247 Points
  • Member since 2012
  • Sr. Technical Analyst
  • Jade Global Software Pvt. Ltd.


  • Chatter
    Feed
  • 128
    Best Answers
  • 1
    Likes Received
  • 2
    Likes Given
  • 2
    Questions
  • 636
    Replies

I do have a page with /apex/AccountPrioritySort?id={!Account_Plan__c.Id}&type=AP. Please find my code as below

Visual Force Page

<apex:page standardController="Account_Plan__c" extensions="accountprioritysort1" tabStyle="Account" id="thePage">
    <apex:form id="theForm" >
        <apex:pageBlock title="Editing Top 5 Account Priorities" mode="edit">
            <apex:messages />
                <apex:pageBlockButtons location="top">
                    <apex:commandButton value="Update Sorted Account Priorities" action="{!SaveAction}"/>
                    <apex:commandButton value="Cancel" action="{!Cancel}"/>
                </apex:pageBlockButtons>
            
                <apex:pageBlockTable value="{!actPList}" var="item">
                    <apex:column value="{!item.Account_Priorities__c}"/>
                    <apex:column headervalue="# (Top 5 Priorities)">
                        <apex:inputField value="{!item.Field1__c}"/>
                    </apex:column>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

APEX Class

public with sharing class accountprioritysort1 {    

    public ApexPages.StandardController stdController {get; set;}
    public Account_Plan__c AccPri { get; set; }
    public list<Company_Priorities__c> actPList  { get; set; }
    public integer aField { get; set;}
    
    public accountprioritysort1 (ApexPages.StandardController stdController){
        System.debug('Is it in the Constructor');
        this.stdController = stdController;
        this.AccPri = (Account_Plan__c)this.stdController.getRecord();
        actPList = [select Field1__c,Account_Priorities__c from Company_Priorities__c where Account_Plan__c =: AccPri.Id
                ORDER BY Field1__c ASC ];
    }
    
    public PageReference SaveAction(){
        update actPList;
        PageReference page = new PageReference('/apex/AccountPrioritySort?id='+AccPri.id);
        page.setRedirect(true);
        return page;
    }
    
    public PageReference CancelAction(){
            PageReference page = new PageReference('/apex/AccountPrioritySort?id='+AccPri.id);
            page.setRedirect(true);
            return page;
        }
    }


/apex/AccountPrioritySort?id={!Account_Plan__c.Id}&type=AP

Now i want to pass this 


1. The value (which is as type=AP) from the Parameter Type in the Apex Controller

2. How can render by using the type variable to between Account Priorities and Risk in the VF page and Controller. This type should be used to decide what data needs to be saved i.e. should the risk code execute or Account priorities code execute.
 

Can any one help on this code.

 

HI All.

I'm only getting 70% coverage and I'm not sure how to cover the variables.

These are the lines not covered.

     Line 16 qty = o.Total_Roundtables__c;
            17 orderId = o.Id;
            18 eventId = o.Event__c;
            19 eventName = o.Event__r.Name;

            31 r=new Roundtables__c (Order__c=orderId, Status__c ='Unallocated', Event__c = eventId);
            32 rList.add(r);

Can anyone help?

Here's my trigger
trigger CreateRoundtables on Order (after insert, after update) {

    public double qty;
    public id orderId;
    public id eventId;
    public string eventName;


    
    Id orderRecType = Schema.SObjectType.Order.getRecordTypeInfosByName().get('Order').getRecordTypeId(); 
    
    List <OrderItem> oi = [Select id, Roundtables__c from OrderItem where Roundtables__c>0 ];
    system.debug(oi);
    for(order o:trigger.new){
        if(o.BU__c=='MTB' && o.Total_Roundtables__c >= 1 && O.Attendee_Type__c =='Sponsor' && o.Status == 'Approved'){
         	qty = o.Total_Roundtables__c;
            orderId = o.Id;
            eventId = o.Event__c;
            eventName = o.Event__r.Name;
            system.debug('Order ID '+ orderId);
            system.debug('Event Name '+ eventName);
        }
    }
    
    List <Roundtables__c> curRT = [Select id, Order__c from Roundtables__c where Order__c =: orderId];
    List <Roundtables__c> rList = new list <Roundtables__c>();
    Roundtables__c r;
    
    if(curRT.size() <> qty){
    for(Integer m=1;m<=qty;m++){
        r=new Roundtables__c (Order__c=orderId, Status__c ='Unallocated', Event__c = eventId);
        rList.add(r);
    }
    }
	insert rList;
}

Here's the test class
@istest (SeeAllData = true) 
public class CreateRoundTableTEST {
	
    static testMethod void TESTcreateRoundTables(){
        
        //Insert Test Accounts
		Account acc = new Account();
        acc.Type='Other';
        acc.name='test ';
        acc.NumberOfEmployees=10;
        acc.BillingStreet='BillingStreet'; 
        acc.BillingCity = 'BillingCity';
        acc.BillingState = 'BillingState';
        acc.BillingCountry = 'BillingCountry'; 
        acc.BillingPostalCode = 'BillingPostalCode';
        acc.NumberOfEmployees = 50; 
        insert acc;
        
        Account acc2 = new Account();
        acc2.Type='AX Company';
        acc2.name='test 1';
        acc2.BillingStreet='BillingStreet1'; 
        acc2.BillingCity = 'BillingCity';
        acc2.BillingState = 'BillingState';
        acc2.BillingCountry = 'BillingCountry'; 
        acc2.BillingPostalCode = 'BillingPostalCode';
        acc2.NumberOfEmployees = 50; 
        insert acc2;
   
        Project__c testProject = new Project__c();
        testProject.name = 'test Project';
        testProject.Project_Code__c = 'SUM123';
        insert testProject;
   
        //Insert Test Event
        Event__c testEvent = new Event__c();
        testEvent.name='testEvent';
        testEvent.Start_Date__c =system.today();
        testEvent.End_Date__c=system.today().addDays(2);
        testEvent.name='testEvent';
        testEvent.AX_Company__c = acc2.Id;
        testEvent.project__c = testProject.Id;
        Insert testEvent;
        
        //Insert Test Contacts
        Contact con = new contact();
        con.lastname='test';
        con.accountid=acc.id;
        con.FirstName = 'FirstName';
        con.MailingStreet = 'MailingStreet'; 
        con.MailingCity = 'MailingCity';
        con.MailingState = 'MailingState';
        con.MailingCountry = 'MailingCountry';
        con.MailingPostalCode = 'MailingPostalCode';  
        con.IsOpen4All__c=false;      
        insert con;
        
        Contact con2 = new contact();
        con2.lastname='test';
        con2.accountid=acc.id;
        con2.FirstName = 'FirstName';
        con2.MailingStreet = 'MailingStreet'; 
        con2.MailingCity = 'MailingCity';
        con2.MailingState = 'MailingState';
        con2.MailingCountry = 'MailingCountry';
        con2.MailingPostalCode = 'MailingPostalCode';  
        con2.IsOpen4All__c=false;      
        insert con2;
        
        //insert Test Campaign
        Campaign testCampaign1       = new Campaign();
        testCampaign1.name           = 'TestCampaign';
        testCampaign1.Member_Type__c = 'Delegate';
        testCampaign1.Type = 'Call List';
        insert testCampaign1;

       test.startTest();
         Id standardPriceBookId = Test.getStandardPricebookId();
        order o1 = new order();
        o1.accountid=acc.id;
        o1.EffectiveDate= system.today();
        o1.Attendee_Type__c='Sponsor';
        o1.pricebook2id=standardPriceBookId;
        o1.Primary_Campaign_Source__c=testCampaign1.id;
        o1.Price_List__c='test';
        o1.Status='Draft';
        o1.Sold_On_Date__c= system.today();
        o1.Main_POC__c=con2.id;
        o1.Event__c = testEvent.id;
        insert o1;
        
         Id dealOrderId = [Select Id, DeveloperName FROM RecordType where SobjectType = 'Order' and DeveloperName = 'Deal' limit 1].Id;

        o1.recordtypeid=dealOrderId;
        update o1;

        Product2 pd = new Product2(Name='MTB Prod',isActive=true, Number_of_Roundtables__c =2);
        pd.IsActive = true;
        insert pd;
        
        //Id standardPriceBookId = Test.getStandardPricebookId();
        
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=pd.Id, UnitPrice=99, isActive=true);
        insert pbe;
        
        OrderItem ordPd = new OrderItem(PriceBookEntryId=pbe.Id, OrderId=o1.Id, Quantity=1, UnitPrice=99);
        insert ordPd;
        o1.status='Approved';
        update o1;
        
        
       test.stopTest();
    }
}


 
I currently have a trigger that checks a box when an attachment is added to a custom object called "Contracts__c". I would like to expand this Trigger to only check the box if the actual attatched document includes certain keywords. Is this possible? Here is my current code:

trigger CountAttachment on Attachment (before insert, before delete)
{
if(trigger.isinsert){
List<Contracts__c> co = [select id from Contracts__c where id =: Trigger.New[0].ParentId];
If(co.size()>0)        
{            
co[0].Contract_Attached__c = True;            
update co;        
}
}


if(trigger.isdelete){

List<Contracts__c> co = [select id from Contracts__c where id =: Trigger.old[0].ParentId];        
If(co.size()>0)        
{            
co[0].Contract_Attached__c = false;            
update co;        
}
}
}
Hello all, 

I have created a formula checkbox field, BG_CHBX_06_VALUE__c, and is checked when the value in the referenced field is greater than 75%. 

Is it possible to for it to render a checkmark or the word, YES instead of checking a box? If possible, how can I modify my existing formulat to do so? 

Thanks!

 
IF(
BG_CHBX_06__c > 0.75,True,False
)

 

Hi,

We have set up an approval process called Renew.  This approval process was created via the standard process (adding email alerts, approval/rejection field updates, etc). When we create an offer record the approval process doesn't start - the user must press submit for approval.  Can you create an apex trigger to initiate an approval process when a record has been created?
So in a way we would be pressing the submit for approval for the user automatically.
Can the trigger call on the ID of the approval process to initiate it if certain requirements are met?

Hello,  I am trying to create a validation rule, so that an Opportunity cannot change to a certain Stage Value, once the Opportunity Created date is greater than 30 days.
The Stage Value  is "No Opportunity"

Here is the validation that I have created and It is not working:
AND(ISPICKVAL(StageName, "No Opportunity"), 
(DATEVALUE(CreatedDate) > TODAY() + 30))

If someone can help please.
Hi,

I'm a very beginner developer and I really need some help and ideas here on how to write an apex trigger that will change the opportunity stage from stage A to stage B 90 days from the time the opportunity was put into stage A if the opportunity stage has not already been changed.  I know I'm asking a lot here, but help would greatly be appreciated.  I'm looking for general ideas on how to do it as well as some help with the code.  

I don't believe this can be done with process builder or any other point and click features, right?
I have the following drop down, and I want to send the value of the selected file to my controller .. so if the user selects parent account1 my controller should get that value or if they select parent account2 samething 
<label>Select the Region</label>
                </td>
                <td class="data2Col" style="border-bottom:0px;">
                    <select id="sandler" class="sandler" value="{!regionAccount}">
            <option value=""></option>
            <option value='ParentAccount1'>asdf--zz</option>
            <option value='ParentAccount2'>ggggg</option>
        
        </select>
        </td>
// Recieve the Region Value from Visual Force Page.. 
   public String regionAccount{get;set;}
    public Account regionAccountId{get;set;}
// if regional is not empty 
if (regionAccount != Null ){


      // get the value of region and find the accountId
        regionAccountId = [select Id  from Account where Name = : regionAccount];
        account.ParentId =regionAccountId.Id;
    
 
        }
        else{
        for (Contact parents : parentAccount)
        {
            System.debug('Now I get to here part 2');
            account.ParentId = parents.AccountId;
        }
    }


 
Hi everyone,

I am fairly new to apex and trigger writing but here goes...

I have a custom object called Course_Sale. Our sales team create new course sale records and then attach an invoice in pdf format. I am trying to create a trigger that will copy the id of the attachment just uploaded to a custom field called AttachmentId__c on the Course Sale object.

This attachment id can then be passed into a custom button which will send an email template with the invoice attachment automatically.

I have started the trigger but I am not confident in writing it, It only needs to run on attachments relating to the course sale object and simply needs to copy the attachment id to attachmentId__c on the custom object.

Please can someone have a look at the code below and tell me where I am going wrong?
trigger AttachmentIDtoCourseSale on Attachment (after insert) {
    List course_saleList = new List();
    Set course_saleIds = new Set();
    for (Attachment att : trigger.New){
        if(att.ParentId.getSobjectType() == course_sale.SobjectType){
            course_saleIds.add(att.ParentId);
        }
    }
    course_saleList = [select id, from course_sale where id in : course_saleIds];
    if(course_saleList!=null && course_saleList.size()>0{
        course_sale.AttachmentId__c = "att.Id";
    }
       update course_saleList;
}

Thank you for your help,

Kind regards
Joe
I have a uploaded one csv file in folder called(New Data) in documents in salesforce. Now I want to read the contents of that csv file using apex code so that I can perform some logic and insert the data in salesforce standard object(user).

Anyone please help me in this.

Thanks in advance.
Hi All,

I am trying give a link one VF Page to another VF Page.

 login = [select ID, Name, User_Name__c, Password__c from Registration__c Where User_Name__c=:userName and Password__c=:password];
        if(!login.isEmpty()) {
            Pagereference pr = new PageReference('/apex/timesheet'+login[0].id);  // here Timesheet is another visualforce page
            pr.setReDirect(true);
            return pr;
        }

Error : page timesheeta0928000005arw8aaa does not exist

Thanks in advance
Thulasi.

 
Hi ,

I have come across some trouble with my code. I need to pass some list of values to VF page from My Class. My code is below.
In this, I am marking some latitude + longitude  on the google Map.  locations is coming from the Apex Class.
Along with location ,  I need to pull contacts details +mailing Address to show them in the small window in map. I know, the expression  !contacts.Name , is wrong. How to correct my code. Pls advise.

PAGE CODE
<apex:pageBlockSection rendered="{!resultsAvailable}" title="Locations">
            <apex:map width="600px" height="400px">
                <apex:repeat value="{!locations}" var="pos">
                    <apex:mapMarker position="{!pos}">
                        <!-- Add info window with contact details -->
                        <apex:mapInfoWindow >
                        <apex:outputPanel layout="block" style="font-weight: bold;">
                            <apex:outputText>{!contacts.Name }</apex:outputText>
                        </apex:outputPanel>
                      </apex:mapInfoWindow>
                    </apex:mapMarker>
                </apex:repeat>

            </apex:map>
        </apex:pageBlockSection>

APEX CLASS CODE

 String queryString =            'SELECT Id, Name, MailingStreet, MailingCity, MailingState, Phone, Location__longitude__s, Location__latitude__s ' +            'FROM Contact ' +            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') < 20 ' +            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') ' +            'LIMIT 10';         System.Debug('>>>> the value of queryString is ' + queryString);
        // Run the query         
List <Contact> contacts = database.query(queryString);         
if(contacts.size() > 0 ) {             
// Convert to locations that can be mapped             
locations = new List<Map<String,Double>>();       
      for (Contact con : contacts) {                 
locations.add( new Map<String,Double>{                         
'latitude' => con.Location__latitude__s,                          
'longitude' => con.Location__longitude__s                     
}                 
);             
}         
}         
else {             
System.debug('No results. Query: ' + queryString);         
}

Thanks much in Advance.
Reshmi
Hi All,
     I want to edit the "TYPE" Field in account object.Type is having picklist (prospect,customer-direct etc...) i need to edit these values.
I used navigation set up->customise->accounts->fields
 But i cant edit the picklist values.
can anyone tell me is it possible to change the picklist or i have to add a custome field for the same??
Hi,
I have created an object. Object Name: Text
Fieds:
1. Text Name(Standard field)
2. values (picklist field: values: 1, 2, 3)
3. Text 1 (Text field)
4. Text 2 (Text field)
5. Text 3 (Text field)

Now, I need a vf page. If I select picklist value as '1', then 'Text 1 ' field should be marked as required. If I select value '2', then 'Text 2 ' should be marked as required(red). Here we have to use reRender attribute and fields should be marked as required before saving.


<apex:page standardController="Text__c">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="thePageBlockSection">
<apex:inputField value="{!Text__c.Name}"/>
<apex:inputField value="{!Text__c.Text_values__c}" /> 
<apex:inputField  value="{!Text__c.Text_1__c}" required="{!if(Text__c.Text_values__c== '1'), true, false}"/>
<apex:inputField  value="{!Text__c.Text_2__c}" required="{!if(Text__c.Text_values__c== '2'), true, false}"/> 
<apex:inputField  value="{!Text__c.Text_3__c}" required="{!if(Text__c.Text_values__c== '3'), true, false}"/> 

</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Thank You.
Hi,

I have Vf page which is having 10 records when i selected one record which is having check box than it should be enable the  button  than im going to share selected record with some user ( for sharing i can use apex sharing, let me know), let me know how to do this.

<apex:page Controller="Democlass" extensions="">
<apex:form>
<apex:inputCheckbox id="isCheckBox" style="opacity:{!w2.isPartOrderabilityStatusCode};" value="{!w2.isCheckBox}" >
<apex:actionSupport event="onclick" action="{!checkBoxStaus}" reRender="pb2"/>
</apex:inputCheckBox>
<apex:commandButton value="Add Selected"   rendered="{!(if(isButtonValid==true, true, false))}" action="{!selectRecords}" id="sparebtn" reRender="frm">
<apex:actionSupport event="onclick" rerender="resultsBlock" status="statusSaveTrip"/>
</apex:commandButton>
</apex:form>
</apex:page>

Thanks
Vijay S
 
Hi,
     How to pass the RECORDS from  ONE PAGE to ANOTHER PAGE.please tell me as early as possible.



                                    THANKS&REGARDS
                                    RANGA
 
Hello,
          I have to display the name of the object on a visualforce page. I am actually using a custom label to display the name of the standard object. But, this name of the standard object must be displayed in English and French as well, may I know if it is possible to display the name of the object through the use of Translation? Or is there any other way other than If..Else, constructs.

I thank you.

Kind Regards,
Vijay.
Hai guys ,
I write the simple trigger.Then i want to write a test class but i didnot know how to write the test class for the trigger.
please help me any one.
here is my code
----------------------------------------------------------------
trigger Accountinsert on Account (before insert) 
{
    for(Account a:trigger.new)
    {
        list<Account> myacc = [select id,name from Account where name=:a.name];
        if(myacc.size()>0)
        {
            a.name.addError('Already this name is exist');
        }
        
    }

}
Hello,

I want to see a report of
- Login history, top users
- Applications used on highly basis
  • August 05, 2015
  • Like
  • 0
Hi, 

I am trying to display a summary table using apex:repeat. However, I am not getting the query right. Any help is appreciated. Below is my code.

Object: Time_Table__c  
Fields:  Class__c  --- lookup
             Time__c   --- lookup
             Day__c    --- picklist
             faculty_name__c  --- lookup
 
VF Page:
<apex:page controller="facultydetails_con" sidebar="false" >
<apex:form >
<center>
 <br></br><br></br>
  <b>Select Faculty </b>
  <apex:inputfield value="{!faculty.Faculty_Name__c}"/><br></br><br></br>
  <apex:commandButton value="Submit" action="{!submit}"/>  
  <apex:pageBlock >
   <apex:pageblockSection >
    <apex:repeat value="{!fd}" var="item">
     <apex:outputText value="{!item.Class__c}" />
    </apex:repeat>
   </apex:pageblockSection>
  </apex:pageBlock>
</center> 
</apex:form> 
</apex:page>

Controller:
 
public class facultydetails_con {

   public time_table__c faculty {get; set;}
   public list<time_table__c> fd {get; set;}
   
   public facultydetails_con()
   {
     list<time_table__c> fd = new list<time_table__c>();
   }
   public pagereference submit()
   {
    fd = [select class__c, day__c, faculty_name__c from time_table__c where faculty_name__c = :faculty.faculty_name__c];
    return null;
   }
}

Thank you,
Satya
Hi all, 

I have created one visualforce page. In that There is a picklist component with many values inside.
Now whenever i run that visualforce page on google chrome(Version 32.0.1700.76 m) at that time i
can't able to pull down the scroll bar using mouse first click. can you please help me over this?

I want to create custom functionality similar to Subscription and Vote for content standard salesforce functionality using apex coding

Hi all, 

I have created one visualforce page. In that There is a picklist component with many values inside.
Now whenever i run that visualforce page on google chrome(Version 32.0.1700.76 m) at that time i
can't able to pull down the scroll bar using mouse first click. can you please help me over this?

I do have a page with /apex/AccountPrioritySort?id={!Account_Plan__c.Id}&type=AP. Please find my code as below

Visual Force Page

<apex:page standardController="Account_Plan__c" extensions="accountprioritysort1" tabStyle="Account" id="thePage">
    <apex:form id="theForm" >
        <apex:pageBlock title="Editing Top 5 Account Priorities" mode="edit">
            <apex:messages />
                <apex:pageBlockButtons location="top">
                    <apex:commandButton value="Update Sorted Account Priorities" action="{!SaveAction}"/>
                    <apex:commandButton value="Cancel" action="{!Cancel}"/>
                </apex:pageBlockButtons>
            
                <apex:pageBlockTable value="{!actPList}" var="item">
                    <apex:column value="{!item.Account_Priorities__c}"/>
                    <apex:column headervalue="# (Top 5 Priorities)">
                        <apex:inputField value="{!item.Field1__c}"/>
                    </apex:column>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

APEX Class

public with sharing class accountprioritysort1 {    

    public ApexPages.StandardController stdController {get; set;}
    public Account_Plan__c AccPri { get; set; }
    public list<Company_Priorities__c> actPList  { get; set; }
    public integer aField { get; set;}
    
    public accountprioritysort1 (ApexPages.StandardController stdController){
        System.debug('Is it in the Constructor');
        this.stdController = stdController;
        this.AccPri = (Account_Plan__c)this.stdController.getRecord();
        actPList = [select Field1__c,Account_Priorities__c from Company_Priorities__c where Account_Plan__c =: AccPri.Id
                ORDER BY Field1__c ASC ];
    }
    
    public PageReference SaveAction(){
        update actPList;
        PageReference page = new PageReference('/apex/AccountPrioritySort?id='+AccPri.id);
        page.setRedirect(true);
        return page;
    }
    
    public PageReference CancelAction(){
            PageReference page = new PageReference('/apex/AccountPrioritySort?id='+AccPri.id);
            page.setRedirect(true);
            return page;
        }
    }


/apex/AccountPrioritySort?id={!Account_Plan__c.Id}&type=AP

Now i want to pass this 


1. The value (which is as type=AP) from the Parameter Type in the Apex Controller

2. How can render by using the type variable to between Account Priorities and Risk in the VF page and Controller. This type should be used to decide what data needs to be saved i.e. should the risk code execute or Account priorities code execute.
 

Can any one help on this code.

 

Hi All,

I have written test class for one of my VF Page & covered upto 73% but i failed to cover morethan 75%. Here is my VF Page & Apex Classes
 
<apex:page controller="DataTableEditRemoveController">
<apex:form id="form" >
<apex:pageBlock title="Accounts">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!accs}" var="acc">
<apex:column >
<apex:outputLink title="" value="/{!acc.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
<apex:commandLink action="{!DeleteAccount}" onclick="return confirm('Are you sure?')" value="Del">
    <apex:param value="{!acc.Id}" name="accountid" assignTo="{!SelectedAccountId}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.BillingStreet}"/>
<apex:column value="{!acc.BillingCity}"/>
<apex:column value="{!acc.BillingPostalCode}"/>
<apex:column value="{!acc.BillingCountry}"/>    
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>      
</apex:page>

Here is Controller
 
public class DataTableEditRemoveController {

    public String getRow() {
        return null;
    }

public List<Account> accs { get; set; }

//used to get a hold of the account record selected for deletion
public string SelectedAccountId { get; set; }

public DataTableEditRemoveController() {
//load account data into our DataTable
LoadData();
}

@Testvisible
private void LoadData() {
system.debug('Enter In the Constructor*****');
accs = [Select id, name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account limit 20];
}

public PageReference DeleteAccount()
{
System.debug('SelectedAccountId: '+SelectedAccountId);
accs = [select id,name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account where id=:SelectedAccountId];
System.debug('SIZEOFACC: '+accs.size());
if(accs.size()>0 && accs[0]!= null){
delete accs;
System.debug('DELSIZEOFACC: '+accs.size());
SelectedAccountId = null;

}

//refresh the data
LoadData();
    return null;
}


}

Here is 29 th line is not covered ...............


Here is My Test Class
 
@istest
public class DataTableEditRemoveController_Test{
static testmethod void Method_Test(){

    Account acc = new Account();
    acc.name = 'Test';
    acc.Fax = '555555';
    acc.BillingStreet = 'Korlagunta';
    acc.BillingCity = 'Tirupati';
    acc.BillingPostalCode = 'Tiruapti';
    acc.BillingCountry = 'INDIA';
    insert acc;
    
   // Delete acc;
  system.debug('ACCID******'+acc.id);  
    Test.starttest();
    pagereference pageref = page.Edit_Del_Hyperlink_Fun;
    Test.SetCurrentPageReference(pageref);
    pageref.getParameters().put('SelectedAccountId', String.valueOf(acc.Id));
  string STRID = apexpages.currentpage().getparameters().put('SelectedAccountId',acc.id);
   System.assertEquals(STRID, acc.Id, 'ID\'s should match');
   system.debug('PARAMID******'+apexpages.currentpage().getparameters().put('SelectedAccountId',acc.id)); 
    DataTableEditRemoveController contrll = new DataTableEditRemoveController ();
    contrll.LoadData();
    contrll.DeleteAccount();
    list<Account> a =[select id,name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account where id=:STRID];
    system.debug('LSTACCID******'+a.size());
    Delete a;
    Test.stoptest();

I have checked the debugs, SelectedAccountId its coming in test class but not in main controller..........I am struck here .......Please give me your valuable suggestions.......

Adv Thnx
VSK98
  • August 24, 2016
  • Like
  • 0
how to write the testclass to below class , knidly help me .
public class CurrentRecordIdDemoController{
public String currentRecordId {get;set;}
public String parameterValue {get;set;}
public Account acc{get;set;}

    public CurrentRecordIdDemoController(ApexPages.StandardController controller) {
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        acc = [select id ,name, AccountNumber, Type, Industry from Account where id =: currentRecordId ];
        parameterValue = ApexPages.CurrentPage().getparameters().get('nameParam');
    }
}

Cheers!
chanti
Visualforce Page 1: 
<apex:page standardController="Account" recordSetVar="accountList"
           extensions="DynamicCustomizableListHandler">
    <br/>
    <apex:form >

    <!-- View selection widget, uses StandardController methods -->
    <apex:pageBlock >
        <apex:outputLabel value="Select Account Views: " for="viewsList"/>
        <apex:selectList id="viewsList" size="1" value="{!filterId}">
            <apex:actionSupport event="onchange" rerender="theTable"/>
            <apex:selectOptions value="{!listViewOptions}"/>
        </apex:selectList>
    </apex:pageblock>

    <!-- This list of accounts has customizable columns -->
    <apex:pageBlock title="Accounts" mode="edit">
        <apex:pageMessages />
        <apex:panelGroup id="theTable">
            <apex:pageBlockTable value="{!accountList}" var="acct">
                <apex:column value="{!acct.Name}"/>
                <!-- This is the dynamic reference part -->
                <apex:repeat value="{!displayFields}" var="f">
                    <apex:column value="{!acct[f]}"/>
                </apex:repeat>
            </apex:pageBlockTable>
        </apex:panelGroup>
    </apex:pageBlock>

    <br/>
    <apex:commandButton value="Customize List" action="{!customize}"/>

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

Apex Class:
public class DynamicCustomizableListHandler {

    // Resources we need to hold on to across requests
    private ApexPages.StandardSetController controllerr;
    private PageReference savePage;

    // This is the state for the list "app"
    private Set<String> unSelectedNames = new Set<String>();
    private Set<String> selectedNames = new Set<String>();
    private Set<String> inaccessibleNames = new Set<String>();

    public DynamicCustomizableListHandler(ApexPages.StandardSetController controller) {
        this.controllerr = controller;
        loadFieldsWithVisibility();
    }

    // Initial load of the fields lists
    private void loadFieldsWithVisibility() {
        Map<String, Schema.SobjectField> fields = 
            Schema.SobjectType.Account.fields.getMap();
        for (String s : fields.keySet()) {
            if (s != 'Name') {  // name is always displayed 
                unSelectedNames.add(s);
            }
            if (!fields.get(s).getDescribe().isAccessible()) {
                inaccessibleNames.add(s);
            }
        }
    }

    // The fields to show in the list
    // This is what we generate the dynamic references from
    public List<String> getDisplayFields() { 
        List<String> displayFields = new List<String>(selectedNames);
        displayFields.sort();
        return displayFields;
    }
    
    // Nav: go to customize screen
    public PageReference customize() {
        savePage = ApexPages.currentPage();
        return Page.CustomizeDynamicList;
    }

    // Nav: return to list view
    public PageReference show() {
        // This forces a re-query with the new fields list
        controllerr.reset();
        controllerr.addFields(getDisplayFields());
        return savePage; 
    }

    // Create the select options for the two select lists on the page
    public List<SelectOption> getSelectedOptions() { 
        return selectOptionsFromSet(selectedNames);
    }
    public List<SelectOption> getUnSelectedOptions() { 
        return selectOptionsFromSet(unSelectedNames);
    }
    
    private List<SelectOption> selectOptionsFromSet(Set<String> opts) {
        List<String> optionsList = new List<String>(opts);
        optionsList.sort();
        List<SelectOption> options = new List<SelectOption>();
        for (String s : optionsList) {
            options.add(new 
                SelectOption(s, decorateName(s), inaccessibleNames.contains(s)));
        }
        return options;
    }

    private String decorateName(String s) {
        return inaccessibleNames.contains(s) ? '*' + s : s;
    }

    // These properties receive the customization form postback data
    // Each time the [<<] or [>>] button is clicked, these get the contents
    // of the respective selection lists from the form
    public transient List<String> selected   { get; set; }
    public transient List<String> unselected { get; set; }

    // Handle the actual button clicks. Page gets updated via a
    // rerender on the form
    public void doAdd() {
        moveFields(selected, selectedNames, unSelectedNames);
    }
    public void doRemove() {
        moveFields(unselected, unSelectedNames, selectedNames);
    }
    
    private void moveFields(List<String> items, 
            Set<String> moveTo, Set<String> removeFrom) {
        for (String s: items) {
            if( ! inaccessibleNames.contains(s)) {
                moveTo.add(s);
                removeFrom.remove(s);
            }
        }
    }
}

Visualforce Page 2: 
<apex:page standardController="Account" recordSetVar="ignored"
           extensions="DynamicCustomizableListHandler">
    <br/>
    <apex:form >

    <apex:pageBlock title="Select Fields to Display" id="selectionBlock">
        <apex:pageMessages />
        <apex:panelGrid columns="3">
            <apex:selectList id="unselected_list" required="false" 
                value="{!selected}" multiselect="true" size="20" style="width:250px">
                <apex:selectOptions value="{!unSelectedOptions}"/>
            </apex:selectList>
            <apex:panelGroup >
                <apex:commandButton value=">>" 
                    action="{!doAdd}" rerender="selectionBlock"/>
                <br/>
                <apex:commandButton value="<<" 
                    action="{!doRemove}" rerender="selectionBlock"/>
            </apex:panelGroup>
            <apex:selectList id="selected_list" required="false" 
                value="{!unselected}" multiselect="true" size="20" style="width:250px">
                <apex:selectOptions value="{!selectedOptions}"/>
            </apex:selectList>
        </apex:panelGrid>
        <em>Note: Fields marked <strong>*</strong> are inaccessible to your account</em>
    </apex:pageBlock>
    
    <br/>
    <apex:commandButton value="Show These Fields" action="{!show}"/>

    </apex:form>

</apex:page>

------------------------- The above code is working fine and the below code is not woking as expected, both are same code ----------------------
Anyone can expalin what's the mistake. And i'm getting the error as "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field"

Visualforce Page 
<apex:page standardController="Account" recordSetVar="accountList" extensions="DynamicCustomizableListHandler"> <br />
  
  <apex:form >
      <!-- View selection widget, uses StandaredController method  -->
      <apex:pageBlock >
          <apex:outputLabel value="Select Account Views: " for="viewList"/>
          <apex:selectList id="viewList" size="1" value="{!filterId}">
              <apex:actionSupport event="onchange" reRender="theTable"/>
              <apex:selectOptions value="{!listViewOptions}"/>
          </apex:selectList>
      </apex:pageBlock>
      
      <!-- This list of accounts has customizable coloumns -->
      <apex:pageBlock title="Accounts" mode="edit">
          <apex:pageMessages />
          <apex:panelGroup id="theTable">
              <apex:pageBlockTable value="{!accountList}" var="acct">
                  <apex:column value="{!acct.Name}"/>
                  <!-- This is dynamic reference part -->
                  <apex:repeat value="{!displayFields}" var="f">
                      <apex:column value="{!acct[f]}"/>
                  </apex:repeat>
              </apex:pageBlockTable>
          </apex:panelGroup>
      </apex:pageBlock>
      <br />
      <apex:commandButton value="Customize List" action="{!customize}"/>
  </apex:form>
</apex:page>

Apex Class
public class DynamicCustomizableListHandler {

    // Resources we need to hold on to across requests
    private ApexPages.StandardSetController controllerr;
    private PageReference savePage;
    
    // This is the stage for the list "app"
    private Set<String> unSelectedNames = new Set<String>();
    private Set<String> selectedNames = new Set<String>();
    private Set<String> inaccessibleNames = new Set<String>();
    
    public DynamicCustomizableListHandler(ApexPages.StandardSetController controller) {
        this.controllerr = controller;
        loadFieldsWithVisibility();
    }
    
    // Initial load of the fields list
    private void loadFieldsWithVisibility() {
        Map<String, Schema.SobjectField> fields = Schema.SobjectType.Account.fields.getMap();
        for(String s : fields.keySet()) {
            if(s != 'Name') { // name is always display
                unSelectedNames.add(s);
            }
            if(!fields.get(s).getDescribe().isAccessible()) {
                inaccessibleNames.add(s);
            }
        }
    }
    
    // The fields to show in the list
    // This is what we generate the dynamic reference from
    public List<String> getDisplayFields() {
        List<String> displayFields = new List<String>(selectedNames);
        displayFields.sort();
        return displayFields;
    }
    
    // Nav: go to customize screen
    public PageReference customize() {
        savePage = ApexPages.currentPage();
        return Page.CustomizeDynamicList;
    }
    
    // Nav: return to list view
    public PageReference show() {
        // This force a re-query with the new field list
        controllerr.reset();
        controllerr.addFields(getDisplayFields());
        return savePage;
    }
    
    // Create the select options for the two select lists on the page
    public List<SelectOption> getSelectedOptions() {
        return selectOptionsFromSet(selectedNames);
    }
    
    public List<SelectOption> getUnSelectedOptions() {
        return selectOptionsFromSet(unSelectedNames);
    }
    
    private List<SelectOption> selectOptionsFromSet(Set<String> opts) {
        List<String> optionsList = new List<String>(opts);
        optionsList.sort();
        List<SelectOption> options = new List<SelectOption>();
        for(String s : optionsList) {
            options.add(new SelectOption(s, decorateName(s), inaccessibleNames.contains(s)));
        }
        return options;
    }
    
    private String decorateName(String s) {
        return inaccessibleNames.contains(s) ? '*' + s : s;
    }
    
    // These properties receive the customization from postback data
    // Each time the [<<] or [>>] button are clicked, these get the contents of the respective selection lists from the form
    public transient List<String> selected { get; set; }
    public transient List<String> unselected { get; set; }
    
    // Handle the actual button clicks, Page gets updated via a rerender a form
    public void doAdd() {
        moveFields(selected, selectedNames, unSelectedNames);
    }
    
    public void doRemove() {
        moveFields(unselected, unSelectedNames, selectedNames);
    }
    
    private void moveFields(List<String> items, Set<String> moveTo, Set<String> removeFrom) {
        for(String s : items) {
            if(! inaccessibleNames.contains(s)) {
                moveTo.add(s);
                removeFrom.remove(s);
            }   
        }
    }
}

Visualforce Page
<apex:page standardController="Account" recordSetVar="ignored" extensions="DynamicCustomizableListHandler">
  <br />
  <apex:form >
      <apex:pageBlock title="Select Fields To Display" id="selectionBlock">
          <apex:pageMessages />
          <apex:panelGrid columns="3">
              <apex:selectList id="unselected_list" required="false" value="{!selected}" multiselect="true" size="20" style="width:250px">
                  <apex:selectOptions value="{!unSelectedOptions}"/>
              </apex:selectList>
              <apex:panelGroup >
                  <apex:commandButton value=">>" action="{!doAdd}" rerender="selectionBlock"/>
                  <br />
                  <apex:commandButton value="<<" action="{!doRemove}" reRender="selectionBlock"/>
              </apex:panelGroup>
              <apex:selectList id="selected_list" required="false" value="{!unselected}" multiselect="true" size="20" style="width:250px">
                  <apex:selectOptions value="{!SelectedOptions}"/>
              </apex:selectList>
          </apex:panelGrid>
          <em>Note: Fields marked <strong>*</strong> are inaccessible to your account</em>
      </apex:pageBlock>
      <br />
      <apex:commandButton value="Show These Fields" action="{!show}"/>
  </apex:form>
</apex:page>

 
I'm not sure if I'm going insane or not, but started about a month ago and now on this challenge and I cannot find where they are saying to go to... I'm thinking I'm not in Salesforce Classic view, is there a way to change to that?  


This is my home page.


User-added image
trigger deleteoppafter on Opportunity (after delete) {
if(trigger.isafter && trigger.isdelete){
    list<task> t=new list<task>();
    t=[select whatid from task];
         for(opportunity opp1:trigger.old){
             for(task tt:t){
             if(opp1.id==tt.whatid){
                 t.add(tt);
                 delete t;
                
             }
                 
             }
         }
}
}

i am getting the following error:
Illegeal assignment from list to list.

Please help..!!
Hi Experts,
Many times am getting this error on visualforce page and test calss ,When we will getting list has no errors ?what kind of situation ? how to we can resolved, kindly do the needful


Thank you,
Chanti
Hi All,

I am new Salesforce Lightning experience. I am trying to call an external JavaScript by loading it as a Static resource and calling it in my Lightning application using the following syntax but I am unable to get it work.

<aura:application >
       <ltng:require scripts="{!$Resource.SDFCTestJS}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
</aura:application>

Please suggest how can I get it work.

P.S : I read a solution that we can load Javascript by creating a Helper class and call it from our Component. Can anyone suggest a way so that I don't need to create helper everytime I call a component as I am going to have many; a way that I can include the JS directly from the above.

Thanks in advance.

Warm Regards,
Shubham
SFDC
 
Hello

I opened a ticket with support on this and they are stumped, they sent me here. Seems like a simple question. I have a picklist in accounts. What I want to do is when an user is opening a case for that account, I want the value of the picklist to appear in the new case form. It will show the sensitivity of the customer and the support team will know right away how to address the problems. I tried to use formula fields but they do not support picklist values. Any thoughts would be appreciated.
 
HI All.

I'm only getting 70% coverage and I'm not sure how to cover the variables.

These are the lines not covered.

     Line 16 qty = o.Total_Roundtables__c;
            17 orderId = o.Id;
            18 eventId = o.Event__c;
            19 eventName = o.Event__r.Name;

            31 r=new Roundtables__c (Order__c=orderId, Status__c ='Unallocated', Event__c = eventId);
            32 rList.add(r);

Can anyone help?

Here's my trigger
trigger CreateRoundtables on Order (after insert, after update) {

    public double qty;
    public id orderId;
    public id eventId;
    public string eventName;


    
    Id orderRecType = Schema.SObjectType.Order.getRecordTypeInfosByName().get('Order').getRecordTypeId(); 
    
    List <OrderItem> oi = [Select id, Roundtables__c from OrderItem where Roundtables__c>0 ];
    system.debug(oi);
    for(order o:trigger.new){
        if(o.BU__c=='MTB' && o.Total_Roundtables__c >= 1 && O.Attendee_Type__c =='Sponsor' && o.Status == 'Approved'){
         	qty = o.Total_Roundtables__c;
            orderId = o.Id;
            eventId = o.Event__c;
            eventName = o.Event__r.Name;
            system.debug('Order ID '+ orderId);
            system.debug('Event Name '+ eventName);
        }
    }
    
    List <Roundtables__c> curRT = [Select id, Order__c from Roundtables__c where Order__c =: orderId];
    List <Roundtables__c> rList = new list <Roundtables__c>();
    Roundtables__c r;
    
    if(curRT.size() <> qty){
    for(Integer m=1;m<=qty;m++){
        r=new Roundtables__c (Order__c=orderId, Status__c ='Unallocated', Event__c = eventId);
        rList.add(r);
    }
    }
	insert rList;
}

Here's the test class
@istest (SeeAllData = true) 
public class CreateRoundTableTEST {
	
    static testMethod void TESTcreateRoundTables(){
        
        //Insert Test Accounts
		Account acc = new Account();
        acc.Type='Other';
        acc.name='test ';
        acc.NumberOfEmployees=10;
        acc.BillingStreet='BillingStreet'; 
        acc.BillingCity = 'BillingCity';
        acc.BillingState = 'BillingState';
        acc.BillingCountry = 'BillingCountry'; 
        acc.BillingPostalCode = 'BillingPostalCode';
        acc.NumberOfEmployees = 50; 
        insert acc;
        
        Account acc2 = new Account();
        acc2.Type='AX Company';
        acc2.name='test 1';
        acc2.BillingStreet='BillingStreet1'; 
        acc2.BillingCity = 'BillingCity';
        acc2.BillingState = 'BillingState';
        acc2.BillingCountry = 'BillingCountry'; 
        acc2.BillingPostalCode = 'BillingPostalCode';
        acc2.NumberOfEmployees = 50; 
        insert acc2;
   
        Project__c testProject = new Project__c();
        testProject.name = 'test Project';
        testProject.Project_Code__c = 'SUM123';
        insert testProject;
   
        //Insert Test Event
        Event__c testEvent = new Event__c();
        testEvent.name='testEvent';
        testEvent.Start_Date__c =system.today();
        testEvent.End_Date__c=system.today().addDays(2);
        testEvent.name='testEvent';
        testEvent.AX_Company__c = acc2.Id;
        testEvent.project__c = testProject.Id;
        Insert testEvent;
        
        //Insert Test Contacts
        Contact con = new contact();
        con.lastname='test';
        con.accountid=acc.id;
        con.FirstName = 'FirstName';
        con.MailingStreet = 'MailingStreet'; 
        con.MailingCity = 'MailingCity';
        con.MailingState = 'MailingState';
        con.MailingCountry = 'MailingCountry';
        con.MailingPostalCode = 'MailingPostalCode';  
        con.IsOpen4All__c=false;      
        insert con;
        
        Contact con2 = new contact();
        con2.lastname='test';
        con2.accountid=acc.id;
        con2.FirstName = 'FirstName';
        con2.MailingStreet = 'MailingStreet'; 
        con2.MailingCity = 'MailingCity';
        con2.MailingState = 'MailingState';
        con2.MailingCountry = 'MailingCountry';
        con2.MailingPostalCode = 'MailingPostalCode';  
        con2.IsOpen4All__c=false;      
        insert con2;
        
        //insert Test Campaign
        Campaign testCampaign1       = new Campaign();
        testCampaign1.name           = 'TestCampaign';
        testCampaign1.Member_Type__c = 'Delegate';
        testCampaign1.Type = 'Call List';
        insert testCampaign1;

       test.startTest();
         Id standardPriceBookId = Test.getStandardPricebookId();
        order o1 = new order();
        o1.accountid=acc.id;
        o1.EffectiveDate= system.today();
        o1.Attendee_Type__c='Sponsor';
        o1.pricebook2id=standardPriceBookId;
        o1.Primary_Campaign_Source__c=testCampaign1.id;
        o1.Price_List__c='test';
        o1.Status='Draft';
        o1.Sold_On_Date__c= system.today();
        o1.Main_POC__c=con2.id;
        o1.Event__c = testEvent.id;
        insert o1;
        
         Id dealOrderId = [Select Id, DeveloperName FROM RecordType where SobjectType = 'Order' and DeveloperName = 'Deal' limit 1].Id;

        o1.recordtypeid=dealOrderId;
        update o1;

        Product2 pd = new Product2(Name='MTB Prod',isActive=true, Number_of_Roundtables__c =2);
        pd.IsActive = true;
        insert pd;
        
        //Id standardPriceBookId = Test.getStandardPricebookId();
        
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=pd.Id, UnitPrice=99, isActive=true);
        insert pbe;
        
        OrderItem ordPd = new OrderItem(PriceBookEntryId=pbe.Id, OrderId=o1.Id, Quantity=1, UnitPrice=99);
        insert ordPd;
        o1.status='Approved';
        update o1;
        
        
       test.stopTest();
    }
}


 
public class contactpopulate {
    public void onbeforeinsert(list<contact>TriggerNew)
        {
          onduplicateEmailandphone(TriggerNew);
        }
   void onduplicateEmailandphone(list<Contact>TriggerNew)
   {
        set<string> Set1= New set<string>();
        set<string> Set2= New set<string>();
    
        For(contact con:TriggerNew)
        {
            if(con.Phone!=null)
            {
                Set1.add(con.Phone);
            }
                if(con.Email!=null)
                {
                    Set2.add(con.Email);
                }
            }
        map<id,contact> map1= New map<id,contact>();
        map<id,contact> map2= New map<id,contact>();
        for(contact obj:[select id,name,Phone,Email from contact where Phone in: Set1 OR Email in: Set2])
        {
            map1.put(obj.phone,obj);
            map2.put(obj.Email,obj);
            
        }
    for(contact con:TriggerNew)
    {
        if(con.Phone !=null && map1.get(con.Phone)!=null)
           {
               con.adderror('duplicate phone found please enter new phone');
               
           }
        if(con.Email!=null&& map2.get(con.Email)!=null)
           {
               con.adderror('duplicate email found please enter new email');
           }
    }
    }
}
User-added image

I'd like to write a trigger that will modify the opportunity when an approval is approved. The snapshot shows an approval for discounts. When the discount is too high for a particular opportunity it is flagged for approval. Once the approver approves the opportunity I'd like a few fields to be autofilled. What object do I need to attach this trigger to, if this is indded possible? I would assume that some object exists for the approval. 

​In the Eclipse Force.com IDE I don't see any object for approval when writing new triggers. Your thoughts/assistance are much appreciated!
 
I currently have a trigger that checks a box when an attachment is added to a custom object called "Contracts__c". I would like to expand this Trigger to only check the box if the actual attatched document includes certain keywords. Is this possible? Here is my current code:

trigger CountAttachment on Attachment (before insert, before delete)
{
if(trigger.isinsert){
List<Contracts__c> co = [select id from Contracts__c where id =: Trigger.New[0].ParentId];
If(co.size()>0)        
{            
co[0].Contract_Attached__c = True;            
update co;        
}
}


if(trigger.isdelete){

List<Contracts__c> co = [select id from Contracts__c where id =: Trigger.old[0].ParentId];        
If(co.size()>0)        
{            
co[0].Contract_Attached__c = false;            
update co;        
}
}
}
Hi
Can you help me  how to write custom  Form validation using  "setCustomValidity" (Jquery or Javascript).
for Examle if the field value(Name) is empty when click submit button it should be  disply on Name field  " please enter the Name " ..

Thanks,
Hi,

This is the first Apex trigger I've deployed into production. It creates a renewal opportunity when an original opportunity gets set to closed won. I'm looking for your feedback as to whether it is properly bulkified. When using the data loader I've run into some errors that suggests it's not. Here's a copy of the trigger: 
 
trigger CreateRenewalOppty on Opportunity (before update) {
    
    List<Opportunity> renewals = new List<Opportunity>();
    
    for (Opportunity opp : trigger.new) {
     Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
        Boolean oldOppIsWon = oldOpp.StageName.equals('Closed Won');
        Boolean newOppIsWon = opp.StageName.equals('Closed Won');
        Date myDate = System.today();
        String acctName = [SELECT Account.Name
                          FROM Opportunity
                          WHERE ID IN: trigger.new
                          Limit 1].Account.Name;
        
        
                
        
        if (!oldOppIsWon &&
           newOppisWon &&
           helperClass.firstRun &&
           (opp.Business__c == 'Site' ||
            opp.Business__c == 'District')) {
                Opportunity renewal = new Opportunity();
                renewal.Name = acctName + ' ' + myDate.year() + '-1';
                renewal.CloseDate = opp.CloseDate + 365;
                renewal.StageName = 'Qualified Renewal';
                renewal.AccountId = opp.AccountId;
                renewal.Type = 'Renewal Business';
                renewal.Business__c = opp.Business__c;
               renewal.Term_Expiration_Date__c = opp.Term_Expiration_Date__c;
                renewal.Term_Start_Date__c = opp.Term_Start_Date__c;
                renewal.Primary_Contact_del__c = opp.Primary_Contact_del__c;
                renewal.Subscription_ID__c = opp.Subscription_ID__c;
                renewal.Amount = opp.Amount;
                renewal.Trigger_AM_Sequence__c = true;
                renewal.Notes__c = opp.Notes__c;
                renewal.Student_Username__c = opp.Student_Username__c;
                renewal.Area_of_Interest__c = opp.Area_of_Interest__c;
                renewal.Other_Area_of_Interest__c = opp.Other_Area_of_Interest__c;
                renewal.Postmortem_Notes__c = opp.Postmortem_Notes__c;
                renewal.Activation_Link__c = opp.Activation_Link__c;
                helperClass.firstRun = false;
                              
                
            renewals.add(renewal);
                
              
            }
         
    }
       System.debug('firstRun is ' + helperClass.firstRun);
            System.debug('The list contains ' + renewals.size() + ' opptys');
         try {
           insert renewals; 
         } catch (Exception e) {
           System.debug('Exception type caught ' + e.getTypeName());
         }


I followed the advice to add renewal opportunities to a list and then insert the list - so thought this meant the trigger was properly bulkified? Any other tips on how to improve this trigger would be greatly appreciated as well. Thanks!
  • July 07, 2016
  • Like
  • 0
Hello all, 

I have created a formula checkbox field, BG_CHBX_06_VALUE__c, and is checked when the value in the referenced field is greater than 75%. 

Is it possible to for it to render a checkmark or the word, YES instead of checking a box? If possible, how can I modify my existing formulat to do so? 

Thanks!

 
IF(
BG_CHBX_06__c > 0.75,True,False
)

 
Hi,
I have created an object. Object Name: Text
Fieds:
1. Text Name(Standard field)
2. values (picklist field: values: 1, 2, 3)
3. Text 1 (Text field)
4. Text 2 (Text field)
5. Text 3 (Text field)

Now, I need a vf page. If I select picklist value as '1', then 'Text 1 ' field should be marked as required. If I select value '2', then 'Text 2 ' should be marked as required(red). Here we have to use reRender attribute and fields should be marked as required before saving.


<apex:page standardController="Text__c">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="thePageBlockSection">
<apex:inputField value="{!Text__c.Name}"/>
<apex:inputField value="{!Text__c.Text_values__c}" /> 
<apex:inputField  value="{!Text__c.Text_1__c}" required="{!if(Text__c.Text_values__c== '1'), true, false}"/>
<apex:inputField  value="{!Text__c.Text_2__c}" required="{!if(Text__c.Text_values__c== '2'), true, false}"/> 
<apex:inputField  value="{!Text__c.Text_3__c}" required="{!if(Text__c.Text_values__c== '3'), true, false}"/> 

</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Thank You.

Hi

 

LIST <contact> c=[select lastname,firstname,account.name,account.industry from contact where title='New Software'];
system.debug(c.account.name);
system.debug(c.account.industry);
system.debug('the lastname is '+c.lastname);

 

 

Initial term of field expression must be a concrete SObject: LIST?Means

 

 

Thanks Ramesh

  • November 21, 2013
  • Like
  • 2