• Multiman
  • NEWBIE
  • 30 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 6
    Replies

I have a VF page with a controller. The controller executes a SOQL query and renders the result in the VF page. Straightforward.
I certainly want to respect sharing rules and FLS. This article http://wiki.developerforce.com/page/Enforcing_CRUD_and_FLS describes the FLS part using the isAccessible() method. Another article states that using "with sharing" in the class definition will automatically respect the sharing rules when a SOQL query is executed in the class. Now here comes the surprise:
When I have sharing rules set up for opportunities, I first have to make the opportunities Private in the sharing settings of my org (see http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_understanding.htm). Surprisingly as soon as I do that, the isAccessible() method returns false for every field on the opportunity even if a certain profile actually has access to the fields. Does that make any sense? So as soon as a user actually has access to a record according to the sharing settings, the FLS check in my code would not allow access to any field of the object. How can I solve that?

Any ideas? Thanks
Alex

I try to render a random SOQL query as a nice HTML table. The SOQL query can be configured by an admin (so it is only known at runtime).

I try to execute this code in a managed package:
 
String soqlQuery = ApexPages.currentPage().getParameters().get('soql');
// soqlQuery has now the value of a random SOQL query
// e.g. SELECT id FROM Any_Custom_Object__c LIMIT 10
LIST<sObject> records = Database.query(soqlQuery);
String str = Render(records);

That won't work as Any_Custom_Object__c is not an object within the managed package. So I try this:

1. Have an unmanaged package containing this code
 
String soqlQuery = ApexPages.currentPage().getParameters().get('soql');
// soqlQuery has now the value of a random SOQL query
// e.g. SELECT id FROM Any_Custom_Object__c LIMIT 10
LIST<sObject> records = Database.query(soqlQuery);
// render the SOQL query as a nice HTML table
String str = MyManagedPackage.MyClass.Render(records);

2. Have a managed package in the NS "MyManagedPackage" contains a class "MyClass" with a global method "Render(LIST<sObject> records)". This method renders a list of sObjects as an HTML table.

 
Question 1: Would that code within the managed package work? What if records[0] is actually a custom object? Managed packages have no access to managed packages - but actually I'm just passing it as an sObject.
Id myId = records[0].Id;

Question 2: Would  that code within the managed package work?

String objectName = records[0].getSObjectType().getDescribe().getName();

 

Any other ideas how to execute a random SOQL query and parse its result (and its meta data) from managed code?
 
Thank you so much for any hints.
Alex

I am currently developing a module that I want to publish on AppExchange as a managed package. In a unit test I had (for the sake of test coverage) to create a number of standard objects. E.g. 

    public static testMethod void testHtmlTable2() {
        Account acc = new Account(
            name = 'Test Account',
            Industry = 'Education',
            Website = 'www.website.com', 
            NumberOfEmployees = 20
        );
        try {
            insert acc;
        } catch (Exception e) {}

....

 

Now I'm concerned that a company that is trying to install my package on their org has validation rules in place for Account and the test would fail. Is that a valid concern or are tests of managed packages not executed if and admin hits the "Run All Tests" button in their org?

 

Thanks

Alex

We are currently re-branding one of our products. So I'm looking for a tool that displays all formula fields, validation rules, workflows, field updates, approval processes, apex triggers and apex classes (etc.) that contain the product name. I have to replace the old product name with the new product name.

 

Any ideas?

 

Thanks

I have APEX code that executes a SOQL query dynamically and returns a list of sObject. The SOQL string is only known at runtime (stored in Custom Settings). So I don't know which fields were actually queried.

Now if I want to iterate through the result list and dispaly kind of a table of all values, I would need to know which fields were queried in the SOQL string.

 

Is there a way to find out what fields are contained in the single sObjects?

Thanks

Alex

I am using this query in an APEX class

 

var domainNameLike = '%mydomain.com';
accounts = [SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Email LIKE :domainNameLike)]; 

 

For performance reason I want to limit the number of results with a GROUP BY and/or LIMIT statement in the WHERE subquery like this: 

 

accounts = [SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Email LIKE :domainNameLike GROUP BY AccountId LIMIT 10)]; 

 

However when I am trying to save this, it throws an exception "Error: Compile Error: expecting a right parentheses, found 'GROUP'  "

 

does the variable :domainNameLike somehow conflict with GROUP or LIMIT statements?

What am I doing wrong? How can I limit and group in that subquery?

 

Thanks

Alex

Hi 

I need a list of all accounts, where a contact person exists that has a given email address.

I tired this

 

var emailAddress = 'user@mydomain.com';

 

[SELECT Id, Name FROM Account WHERE (SELECT Email FROM Account.Contacts) IN :emailAddress ]

which does not work.

 

Any ideas?

Thanks

Alex

We have a number of pick-lists that are supposed to contain exactly the same values. So our admins are struggling to ensure that. Whenever an admin adds or changes an item we must not forget to change the others.

So is there any way to define a list of pick list items at a central place and reuse this list for different pick list fields?

Of course I couldleverage the API to do this with a little script but perhaps there is an out-of-the-box solution for this.

 

Thanks

Alex

Hi

how can I create and render the total amount of all values that are displayed in a certain column of a pageBlockTable ?

Since VF iterates over a set of objects there should be a way to do that without a custom controller.

 

Any hint is appreciated.

Thanks

Alex

Hi there

can somebody explain to me what the difference between a controller and a list controller is?

I have no issues displaying a list of related objects with a apex:pageBlockTable with a controller (without using the  recordSetVar attribute in the apex:page element)? So in which cases would I need to use a list controller?

 

Thanks

Alex

I have APEX code that executes a SOQL query dynamically and returns a list of sObject. The SOQL string is only known at runtime (stored in Custom Settings). So I don't know which fields were actually queried.

Now if I want to iterate through the result list and dispaly kind of a table of all values, I would need to know which fields were queried in the SOQL string.

 

Is there a way to find out what fields are contained in the single sObjects?

Thanks

Alex

Hello everybody, This is my first Salesforce post.

 

In my controller, I use a query to get the field related to a rich text area.

My need is to get, for example, 200 first character of a rich text area without HTML markup.

 

I don't know if a method already exists to perform this because when I try to change the field type from rich text area to text area, Salesforce propose if I want to keep or not the HTML markup of rich text area contents.

 

Thank you

M.

  • March 11, 2011
  • Like
  • 0

Hi 

I need a list of all accounts, where a contact person exists that has a given email address.

I tired this

 

var emailAddress = 'user@mydomain.com';

 

[SELECT Id, Name FROM Account WHERE (SELECT Email FROM Account.Contacts) IN :emailAddress ]

which does not work.

 

Any ideas?

Thanks

Alex

Hello ,

 

I have an approval process on Quote that locks the Quote record. While the record is locked/not approved, we want to restrict user to perform actions on Quote like Create PDF via Create PDF button on quote detail page.

 

On looking at Create PDF page, looks like it is making a function call and the URL of the page is not accessible to us which we could have used in custom vfp page and redirected to standard page reference if the record is approved else

show a popup.

 

Is it possible? I have researched quite a bit but did not find any clue. Its a critical requirement for us hence in case anybody has any idea please let me know

 

Thanks

 

Hi

how can I create and render the total amount of all values that are displayed in a certain column of a pageBlockTable ?

Since VF iterates over a set of objects there should be a way to do that without a custom controller.

 

Any hint is appreciated.

Thanks

Alex