• gotherthanthou
  • NEWBIE
  • 125 Points
  • Member since 2009

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 52
    Replies

I am trying to clone checkbox values, but my code is turning all my checkbox field value to true even if they should be false. How do I solve this? Here is my code:

 

trigger OldOpportunityLink on Opportunity (before insert) {

    Set<Id> Ids = new Set<Id>();
    for (Opportunity oppo: Trigger.new){
    System.debug('**** 0 Ids id : '+oppo.id);
    
            Ids.add(oppo.Id);
     System.debug('**** 1 oppo id : '+oppo.id);
     
     }
    
    for(Opportunity unity: Trigger.new) {

       unity.Original_Opportunity__c = unity.Current_Opportunity_Id__c;
    
    List<Opportunity> o =new List <Opportunity>([select id, ps__c,Original_Opportunity__r.ps__c
        from Opportunity limit 1]);
    
        if (o[0].ps__c = true){
                unity.ps__c = true;
                }else if
            (o[0].ps__c = false){
                unity.ps__c = false;
                }
        if (o[0].ais__c = true){
                unity.ais__c = true;
                }else if
            (o[0].ais__c = false){
                unity.ais__c = false;
                }  
        if (o[0].potato__c = true){
                unity.potato__c = true;
                }else if
            (o[0].potato__c = false){
                unity.potato__c = false;
                }
        if (o[0].Farmco__c = true){
                unity.Farmco__c = true;
                }else if
            (o[0].Farmco__c = false){
                unity.Farmco__c = false;
                }                    
        if (o[0].Service_Contract__c = true){
                unity.Service_Contract__c = true;
                }else if
            (o[0].Service_Contract__c = false){
                unity.Service_Contract__c = false;
                }                    
        if (o[0].Processed_Fruit_Veg__c = true){
                unity.Processed_Fruit_Veg__c = true;
                }else if
            (o[0].Processed_Fruit_Veg__c = false){
                unity.Processed_Fruit_Veg__c = false;
                }                    
        if (o[0].Project_System_Eng__c = true){
                unity.Project_System_Eng__c = true;
                }else if
            (o[0].Project_System_Eng__c = false){
                unity.Project_System_Eng__c = false;
                }
        if (o[0].Freshline__c = true){
                unity.Freshline__c = true;
                }else if
                
            (o[0].Freshline__c = false){
                unity.Freshline__c = false;
                }                    
        if (o[0].Pharma__c = true){
                unity.Pharma__c = true;
                }else if
            (o[0].Pharma__c = false){
                unity.Pharma__c = false;
                }                    
        if (o[0].Misc_Other__c = true){
                unity.Misc_Other__c = true;
                }else if
            (o[0].Misc_Other__c = false){
                unity.Misc_Other__c = false;
                }                    
        if (o[0].ISG__c = true){
                unity.ISG__c = true;
                }else if
            (o[0].ISG__c = false){
                unity.ISG__c = false;
                }                    
        if (o[0].Spare_Parts__c = true){
                unity.Spare_Parts__c = true;
                }else if
            (o[0].Spare_Parts__c = false){
                unity.Spare_Parts__c = false;
                }                    
        if (o[0].Thermal_Systems__c = true){
                unity.Thermal_Systems__c = true;
                }else if
            (o[0].Thermal_Systems__c = false){
                unity.Thermal_Systems__c = false;
                }                    
        if (o[0].Upgrade__c = true){
                unity.Upgrade__c = true;
                }else if
            (o[0].Upgrade__c = false){
                unity.Upgrade__c = false;
                }                    
    }
}

 

 

Thanks,

ckellie

Hi there,

 

I have the following test code which updates a field in a related object (CustomObject__r).  The CustomObject is related to Opportunity and the code below runs through successfully.

 

Opportunity o = [select CustomObject__r.Market__c,StatusMessage__c from Opportunity where Id='00600000008HFNLAA5'];
           o.CustomObject__r.Market__c = 'test';
           o.StatusMessage__c = 'test update';
           
            try
            {
                Database.SaveResult srs = Database.update(o);
                if (srs.isSuccess())
                {
                     // successful
                }
            } catch (Exception e) {
                    ApexPages.addMessages(e);
            }      

 

The above code does not return an exception and also is successful based on the return value of isSuccess().  The StatusMessage__c in the main object is successfully updated, but the CustomObject__r.Market__c field does not get updated even though the update transaction as a whole is deemed successful.  Any troubleshooting ideas, or if the above update is not possible (ie. have to fetch back and update CustomObject__c directly)?

 

