• JohanLiljegren
  • NEWBIE
  • 89 Points
  • Member since 2007

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 83
    Replies

Hi Everyone,

 

I'm creating  PDF version of an object. This object has around 400 fields out of which only 120 have to be displayed (predefined list). I don't want to use form elements as they don't render properly on PDF.

 

What I'm hoping for

. .

Name Value

Field Name1Field Value1
Field Name2Field Value2
Field Name120Field Value120

 

 

the only solution, I could figure out was

<apex:outputText>{!$ObjectType.Detriot__c.Fields.Name.Label}</apex:outputText>

<apex:outputText>{!field1}</apex:outputText}

in side a <table> tag.

 

 but there are 120 fields and I have to do this for 30 more objects.Hardcoding doesn't seem like a good approach. Is there a more elegant way to do this? is there a way to perhaps make a list of field names and a list of values, then display those two lists as a table?

 

Thank you,

Sunny_Slp

 

hi folks,

 

I have written a trigger and caling a class from that. It is working fine for new records. If I use data loader then It is throwing me the followig error.

 

Too many DML statements: 151

 

How to resolve this error??

 

Thanks

Raj

I'm trying to incorporate a jQuery Accordion (http://jqueryui.com/demos/accordion/) in a Visualforce page but it comes out garbled (see screenshot):

 

Garbled output

 

If I remove the standard stylesheets (standardstylesheets="false") and header (showheader="false") it comes out as I'd want it to (see screenshot):

Nice output

Problem is, I have other things on the page that needs the standard stylesheets.


How would I define the accordion so that it plays nice inside of a standard stylesheets Visualforce page?

I'm thinking I need to override some styles, but I can't figure out what/how.

 

Here's a short version of the page with just the accordion part:

<apex:page cache="false" expires="0" sidebar="false" >
    <apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-1.7.1.min.js')}"  />
    <apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-ui-1.8.18.custom.min.js')}"  />
    <apex:stylesheet value="{!URLFOR($Resource.jquery, '/css/ui-lightness/jquery-ui-1.8.18.custom.css')}"  />

    <script>
        $j = jQuery.noConflict();

        $j(document).ready(function($)
        {
            $j("#SFDCSalesPanel").accordion();
        });
    </script>

    <apex:pageBlock id="playBlock" >
        <div id="SFDCSalesPanel">
            <h3><a href="#">Header 1</a></h3>
            <div>Content 1</div>
            <h3><a href="#">Header 2</a></h3>
            <div>Content 2</div>
            <h3><a href="#">Header 3</a></h3>
            <div>Content 3</div>
        </div>
    </apex:pageBlock>
</apex:page>

 

I'm seeing an issue in Safari when I have a Visualforce page embedded on the Account record and the Visualforce page consists of a component in combination with either the page itself or the component containing an

<apex:form>

 

tag.

 

I've tested this in Firefox 3, IE 6 and Google Chrome - they all behave as I would expect them to, i.e. they show the Account page with my small VF piece embedded.

The problem I'm seeing is that almost (scary, huh?) every time I display the page in Safari, Safari pops up a dialog box asking what to do about the servlet.integration file Salesforce is offering it, i.e. do I want to save it, open it or just cancel altogether. To make matters worse, once every 10 to 20 times(?) the page renders correctly and shows my VF page embedded on the page layout. Hey, what the...?

 

I've narrowed down the code to this minimalistic (and not that very useful) 3-piece code collection. One custom Controller, one Component using the Controller and one Visualforce page showing the Component plus a form.

 

The Controller

public class TheController {
//It seems there needs to be something instantiated in

//the controller to trigger issue in Safari.

//If left empty, there's no issue in Safari, however the

//functionality becomes somewhat limited =)
Integer aVar=1;
}

 

The Component

<apex:component controller="TheController">
Some text and tags, does not matter...
</apex:component>

 

The Visualforce page

