• DavidHabib.ax407
  • NEWBIE
  • 0 Points
  • Member since 2008

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

I have a managed package that includes a css file that I want to allow the user to be able to modify, in order to change the styling of my visualforce page, when they host it on their website through Sites.

 

Originally, I made my css file a static resource, but found that it was locked down in a managed package.  So I then came up with the following hack...

 

in my controller class:

 

    // the instance specific url to the css that can be modified by the user.
    public string strURLtoCSSFile {
        get {
            if (strURLtoCSSFile == null) {
                list<Document> listDocs = [SELECT Name, Id From Document WHERE Name = 'MyCSS.css' LIMIT 1 ];
                if (listDocs.size() > 0) {
                    Document doc = listDocs[0];
                    string imageid = doc.id;
                    imageid = imageid.substring(0,15);
                    strURLToCSSFile = '/servlet/servlet.FileDownload?file=' + imageid;
                }
            }
            return strURLtoCSSFile;
        }        
        set;
    } 

 

in my visualforce page:

  <apex:stylesheet value="{!strURLtoCSSFile}" />

 

This seemed to work great when testing the visualforce page directly.  But when the visualforce page was being surfaced through Sites, I found that I had to enable Read permissions on the Documents standard object in the Site's Public Access Settings.

 

Unfortunately, this seems to open up all documents as readable to the Site.  I found no way to set this either per directory or per actual file.

 

Any ideas on how to correctly set the permissions, or a better way to do this?

Thanks!

Dave

I was using a set of sObjects, assuming that the set would prevent me from putting the same sObject in the set multiple times.  Unfortunately, I found that if I modified one of the fields of the sObject between additions to the set, then the sObject would get put on multiple times.  Is this expected behavior or a bug?

 

Here is a sample test routine which asserts, exposing the problem:

 

    static testmethod void SetSobjectBug() {
        Account acc = new Account(name='Individual');
        insert acc;
        Contact con = new Contact(Lastname='Testy', AccountId=acc.Id);
        insert con;
        Campaign cmp = new Campaign(name='Test Campaign');
        insert cmp;
        CampaignMember cm = new CampaignMember(CampaignId=cmp.Id, ContactId=con.Id, Status='Sent');
        
        Set<CampaignMember> setCM = new Set<CampaignMember>();
        system.assert(setCM.add(cm));
        cm.Status = 'Responded';
        system.assert(setCM.add(cm) == false);  // THIS ASSERTS.  If cm.Status is not changed, it won't assert.
    }

 

I was assuming the set was holding onto a reference to the object, but given this assert, I wonder if the set is make a full copy of the object, and doing a full compare to test membership?

 

Thanks,
Dave

I have a VisualForce page which is bound to an Opportunity I've created of a specific record type.  Unfortunately, the Stage picklist shows all stages defined in this salesforce instance, rather than just the stages defined on the sales process for this opportunity record type.

 

How come the stage picklist is not filtering?  Is there a way to fix this?

 

I could use my own picklist to show just the stages I expect, but I'd rather not do this extra work.

 

Thanks,

Dave

Campaign object's now have a CampaignMemberRecordType field which is the record type to create CampaignMember records with. 

 

Unfortunately, I can't set it in Apex code.  Eclipse complains with "Invalid field CampaignMemberRecordType for SObject Campaign".

 

I also tried using CampaignMemberType, but also got an Eclipse error.

 

What do I need to do to be able to set this programmatically?

 

Thanks,
Dave

I've got a ~6 month old developer account that I'd like to enable Sites on.  I've tried some of the older links I found on the discussion board, but they didn't seem to do anything.

 

Thanks for any help,

Dave

I have a sandbox on a production system that I've been able to successfully use with the Apex Data Loader and the Eclipse Force IDE for several months.

 

Today, I can no longer login to my sandbox account with either tool.  I reset my security token, but I still cannot login.  I am able to login to the production system without problems with these tools.  I can also login to the sandbox from the Browser without problems.

 

Please help!

Thanks,

Dave

I'm trying to write my first trigger (on Contacts), and I'm finding that the Trigger.new collection of Contacts seem to only hold contact.Id, but all other fields of the contacts are null. 
 
Here's the code, and it asserts at c.Name != null.  All the other sample code I've looked at seem to reference fields of the objects in Trigger.new without any problems.  What am I doing wrong?
 
trigger ContactTrigger on Contact (after insert, after update) {

    for (Contact c:Trigger.new) {

        system.assert(c != null);

        system.assert(c.Id != null);

        system.assert(c.Name != null);

    }

}

I was using a set of sObjects, assuming that the set would prevent me from putting the same sObject in the set multiple times.  Unfortunately, I found that if I modified one of the fields of the sObject between additions to the set, then the sObject would get put on multiple times.  Is this expected behavior or a bug?

 

Here is a sample test routine which asserts, exposing the problem:

 

    static testmethod void SetSobjectBug() {
        Account acc = new Account(name='Individual');
        insert acc;
        Contact con = new Contact(Lastname='Testy', AccountId=acc.Id);
        insert con;
        Campaign cmp = new Campaign(name='Test Campaign');
        insert cmp;
        CampaignMember cm = new CampaignMember(CampaignId=cmp.Id, ContactId=con.Id, Status='Sent');
        
        Set<CampaignMember> setCM = new Set<CampaignMember>();
        system.assert(setCM.add(cm));
        cm.Status = 'Responded';
        system.assert(setCM.add(cm) == false);  // THIS ASSERTS.  If cm.Status is not changed, it won't assert.
    }

 

I was assuming the set was holding onto a reference to the object, but given this assert, I wonder if the set is make a full copy of the object, and doing a full compare to test membership?

 

Thanks,
Dave

Campaign object's now have a CampaignMemberRecordType field which is the record type to create CampaignMember records with. 

 

Unfortunately, I can't set it in Apex code.  Eclipse complains with "Invalid field CampaignMemberRecordType for SObject Campaign".

 

I also tried using CampaignMemberType, but also got an Eclipse error.

 

What do I need to do to be able to set this programmatically?

 

Thanks,
Dave

I'm trying to write my first trigger (on Contacts), and I'm finding that the Trigger.new collection of Contacts seem to only hold contact.Id, but all other fields of the contacts are null. 
 
Here's the code, and it asserts at c.Name != null.  All the other sample code I've looked at seem to reference fields of the objects in Trigger.new without any problems.  What am I doing wrong?
 
trigger ContactTrigger on Contact (after insert, after update) {

    for (Contact c:Trigger.new) {

        system.assert(c != null);

        system.assert(c.Id != null);

        system.assert(c.Name != null);

    }

}