thanks

Hi,

 

I have started developing visualforce and apex just today noon. so please excuse me,

 

I have added a visual force page and have displaed in a custom tab. But i now want to add some functions in a apex class.

 

When i go to  Name | Setup | Develop .. there are only API, COMPONENTS, CUSTOM SETTINGS, EMAIL SERVICES, PAGES, STATIC RESOURCES, REMOTE ACCESS.

 

There is no "Apex Classes" there. please tell me whether i have to enable something somewhere?

 

Thanks and Regards,

Dinesh.N

I'm hoping someone can tell me what I'm doing wrong here.  Whenever I press the "Count Selected" button, this is what shows up in the debug log no matter how many records I have manually selected on the displayed page:

 

[20]|DEBUG|xyzzy: Num Selected 0

 

Here is the page, followed by the controller.  Obviously these are slimmed down from the actual page and controller I am working on.

 

<apex:page standardController="Account" recordSetVar="true" extensions="aaaDonNotPackageController" id="page">
    <apex:pageBlock mode="mainDetail" id="PB" >
        <apex:form id="form">
            <apex:commandButton value="Count Selected" action="{!CountSelected}" /> 
        </apex:form>            
        <apex:enhancedList id="list" type="Account" height="570" width="1200" rowsPerPage="25"  customizable="true"/>
    </apex:pageBlock>
</apex:page>

 

global with sharing class aaaDonNotPackageController 
{
    public ApexPages.StandardSetController setController;
 
    // Constructor    
    public aaaDonNotPackageController (ApexPages.StandardSetController controller)
    {
        Initialize(controller);
    }   
    
    // placed outside constructor for easier debugging    
    private void Initialize (ApexPages.StandardSetController controller)
    {
        setController = controller;
    }
    
    public void CountSelected()
    {
        List<sObject> selAccts = setController.getSelected (); 
        system.debug ('xyzzy: Num Selected ' + string.valueof(selAccts.size()));                    
    }
}

 

Not sure if this is the right forum - moderator please feel free to move.

 

I have a custom button on a list controller (enhanced) that executes javascript

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")} 

accts = {!GETRECORDIDS($ObjectType.Account)};

 

This gets me all the ID's for the accounts that the user has selected.  Is there any way to access the entire recordset - ie even ones the user has not selected?

When you check the top box on a page with Multi-Record Selection, it selects/deselects only the records currently displayed on the page.  So if there are 50 records in the view but only 25 records per page, it only affects the 25.

 

How would I go about implementing a "Select All" link or button?

I'm trying to get the owner field and ChangeOwner link onto a VF page for a custom object.  Owner field is just fine.  But I can't get ChangeOwner to work.

 

I'm trying this code:

<apex:outputLink value="{!URLFOR($Action.CustomObject__c.ChangeOwner,CustomObject__c.id)}" rendered="true" >[Change]</apex:outputLink>

 

When the page renders, the link shows up fine.  But when I try clicking on the link it sends me to the login page saying in red that I have to be logged in to perform that function.  I am, obviously, already logged in when I click the link.

 

Ideas?