<apex:page standardController="Account" tabStyle="Account" >
<!-- The combination of a custom component and a form (either here
in the page, or within the component itself) triggers an issue
in Safari.
Instead of showing the inline VF page, it asks if I want to
download the servlet.integration file
Remove either the custom component or the form tag and the
issue disappears.
No problems either way in Firefox 3, IE 6 or Google Chrome.
-->
<c:TheComponent />
<apex:form />
</apex:page>

 

 

Am I doing something forbidden here?

Is my installation of Safari ready to be put to sleep?

Am I losing my mind?

If none of the above, why is Force.com compiling this to a piece of HTML that Safari doesn't understand? And most of all, why isn't it consistent, i.e. always repeatable?

 

Any suggestions, questions etc are more than welcome!

 

Regards

//Johan Liljegren

Message Edited by JohanLiljegren on 01-22-2009 11:17 AM
Hi all,

I've written one of my first Apex classes, with a webservice enabled function that I call from an S-Control, that does a bit of calculations, updates some fields and then returns.
Problem is, I get 100% code coverage in Sandbox, but when I go to deploy it to Production I get only 48%. Do anyone have any suggestions on why that could be and what I could change to get more coverage in Production?

Code:
global class Calculate_Budget_Expenses
{
    WebService static Boolean CalculateBudgetExpenses( String ID )
    {
     ID budgetID = ID;
     
        Double ProgramExpensesToDate = 0;
        Double PlannedExpenses = 0;
        Double AdditionalExpensesNotCommitted = 0;
        Double QuarterBudgetConverted = 0;

        for ( Campaign tempCampaign : [ select Id,
convertCurrency(Total_Program_Expenses__c),
convertCurrency(Program_Budget__c),
convertCurrency(Expenses_Not_Committed__c)
from Campaign
where Marketing_Budget__c = :ID ] ) { ProgramExpensesToDate += tempCampaign.Total_Program_Expenses__c; PlannedExpenses += tempCampaign.Program_Budget__c; AdditionalExpensesNotCommitted += tempCampaign.Expenses_Not_Committed__c; } for ( Marketing_Budget__c tempBudget : [ SELECT convertCurrency(Quarter_Budget__c)
FROM Marketing_Budget__c
WHERE Id = :budgetID ] ) { QuarterBudgetConverted += tempBudget.Quarter_Budget__c; } Marketing_Budget__c Budget = [ SELECT Program_Expenses_To_Date__c,
Planned_Expenses__c,
Additional_Expenses_Not_Committed__c
from Marketing_Budget__c
where ID = :BudgetID ];

List<Marketing_Budget__c> Budgets = new List<Marketing_Budget__c>();
Budgets.Add(Budget);

Budget.Program_Expenses_To_Date__c = ProgramExpensesToDate;
Budget.Planned_Expenses__c = PlannedExpenses;
Budget.Additional_Expenses_Not_Committed__c = AdditionalExpensesNotCommitted;
Budget.Quarter_Budget_Converted__c = QuarterBudgetConverted;

Update Budgets;

return true;
}
static testMethod void test() {
Campaign camp = [ select Marketing_Budget__c
from Campaign
where Marketing_Budget__c != null limit 1 ];

Marketing_Budget__c budget = [ select Id
from Marketing_Budget__c
where Id = :camp.Marketing_Budget__c ];

CalculateBudgetExpenses(budget.Id);
}
}

 

In need of deactivating a trigger in Production? Haven't found a way to do it?
I don't know if people are aware of this, but I've seen numerous posts about it, I've suffered from it myself and even had support tell me it's not possible.

So I was a bit surprised when today, playing around in Eclipse, I successfully managed to deactivate and activate a trigger in Production!
What you need to do is to open the metadata file accompanying the trigger. So, if your trigger is Foo.trigger, you would have a Foo.trigger-meta.xml.
Open that one, change the value of the element <active> to "false" and save the file.
Once saved, doublecheck through the GUI and the checkbox for Active is no longer there!
Sweet!

Of course, to re-activate the trigger, just change the <active> element to "true" again.

Hope this helps someone.

//Johan
I'm trying to override the 'New' button for a custom object (Contract) tied to Opportunity.
When I click New I want it to populate the Client Name on the Contract with the name of the Account that the Opportunity is tied to, basically doing a two level field reference.
I've managed to set other fields, so that's not the problem. The problem is i don't know how to reference the Account Name.

To get the name of the Opportunity, I just use {!Opportunity.Name}, but you can't say {!Opportunity.Account.Name} or {!Account.Name} or something like that.
Do I need to do a SOQL query to get to the Account name or is it possible by any other notation?

Regards
//Johan
After installing "Connect for Lotus Notes", my Lotus Notes client refuses to start and neither Salesforce.com support nor our internal Lotus Notes support manages to help me fix it.
So, any ideas on how I should troubleshoot?
What I did thus far:
  • Added a registry value to make the log file more verbose => no real error messages that gave me any more clues
  • Checked my notes.ini file to make sure that it contains
          AddinMenus=sfdcmenu
    which it does
The only way for me to access Lotus Notes is to uninstall "Connect for Lotus Notes".

Any ideas or things I should be checking?
I really need to get this up and running, but being a rather new product there's not much support for it.

Thanks in advance,
//Johan Liljegren


Message Edited by JohanLiljegren on 12-21-2007 05:06 AM
Hi all,

First message on this board, be gentle. =)

We have a lot of custom fields all over our org, in different objects, both standard and custom ones, that I suspect to be not used. Either not used anymore, or has never been used, just put in to "test something" by a previous admin.

Do you guys have any tips on how to create a listing of some sort to see for example:
  • Fields with no data
  • Fields with very little data
  • Fields that are not on any page layouts
Would this be possible via an S-Control or would I be better off looking at creating a stand-alone Java (or similar) program? Any other ideas?

Thanks in advance!

Regards
//Johan Liljegren

I'm trying to incorporate a jQuery Accordion (http://jqueryui.com/demos/accordion/) in a Visualforce page but it comes out garbled (see screenshot):

 

Garbled output

 

If I remove the standard stylesheets (standardstylesheets="false") and header (showheader="false") it comes out as I'd want it to (see screenshot):

Nice output

Problem is, I have other things on the page that needs the standard stylesheets.


How would I define the accordion so that it plays nice inside of a standard stylesheets Visualforce page?

I'm thinking I need to override some styles, but I can't figure out what/how.

 

Here's a short version of the page with just the accordion part:

<apex:page cache="false" expires="0" sidebar="false" >
    <apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-1.7.1.min.js')}"  />
    <apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-ui-1.8.18.custom.min.js')}"  />
    <apex:stylesheet value="{!URLFOR($Resource.jquery, '/css/ui-lightness/jquery-ui-1.8.18.custom.css')}"  />

    <script>
        $j = jQuery.noConflict();

        $j(document).ready(function($)
        {
            $j("#SFDCSalesPanel").accordion();
        });
    </script>

    <apex:pageBlock id="playBlock" >
        <div id="SFDCSalesPanel">
            <h3><a href="#">Header 1</a></h3>
            <div>Content 1</div>
            <h3><a href="#">Header 2</a></h3>
            <div>Content 2</div>
            <h3><a href="#">Header 3</a></h3>
            <div>Content 3</div>
        </div>
    </apex:pageBlock>
</apex:page>

 

Hi all,

 

I'm trying to share a record with certain users when they are assigned via a lookup (on Project_Activity__c) but i cant find the sharing object, i have a custom object Project__c but there isnt a sharing object Project_Share do i have to generate this somehow? the project is the master in a master detail relationship with Project_Activity__c. I've got the sample code from salesforce and it all looks ok but im getting invalid type Project_Share as this object doesnt exist, does anyone know what i need to do?

 