Scenario: a row gets added to AsyncApexJob with a JobType of either 'TestRequest' or 'TestWorker'.  When it completes, the status gets set to 'Completed', but CompletedDate remains null.  It gets filled in for the other JobTypes (''BatchApex' and 'Future')

 

Is this intentional?  If so, why?

There is a maximum # of statements that you can execute during a single invocation of APEX.

 

Is there any way to programatically determine how close I am to that imit?  I have a recursive procedure that I want to run until it gets close to the limit and then turn itself off before it triggers an unrecoverable error. (you cannot catch that type of error)

 

While I'm at it I wouldn't mind knowing how close I am to running out of heap and levels of nesting.

Can you relate a task to more than one object?

 

IE - there is a Related to field that let's you relate it to many different object types, but I need to relate them to two (or more) different objects at the same time.

 

Example: Project and Context

 

"This task is related to the XYZ Project (Project: XYZ) and I can only perform this task when I'm located at the North Building (Context: At North Building)."

 

I tried to create a new Lookup field on task (Activity) but the Lookup option wasn't available.  I can't make it a picklist because users need be able to make their own ad-hoc Contexts.

We're a 3rd party developer using FDC as our platform.

 

We're looking for a way, preferably in APEX, to query the amount of used data space.  The usual limit for an org is 1GB - our goal is to perform specific actions when a customer begins to approach this limit.

 

One approach we thought of was to count the number of rows in each object, because every row takes up 2K.  But we store data in over 30 objects and I'm concerned about governors.

How do I discard a sandbox that I don't want anymore?

In this validation rule, it is ensuring that the end is either on or after the start.  This works fine if the dates are different, but if they are the same it should pass, but it's not doing so.  Any ideas?  I have confirmed that they are both of type date and neither is DateTime.

I can't seem to access the old report builder at all any more. 

 

1.  Did it go away?

2.  Is there an org-wide setting that someone might have flipped to make it go away?  If so, how do I get it back?

3.  Am I just seeing things?

I accidently deleted an APEX test method that I was working on.  It was brand new so it had never been saved down to Eclipse or deployed anywhere.

 

Is there any way to get it back?  Trashcan seems to be for data only, and the Deleted Objects link that appears below many metadata objects does not appear to be present.

Is it possible for a FDC ID Field to contain a comma?

Could someone point me towards any documentation on how to access a custom object's History tracking information through APEX?  I looked through the APEX reference but I may have missed it - if it's in there can you cite a page #?

There doesn't seem to be a way for me to know whether or not a field has it's data changes being tracked in History.

 

Can anyone help me out?  I want to write an app that will give me a complete list of audited fields in an org.

Does anyone have the exact regex that force.com uses to validate it's email field type?
Is there a way to throw away a partner portal test org?  I know there's a limit to how many you can have at once, and that they expire after awhile, but I have one that is now pretty worthless to me and I want to delete it.

We're building an application from the ground up.  We use only 2 standard objects, and those in ways slightly different from how they're used in native salesforce apps.

 

There are a slew of reports for the standard objects.  Most of our users are not going to be super-sophisticated, so we don't want them hanging around to confuse them.  So far what I have done is gone into each Report Folder and marked the folder "Hidden from All Users".  My problem is that they're still visible to the admin user in the Folder drop-down (and each deployment to a customer will have at least one admin).  

 

Is there any way to delete these reports entirely? Or will it have to be a training issue where we tell each Admin "Don't enable these or you will confuse your employees."?

Is there any way to have code run or go to a specific VF page when a user first logs into a new org?  Our application has certain settings, and we want to:

 

(1) Take them to a "Setup Wizard" page when they first login, and continue to do so on login until all the decisions have been made

 

(2) Preferably prevent them from accessing the rest of the app until those decisions have been made, though this may not be mandatory

 

(3) After the decisions have been made, no longer have the setup wizard appear, but the user can still navigate to it if they wish

I know this is in the doco somewhere, but I have been unable to find it.

 

What is the maximum # of fields in an object, and what is the maximum # of formula fields in an object?

 

Do formula fields use data storage space, or are they calculated when a record is retrieved?

Hi,

 

I want to run a query in Salesforce because I cannot get the result I want from reporting.

 

We have a Custom Object A. Object A is the master of Object B.

 

I want to get a list of all the records in object A that have no related records from Object B. Is that possible?

 

Regards,

 

HighPar

I'm hoping someone can tell me what I'm doing wrong here.  Whenever I press the "Count Selected" button, this is what shows up in the debug log no matter how many records I have manually selected on the displayed page:

 

[20]|DEBUG|xyzzy: Num Selected 0

 

Here is the page, followed by the controller.  Obviously these are slimmed down from the actual page and controller I am working on.

 

<apex:page standardController="Account" recordSetVar="true" extensions="aaaDonNotPackageController" id="page">
    <apex:pageBlock mode="mainDetail" id="PB" >
        <apex:form id="form">
            <apex:commandButton value="Count Selected" action="{!CountSelected}" /> 
        </apex:form>            
        <apex:enhancedList id="list" type="Account" height="570" width="1200" rowsPerPage="25"  customizable="true"/>
    </apex:pageBlock>
</apex:page>

 

global with sharing class aaaDonNotPackageController 
{
    public ApexPages.StandardSetController setController;
 
    // Constructor    
    public aaaDonNotPackageController (ApexPages.StandardSetController controller)
    {
        Initialize(controller);
    }   
    
    // placed outside constructor for easier debugging    
    private void Initialize (ApexPages.StandardSetController controller)
    {
        setController = controller;
    }
    
    public void CountSelected()
    {
        List<sObject> selAccts = setController.getSelected (); 
        system.debug ('xyzzy: Num Selected ' + string.valueof(selAccts.size()));                    
    }
}

 

I wonder how I can start an autonumber from a pre-established number. For example starting from the number 2250? I hope you can help me. No more. Thanks to all who respond.

I wanted get some feedback NORMS from the user community on this:

 

1. If you have code that was written last year lets say (old code). 

2. Then today you write a validation rule (VR) that will pop up if a user attempts to save a record that has historical data that break that VR.

 

Now when a process is executed to work on that same record via the apex code mention in 1 above the update action in the apex code does not work because of the VR rule.  Now this code doesn't seem to display an error on the screen either.

 

VR's seem to be causing all kinds of issues in relation with Apex code.

 

 

I have an ideas but not sure if there is a better way:

 

1. Update the historical data to adhire to the new VR (Not always easy)

 


How are you dealing with this type of issue?

 

 

 



Hi,

 

I have a page layout associated to the object where a particular field had been made Required. Pl mark that the field is made required at Page Layout and not at Object.

 

There are 2 different profiles who can access this object and both use the same page layout for the object.

Profile 1 has the above required field hidden and profile 2 has this field visible.

 

When the user of Profile 1 tries to create a record, he obviously would not be able to enter the value for the field. But, by the virtue of the field being required on the page, he should be thrown an error when he saves the record. But I notice that the system allows him to save the record though he had not entered the value for this field.

Is this the expected behaviour. Can anyone pls help me why it behaves this way.

 

Thanks.

 

  • September 28, 2011
  • Like
  • 0

I'm trying to get the owner field and ChangeOwner link onto a VF page for a custom object.  Owner field is just fine.  But I can't get ChangeOwner to work.

 

I'm trying this code:

<apex:outputLink value="{!URLFOR($Action.CustomObject__c.ChangeOwner,CustomObject__c.id)}" rendered="true" >[Change]</apex:outputLink>

 

When the page renders, the link shows up fine.  But when I try clicking on the link it sends me to the login page saying in red that I have to be logged in to perform that function.  I am, obviously, already logged in when I click the link.

 

Ideas?

I am trying to clone checkbox values, but my code is turning all my checkbox field value to true even if they should be false. How do I solve this? Here is my code:

 

trigger OldOpportunityLink on Opportunity (before insert) {

    Set<Id> Ids = new Set<Id>();
    for (Opportunity oppo: Trigger.new){
    System.debug('**** 0 Ids id : '+oppo.id);
    
            Ids.add(oppo.Id);
     System.debug('**** 1 oppo id : '+oppo.id);
     
     }
    
    for(Opportunity unity: Trigger.new) {

       unity.Original_Opportunity__c = unity.Current_Opportunity_Id__c;
    
    List<Opportunity> o =new List <Opportunity>([select id, ps__c,Original_Opportunity__r.ps__c
        from Opportunity limit 1]);
    
        if (o[0].ps__c = true){
                unity.ps__c = true;
                }else if
            (o[0].ps__c = false){
                unity.ps__c = false;
                }
        if (o[0].ais__c = true){
                unity.ais__c = true;
                }else if
            (o[0].ais__c = false){
                unity.ais__c = false;
                }  
        if (o[0].potato__c = true){
                unity.potato__c = true;
                }else if
            (o[0].potato__c = false){
                unity.potato__c = false;
                }
        if (o[0].Farmco__c = true){
                unity.Farmco__c = true;
                }else if
            (o[0].Farmco__c = false){
                unity.Farmco__c = false;
                }                    
        if (o[0].Service_Contract__c = true){
                unity.Service_Contract__c = true;
                }else if
            (o[0].Service_Contract__c = false){
                unity.Service_Contract__c = false;
                }                    
        if (o[0].Processed_Fruit_Veg__c = true){
                unity.Processed_Fruit_Veg__c = true;
                }else if
            (o[0].Processed_Fruit_Veg__c = false){
                unity.Processed_Fruit_Veg__c = false;
                }                    
        if (o[0].Project_System_Eng__c = true){
                unity.Project_System_Eng__c = true;
                }else if
            (o[0].Project_System_Eng__c = false){
                unity.Project_System_Eng__c = false;
                }
        if (o[0].Freshline__c = true){
                unity.Freshline__c = true;
                }else if
                
            (o[0].Freshline__c = false){
                unity.Freshline__c = false;
                }                    
        if (o[0].Pharma__c = true){
                unity.Pharma__c = true;
                }else if
            (o[0].Pharma__c = false){
                unity.Pharma__c = false;
                }                    
        if (o[0].Misc_Other__c = true){
                unity.Misc_Other__c = true;
                }else if
            (o[0].Misc_Other__c = false){
                unity.Misc_Other__c = false;
                }                    
        if (o[0].ISG__c = true){
                unity.ISG__c = true;
                }else if
            (o[0].ISG__c = false){
                unity.ISG__c = false;
                }                    
        if (o[0].Spare_Parts__c = true){
                unity.Spare_Parts__c = true;
                }else if
            (o[0].Spare_Parts__c = false){
                unity.Spare_Parts__c = false;
                }                    
        if (o[0].Thermal_Systems__c = true){
                unity.Thermal_Systems__c = true;
                }else if
            (o[0].Thermal_Systems__c = false){
                unity.Thermal_Systems__c = false;
                }                    
        if (o[0].Upgrade__c = true){
                unity.Upgrade__c = true;
                }else if
            (o[0].Upgrade__c = false){
                unity.Upgrade__c = false;
                }                    
    }
}

 

 

Thanks,

ckellie

Out of curiosity, when creating a new custom object there is a checkbox "Starts with vowel sound".  What is this used for?

  • February 11, 2011
  • Like
  • 0

Hello-

 

I've successfully created a custom object (it looks great!) in my Contact Manager Edition of Salesforce. I'd like to be able to take that information and put it into a document that I can print out and give to a customer (essentially creating a quote). I tried to do this as a report, but all I can get is a grid report. Is there a way to create an apex code doc to do this? Is there perhaps an apex template somewhere for this? I'd use the print button, but I don't want all the information on this to be revealed to the customer, and I want the opportunity to put generic text in the document.

Thanks for your help-

Hi there,

 

I have the following test code which updates a field in a related object (CustomObject__r).  The CustomObject is related to Opportunity and the code below runs through successfully.

 

Opportunity o = [select CustomObject__r.Market__c,StatusMessage__c from Opportunity where Id='00600000008HFNLAA5'];
           o.CustomObject__r.Market__c = 'test';
           o.StatusMessage__c = 'test update';
           
            try
            {
                Database.SaveResult srs = Database.update(o);
                if (srs.isSuccess())
                {
                     // successful
                }
            } catch (Exception e) {
                    ApexPages.addMessages(e);
            }      

 

The above code does not return an exception and also is successful based on the return value of isSuccess().  The StatusMessage__c in the main object is successfully updated, but the CustomObject__r.Market__c field does not get updated even though the update transaction as a whole is deemed successful.  Any troubleshooting ideas, or if the above update is not possible (ie. have to fetch back and update CustomObject__c directly)?

 

thanks

Hi,

 

I have started developing visualforce and apex just today noon. so please excuse me,

 

I have added a visual force page and have displaed in a custom tab. But i now want to add some functions in a apex class.

 

When i go to  Name | Setup | Develop .. there are only API, COMPONENTS, CUSTOM SETTINGS, EMAIL SERVICES, PAGES, STATIC RESOURCES, REMOTE ACCESS.

 

There is no "Apex Classes" there. please tell me whether i have to enable something somewhere?

 

Thanks and Regards,

Dinesh.N

Working on this now..

Is there any way to audit the deletion of a child record?  We are using custom objects and need to track when an appointment was deleted from a schedule.  We could write triggers to handle this for us, but I was hoping for a more built-in approach.  Recycle bin is somewhat close to what we need, but we need the information permanently.

It appears that if a user sets the IsPrivate field to true on an Opportunity record, all workflows are bypassed when saving the record.  I can't find any help text for this field and my best guess is that it would have something to do with a sharing model.  I would NOT have guessed that it bypasses workflow rules as that seems like a great way to get bad data into your org.  What other magic is tied to this field?

Hi

i just meet one question, when i convert the string to integer type. i used the integer.valueof() method . but if string like 'ABCDEF' that can't  do integer conversion but throw System.TypeException.

could i do judgement first first? like if the string parameter s='123'  can do integer conversion, and then i call the integer.valueof(s)

is there any method ??

 

 

 

For example if I want to delete records and not have them bump other records out of the recycle bin. I know we will never need to recover the records I am deleting, and I dont want them to remove record that are in the recycle bin which may need to be recovered.