Thanks Guys

Hi Folks,

               How to update original object fields with update DML statement in trigger after insert event. My code:

 

trigger myTrigger on Account (after insert) {

Account myAccount = trigger.new[0];
myAccount.Type = 'Enterprise Customer';
update myAccount;
}

 

Here the update DML statement throws the exception: System.FinalException: Record is read-only:

 

Please let me know and all suggestions are appreciated with any sample code or correction to above code.

 

Thanks.

Hi,

Is it possible to create multiple user records by importing like record import using data loader?

 

Thanks

 

If a field is not visible,  sobject.fields.getMap() does not return that field. I was hoping it did and then I could check if the field is visible to current user (through isAccessibe)

 

In EE/UE, if I made a field invisible through field level security, this function does not return it.

In PE, if I remove it from screen layout,  the field is not returned either.

 

Is there another way? Seems like a bug that SFDC would not return all fields, but provide isAccessible function....

 

FYI, isAccessibile is inconsistent. If I remove from screen layout in EE/UE edition, it still return true. In the UI, it shows it as hidden under  Admin Setup->Security Controls->Field Accessibility). In Apex, it seems to mean visiblilty.

 

 

 

 

Hi Everyone,

 

I'm creating  PDF version of an object. This object has around 400 fields out of which only 120 have to be displayed (predefined list). I don't want to use form elements as they don't render properly on PDF.

 

What I'm hoping for

. .

Name Value

Field Name1Field Value1
Field Name2Field Value2
Field Name120Field Value120

 

 

the only solution, I could figure out was

<apex:outputText>{!$ObjectType.Detriot__c.Fields.Name.Label}</apex:outputText>

<apex:outputText>{!field1}</apex:outputText}

in side a <table> tag.

 

 but there are 120 fields and I have to do this for 30 more objects.Hardcoding doesn't seem like a good approach. Is there a more elegant way to do this? is there a way to perhaps make a list of field names and a list of values, then display those two lists as a table?

 

Thank you,

Sunny_Slp

 

I'm starting to get a little dangerous with APEX.  :smileyhappy:

 

My sandbox went down for mainteniance as I was getting ready to test this a second time - it didn;' work the first time.  I think I might be misunderstanding how trigger.old and new are suppsed to work.   Will this code automatically convert a lead when the status is changed to qualified?

 

Also - my test class only gets 76% converage.  To help get a better understanding, what would I need to add to get to 100%?

 

trigger LeadConvert on Lead (after update) {

  // no bulk processing; will only run from the UI and Lead Status must be changed to qualified 
  if (Trigger.new.size() == 1) {
    if (Trigger.old[0].isConverted == false)  {
    if (Trigger.new[0].isConverted == false && Trigger.new[0].Status == 'Qualified') {
 
              }
         }
    }
}

 Test Class:

 

public class LeadConvert {

    static testMethod void LeadConvert() {
    
    //create a lead with qualified status
    lead l1 = new lead();
    l1.status = 'Qualified';  
    l1.lastname = 'Joe';         
    l1.firstname = 'Smith';         
    l1.company = 'Company ABC'; 
    l1.isConverted = False ;
    insert l1;
    string holder = l1.id;
    
    //create lead that does not match criteria
    Lead L2 = new lead();
    L2.Status = 'Open';
    L2.lastname = 'Jane';         
    L2.firstname = 'Smith';         
    L2.company = 'Company DEF';
    L2.isConverted = False;
    insert L2;
    string holder2 = L2.id;  
    
    //Update 
    L2.Status = 'Qualified';
    update L2;
        }
 }

 

List<Course_Allocation__c> allocateList = new List<Course_Allocation__c>() ;

for(Lecturer__c lec: Trigger.new){                        
                myList.add(new Course_Allocation__c(Name = lec.Name, Full_Name__c = lec.Last_Name__c,
                Email__c = lec.Email__c, Mobile_Number__c = lec.Mobile_Number__c,
                Department__c = lec.Department__r.Name));
 }


But after insertion Department__c field is empty, why?


Hi,

 

I would like to know if anyone has any experience in building an approval process where the approvers are picked by the user before submitting the record for approval?

 

Basically, our use-case is as follows:

 

  1. We want to have a reference to multiple User objects (e.g. multi-select, multiple lookups - just assume this has been handled)
  2. Before submitting a record, the user picks one or several users as approvers
  3. When submitting the record, an approval process should be initiated
  4. Whenever an approver approves a record, it should go on to the next approver selected in the user list in step 1

I'm not sure if we can use the native approval process at all or if we are forced to basically code the whole flow ourselves?

 

Is it even possible to create approval processes in Apex? Can one intercept approval processes build by the native functionality and basically override who the next approver should be based on a set of criteria in the code?

 

I've found, and read, some topics on the boards but none of them seem to cover what we would like to achieve. Basically, we're looking for an extremely flexible solution where the submitter of the record decides the list of approvers.

 

I'm looking forward to some great input you guys.

 

Kind regards,

Søren Nødskov Hansen

Hi,

Can anyone please advise me as to how to measure User Adoption of customized functionalities built via Visualforce Pages, Apex codes, etc? Example, on a button click on Account detail page a Visualforce Page opens which shows Account Team Hierarchy of that account alongwith the teams at each account level(levels = 3).

I want to know how many users click on that button and see this page?

Similarly, there are couple of more Visualforce Pages on Account's and Contact's detail pages. I want to know whether users are really utilising it or not?

Is there any tool or App Exchange product/application for the same?

Please assist.


Thanks,

Vimal

How to access currency symbol of organization from Visual force page. (or Currency ISO Code)

 

Thanks in Advance.

hi folks,

 

I have written a trigger and caling a class from that. It is working fine for new records. If I use data loader then It is throwing me the followig error.

 

Too many DML statements: 151

 

How to resolve this error??

 

Thanks

Raj

We have a formula field on Account that displays the record type as text - it's not really for end user consumption (looking at a record will display the record type anyway) but to make life easier elsewhere. The formula is: $RecordType.Name

 

On a Case, we are trying to use the value of this field in another formula field. To make it easy, imagine we have a formula field on Case called "Account Record Type" - it's a formula that is essentially: Account.My_Custom_RecordType_Formula_Field__c

 

The problem is the value in the "Account Record Type" field on the Case is showing the Case's record type, not the account record type. It's almost as if the account field formula is being evaluated on the Case.

 

Is this standard behaviour? Any explanations? Thanks in advance, and sorry if this means I flunk config 101 :)

  • July 07, 2010
  • Like
  • 0

I have the need to import thousands of contacts from internet lists.  The lists are usually vertical instead of horizontal.  In other words, when I copy and paste into Excel, all the data goes into column A.  I need for the name to be in column A, the phone # in column B, etc.  I'm sure there is a way to pivot the data around and have tried using pivot tables but no luck so far.  Currently, I am having to cut and paste the data into the columns I need so it imports into SalesForce.  Anybody solved this issue before?

 

I am not sure which function should be used between ISNULL and ISBLANK.

 

Can anyone describe this for me?

 

Thank you in advance.

  • July 06, 2010
  • Like
  • 0

Requirement: A group of X people in the system should have the right to Add team members to Accounts. The group of people may belong to 1 single profile but not necessarily

 

Problem: This is what salesforce says about the permissions a user need to have to add a Team member to a Account Group.

a. He is a System Administrator

b. He is the Owner of the Account

c. He is the Manager of the Owner

d. He has Modify all Data and Manage user permission on his profile.

 

In my case, none of the above condition is satisfactory for the group of X people. Is there any other way I can give them the permission to add Account Team Member? I also found that if a User A is added to Account Team with Read/Write permission, he can add another Team Member  but he can only provide that other member Read Access.

 Can I use this in some way?